What topic is necessary for gtk4 tutorials for beginners?

I am making a gtk4 tutorial for beginners on github (https://github.com/ToshioCP/Gtk4-tutorial).
I am happy if you give me advice.

I’ve put the following in the tutorial.

  • How to generate and run GtkApplication
  • Widgets and their parent-child relationship
  • Objects and their parent-child relationoship
  • Ui file and GtkBuilder
  • Signals. generating, emitting, connecting handlers
  • Meson build system
  • Menus and actions

In addition, what other topic is necessary for the tutorial for beginners?
I’m not an expert, I’m studying gtk4 at present and My knowledge about gtk4 is limited.
Therefore, your advice from the view of whole gtk4 is welcome.

Any other advice and/or suggestion is also appreciated.

I(m sorry if this topic is not appropriate for gnome discource.

Thank you very much.

6 Likes

Ui file and GtkBuilder would be nice because I do not really cover that in my GTK4 book yet. And maybe you can try to explain if/how Glade can be used with GTK4, as many people seem to like Glade.

And of course it would be nice if you could proof read my book. You may push issues or suggestions to github issue tracker.

[EDIT]

And explaining how users can best install GTK4 when package managers do not yet have GTK4. And how GTK4 can be best installed on Windows and Mac. And how users can debug their apps, how they can use valgrind and debug crashes.

1 Like

Thank you very much for your advice, Stefan.

I’ve already written about Ui files and GtkBuilder in my tutorial.
I would like to write about Glade, but maybe in the future.
Because gtk4 is really new and Glade might not work on gtk4 now, mightn’t it?

I will write how to install gtk4 on ubuntu soon.
However, I don’t know about windows and macos unfortunately.
So, it is impossible for me to write the installation to them.
If someone write them and add them to my tutorial, it is really helpful.

Anyway, thank you very much Stefan.
I will read your book soon.

Toshio

1 Like

GtkColumnView is a new control and will be used widely, maybe it’s a good idea for taking a tutorial for it.

Thank you Andy.

I haven’t used GtkColumnView yet.
I will study it and think about putting it in my tutorial.

Thank your for that work! It seems very helpful! I have put a link in the wiki of my gtk-fortran project.

Thank you Vincent.
I’m very happy to hear that.

A tutorial about drawing in GTK 4 could be useful:
https://blog.gtk.org/2020/04/24/custom-widgets-in-gtk-4-drawing/
I am still using Cairo (“Drawing the old-fashioned way”), but the advice seems now to use GtkSnapshot. They talk also about textures. And there is a gtk_snapshot_append_cairo() function which interests me in my own project because PLplot is offering a Cairo driver.

+1 for Meson.

At the end, we should have a section that build an application from the scratch based on concepts we cover. For example, Image Viewer, Text Editor, To Do, Note taking app, or Markdown Editor. This way, we know how to use concepts cover earlier in tutorial in action.

Hello, Vincent. Thank you for the post again.
I’ve read the blog and Gtk4 API document, and I’m thinking that there are two options for drawing.

  • Use GtkDrawingArea with Cairo.
  • Use GtkGLArea with OpenGL.

The blog describes that Gtk4 uses

void (* snapshot) (GtkWidget *widget, GtkSnapshot *snapshot)

instead of

gboolean (* draw) (GtkWidget *widget, cairo_t *cr)

in GtkWidgetClass.

This virtual function is used to draw the widget itself.
Therefore, it is necessary when you make your own Gtkwidget.

I’m not sure if this is useful for custom drawing in gtk4, but maybe the two options above are the common way.
If my understanding is wrong, please make a correction.

I’m planning to add an example of GtkDrawingArea and Cairo to my tutorial. It will take some time.

I hope you will have a great success in your project.

Toshio

1 Like

Thank you Kiran for the comment.

I agree.
Such applications are important for tutorals.

I’ve put a very simple text editor in the tutorial repository. The location is Gtk4-tutorial/src/tfe5. So, readers can try to compile and execute it if they download the whole tutorial files from the repository. And the list of the source file is in tfe5 source files.

However, it is obscure for readers to find it. I will soon add a link to the body of the tutorial and how to compile and execute the simple editor in section 14.

I’m planning to add another sample application to the tutorial. It is a simple turtle graphics interpreter. It includes custom drawing with GtkDrawingArea and Cairo. And I want to add very simple explanation about lexical analysis and parser generator.

Toshio

1 Like

Are you going to introduce the installation of GTK4 as well?

Thank you for the comment, Michael.

I put the gtk4 installation instruction into the tutorial four days ago (13/Jan/2021).
See Section 2.

The tutorial is under development and unstable.
It is frequently updated recently.
So, It is good for readers to see the repository itself, not the downloaded files.

I’d like to say thank you to all the readers of my tutorial. I want to add some information about it.

If you want to get the tutorial as html or pdf, see Readme_for_developers.md.
The instrution is as follows.

  • Prerequisite: ruby, rake, pandoc and pdflatex
  • Git clone or download zip from the git repository.
  • Change your current directory at the top of the downloaded files.
  • type rake html to generate html files under html directory.
  • type rake pdf to generate pdf files under latex directory.

However, the tutorial is unstable now. I think it is good for readers to see the repository directly at present.

1 Like

The most “necessary” thing is that you should try to incorporate them into official documents or wikis.

There are so many “tutorials for beginners” which are of sub-quality and full of out-of-date content during the gtk3 ages. Then they become ash and dust. Just Google it “gtk3 tutorial”, most of them are incomplete or less qualified.

Putting them in your personal repo may implicitly lower your standard of quality for the material.

There are “tutorial” at the head of gtk4’s doc, and they are a lot of space to improve. Besides, anyone tries to use GTK may encounter them.

Use your materials to improve overall doc >> yet another not-so-good tutorial.

Sry for hostile language.

Thank you for the advice, Zetrov.

The most “necessary” thing is that you should try to incorporate them into official documents or wikis.

There are “tutorial” at the head of gtk4’s doc, and they are a lot of space to improve. Besides, anyone tries to use GTK may encounter them.

I think it’s very important to improve official documents and wikis. And maybe I could put some part of my tutorial into wikis. However, the tutorial in Gtk4 reference manual is like an introduction so it should be brief and to the point. It is not appropriate to put my whole tutorial into it.

In my experience, beginners who read the reference manual feel dificulties because of the lack of other basic concepts as GObject, GIO, Glib, Cairo and so on. Therefore, My tutorial includes them widely, not limited to gtk4. I don’t know such tutorials in the official gnome website so far. If there is a plan to make a tutorial like that in the official website, I want to make a contribution.

For now, I want to make effort to keep my tutorial corresponds to the latest gtk4 libraries.
Fortunately, I’m not so busy now and I’ll be able to do it for at least a couple of years.