Re: GTK4 documentation



On 12 December 2017 at 18:19, Igor Korot <ikorot01 gmail com> 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.

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().

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.

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]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]