? depcomp
? goption.diff
? gtk-doc.make
? libgnome-zip
? p-bui-diff
? p-bui-new
? p-bui-old
? p-diff
? p-new
? p-old
? stamp-h1
? t
? doc/reference/libgnome.interfaces
? doc/reference/libgnome.prerequisites
? doc/reference/version.xml
? libgnome/stamp-libgnometypebuiltins.h
? po/stamp-it
Index: configure.in
===================================================================
RCS file: /cvs/gnome/libgnome/configure.in,v
retrieving revision 1.218
diff -p -u -u -p -r1.218 configure.in
--- configure.in	6 Sep 2005 11:55:25 -0000	1.218
+++ configure.in	29 Sep 2005 13:29:47 -0000
@@ -19,9 +19,9 @@ dnl required versions of other tools.
 m4_define([audiofile_required_version], [0.2.3])
 m4_define([esound_required_version],    [0.2.26])
 m4_define([gconf_required_version],     [1.1.11])
-m4_define([glib_required_version],      [2.6.0])
+m4_define([glib_required_version],      [2.8.0])
 m4_define([gnome_vfs_required_version], [2.5.3])
-m4_define([libbonobo_required_version], [2.0.0])
+m4_define([libbonobo_required_version], [2.13.0])
 m4_define([gobject_required_version], [2.0.0])
 
 dnl libtool versioning from libgnome
Index: doc/reference/tmpl/gnome-program.sgml
===================================================================
RCS file: /cvs/gnome/libgnome/doc/reference/tmpl/gnome-program.sgml,v
retrieving revision 1.8
diff -p -u -u -p -r1.8 gnome-program.sgml
--- doc/reference/tmpl/gnome-program.sgml	7 Mar 2005 13:36:03 -0000	1.8
+++ doc/reference/tmpl/gnome-program.sgml	29 Sep 2005 13:29:47 -0000
@@ -81,7 +81,8 @@ required modules are initialized (althou
 @class_init: A function to call to initialise this module prior to creating any
 instances (can be %NULL).
 @opt_prefix: Unused.
-@expansion1: Unused.
+@expansion1: A #GOptionGroup for the special arguments this module supports when
+parsing options with GOption (can be %NULL).
 
 <!-- ##### STRUCT GnomeModuleRequirement ##### -->
 <para>
@@ -312,7 +313,8 @@ int main(int argc, char **argv) {
 <!-- ##### MACRO GNOME_PARAM_POPT_TABLE ##### -->
 <para>
 This parameter contains the table of options to be passed to popt (write on
-init only).
+init only). Mutually exclusive with using #GNOME_PARAM_GOPTION_CONTEXT
+parameter.
 </para>
 
 
@@ -328,6 +330,15 @@ This parameter contains the flags to use
 <para>
 This parameter contains the context pointer that #GnomeProgram is using for
 popt parsing (readable).
+</para>
+
+
+
+<!-- ##### MACRO GNOME_PARAM_GOPTION_CONTEXT ##### -->
+<para>
+This parameter contains the GOptionContext pointer that #GnomeProgram is using for
+GOption parsing (write on init only). Mutually exclusive with using the
+#GNOME_PARAM_POPT_TABLE parameter.
 </para>
 
 
Index: libgnome/gnome-init.c
===================================================================
RCS file: /cvs/gnome/libgnome/libgnome/gnome-init.c,v
retrieving revision 1.110
diff -p -u -u -p -r1.110 gnome-init.c
--- libgnome/gnome-init.c	28 Mar 2005 15:45:07 -0000	1.110
+++ libgnome/gnome-init.c	29 Sep 2005 13:29:47 -0000
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 
 #include <glib.h>
+#include <glib/goption.h>
 #include <glib/gstdio.h>
 #include "gnome-i18nP.h"
 
@@ -146,6 +147,9 @@ gnome_bonobo_activation_module_info_get 
 		bonobo_activation_pre_args_parse, bonobo_activation_post_args_parse,
 		bonobo_activation_popt_options
 	};
+
+	module_info.expansion1 = (gpointer) bonobo_activation_get_goption_group ();
+
 	if (module_info.version == NULL) {
 		module_info.version = g_strdup_printf
 			("%d.%d.%d",
@@ -263,6 +267,56 @@ libgnome_option_cb (poptContext ctx, enu
 	}
 }
 
+static gboolean
+libgnome_goption_epeaker (const gchar *option_name,
+			  const gchar *value,
+			  gpointer data,
+			  GError **error)
+{
+	g_object_set (G_OBJECT (gnome_program_get ()),
+		      GNOME_PARAM_ESPEAKER, value, NULL);
+
+	return TRUE;
+}
+
+static gboolean
+libgnome_goption_disable_sound (const gchar *option_name,
+				const gchar *value,
+				gpointer data,
+				GError **error)
+{
+	g_object_set (G_OBJECT (gnome_program_get ()),
+		      GNOME_PARAM_ENABLE_SOUND, FALSE, NULL);
+
+	return TRUE;
+}
+
+static gboolean
+libgnome_goption_enable_sound (const gchar *option_name,
+			       const gchar *value,
+			       gpointer data,
+			       GError **error)
+{
+	g_object_set (G_OBJECT (gnome_program_get ()),
+		      GNOME_PARAM_ENABLE_SOUND, TRUE, NULL);
+
+	return TRUE;
+}
+
+static void 
+libgnome_goption_version (void)
+{
+	GnomeProgram *program;
+
+	program = gnome_program_get ();
+
+	g_print ("Gnome %s %s\n",
+		 gnome_program_get_app_id (program),
+		 gnome_program_get_app_version (program));
+	
+	exit (0);
+}
+
 static int
 safe_mkdir (const char *pathname, mode_t mode)
 {
@@ -423,6 +477,24 @@ static struct poptOption gnomelib_option
 	  NULL, 0 , NULL, NULL}
 };
 
+static const GOptionEntry gnomelib_goptions [] = {
+	{ "disable-sound", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,                                 
+	  libgnome_goption_disable_sound, N_("Disable sound server usage"), NULL },     
+
+	{ "enable-sound", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,                                  
+	  libgnome_goption_enable_sound, N_("Enable sound server usage"), NULL },       
+
+	{ "espeaker", '\0',0, G_OPTION_ARG_CALLBACK,                                    
+	  libgnome_goption_epeaker,
+	  N_("Host:port on which the sound server to use is running"),
+	  N_("HOSTNAME:PORT") },                                                 
+
+	{ "version", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+	  (GOptionArgFunc) libgnome_goption_version, VERSION, NULL },
+
+	{ NULL }
+};
+
 #ifndef G_OS_WIN32
 
 static void
@@ -467,6 +539,15 @@ libgnome_module_info_get (void)
 		NULL, NULL, NULL, NULL
 	};
 	int i = 0;
+	
+	GOptionGroup *option_group;
+	option_group = g_option_group_new ("gnome",
+					   N_("GNOME Library"),
+					   N_("Show GNOME options"),
+					   NULL, NULL);
+	g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+	g_option_group_add_entries (option_group, gnomelib_goptions);
+	module_info.expansion1 = (gpointer) option_group;
 
 	if (module_info.requirements == NULL) {
 		static GnomeModuleRequirement req[4];
Index: libgnome/gnome-program.c
===================================================================
RCS file: /cvs/gnome/libgnome/libgnome/gnome-program.c,v
retrieving revision 1.77
diff -p -u -u -p -r1.77 gnome-program.c
--- libgnome/gnome-program.c	9 Jun 2005 08:57:30 -0000	1.77
+++ libgnome/gnome-program.c	29 Sep 2005 13:29:48 -0000
@@ -98,6 +98,7 @@ struct _GnomeProgramPrivate {
 
     /* valid-while: state == APP_PREINIT_DONE */
     poptContext arg_context;
+    GOptionContext *goption_context;
 
     /* valid-while: state == APP_PREINIT_DONE */
     GArray *top_options_table;
@@ -124,6 +125,7 @@ enum {
     PROP_POPT_TABLE,
     PROP_POPT_FLAGS,
     PROP_POPT_CONTEXT,
+    PROP_GOPTION_CONTEXT,
     PROP_LAST
 };
 
@@ -157,6 +159,9 @@ gnome_program_set_property (GObject *obj
     program = GNOME_PROGRAM (object);
 
     switch (param_id) {
+    case PROP_GOPTION_CONTEXT:
+	program->_priv->goption_context = g_value_get_pointer (value);
+	break;
     case PROP_POPT_TABLE:
 	program->_priv->prop_popt_table = g_value_peek_pointer (value);
 	break;
@@ -256,6 +261,9 @@ gnome_program_get_property (GObject *obj
     case PROP_POPT_CONTEXT:
 	g_value_set_pointer (value, program->_priv->arg_context);
 	break;
+    case PROP_GOPTION_CONTEXT:
+	g_value_set_pointer (value, program->_priv->goption_context);
+	break;
     case PROP_GNOME_PATH:
 	if (program->_priv->gnome_path)
 	    g_value_take_string (value, g_strjoinv (":", program->_priv->gnome_path));
@@ -458,6 +466,15 @@ gnome_program_class_init (GnomeProgramCl
 
     g_object_class_install_property
 	(object_class,
+	 PROP_GOPTION_CONTEXT,
+	 g_param_spec_pointer (GNOME_PARAM_GOPTION_CONTEXT,
+			       _("GOption Context"), 
+			       _("The goption context pointer that GnomeProgram "
+				 "is using"),
+			       (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+    g_object_class_install_property
+	(object_class,
 	 PROP_HUMAN_READABLE_NAME,
 	 g_param_spec_string (GNOME_PARAM_HUMAN_READABLE_NAME,
 			      _("Human readable name"), 
@@ -661,7 +678,7 @@ gnome_program_finalize (GObject* object)
 	self->_priv->prop_app_datadir = NULL;
 	g_free (self->_priv->prop_espeaker);
 	self->_priv->prop_espeaker = NULL;
-
+	
 	g_strfreev (self->_priv->gnome_path);
 	self->_priv->gnome_path = NULL;
 
@@ -676,8 +693,13 @@ gnome_program_finalize (GObject* object)
 	if (self->_priv->arg_context != NULL) {
 		poptFreeContext (self->_priv->arg_context);
 		g_dataset_destroy (self->_priv->arg_context);
+		self->_priv->arg_context = NULL;
+	}
+
+	if (self->_priv->goption_context != NULL) {
+		g_option_context_free (self->_priv->goption_context);
+		self->_priv->goption_context = NULL;
 	}
-	self->_priv->arg_context = NULL;
 
 	if (self->_priv->top_options_table != NULL)
 		g_array_free (self->_priv->top_options_table, TRUE);
@@ -1267,7 +1289,8 @@ set_context_data (poptContext con,
  * needs to be done prior to command line argument parsing. The poptContext
  * returned can be used for getopt()-style option processing.
  *
- * Returns: A poptContext representing the argument parsing state.
+ * Returns: A poptContext representing the argument parsing state,
+ * or %NULL if using GOption argument parsing.
  */
 poptContext
 gnome_program_preinit (GnomeProgram *program,
@@ -1275,9 +1298,9 @@ gnome_program_preinit (GnomeProgram *pro
 		       int argc, char **argv)
 {
     GnomeModuleInfo *a_module;
-    poptContext argctx;
+    poptContext argctx = NULL;
     int i;
-
+    
     g_return_val_if_fail (program != NULL, NULL);
     g_return_val_if_fail (GNOME_IS_PROGRAM (program), NULL);
     g_return_val_if_fail (argv != NULL, NULL);
@@ -1340,8 +1363,20 @@ gnome_program_preinit (GnomeProgram *pro
 	}
     }
 
-    /* 5. Create a top-level 'struct poptOption *' for use in arg-parsing. */
-    {
+    if (program->_priv->goption_context) {
+        /* Add the modules' GOptionGroup:s to our context */
+
+	for (i = 0; (a_module = g_ptr_array_index (program_modules, i)); i++) {
+		GOptionGroup *group = (GOptionGroup *) a_module->expansion1;
+		if (group) {
+			g_option_context_add_group (program->_priv->goption_context,
+						    group);
+		}
+	}
+
+    } else {
+        /* 5. Create a top-level 'struct poptOption for use in arg-parsing. */
+
 	struct poptOption includer = {NULL, '\0', POPT_ARG_INCLUDE_TABLE,
 				      NULL, 0, NULL, NULL};
 	struct poptOption callback =
@@ -1386,16 +1421,15 @@ gnome_program_preinit (GnomeProgram *pro
 	includer.descrip = _("Dynamic modules to load");
 	includer.argDescrip = _("MODULE1,MODULE2,...");
 	g_array_append_val (program->_priv->top_options_table, includer);
-    }
 
-    argctx = program->_priv->arg_context = poptGetContext
-	(program->_priv->app_id, argc, (const char **) argv,
-	 (struct poptOption *) program->_priv->top_options_table->data,
-	 program->_priv->prop_popt_flags);
-  
+    	argctx = program->_priv->arg_context = poptGetContext
+		(program->_priv->app_id, argc, (const char **) argv,
+		 (struct poptOption *) program->_priv->top_options_table->data,
+		 program->_priv->prop_popt_flags);
+    }
     /* 7. Cleanup/return */
     program->_priv->state = APP_PREINIT_DONE;
-
+    
     return argctx;
 }
 
@@ -1449,30 +1483,50 @@ gnome_program_module_load (const char *m
 void
 gnome_program_parse_args (GnomeProgram *program)
 {
-    int nextopt;
-    poptContext ctx;
+	GnomeProgramPrivate *priv;
 
-    g_return_if_fail (program != NULL);
-    g_return_if_fail (GNOME_IS_PROGRAM (program));
+	g_return_if_fail (program != NULL);
+	g_return_if_fail (GNOME_IS_PROGRAM (program));
 
-    if (program->_priv->state != APP_PREINIT_DONE)
-	return;
+	if (program->_priv->state != APP_PREINIT_DONE)
+		return;
 
-    /* translate popt output by default */
+	priv = program->_priv;
+	g_return_if_fail ((priv->arg_context != NULL && priv->goption_context == NULL) ||
+			  (priv->arg_context == NULL && priv->goption_context != NULL));
+	
+	if (priv->goption_context) {
+		GError *error = NULL;
+		gint argc = priv->argc;
+		gchar **argv = priv->argv;
+
+		if (!g_option_context_parse (priv->goption_context, &argc, &argv, &error)) {
+			/* Translators: the first %s is the error message, 2nd %s the program name */
+			g_print(_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
+				error->message, program->_priv->argv[0]);
+			g_error_free (error);
+			exit (1);
+		}
+	} else {
+		/* translate popt output by default */
+		int nextopt;
+		poptContext ctx;
 #ifdef ENABLE_NLS
-    setlocale (LC_ALL, "");
+		setlocale (LC_ALL, "");
 #endif
-    ctx = program->_priv->arg_context;
-    while ((nextopt = poptGetNextOpt (ctx)) > 0 || nextopt == POPT_ERROR_BADOPT)
-	/* do nothing */ ;
-
-    if (nextopt != -1) {
-	g_print ("Error on option %s: %s.\nRun '%s --help' to see a full list of available command line options.\n",
-		 poptBadOption (ctx, 0),
-		 poptStrerror (nextopt),
-		 program->_priv->argv[0]);
-	exit (1);
-    }
+		ctx = program->_priv->arg_context;
+		while ((nextopt = poptGetNextOpt (ctx)) > 0 || nextopt == POPT_ERROR_BADOPT)
+			/* do nothing */ ;
+
+		if (nextopt != -1) {
+			g_print ("Error on option %s: %s.\nRun '%s --help' to see a full list of available command line options.\n",
+			poptBadOption (ctx, 0),
+			poptStrerror (nextopt),
+			program->_priv->argv[0]);
+			exit (1);
+		}
+	
+	}
 }
 
 static char *
Index: libgnome/gnome-program.h
===================================================================
RCS file: /cvs/gnome/libgnome/libgnome/gnome-program.h,v
retrieving revision 1.29
diff -p -u -u -p -r1.29 gnome-program.h
--- libgnome/gnome-program.h	19 Jul 2004 09:49:59 -0000	1.29
+++ libgnome/gnome-program.h	29 Sep 2005 13:29:48 -0000
@@ -113,6 +113,7 @@ gnome_program_locate_file               
 #define GNOME_PARAM_POPT_TABLE          "popt-table"
 #define GNOME_PARAM_POPT_FLAGS          "popt-flags"
 #define GNOME_PARAM_POPT_CONTEXT        "popt-context"
+#define GNOME_PARAM_GOPTION_CONTEXT     "goption-context"
 #define GNOME_PARAM_CREATE_DIRECTORIES  "create-directories"
 #define GNOME_PARAM_ENABLE_SOUND        "enable-sound"
 #define GNOME_PARAM_ESPEAKER            "espeaker"
