[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk
Subject:    Re: Beginners guide
From:       Timothy Ward <gtwa001 () gmail ! com>
Date:       2018-04-27 18:27:06
Message-ID: 1524853626.2190.17.camel () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Emmanuele,
I do agree with you but, From a beginners concept,The concept of Gtk-
application and the handling of applications arguments is confusing
coming from someone who is still learning from say - standard "C" as
they are handled the same way in just about any example on a google
search,  
When you combine this with the concept of main loop and  instances that
need to be created, controlled and destroyed then the complexity may be
simple for an experienced programmer, but not to a beginner. 
In other words the original way is easy to understand what is actually
going on, but the new way is complex and needs further explanation for
a beginner to understand the concept and to be able to write and apply
the code correctly.
These needs to be explained by a beginner for a beginner with input
from experienced people with good example that explain what the steps
are actually doing in the code and why you need to use them. 
The beginners guide is a great start for this, thanks to the author,
please do not stop.
Regards


On Fri, 2018-04-27 at 14:54 +0100, Emmanuele Bassi wrote:
> Hi;
> 
> thanks for your contributions: documentation is always welcome.
> 
> On 24 April 2018 at 19:39, Jim Reilly <jimreillyindevon@gmail.com>
> wrote:
> > I have put together a guide to help beginners to get started using
> > gtk+3.0 in the hope that it might be useful. I do not have a web
> > site through which I can make it available so I have attached it to
> > this e-mail so that, if anyone thinks it is worth reading, they can
> > make it accessible to others.
> > 
> > 
> 
> It would have been nicer to have some form of text source, in order
> to provide you with feedback.
> 
> In any case, here's a rough list of improvements to the examples and
> practices, to match the current best practices for GTK development:
> 
> > gcc program_name.c  ­o program_name `pkg ­config –cflags gtk+ ­3.0
> –libs gtk+ ­3.0`
> 
> Be careful that your typesetting program is replacing `--` with `–`.
> Additionally, this is not really portable: compiler flags should
> always come first, followed by the sources, and then the linker
> flags; additionally, you *really* want to encourage developers to
> enable warnings. A command line you may want to use is:
> 
>     gcc -Wall `pkg-config --cflags gtk+-3.0` -o program_name
> program_name.c `pkg-config --libs gtk+-3.0`
> 
> > Basic program
> 
> I understand that dropping straight into GtkApplication may be weird,
> but it is *strongly* recommended to use the GApplication API to
> create even simple examples. Developers will be tempted to keep using
> gtk_init()/gtk_main() when porting from older versions of GTK;
> additionally, Linux applications are made of things like a binary, a
> desktop file, and a well-known name owned on the session bus. It's
> important that people write well-behaved applications, if they want
> to use features like application menus and notifications, or if they
> want to be ready for the near future when we'll be able to do proper
> session and resource management. A basic program using GtkApplication
> is not really any more complicated than a plain binary:
> 
> ```
> static void
> on_activate (GApplication *app)
> {
>   GtkWidget *app_window = gtk_application_window_new (app);
> 
>   // populate the UI
> 
>   gtk_widget_show (app);
> }
> 
> int
> main (int argc, char *argv[])
> {
>   GtkApplication *app = gtk_application_new ("com.example.MyApp", 0);
> 
>   g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
> 
>   return g_application_run (G_APPLICATION (app), argc, argv);
> }
> ```
> 
> And it will take care of handling things like "closing the window
> will terminate the application" for you, without having to go through
> delete-event.
> 
> > Events
> 
> The function declarations for the callbacks return `void`, but they
> should return `gboolean`, like the example does. You should also use
> `GDK_EVENT_STOP` and `GDK_EVENT_PROPAGATE` in lieu of `TRUE` and
> `FALSE`, respectively, to enhance readability.
> 
> > Missing content
> 
> You should point developers in the direction of GtkBuilder, for
> constructing your UI with XML (and Glade, if you don't want to hand-
> edit your UI definitions); menus should also be defined using XML and
> GtkBuilder, and associated to applications using the GtkApplication,
> GMenu, and GAction API; this allows creating menus that will
> automatically work on different platforms, as well as be easier to
> construct than a pile of GtkMenuItem and GtkMenu widgets.
> 
> There are various wiki pages that you may be interested in; see the
> "How Do I" section: https://wiki.gnome.org/HowDoI/
> 
> Thanks again for your work!
> 
> Ciao,
>  Emmanuele.
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-list
[Attachment #5 (text/html)]

<html><head></head><body><div>Hi Emmanuele,</div><div><br></div><div>I do agree with \
you but, From a beginners concept,The concept of Gtk-application and the handling of \
applications arguments is confusing coming from someone who is still learning from \
say - standard "C" as they are handled the same way in just about any example on a \
google search,&nbsp;&nbsp;</div><div><br></div><div>When you combine this with the \
concept of main loop and  instances that need to be created, controlled and destroyed \
then the complexity may be simple for an experienced programmer, but not to a \
beginner.&nbsp;</div><div><br></div><div>In other words the original way is easy to \
understand what is actually going on, but the new way is complex and needs further \
explanation for a beginner to understand the concept and to be able to write and \
apply the code correctly.</div><div><br></div><div>These needs to be explained by a \
beginner for a beginner with input from experienced people with good example that \
explain what the steps are actually doing in the code and why you need to use them. \
</div><div><br></div><div>The beginners guide is a great start for this, thanks to \
the author, please do not \
stop.</div><div><br></div><div>Regards</div><div><br></div><div><br></div><div><br></div><div>On \
Fri, 2018-04-27 at 14:54 +0100, Emmanuele Bassi wrote:</div><blockquote type="cite" \
style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div \
dir="ltr"><div>Hi;<br><br></div>thanks for your contributions: documentation is \
always welcome.<br><div class="gmail_extra"><br><div class="gmail_quote">On 24 April \
2018 at 19:39, Jim Reilly <span dir="ltr">&lt;<a \
href="mailto:jimreillyindevon@gmail.com" \
target="_blank">jimreillyindevon@gmail.com</a>&gt;</span> wrote:<br><blockquote \
type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf \
solid;padding-left:1ex">I have put together a guide to help beginners to get started \
using gtk+3.0 in the hope that it might be useful. I do not have a web site through \
which I can make it available so I have attached it to this e-mail so that, if anyone \
thinks it is worth reading, they can make it accessible to others.<br> \
<br></blockquote><div><br></div><div>It would have been nicer to have some form of \
text source, in order to provide you with feedback.<br><br></div><div>In any case, \
here's a rough list of improvements to the examples and practices, to match the \
current best practices for GTK development:<br><br>&gt; gcc program_name.c  ­o \
program_name `pkg ­config –cflags gtk+ ­3.0 –libs gtk+ ­3.0`<br><br></div><div>Be \
careful that your typesetting program is replacing `--` with `–`. Additionally, \
this is not really portable: compiler flags should always come first, followed by the \
sources, and then the linker flags; additionally, you *really* want to encourage \
developers to enable warnings. A command line you may want to use \
is:<br><br></div><div>&nbsp; &nbsp; gcc -Wall `pkg-config --cflags gtk+-3.0` -o \
program_name program_name.c `pkg-config --libs \
gtk+-3.0`<br></div></div><br></div><div class="gmail_extra">&gt; Basic \
program<br><br></div><div class="gmail_extra">I understand that dropping straight \
into GtkApplication may be weird, but it is *strongly* recommended to use the \
GApplication API to create even simple examples. Developers will be tempted to keep \
using gtk_init()/gtk_main() when porting from older versions of GTK; additionally, \
Linux applications are made of things like a binary, a desktop file, and a well-known \
name owned on the session bus. It's important that people write well-behaved \
applications, if they want to use features like application menus and notifications, \
or if they want to be ready for the near future when we'll be able to do proper \
session and resource management. A basic program using GtkApplication is not really \
any more complicated than a plain binary:<br><br>```<br></div><div \
class="gmail_extra">static void<br></div><div class="gmail_extra">on_activate \
(GApplication *app)<br>{<br></div><div class="gmail_extra">&nbsp; GtkWidget \
*app_window = gtk_application_window_new (app);<br><br></div><div \
class="gmail_extra">&nbsp; // populate the UI<br></div><div \
class="gmail_extra"><br></div><div class="gmail_extra">&nbsp; gtk_widget_show \
(app);<br></div><div class="gmail_extra">}<br><br></div><div \
class="gmail_extra">int<br></div><div class="gmail_extra">main (int argc, char \
*argv[])<br>{<br></div><div class="gmail_extra">&nbsp; GtkApplication *app = \
gtk_application_new ("com.example.MyApp", 0);<br><br></div><div \
class="gmail_extra">&nbsp; g_signal_connect (app, "activate", G_CALLBACK \
(on_activate), NULL);<br><br></div><div class="gmail_extra">&nbsp; return \
g_application_run (G_APPLICATION (app), argc, argv);<br></div><div \
class="gmail_extra">}<br>```<br><br></div><div class="gmail_extra">And it will take \
care of handling things like "closing the window will terminate the application" for \
you, without having to go through delete-event.<br clear="all"></div><div \
class="gmail_extra"><br></div><div class="gmail_extra">&gt; Events<br><br></div><div \
class="gmail_extra">The function declarations for the callbacks return `void`, but \
they should return `gboolean`, like the example does. You should also use \
`GDK_EVENT_STOP` and `GDK_EVENT_PROPAGATE` in lieu of `TRUE` and `FALSE`, \
respectively, to enhance readability.<br><br></div><div class="gmail_extra">&gt; \
Missing content<br></div><div class="gmail_extra"><br></div><div \
class="gmail_extra">You should point developers in the direction of GtkBuilder, for \
constructing your UI with XML (and Glade, if you don't want to hand-edit your UI \
definitions); menus should also be defined using XML and GtkBuilder, and associated \
to applications using the GtkApplication, GMenu, and GAction API; this allows \
creating menus that will automatically work on different platforms, as well as be \
easier to construct than a pile of GtkMenuItem and GtkMenu widgets.<br></div><div \
class="gmail_extra"><br></div><div class="gmail_extra">There are various wiki pages \
that you may be interested in; see the "How Do I" section: <a \
href="https://wiki.gnome.org/HowDoI/">https://wiki.gnome.org/HowDoI/</a><br></div><div \
class="gmail_extra"><br></div><div class="gmail_extra">Thanks again for your \
work!<br><br></div><div class="gmail_extra">Ciao,<br></div><div \
class="gmail_extra">&nbsp;Emmanuele.<br></div><div \
class="gmail_extra"><br><pre>_______________________________________________ gtk-list \
mailing list <a href="mailto:gtk-list@gnome.org">gtk-list@gnome.org</a>
<a href="https://mail.gnome.org/mailman/listinfo/gtk-list">https://mail.gnome.org/mailman/listinfo/gtk-list</a>
 </pre></div></div></blockquote></body></html>



_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic