GTK good stuff?

So I am working on ruby-gtk3 again. It’s quite ok.

Today I used Gtk::SearchBar and Gtk::SearchEntry,
and combined it with a missing popover-widget
(e. g. if no result is found). This was quite simple to

I was wondering … what if we’d have TONS of such small
examples that people could sort of re-use like in a LEGO
building block? I collected many examples in my own
project, but I am wondering whether I am not missing
so many more examples. I even integrated most pygobject
examples into my ruby-gtk3 centric project now … and
now I am wondering whether to look at next.

Perhaps upstream gtk could bundle many more smaller
snippets that could showcase useful tidbits? With the
example of Gtk::SearchEntry and ctrl+f key I can get a
quick search-field toggle for all my ruby-gtk3 widgets
now, which is super-convenient. I kind of would like
to have similar small widgets tying together functionality
but not necessarily having to create them all on my own
if that makes sense, but just to re-use what may exist out
there. Even just small examples how things work, like how
to embed videos from youtube into a gtk application (it’s
ok to e. g. use youtube-dl first to download, and then display
it, but without code to look at, I tend to struggle how to best
do this in gtk usually.)

Hi! :slight_smile:

Did you have a look at the GTK demos (and the GTK widget factory)? They provide a decent amount of examples that use most available GTK widgets.

Otherwise looking at how other GNOME apps do stuff is a good way of learning too, and there’s lots of them here hence lots of examples too.

Are you the current maintainer of the Ruby gtk3 bindings? If so, how far are you with GTK4 support?

I think OP is talking about reusable widget components that they can plug into their code instead of writing from scratch. Something like how libadwaita provides responsive widgets. :thinking: :sweat_smile:

From what I understood it’s about finding examples that shows how to do e.g. proper search entry behaviour.

From what I understood now he is not a Ruby GTK bindings dev or maintainer, see

Towards GTK4 - a plea

So his writing

So I am working on ruby-gtk3 again. It’s quite ok.

is really a bit strange for being just a part time user :frowning:

This tells me that OP wants reusable examples. But still, it could be just examples. Not sure anyway. :sweat_smile:

Personally I think that a set of small example programs is more useful than larger, more complex and more difficult example programs. That is why my Nim GTK4 book and my Nim programming book contains a lot of small examples only. I really like the small program on page which shows the code for multiple programming languages.

At least examples should be complete and should contain the instructions to compile and run the code. The examples from gtk4-demo are unfortunately not complete and are really difficult for beginners. I recently tried to convert the listview_clocks.c to Nim. First step was to makes it a standalone C code, which was already not easy. For C examples we should always consider the ability to port it to other languages, so whenever possible avoiding call of varargs functions or use of C macros as these may not be available in other languages.

So a set of a few hundred well commented small examples as the one from each for a dozen of different languages would be a fine start :slight_smile:

Maybe I should mention that not all people see the need for small examples. Maybe one year ago I was discussing with a bright Nim dev, and he told me that I should better write large programs, from which people can extract whatever they need. He may be bright, but he could not really convince me.

If you ever plan to make a book or just Git(lab/hub) pages that shows how-to stuffs in GTK in multiple languages, ping me in. That would be an excellent idea and I can collaborate :smiley:

It is in no way “an excellent idea” as it is just obvious.

Indeed for some of the Nim code examples I already started with a C code example, as in section

For all programming languages that do not strongly enforce OOP classes code style the example programs look very similar. Nim and C shape are very close, and I assume that some other languages like Golang would produce a similar structure. The book is written with AsciiDoctor, which since version 2.0 supports these collapsing boxes which one can open and close by clicking on the small triangle, That would be one way to show/hide the code for various program versions. At least for C examples that should work fine, so I may later provide for each Nim example an collapsed C code example additional. For languages with very strong OOP character like Java, Python, Ruby I am not sure if a separate modified book would make more sense.

But currently I am concentrating more on the Nim beginner book, as it seems to have more interested users, see Computer Programming with the Nim Programming Language Currently 29 github stars vs only 8 for the GTK4 book.

1 Like

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