ToshioCP / Gtk4-tutorial

GTK 4 tutorial for beginners
https://toshiocp.github.io/Gtk4-tutorial/
548 stars 50 forks source link

Chaining up of objects in GTK need explaining with examples #11

Closed gitsop01 closed 11 months ago

gitsop01 commented 2 years ago

!) how a widget is created and chained up to the parent requires explanation as GTK4 does not handle command line arguments and is required to know the steps to write correct code in GTK.

ToshioCP commented 2 years ago

Thank you for the post.

I'd like to clarify your message so that I will be able to improve the tutorial.

How a widget is created and chained up to the parent ...

Does parent means parent class? Or something other than that?

as GTK4 does not handle command line arguments ...

Functions gtk_application_new () and g_application_run () are used to implement a Gtk application. If you want to handle command line arguments and the arguments are not files, G_APPLICATION_HANDLES_COMMAND_LINE is used as the second argument of gtk_application_new. These are described in GIO reference manual.

If you pointed out the things I described above, I think that handling arguments other than files are not a common topic.

I'll be happy if you answer these things.

gitsop01 commented 2 years ago

Yes the reference to chaining up is in relation to classes and the types, initiallising a class, using the class oblect, disposing of the class object and finalising a class object.. They need example to explain what they are used for and why, What is the reason for their use, etc. Many tutorial without this in it, are not complete and if it is used in a GTK example or GTK code base it should be explained in full, to provide understanding to those who are trying to learn the basics.

Setting up a G_APPLICATION_HANDLES_COMMAND_LINE is not a simple process and needs explanation in a tutorial as people need to know why this is required as against the standard way of including command line arguments in the "C" language.

ToshioCP commented 2 years ago

Thank you for the reply.

The first thing you pointed out is the initialization and destruction process of GObject class and instances. I agree with you about the importance of these things. However, 'Gtk4 tutorial' is focused on the widgets so there are only a little explanation about GObject initialization and destruction. Instead, I wrote 'GObject tutorial' in my GITHUB repository. Its explanation includes the initialization and destruction of GObject. And readers who want to know about GObject itself can refer to 'GObject tutorial'.

I will modify the 'Readme.md' file of 'Gtk4 tutorial' and add the link to 'GObject tutorial' for the convenience of readers.

Setting up a G_APPLICATION_HANDLES_COMMAND_LINE is not a simple process and needs explanation in a tutorial as people need to know why this is required as against the standard way of including command line arguments in the "C" language.

I think that gtk4 application doesn't need the option in many cases. And if the tutorial includes it, lots of explanation is necessary and it will be a burden for the beginners. So, I think it's better not to explain it in the tutorial but put a link to GIO reference manual (g_application_run) in section 7.