How to study GTK4?

, ,

I know this question is asked a lot, but honestly its been so tiring to study gtk docs, do you guys have any suggestions on how i can improve? My code is a total mess and its basically been trial and error. Should i go to gtk3 first and then move to gtk4? Any idea is appreciated…

1 Like

Starting with GTK 3 to move to GTK 4 is not an good idea. GTK 3 will likely be as confusing as GTK 4, just older. And there have been some fundamental changes as well. So you should definitely stay with GTK 4.

As for improving yourself:
Unfortunately, there is no simple “use this to improve yourself”. Especially since we don’t know how much knowledge you already have. Learning something new will always be a difficult process with trial and error, as you make mistakes and learn from it.

But, just a few general pointers:

  • GNOME has some tutorials covering the basics
  • Workbench has good, small examples and is a good playground to test some ideas
  • If there is an app that already does something similar, you can look in its source code to learn from their approach

If you have questions about a specific topic, you can also always ask them here or in the #app-dev:gnome.org Matrix room.

And last, but not least:
Try to avoid using LLM as a quick solution. An LLM might give you a quick answer, but it doesn’t really help you to learn the concepts well. If you’re really interested in learning something, there is no way around getting into the matter yourself.

2 Likes

Thank you for the suggestions and yes, i do try to avoid LLM

1 Like

The real question is: are you learning to code in C and learning GTK at the same time?

If you already know another programming language, you probably want to use that to avoid the double learning curve—especially because C/GObject is not really how people learn plain C.

If you are learning a programming language at the same time as GTK, then you may want to start with an easier language with built-in syntactic sugar for object orientation, like Python; or you may want to look at JavaScript/TypeScript.

2 Likes

I’ve been programming in C for the past 7-8 months now, but i can still say i am learning. I prefer to learn and study with good theory and practical problems in the same time. I am already familiar with python and i’ve used tkinter before, but i want to get my hands on some GUI programming with C and GTK.

I would still recommend using Python for your first GTK app, ie text editor or video player. After doing that you would know the basics and what workflow works for you. Only C docs exist, officially at least, but you will fast learn how to use them with Python. Even if you’re a good C coder I would still recommend learning GTK with Python first as it’ll probably be faster anyway.

1 Like

Making the first application you develop an text editor or an video player, aka. quite complex applications, is certainly an recommendation. But definitely not one I would make…

But I do agree with using a less complex language for the first app. C is, compared to Python, Vala or similar, a relatively complex language.

1 Like

I did not know about workbench, and this seems to be a great resource. Thanks !

I also share the opinion of @viktorptrv and others that the learning curve of GLib/Gtk is very steep.

I often refer back to GObject tutorial and Gtk4 Tutorial.

Sébastien Wilmet also wrote some introduction about the GLib/Gtk Development platform.

Even if LLMs are not a good way to learn, sometimes, if you do not have any clue, you can still make a request, and you will be provided with some Objects you may use for achieving your objective. Once you know the objects you may use, you may refer to the official documentation for these objects.

Another good resource are the unit tests of GLib/Gtk which also show how these functions are used “in practice”.

Finally, another way of seeing the objects and their methods in action is to perform a search in the GNOME respository. Since I did not find a way of doing that in GNOME Gitlab (if somebody knows, please explain :slight_smile: ), I am often using the mirror on Github for performing a seach. For instance, if you would like to see examples of use of the function g_dbus_connection_call, I use Github search’s functionality with the following prompt:

g_dbus_connection_call language:C NOT repo:GNOME/glib org:GNOME

and I get examples from GNOME projects such as GIMP, Mutter, evince, etc. This should normally be reference code to be learnt from.

2 Likes

Thank you for the information! Will def check out the guides you’ve given me!

Best Regards,

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.