Le 21/03/2011 17:03, John Coppens a écrit :
> On Mon, 21 Mar 2011 15:42:17 +0100
> Colomban Wendling <lists....@herbesfolles.org> wrote:
> 
>>> The form (-de), frequently used, fails though it is advertised
>>> in the Command line parser description:
>>>
>>> http://library.gnome.org/devel/glib/unstable/glib-Commandline-option-parser.html#g-option-context-add-main-entries
>>>
>>> {"debug", 'd', 0, G_OPTION_ARG_STRING, &dbg, "Debug options", "opts"},
>>> why?
>>
>> This is NOT meant to work as you seem to expect, and the docs tells you:
>> "-de" is the same as "-d -e", not "-d e".
>> This is a very common thing, and most commands works this way (apart
>> perhaps cut).
> 
> Ok... But if I put d: in getopt's arg list, I do expect an argument,
> and -de is parsed as -d e. Why doesn't GOptionEntry, with a specified
> G_OPTION_ARG_STRING do the same?

Don't know why, I'm no GLib developer nor never worried about it. But
how getopt handle arguments "d:e" if you give it "-de"? Does this mean
"-d -e" or "-d e"?
I'd think that GOption behavior is at least easier to understand.

>>> 3) The reason I wanted to migrate to GOption, is that it seems
>>> gnome_program_init doesn't eliminate the recognized default arguments
>>> such as --g-fatal-warnings, if added. So, in gdb, a run
>>> --g-fatal-warnings produces an error in getopt. 
>>
>> AFAIR, --g-fatal-warnings is NOT a standard option. You're expected to
>> use the environment variable G_DEBUG:
>> G_DEBUG=fatal-warnings gdb yourapp
>>
>> See http://library.gnome.org/devel/glib/unstable/glib-running.html
> 
> http://library.gnome.org/devel/gtk/2.21/gtk-running.html
> 
> Or doesn't GNOME pass those arguments to GTK?
> 
> (BTW, gimp accepts --g-fatal-warnings)

Use gtk_get_option_group(), see
http://library.gnome.org/devel/gtk/2.21/gtk-General.html#gtk-get-option-group
and
http://library.gnome.org/devel/glib/unstable/glib-Commandline-option-parser.html#glib-Commandline-option-parser.description

>>> I've looked through numerous pages - can anyone point to an app that
>>> actually uses GOption for more than a minimal options set?
>>
>> Most GNOME programs, and let's guess: GIMP ;)
> 
> Strange that gimp didn't jump out with a google search. Isn't the code
> visible on the net?

Of course: http://git.gnome.org/browse/gimp/tree/

Regards,
Colomban
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to