On 28.05.25 00:25, David Pirotte wrote:
Hello Zelphir,
[...]
I am slowly figuring things out with G-Golf and trying to build my
own examples for how to do things with it. (repo:
https://codeberg.org/ZelphirKaltstahl/guilt-gtk-g-golf-examples, or
most recent branch:
https://codeberg.org/ZelphirKaltstahl/guilt-gtk-g-golf-examples/src/branch/feature/add-menu-bar)
Before answering your specific quiz, let me immediately suggest:
- never refer to (nor even read) earlier doc versions of gtk,
always read and take examples from gtk-4 (and g-golf);
Ah, my bad! I have so many browser tabs open at the moment pointing to various
documentation websites, that I must have clicked an older one at some point. Now
that I changed the URL of that tab in my browser, I see the different look and
hopefully catch it next time : )
- use libadwaita, and only use gtk for those widgets that are
not provided by libadwaita;
To be honest, I still don't really know, what libadwaita does or ads and why it
is better to use that. In the past I have used GTK3 from Python and that worked
fine without anything extra. What is the reason why libadwaita is preferred? I
was thinking to keep things as simple as possible. Doesn't GTK already have
everything one usually needs? Like all the widgets, layout managers, even CSS
themes.
- use templates, and define your app (as much as possible) in
its sxml files (because it is easier to write and read, to
answer one of your below quiz) - use a subdir for those and
copy/use the makefile that is in g-golf's libadwaita demo to
generate the .ui files whenever you make changes;
I am planning to do that. I just find the separate SXML to XML file step
cumbersome and would prefer, if it is all done in one go.
Perhaps I could live with exporting the XML when the app starts, but then it
would happen every time, often needlessly ...
I think my problem is, that I am not sure yet, how to create other widgets from
UI file. Do they all have `#:template` argument for the constructor? The answer
to that is probably the same as to the question whether they all have a
`template` member/slot, because the docs of G-Golf mention that such members
turn into keyword args. I simply don't know yet and subsequently don't know
whether I later will be able to create some dialog or some dynamically created
widget using a template, or later will have a split in the code between
templated and not templated.
-> Does every widget have a way using its constructor to specify a UI file (and
have it use that)?
[ there is a primary menu example in g-golf, the adwaita-1-demo
[ port
Yep, that's the one I looked at mostly.
That is the one, that took me quite a while to figure out, that the SXML there
is not used directly, but must have some build (export to XML) step somewhere
else. But now it is clear!
To reiterate one point though: If there had been a comment above the SXML
telling me, that these are not used directly, but translated to XML files by a
separate build step, I think that would have helped me.
- most of the difficulties you are facing are due to the
inherent complexities of the upstream libraries, not g-golf
(which actually 'makes things' a lot easier then if you had
to program your app in C).
I believe you. However, there are also lots of explained examples in the docs
using C code ; ) Now I am not always sure, whether calling all the equivalent
G-Golf procedures is the right thing to do in all cases. (for example:
g-object-unref).
(Q1) Using G-Golf, does one ever have to call `g-object-unref`, or
does G-Golf take care of that?
Unless you find a bug, g-golf takes care of those.
Ah that's a great relieve! I take it, that there is no fiddling with GC and
similar stuff then.
Thanks for all the input!
Best regards,
Zelphir
--
repositories: https://notabug.org/ZelphirKaltstahl,
https://codeberg.org/ZelphirKaltstahl