Web lists-archives.com

Re: GTK4 documentation

Hi, Emmanuelle,

On Tue, Dec 12, 2017 at 1:29 PM, Emmanuele Bassi <ebassi@xxxxxxxxx> wrote:
> On 12 December 2017 at 18:19, Igor Korot <ikorot01@xxxxxxxxx> wrote:
>>  Hi, ALL,
>> On the page https://developer.gnome.org/gtk4/stable/gtk4-General.html
>> in the "Description"
>> part in the sample code it is referencing the "gtk_init( &argc, &argv );".
>> However, if you look at the actual function -
>> https://developer.gnome.org/gtk4/stable/gtk4-General.html#gtk-init -
>> it is documented as "void gtk_init(void);", i.e. it does not take any
>> arguments.
>> I am not sure which one is correct - just wanted to report this to you guys.
> The reference hasn't been updated, as we're still releasing developers
> snapshots and we're churning on the API. By the time 4.0 is released,
> the API reference will be updated.

This probably means that you are aware of that, right?
However you decision is not that good - for people who will want to port early
at least.
I don't know if I'm the only one or not, but...

>> Moreover, if the function is documented correctly, then there is no
>> way to pass command-line
>> arguments to the program. Or is there?
> First of all, the arguments vector you passed to gtk_init() were for
> GDK and GTK *only*, not for your application; gtk_init() has always
> removed the arguments it interpreted, and then gave the arguments
> vector back to you, to do with it as you pleased. Historically, you
> typically should have gotten the GOptionGroup from GDK and GTK, added
> it to your GOptionContext, and then parsed the arguments vector using
> g_option_context_parse().

Does this mean this will be changed?
And I will have to rewrite this piece of code completely?

> In GTK+ 4.x, we removed the command line arguments for GDK and GTK, in
> favour of settings and environment variables — the same ones we
> already used, like DISPLAY, or G_DEBUG. This simplifies the
> initialisation process, and it ensures that your application is in
> charge of parsing the command line, not the library (or libraries) you
> happen to use.

So there will be no more GOptionGroup/Context?

Thank you.

> Finally, you should not be using gtk_init()/gtk_main() in newly
> written code even with GTK+ 3.x; use GtkApplication instead, as it's
> the preferred way to create an application with modern GTK.
> Ciao,
>  Emmanuele.
> --
> https://www.bassi.io
> [@] ebassi [@gmail.com]
gtk-list mailing list