Beginners guide

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Beginners guide

Jim Reilly
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.

regards

Jim Reilly.


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

Beginner's Guide to GTK+3.0.pdf (312K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Leo Ufimtsev
Hello Jim,

This looks like a great guide!

We will probably make use of this for our interns.

Do you have the sources?
Would you consider putting it into a git hub repo and be open to pull requests?





On Tue, Apr 24, 2018 at 2:39 PM, Jim Reilly <[hidden email]> 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.

regards

Jim Reilly.


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list




--
Leo Ufimtsev, Software Engineer, Red Hat

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Göran Hasse
In reply to this post by Jim Reilly
Books don't have to be very thick to be called books.

Make a small book on: https://en.wikibooks.org/wiki/Subject:Computing

/gh

Den 2018-04-24 kl. 19:39, skrev Jim Reilly:

> 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.
>
> regards
>
> Jim Reilly.
>
>
>
> _______________________________________________
> gtk-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-list
>

--
Göran Hasse
Raditex Control AB
Boo 229
715 91 ODENSBACKEN
http://www.rscada.se
OrgNr: 556611-8773
email: [hidden email]
tel: 019-450105
mob: 070-5530148
Lat:  59.18805083 Long: 15.50300449
URL: http://alturl.com/3e6hf
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Leo Ufimtsev


On Tue, Apr 24, 2018 at 3:20 PM, Göran Hasse <[hidden email]> wrote:
Books don't have to be very thick to be called books.

Make a small book on: https://en.wikibooks.org/wiki/Subject:Computing

+1
 


/gh

Den 2018-04-24 kl. 19:39, skrev Jim Reilly:
> 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.
>
> regards
>
> Jim Reilly.
>
>
>
> _______________________________________________
> gtk-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-list
>

--
Göran Hasse
Raditex Control AB
Boo 229
715 91 ODENSBACKEN
http://www.rscada.se
OrgNr: 556611-8773
email: [hidden email]
tel: 019-450105
mob: 070-5530148
Lat:  59.18805083 Long: 15.50300449
URL: http://alturl.com/3e6hf
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list



--
Leo Ufimtsev, Software Engineer, Red Hat

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Marshall Lake
In reply to this post by Jim Reilly

Thanks for this.  I can use all the help I can get.


> Date: Tue, 24 Apr 2018 19:39:06 +0100
> From: Jim Reilly <[hidden email]>
>
> 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.

--
Marshall Lake -- [hidden email] -- http://www.mlake.net
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Igor Chetverovod
In reply to this post by Jim Reilly
Hello Jim,
Thank you for book.
I think this guide must include  information about main context and main loop and  how to split UI handling and other computations to several  main  loops running in several threads.  Because one day beginner using in application single main loop will be faced with freezing of UI. 

Без вирусов. www.avast.ru

2018-04-24 21:39 GMT+03:00 Jim Reilly <[hidden email]>:
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.

regards

Jim Reilly.


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Stefan Salewski-2
In reply to this post by Jim Reilly
On Tue, 2018-04-24 at 19:39 +0100, Jim Reilly wrote:
> I have put together a guide to help beginners

>All GTK+3.0 programs contain the same basic instructions, and

Well, maybe you should also mention the preferred GTK3 app style as I
did in the second example in

https://github.com/StefanSalewski/gintro
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Patrick-218
Hi Jim

I have been using 2.0 and dreading the switch. Your guide is helpful,
thanks for taking the time to do this-Pat
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Emmanuele Bassi
In reply to this post by Jim Reilly
Hi;

thanks for your contributions: documentation is always welcome.

On 24 April 2018 at 19:39, Jim Reilly <[hidden email]> 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
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Emmanuele Bassi
In reply to this post by Patrick-218
On 27 April 2018 at 14:06, Patrick <[hidden email]> wrote:

I have been using 2.0 and dreading the switch. Your guide is helpful, thanks for taking the time to do this-Pat


Porting applications from 2.x to 3.x already has a whole section on the API reference — including the preparatory work you need to do before beginning the port proper:

  https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html

If there are missing items, please: feel free to file bugs.

Ciao,
 Emmanuele.

--

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Timothy Ward
In reply to this post by Emmanuele Bassi
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 <[hidden email]> 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
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Paul Davis


On Fri, Apr 27, 2018 at 2:27 PM, Timothy Ward <[hidden email]> wrote:
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. 

​GtkApplication is precisely where beginners should start. The fact that introductory books on C programming don't mention event loops, is not a justification for hiding the fact that GUI applications (fully translated: applications that accept unbounded and unpredictable user input while running) are conceptually and fundamentally different from data-driven programming.

The sooner "beginners" are exposed to this concept, the better. And let's be honest: it's no more complex than at least a half-dozen other conpcets that the developer of a contemporary GUI application will need to face along the way. Quite possibly one of the simplest, in fact.

The same thing applies to the GAction/GtkAction concept. Most GTK+ applications would be very much better designed internally and at the UI/UX level if their developers started from this concept, but it is generally deemed "too advanced". In reality, it provides the appropriate simplifications and scaffolding to build applications that work in the way that users expect in 2018 and beyond.​



_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Stefan Salewski-2
In reply to this post by Emmanuele Bassi
On Fri, 2018-04-27 at 14:54 +0100, Emmanuele Bassi wrote:
> There are various wiki pages that you may be interested in; see the
> "How Do I" section: https://wiki.gnome.org/HowDoI/

I wonder that you do not recommend the page

https://developer.gnome.org/gtk3/stable/ch01s04.html#id-1.2.3.12.5

Is that one already outdated?
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Beginners guide

Emmanuele Bassi

On Sat, 28 Apr 2018 at 06:21, Stefan Salewski <[hidden email]> wrote:
On Fri, 2018-04-27 at 14:54 +0100, Emmanuele Bassi wrote:
> There are various wiki pages that you may be interested in; see the
> "How Do I" section: https://wiki.gnome.org/HowDoI/

I wonder that you do not recommend the page

https://developer.gnome.org/gtk3/stable/ch01s04.html#id-1.2.3.12.5

Is that one already outdated?
No, but that’s easier to find than the How Do I wiki pages.

Ciao,
 Emmanuele.
--

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list