Index: configure.in
===================================================================
RCS file: /cvs/gnome/ORBit2/configure.in,v
retrieving revision 1.169
diff -p -u -u -p -r1.169 configure.in
--- configure.in	2 May 2006 20:48:28 -0000	1.169
+++ configure.in	15 May 2006 13:20:57 -0000
@@ -113,7 +113,7 @@ fi
 
 AC_PROG_AWK
 
-GLIB_REQUIRED=2.6.0
+GLIB_REQUIRED=2.8.0
 LIBIDL_REQUIRED=0.8.2
 AC_SUBST(GLIB_REQUIRED)
 AC_SUBST(LIBIDL_REQUIRED)
@@ -198,10 +198,6 @@ AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(sock
 AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
 AC_CHECK_FUNC(sigaction)
 AC_CHECK_FUNC(syslog)
-
-AC_CHECK_LIB(popt, poptStrippedArgv, POPT_LIBS=-lpopt, AC_MSG_ERROR([You must have popt version 1.5 or greater installed.]))
-AC_SUBST(POPT_LIBS)
-AC_CHECK_HEADER(popt.h,,AC_MSG_ERROR([Failed to find popt.h - you may have to adjust your environment]))
 
 dnl This generates warnings from autoconf...
 AC_C_BIGENDIAN
Index: src/idl-compiler/orbit-idl-main.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/idl-compiler/orbit-idl-main.c,v
retrieving revision 1.32
diff -p -u -u -p -r1.32 orbit-idl-main.c
--- src/idl-compiler/orbit-idl-main.c	10 Mar 2005 12:05:21 -0000	1.32
+++ src/idl-compiler/orbit-idl-main.c	15 May 2006 13:20:57 -0000
@@ -27,12 +27,19 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <string.h>
 #include <glib.h>
 #include <libIDL/IDL.h>
-#include <popt.h>
+#include <glib/goption.h>
+#include <glib/gi18n.h>
 
 #include "orbit-idl2.h"
 
+/* FIXME: this program doesn't seem to support i18n? */
+#ifndef GETTEXT_PACKAGE
+#define GETTEXT_PACKAGE NULL
+#endif
+
 /* Settings made from the command line (prefaced with cl_) */
 static gboolean cl_disable_stubs = FALSE,
   cl_disable_skels = FALSE,
@@ -42,7 +49,6 @@ static gboolean cl_disable_stubs = FALSE
 static int cl_idlwarnlevel = 2;
 static int cl_debuglevel = 0;
 static int cl_is_pidl = 0;
-static int cl_output_version = 0;
 static int cl_disable_idata = 0;
 static int cl_enable_imodule = 0;
 static int cl_add_imodule = 0;
@@ -54,124 +60,179 @@ static char *cl_backend_dir = NULL;
 static gboolean cl_onlytop = FALSE;
 static char *cl_deps_file = NULL;
 static char *cl_output_directory = "";
+static char **idl_files = NULL;
 
 #define BASE_CPP_ARGS "-D__ORBIT_IDL__ "
 static GString *cl_cpp_args;
 
-static char *c_output_formatter = NULL;
+/* Callbacks for goption */
 
-/* Callbacks for popt */
-static void
-cl_libIDL_version_callback(poptContext con, enum poptCallbackReason reason,
-			   const struct poptOption *opt, char *arg,
-			   void *data)
+static gboolean
+cl_libIDL_version_callback (const char *option_name,
+			    const char *value,
+			    gpointer data,
+			    GError **error)
 {
-  g_print("libIDL %s (CORBA %s)",
+  g_print("libIDL %s (CORBA %s)\n",
 	  IDL_get_libver_string(),
 	  IDL_get_IDLver_string());
-
   exit(0);
 }
 
-static void
-cl_cpp_callback(poptContext con, enum poptCallbackReason reason,
-		const struct poptOption *opt, char *arg,
-		void *data)
-{
-  g_assert(opt!=NULL);
-
-  if(opt->shortName=='D')
-    g_string_append(cl_cpp_args, "-D");
-  else if(opt->shortName=='I')
-    g_string_append(cl_cpp_args, "-I");
+static gboolean
+cl_cpp_define_callback (const char *option_name,
+			const char *value,
+			gpointer data,
+			GError **error)
+{
+  g_string_append_printf (cl_cpp_args, "-D%s ", value);
+  return TRUE;
+}
 
-  g_string_append(cl_cpp_args, arg);
-  g_string_append_c(cl_cpp_args, ' ');
+static gboolean
+cl_cpp_include_callback (const char *option_name,
+			 const char *value,
+			 gpointer data,
+			 GError **error)
+{
+  g_string_append_printf (cl_cpp_args, "-I%s ", value);
+  return TRUE;
 }
 
-static const
-struct poptOption cl_libIDL_callback_options[] = {
-  {NULL, '\0', POPT_ARG_CALLBACK, (void *)cl_libIDL_version_callback,
-   0, NULL, NULL},
-  {"libIDL-version", '\0', POPT_ARG_NONE, NULL, 0,
-   "Show version of libIDL used.", NULL},
-  {NULL, '\0', 0, NULL, 0, NULL, NULL}
+static gboolean
+cl_version_callback (const char *option_name,
+		     const char *value,
+		     gpointer data,
+		     GError **error)
+{
+  g_print ("orbit-idl-2 %s - serial %d\n",
+           VERSION, ORBIT_CONFIG_SERIAL);
+  exit(0);
+}
+
+static gboolean
+cl_c_output_formatter_callback (const char *option_name,
+				const char *value,
+				gpointer data,
+				GError **error)
+{
+  g_warning ("Do not use the 'c-output-formatter' option. It is ignored and will soon go away.");
+  return TRUE;
+}
+
+static const GOptionEntry cl_libIDL_goptions[] = {
+  { "libIDL-version", 0, 0, G_OPTION_ARG_CALLBACK, cl_libIDL_version_callback, N_("Show version of libIDL used"), NULL },
+  { NULL }
 };
 
-static const
-struct poptOption cl_cpp_callback_options[] = {
-  {NULL, '\0', POPT_ARG_CALLBACK, (void *)cl_cpp_callback, 0, NULL, NULL},
-  {"define", 'D', POPT_ARGFLAG_ONEDASH | POPT_ARG_STRING, NULL, 0,
-   "Define value in preprocessor", NULL},
-  {"include", 'I', POPT_ARGFLAG_ONEDASH | POPT_ARG_STRING, NULL, 0,
-   "Add search path for include files", NULL},
-  {NULL, '\0', 0, NULL, 0, NULL, NULL}
+static const GOptionEntry cl_cpp_goptions[] = {
+  { "define", 'D', G_OPTION_FLAG_FILENAME, G_OPTION_ARG_CALLBACK, cl_cpp_define_callback, N_("Define value in preprocessor"), N_("DEFINE") },
+  { "include", 'I', G_OPTION_FLAG_FILENAME, G_OPTION_ARG_CALLBACK, cl_cpp_include_callback, N_("Add search path for include files"), N_("DIR") },
+  { NULL }
 };
 
-static
-struct poptOption options[] = {
-  {NULL, '\0', POPT_ARG_INCLUDE_TABLE, &cl_cpp_callback_options, 0, NULL, NULL},
-  {NULL, '\0', POPT_ARG_INCLUDE_TABLE, &cl_libIDL_callback_options, 0, NULL, NULL},
-  {"version", 'v', POPT_ARG_NONE, &cl_output_version, 0, "Output compiler version and serial", NULL},
-  {"lang", 'l', POPT_ARG_STRING, &cl_output_lang, 0, "Output language (default is C)", NULL},
-  {"debug", 'd', POPT_ARG_INT, &cl_debuglevel, 0, "Debug level 0 to 4", NULL},
-  {"idlwarnlevel", '\0', POPT_ARG_INT, &cl_idlwarnlevel, 0, "IDL warning level 0 to 4, default is 2", NULL},
-  {"showcpperrors", '\0', POPT_ARG_NONE, &cl_showcpperrors, 0, "Show CPP errors", NULL},
-  {"nostubs", '\0', POPT_ARG_NONE, &cl_disable_stubs, 0, "Don't output stubs", NULL},
-  {"noskels", '\0', POPT_ARG_NONE, &cl_disable_skels, 0, "Don't output skels", NULL},
-  {"nocommon", '\0', POPT_ARG_NONE, &cl_disable_common, 0, "Don't output common", NULL},
-  {"noheaders", '\0', POPT_ARG_NONE, &cl_disable_headers, 0, "Don't output headers", NULL},
-  {"noidata", '\0', POPT_ARG_NONE, &cl_disable_idata, 0, "Don't generate Interface type data", NULL},
-  {"imodule", 'i', POPT_ARG_NONE, &cl_enable_imodule, 0, "Output only an imodule file", NULL},
-  {"add-imodule", '\0', POPT_ARG_NONE, &cl_add_imodule, 0, "Output an imodule file", NULL},
-  {"skeleton-impl", '\0', POPT_ARG_NONE, &cl_enable_skeleton_impl, 0, "Output skeleton implementation", NULL},
-  {"backenddir", '\0', POPT_ARG_STRING, &cl_backend_dir, 0, "Override IDL backend library directory", "DIR"},
-  {"c-output-formatter", '\0', POPT_ARG_STRING, &c_output_formatter, 0, "DEPRECATED and IGNORED", "PROGRAM"},
-  {"onlytop", '\0', POPT_ARG_NONE, &cl_onlytop, 0, "Inhibit includes", NULL},
-  {"pidl", '\0', POPT_ARG_NONE, &cl_is_pidl, 0, "Treat as Pseudo IDL", NULL},
-  {"nodefskels", '\0', POPT_ARG_NONE, &cl_disable_defs_skels, 0, "Don't output defs for skels in header", NULL},
-  {"deps", '\0', POPT_ARG_STRING, &cl_deps_file, 0, "Generate dependency info suitable for inclusion in Makefile", "FILENAME"},
-  {"headerguardprefix", '\0', POPT_ARG_STRING, &cl_header_guard_prefix, 0, "Prefix for #ifdef header guards. Sometimes useful to avoid conflicts.", NULL},
-  {"output-dir", '\0', POPT_ARG_STRING, &cl_output_directory, 0, "Where to put generated files. This directory must exist.", NULL},
-  POPT_AUTOHELP
-  {NULL, '\0', 0, NULL, 0, NULL, NULL}
+static const GOptionEntry goptions[] = {
+  { "version", 'v', 0, G_OPTION_ARG_CALLBACK, cl_version_callback, N_("Output compiler version and serial"), NULL },
+  { "lang", 'l', 0, G_OPTION_ARG_STRING, &cl_output_lang, N_("Output language (default is C)"), N_("LANG") },
+  { "debug", 'd', 0, G_OPTION_ARG_INT, &cl_debuglevel, N_("Debug level (0 to 4)"), N_("LEVEL") },
+  { "idlwarnlevel", 0, 0, G_OPTION_ARG_INT, &cl_idlwarnlevel, N_("IDL warning level (0 to 4, default is 2)"), N_("LEVEL") },
+  { "showcpperrors", 0, 0, G_OPTION_ARG_NONE, &cl_showcpperrors, N_("Show CPP errors"), NULL },
+  { "nostubs", 0, 0, G_OPTION_ARG_NONE, &cl_disable_stubs, N_("Don't output stubs"), NULL },
+  { "noskels", 0, 0, G_OPTION_ARG_NONE, &cl_disable_skels, N_("Don't output skels"), NULL },
+  { "nocommon", 0, 0, G_OPTION_ARG_NONE, &cl_disable_common, N_("Don't output common"), NULL },
+  { "noheaders", 0, 0, G_OPTION_ARG_NONE, &cl_disable_headers, N_("Don't output headers"), NULL },
+  { "noidata", 0, 0, G_OPTION_ARG_NONE, &cl_disable_idata, N_("Don't generate Interface type data"), NULL },
+  { "imodule", 'i', 0, G_OPTION_ARG_NONE, &cl_enable_imodule, N_("Output only an imodule file"), NULL },
+  { "add-imodule", 0, 0, G_OPTION_ARG_NONE, &cl_add_imodule, N_("Output an imodule file"), NULL },
+  { "skeleton-impl", 0, 0, G_OPTION_ARG_NONE, &cl_enable_skeleton_impl, N_("Output skeleton implementation"), NULL },
+  { "backenddir", 0, 0, G_OPTION_ARG_FILENAME, &cl_backend_dir, N_("Override IDL backend library directory"), N_("DIR") },
+  { "c-output-formatter", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, &cl_c_output_formatter_callback, "DEPRECATED and IGNORED", "PROGRAM" },
+  { "onlytop", 0, 0, G_OPTION_ARG_NONE, &cl_onlytop, N_("Inhibit includes"), NULL },
+  { "pidl", 0, 0, G_OPTION_ARG_NONE, &cl_is_pidl, N_("Treat as Pseudo IDL"), NULL },
+  { "nodefskels", 0, 0, G_OPTION_ARG_NONE, &cl_disable_defs_skels, N_("Don't output defs for skels in header"), NULL },
+  { "deps", 0, 0,  G_OPTION_ARG_FILENAME, &cl_deps_file, N_("Generate dependency info suitable for inclusion in Makefile"), N_("FILENAME") },
+  { "headerguardprefix", 0, 0, G_OPTION_ARG_STRING, &cl_header_guard_prefix, N_("Prefix for #ifdef header guards. Sometimes useful to avoid conflicts."), N_("PREFIX") },
+  { "output-dir", 0, 0, G_OPTION_ARG_FILENAME, &cl_output_directory, N_("Where to put generated files. This directory must exist."), N_("DIR") },
+  { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &idl_files, NULL, N_("<IDL files>") },
+  { NULL }
 };
 
 /********** main routines **********/
-int main(int argc, const char *argv[])
+int main(int argc, char *argv[])
 {
-  poptContext pcon;
-  int rc, retval = 0;
-  const char *arg;
+  GOptionContext *context;
+  GOptionGroup *group;
+  GError *error = NULL;
   OIDL_Run_Info rinfo;
+  GPtrArray *args;
+  int retval = 0;
+  gboolean result;
+  gpointer freeme;
+  guint i;
 
   /* Argument parsing, etc. */
   cl_cpp_args = g_string_new("-D__ORBIT_IDL__ ");
 
-  pcon = poptGetContext ("orbit-idl-2", argc, argv, options, 0);
-  poptSetOtherOptionHelp (pcon, "<IDL files>");
-
-  if(argc < 2) {
-  	poptPrintUsage(pcon, stdout, 0);
-	return 0;
+  /* GOption cannot parse single-letter options without space
+   * between option and argument (-I../dir) or single-dash options.
+   * So fix those up before parsing, to retain command line compatibility
+   * with previous popt based versions of orbit-idl-2
+   */
+  args = g_ptr_array_sized_new (2 * argc);
+  g_ptr_array_add (args, g_strdup (argv[0]));
+
+  for (i = 1; i < argc; ++i) {
+    if (argv[i][0] == '-' &&
+	(argv[i][1] == 'D' || argv[i][1] == 'I') &&
+	argv[i][2] != '\0') {
+      g_ptr_array_add (args, g_strndup (argv[i], 2));
+      g_ptr_array_add (args, g_strdup (argv[i] + 2));
+    } else if (strcmp (argv[i], "-define") == 0 ||
+               strcmp (argv[i], "-include") == 0) {
+      g_ptr_array_add (args, g_strdup_printf ("-%s", argv[i]));
+    } else {
+      g_ptr_array_add (args, g_strdup (argv[i]));
+    }
   }
 
-  if((rc=poptGetNextOpt(pcon)) < -1) {
-    g_print ("orbit-idl-2: bad argument %s: %s\n", 
-    		poptBadOption(pcon, POPT_BADOPTION_NOALIAS),
-		poptStrerror(rc));
-    exit(0);
+  /* Parsing will modify the array; memdup it beforehand
+   * so we can free it correctly
+   */
+  argc = args->len;
+  argv = freeme = g_memdup (args->pdata, argc * sizeof (gpointer));
+  g_ptr_array_add (args, NULL); /* so we can use g_strfreev */
+
+  /* Now parse the options */
+  context = g_option_context_new ("");
+  g_option_context_add_main_entries (context, goptions, GETTEXT_PACKAGE);
+
+  group = g_option_group_new ("libIDL", N_("libIDL options"), N_("Show libIDL options"), NULL, NULL);
+  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
+  g_option_group_add_entries (group, cl_libIDL_goptions);
+  g_option_context_add_group (context, group);
+
+  group = g_option_group_new ("cpp", N_("Preprocessor options"), N_("Show preprocessor options"), NULL, NULL);
+  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
+  g_option_group_add_entries (group, cl_cpp_goptions);
+  g_option_context_add_group (context, group);
+
+  result = g_option_context_parse (context, &argc, &argv, &error);
+ 
+  g_option_context_free (context);
+  g_strfreev ((char **) g_ptr_array_free (args, FALSE));
+  g_free (freeme);
+
+  if (!result) {
+    g_print ("orbit-idl-2: %s\n", error->message);
+    g_error_free (error);
+    exit (1);
   }
 
-  if (cl_output_version) {
-	  printf ("orbit-idl-2 %s - serial %d\n\n",
-		  VERSION, ORBIT_CONFIG_SERIAL);
-	  exit (0);
+  if (!idl_files) {
+    g_print ("No input files given!\n");
+    exit (1);
   }
 
-  if (c_output_formatter != NULL)
-	  g_warning ("Please do not use the 'c-output-formatter' option. It is ignored and will soon go away.");
-
   /* Prep our run info for the backend */
   rinfo.cpp_args = cl_cpp_args->str;
   rinfo.debug_level = cl_debuglevel;
@@ -213,14 +274,14 @@ int main(int argc, const char *argv[])
 	  cl_enable_imodule ? "imodule" : "");
 	   
   /* Do it */
-  while((arg=poptGetArg(pcon))!=NULL) {
-    rinfo.input_filename = g_strdup (arg); /* g_path_get_basename(arg); - what !? */
-    if (!orbit_idl_to_backend(arg, &rinfo)) {
-      g_warning("%s compilation failed", arg);
+  for (i = 0; idl_files[i]; ++i) {
+    g_print ("Processing file %s\n", idl_files[i]);
+    rinfo.input_filename = idl_files[i];
+    if (!orbit_idl_to_backend(idl_files[i], &rinfo)) {
+      g_warning("%s compilation failed", idl_files[i]);
       retval = 1;
     }
-    g_free(rinfo.input_filename);
   }
 
-  return retval;
+  exit (retval);
 }
Index: src/services/name/boot.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/services/name/boot.c,v
retrieving revision 1.4
diff -p -u -u -p -r1.4 boot.c
--- src/services/name/boot.c	28 Jan 2005 15:46:51 -0000	1.4
+++ src/services/name/boot.c	15 May 2006 13:20:57 -0000
@@ -6,9 +6,14 @@
 #  include <syslog.h>
 #endif
 #include <signal.h>
-#include <popt.h>
+#include <glib/goption.h>
+#include <glib/gi18n.h>
 #include "CosNaming_impl.h"
 
+#ifndef GETTEXT_PACKAGE
+#define GETTEXT_PACKAGE NULL
+#endif
+
 static void
 signal_handler(int signo){
 #ifdef HAVE_SYSLOG
@@ -24,13 +29,9 @@ signal_handler(int signo){
 
 static char *opt_corbaloc_key = NULL;
 
-static const struct poptOption TheOptions[] = {
-    { "key", 0, POPT_ARG_STRING, &opt_corbaloc_key, 0, 
-    	"Respond to corbaloc requests with this object key", "string" },
-#if 0
-    ORBIT_POPT_TABLE,
-#endif
-    POPT_AUTOHELP
+static const GOptionEntry goptions[] = {
+    { "key", 0, 0, G_OPTION_ARG_STRING, &opt_corbaloc_key,
+      N_("Respond to corbaloc requests with this object key"), N_("KEY") },
     { NULL }
 };
 
@@ -80,22 +81,22 @@ main (int argc, char *argv[])
   orb = CORBA_ORB_init (&argc, argv, "orbit-local-orb", &ev);
   
   {
-  	poptContext	pcxt;
-	int		rc;
-        pcxt = poptGetContext(progname, argc, (const char**)argv, 
-		TheOptions, 0);
-      	if ( (rc=poptGetNextOpt(pcxt)) < -1 ) {
-	    g_warning("%s: bad argument %s: %s\n",
-	    		progname, 
-			poptBadOption(pcxt, POPT_BADOPTION_NOALIAS), 
-			poptStrerror(rc));
-	    exit(1);
-      }
-      if ( poptGetArg(pcxt) != 0 ) {
-	    g_warning("%s: leftover arguments.\n", progname);
+        GOptionContext *context;
+        GError *error = NULL;
+        gboolean result;
+
+        context = g_option_context_new("");
+        g_option_context_add_main_entries(context, goptions, GETTEXT_PACKAGE);
+
+        result = g_option_context_parse(context, &argc, &argv, &error);
+        g_option_context_free(context);
+
+        if (!result) {
+            g_warning("%s: bad arguments: %s\n",
+                      progname, error->message);
+            g_error_free(error);
 	    exit(1);
-      }
-      poptFreeContext(pcxt);
+        }
   }
 
   {
