GNOME Bugzilla – Bug 307312
gnome_program_init () should support GOption
Last modified: 2005-10-03 14:52:35 UTC
With glib-2.6 there was the the GOption parsing facility added. This is much appreciated - especially for programs which are also cross platform like Dia. But there seems to be no clean way to integrate required gnome program initialization GOption. So currently POPT (for GNOME) and GOption (for the rest) need to maintained which is quite a bloody mess: http://cvs.gnome.org/viewcvs/dia/app/app_procs.c See also: http://www.gtk.org/api/2.6/glib/glib-Commandline-option-parser.html
Created attachment 48010 [details] [review] GOption patch for libgnome Added 4 new parms - PARM_GOPTION_CONTEXT (readonly) - GOption Contexzt - PARM_GOPTION_TABLE - The Applications GOptionEntry - PARM_GOPTION_NAME - The name to add to help - PARM_GOPTION_ENABLE - tell libgnome to use goption (default is FALSE) Using module.info.expansion1 to get the other GOptionGroup from the modules that get loaded
Created attachment 48011 [details] [review] GOption Patch for libgnomeui Just added GoptionTable to the GnomeModuleInfo and add GOptionGroup to expansion1
Created attachment 48012 [details] [review] GOption Patch for libbonobo Just added GoptionTable to the GnomeModuleInfo and add GOptionGroup to expansion1
Created attachment 48013 [details] [review] GOption patch for libbonoboui Just added GoptionTable to the GnomeModuleInfo and added GOptionGroup to expansion1. Need to check if goption is enabled for bonobo-ui-init_gtk.c because gtk_get_option_group sets up the arguments and calls gtk_init already for us.
Just apply all the patches above in the appropriate modules. Just tell me if you need anything changed or added. I used to expansion1 to avoid adding a new gpointer to GnomeModuleInfo, but would be easy to change that.
This patchset depends on the patch from Bug 302632: no way to have a no-arg G_OPTION_ARG_CALLBACK; which now has been committed.
Created attachment 48015 [details] [review] GOption patch for libbonoboui I had debug g_print statement in the last patch, which I forgot to remove.
Created attachment 48136 [details] [review] Add GOption to libgnome I fixed a bug in my libgnome patch concerning error handling of goption_context_parse. So now it will inform the user of incorrect options and tell them to type --help.
Anders, could you comment on these?
This patch has another dependency for bug 308886. I am currently using G_OPTION_FLAG_NO_ARG for some of the goption_tables, but this flag might be removed for a more generic G_OPTION_CALLBACK.
Bug 308886 has been fixed and nothing has to be changed with the patches; so they can be used now without any problems.
Can someone look at this patch and commit it?
I noticed that you only added a param for an array of GOptionEntry:s, which means that all of the program's options will be in just one, the main, option group. I think it would make sense to add a parm for an array of GOptionGroup:s, so that programs can organise their options into option groups.
Mr. Meeks: kmaraas ok'd the libgnome[ui] patches on irc, but they depend on the libbonobo[ui] patches (attachment 48012 [details] [review] and attachment 48015 [details] [review]); are those ok with you?
I have no problem with the thrust of the patch as long as it doesn't break the ABI :-)
Created attachment 52803 [details] [review] updated patch for libbonobo Final libbonobo patch: bump libbonobo version to 2.13.0, and update glib requirement. No ABI changes; one API addition: bonobo_activation_get_goption_group(), which is similar to the existing extern struct poptOption bonobo_activation_popt_options[] for popt.
Created attachment 52804 [details] [review] updated libgnome patch Final patch for libgnome: bump libbonobo and glib requirements. I simplified the previous patch: instead of passing GNOME_PARAM_GOPTION_ENABLE, _TABLE, _NAME (and _GETTEXT_DOMAIN, which the patch was missing!) just so libgnome can do g_option_context_new() + g_option_context_add_main_entries(), I reduced that to one param GNOME_PARAM_GOPTION_CONTEXT which if set enabled GOption argument parsing, i.e. like this: context = g_option_context_new ("test"); g_option_context_add_main_entries (context, entries, GETTEXT_DOMAIN); gnome_program_inti (...., GNOME_PARAM_GOPTION_CONTEXT, context,...); One thing I'm unsure about is memory management: should the context become the owned by the GnomeProgram (it's that way now), or not? (GOptionContext isn't refcounted.) I added documentation for the new parameter, and note to gnome_program_preinit docs that it'll return NULL when using GOption parsing (this is no API or ABI breakage since GOption parsing is enabled only when you enable it explicitly).
Created attachment 52805 [details] [review] updated libbonoboui patch Final patch for libbonoboui: bump version to 2.13.0, and bonobo-activation/libgnome requirements to 2.13.0 and glib to 2.8.0 to appropriate value.
Created attachment 52806 [details] [review] updated libgnomeui patch Final patch for libgnomeui: bump bonobo/glib/libgnome required versions. Use GOption parsing in testgnome.c.
Fixed on libbonobo/libgnome/libonoboui/libgnomeui HEAD. I filed bug 317545 to deprecated the old popt argument parsing.