Re: gtk_init_with_args behavior





On 21/05/2018 01:27, Allin Cottrell wrote:
On Sun, 20 May 2018, Miroslav Rajcic wrote:

I've been doing it exactly like that in my own program, first getting the UTF-16 from Windows API, then converting to UTF-8 using g_utf16_to_utf8.

Thanks, I've now been able to confirm for myself that that works fine.

IMO, hooking this with gtk_init_with_args is not needed, GTK can use the standard args of the program, passed via "main()" function parameters, but you will bypass that mechanism completely and use API to fetch UTF-16 process parameters directly from OS.

gtk_init_with_args is still useful in my case: it automatically screens out any command-line arguments that are just option flags or parameters, via the GOptionEntry mechanism, leaving only a filename argument to which my program has to respond (but which may be broken in plain argv). Fortunately, it works fine after conversion via g_utf16_to_utf8. So my workflow is:

GetCommandLineW
CommandLineToArgvW
convert array of UTF-16 strings to UTF-8
pass the converted array to gtk_init_with_args

Hi,
I use:

filename = g_locale_to_utf8((argv*), -1, NULL, NULL, NULL);
do something with filename
free(filename)

This works also on windows.

Ciao,
Tito


Allin Cottrell

ref: https://mail.gnome.org/archives/gtk-app-devel-list/2018-May/msg00052.html
and following


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