--===============7762575941164603825== Content-Type: multipart/alternative; boundary="000000000000d31f28056ad4d839" --000000000000d31f28056ad4d839 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi; thanks for your contributions: documentation is always welcome. On 24 April 2018 at 19:39, Jim Reilly 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 whi= ch > 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 =C2=ADo program_name `pkg=C2=ADconfig =E2=80=93cflags = gtk+=C2=AD3.0 =E2=80=93libs gtk+=C2=AD3.0` Be careful that your typesetting program is replacing `--` with `=E2=80=93`= . 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 =3D gtk_application_window_new (app); // populate the UI gtk_widget_show (app); } int main (int argc, char *argv[]) { GtkApplication *app =3D 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. --=20 https://www.bassi.io [@] ebassi [@gmail.com] --000000000000d31f28056ad4d839 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi;

thanks for your contributions: docum= entation is always welcome.

On 24 April 2018 at 19:39, Jim Reilly <<= a href=3D"mailto:jimreillyindevon@gmail.com" target=3D"_blank">jimreillyind= evon@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 sit= e through which I can make it available so I have attached it to this e-mai= l so that, if anyone thinks it is worth reading, they can make it accessibl= e 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 =C2=ADo program_name `pkg=C2=ADconfig =E2=80=93cfl= ags gtk+=C2=AD3.0 =E2=80=93libs gtk+=C2=AD3.0`

Be careful= that your typesetting program is replacing `--` with `=E2=80=93`. Addition= ally, this is not really portable: compiler flags should always come first,= followed by the sources, and then the linker flags; additionally, you *rea= lly* want to encourage developers to enable warnings. A command line you ma= y want to use is:

=C2=A0 =C2=A0 gcc -Wall `pkg-config --c= flags gtk+-3.0` -o program_name program_name.c `pkg-config --libs gtk+-3.0`=

> Basic program
=
I understand that dropping straight in= to GtkApplication may be weird, but it is *strongly* recommended to use the= GApplication API to create even simple examples. Developers will be tempte= d to keep using gtk_init()/gtk_main() when porting from older versions of G= TK; additionally, Linux applications are made of things like a binary, a de= sktop file, and a well-known name owned on the session bus. It's import= ant that people write well-behaved applications, if they want to use featur= es like application menus and notifications, or if they want to be ready fo= r 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 com= plicated than a plain binary:

```
static void
on_activate (GApplication= *app)
{
=C2=A0 GtkWidget *app_windo= w =3D gtk_application_window_new (app);

=C2=A0 // populate the UI

=C2=A0 gtk_widget_show (app);
}

int
=
main (int argc, char *argv[])
{
=C2=A0 GtkApplication *app =3D gtk_application_new (= "com.example.MyApp", 0);

= =C2=A0 g_signal_connect (app, "activate", G_CALLBACK (on_activate= ), NULL);

=C2=A0 return g_applicati= on_run (G_APPLICATION (app), argc, argv);
}
```

And it will take care o= f handling things like "closing the window will terminate the applicat= ion" for you, without having to go through delete-event.

&= gt; Events

The function declaration= s for the callbacks return `void`, but they should return `gboolean`, like = the example does. You should also use `GDK_EVENT_STOP` and `GDK_EVENT_PROPA= GATE` in lieu of `TRUE` and `FALSE`, respectively, to enhance readability.<= br>
> Missing content

You should point= developers in the direction of GtkBuilder, for constructing your UI with X= ML (and Glade, if you don't want to hand-edit your UI definitions); men= us should also be defined using XML and GtkBuilder, and associated to appli= cations using the GtkApplication, GMenu, and GAction API; this allows creat= ing menus that will automatically work on different platforms, as well as b= e easier to construct than a pile of GtkMenuItem and GtkMenu widgets.

There a= re various wiki pages that you may be interested in; see the "How Do I= " section: https://wiki.gno= me.org/HowDoI/

Thanks again for your work!

Ciao,
=C2=A0Emmanuele.
--000000000000d31f28056ad4d839-- --===============7762575941164603825== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ gtk-list mailing list gtk-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-list --===============7762575941164603825==--