Index: configure.in
===================================================================
--- configure.in	(Revision 2209)
+++ configure.in	(Arbeitskopie)
@@ -30,6 +30,8 @@
 STARTUP_NOTIFICATION_REQUIRED=0.8
 VTE_REQUIRED=0.15.3
 GNOMEVFS_REQUIRED=2.4
+GLIB_REQUIRED=2.12.0
+LIBGNOME_REQUIRED=2.14.0
 
 ## here we get the flags we'll actually use
 PKG_CHECK_MODULES(TERM, dnl
@@ -37,9 +39,11 @@
  gconf-2.0 >= $GCONF_REQUIRED dnl
  libglade-2.0 dnl
  libgnomeui-2.0 dnl
+ libgnome-2.0 >= $LIBGNOME_REQUIRED dnl
  libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_REQUIRED dnl
  vte >= $VTE_REQUIRED dnl
- gnome-vfs-2.0 >= $GNOMEVFS_REQUIRED)
+ gnome-vfs-2.0 >= $GNOMEVFS_REQUIRED dnl
+ glib >= $GLIB_REQUIRED)
 
 TERM_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $TERM_LIBS"
 TERM_CFLAGS="$X_CFLAGS $TERM_CFLAGS"
Index: ChangeLog
===================================================================
--- ChangeLog	(Revision 2209)
+++ ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@
+2007-05-06  Christian Kirbach  <Christian.Kirbach@googlemail.com>
+
+	* src/terminal.c: Migrate from popt to GOption.
+	* configure.in: require glib >= 2.12.0, libgnome-2.0 >= 2.14.0
+
 2007-03-12  Vincent Untz  <vuntz@gnome.org>
 
 	* configure.in: post-release bump to 2.18.1.
Index: src/terminal.c
===================================================================
--- src/terminal.c	(Revision 2209)
+++ src/terminal.c	(Arbeitskopie)
@@ -38,7 +38,6 @@
 #include <libgnome/gnome-help.h>
 #include <libgnomeui/gnome-ui-init.h>
 #include <libgnomeui/gnome-client.h>
-#include <popt.h>
 #include <string.h>
 #include <stdlib.h>
 #include <time.h>
@@ -134,12 +133,12 @@
 static gboolean terminal_invoke_factory (int argc, char **argv);
 static void option_parsing_results_free (OptionParsingResults *results);
 
-
+/*
 static void parse_options_callback (poptContext              ctx,
                                     enum poptCallbackReason  reason,
                                     const struct poptOption *opt,
                                     const char              *arg,
-                                    void                    *data);
+                                    void                    *data); */
 static void client_die_cb          (GnomeClient             *client,
                                     gpointer                 data);
 
@@ -171,202 +170,195 @@
   OPTION_LAST
 };  
 
-struct poptOption options[] = {  
+char *test;
+
+static GOptionEntry goptions[] = {  
   {
-    NULL, 
-    '\0', 
-    POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
-    parse_options_callback, 
-    0, 
-    NULL, 
-    NULL
-  },
-  {
     "command",
     'e',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_COMMAND,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_COMMAND,
     N_("Execute the argument to this option inside the terminal."),
     NULL
   },
   {
     "execute",
     'x',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_EXECUTE,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_EXECUTE,
     N_("Execute the remainder of the command line inside the terminal."),
     NULL
   },
   {
     "window",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_WINDOW,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_WINDOW,
     N_("Open a new window containing a tab with the default profile. More than one of these options can be provided."),
     NULL
   },
   {
     "window-with-profile",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_WINDOW_WITH_PROFILE,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_WINDOW_WITH_PROFILE,
     N_("Open a new window containing a tab with the given profile. More than one of these options can be provided."),
     N_("PROFILENAME")
   },
   {
     "tab",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_TAB,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_TAB,
     N_("Open a new tab in the last-opened window with the default profile. More than one of these options can be provided."),
     NULL
   },
   {
     "tab-with-profile",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_TAB_WITH_PROFILE,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_TAB_WITH_PROFILE,
     N_("Open a new tab in the last-opened window with the given profile. More than one of these options can be provided."),
     N_("PROFILENAME")
   },
   {
     "window-with-profile-internal-id",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_WINDOW_WITH_PROFILE_ID,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_WINDOW_WITH_PROFILE_ID,
     N_("Open a new window containing a tab with the given profile ID. Used internally to save sessions."),
     N_("PROFILEID")
   },
   {
     "tab-with-profile-internal-id",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_TAB_WITH_PROFILE_ID,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_TAB_WITH_PROFILE_ID,
     N_("Open a new tab in the last-opened window with the given profile ID. Used internally to save sessions."),
     N_("PROFILEID")
   },
   {
     "role",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_ROLE,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_ROLE,
     N_("Set the role for the last-specified window; applies to only one window; can be specified once for each window you create from the command line."),
     N_("ROLE")
   },
   {
     "show-menubar",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_SHOW_MENUBAR,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_SHOW_MENUBAR,
     N_("Turn on the menubar for the last-specified window; applies to only one window; can be specified once for each window you create from the command line."),
     NULL
   },
   {
     "hide-menubar",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_HIDE_MENUBAR,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_HIDE_MENUBAR,
     N_("Turn off the menubar for the last-specified window; applies to only one window; can be specified once for each window you create from the command line."),
     NULL
   },
   {
     "full-screen",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_FULLSCREEN,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_FULLSCREEN,
     N_("Set the last-specified window into fullscreen mode; applies to only one window; can be specified once for each window you create from the command line."),
     NULL
   },
   {
     "geometry",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_GEOMETRY,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_GEOMETRY,
     N_("X geometry specification (see \"X\" man page), can be specified once per window to be opened."),
     N_("GEOMETRY")
   },
   {
     "disable-factory",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_DISABLE_FACTORY,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_DISABLE_FACTORY,
     N_("Do not register with the activation nameserver, do not re-use an active terminal"),
     NULL
   },
   {
     "use-factory",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_USE_FACTORY,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_USE_FACTORY,
     N_("Register with the activation nameserver [default]"),
     NULL
   },
   {
     "startup-id",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_STARTUP_ID,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_STARTUP_ID,
     N_("ID for startup notification protocol."),
     NULL
   },
   {
     "title",
     't',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_TITLE,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_TITLE,
     N_("Set the terminal's title"),
     N_("TITLE")
   },
   {
     "working-directory",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_WORKING_DIRECTORY,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_WORKING_DIRECTORY,
     N_("Set the terminal's working directory"),
     N_("DIRNAME")
   },
   {
     "default-working-directory",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_DEFAULT_WORKING_DIRECTORY,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_DEFAULT_WORKING_DIRECTORY,
     N_("Set the default terminal's working directory. Used internally"),
     N_("DIRNAME")
   },
   {
     "zoom",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_ZOOM,
+    0,
+    0,
+    G_OPTION_ARG_STRING,
+    &OPTION_ZOOM,
     N_("Set the terminal's zoom factor (1.0 = normal size)"),
     N_("ZOOMFACTOR")
   },
   {
     "active",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_ACTIVE,
+    0,
+    0,
+    G_OPTION_ARG_NONE,
+    &OPTION_ACTIVE,
     N_("Set the last specified tab as the active one in its window"),
     N_("ZOOMFACTOR")
   },
@@ -376,179 +368,173 @@
    */
   {
     "tclass",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_STRING,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "font",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_STRING,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "nologin",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "login",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "foreground",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_STRING,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "background",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_STRING,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "solid",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "bgscroll",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "bgnoscroll",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "shaded",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "noshaded",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "transparent",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "utmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "noutmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "wtmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "nowtmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "lastlog",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "nolastlog",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "icon",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_STRING,
+    &OPTION_COMPAT,
     NULL, NULL
   },  
   {
     "termname",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_STRING,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
     "start-factory-server",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN,
+    G_OPTION_ARG_NONE,
+    &OPTION_COMPAT,
     NULL, NULL
   },
   {
-    NULL,
-    '\0',
-    0,
-    NULL,
-    0,
-    NULL,
     NULL
   }
 };
@@ -741,7 +727,7 @@
   
   return iw;
 }
-
+/*
 static void
 parse_options_callback (poptContext              ctx,
                         enum poptCallbackReason  reason,
@@ -755,7 +741,7 @@
 
   if (reason == POPT_CALLBACK_REASON_POST)
     {
-      /* Make sure we have some window */
+      /* Make sure we have some window */ /* 
       if (results->initial_windows == NULL)
         ensure_top_window (results);
 
@@ -1113,7 +1099,7 @@
         /* Try reading a locale-style double first, in case it was
          * typed by a person, then fall back to ascii_strtod (we
          * always save session in C locale format)
-         */
+         */ /*
         end = NULL;
         val = g_strtod (arg, &end);
         if (end == NULL || *end != '\0')
@@ -1180,9 +1166,9 @@
     case OPTION_LAST:
       g_assert_not_reached ();
       break;
-      /* no default so we get warnings on missing items */
+      /* no default so we get warnings on missing items */ /*
     }
-}
+} */
 
 static void
 option_parsing_results_free (OptionParsingResults *results)
@@ -1569,7 +1555,8 @@
 main (int argc, char **argv)
 {
   GError *err;
-  poptContext ctx;
+  GOptionContext *context;
+  GOptionGroup *option_group;
   int i;
   int argc_copy;
   char **argv_copy;
@@ -1643,14 +1630,22 @@
   
   module_info.requirements = reqs;
 
-  options[0].descrip = (void*) results; /* I hate GnomeProgram, popt, and their
-                                         * mutant spawn
-                                         */
+  context = g_option_context_new (N_("- GNOME Terminal Emulator"));
+
+  option_group = g_option_group_new (N_("gnome-terminal"),
+                                     N_("GNOME Terminal Emulator"),
+				     N_("Show GNOME Terminal options"),
+				     results,
+				     NULL);
+
+  g_option_context_add_main_entries (context, option_group, GETTEXT_PACKAGE);
+  g_option_group_set_parse_hooks(option_group, NULL, post_options_callback);
+
   program = gnome_program_init (PACKAGE, VERSION,
                                 &module_info,
                                 argc,
                                 argv,
-                                GNOME_PARAM_POPT_TABLE, options,
+                                GNOME_PARAM_GOPTION_CONTEXT, context,
                                 GNOME_PARAM_APP_PREFIX, TERM_PREFIX,
                                 GNOME_PARAM_APP_SYSCONFDIR, TERM_SYSCONFDIR,
                                 GNOME_PARAM_APP_DATADIR, TERM_DATADIR,
@@ -1661,15 +1656,8 @@
                 GNOME_PARAM_POPT_CONTEXT, &ctx,
                 NULL);
   
-  args = poptGetArgs (ctx);
-  if (args)
-    {
-      g_printerr (_("Invalid argument: \"%s\"\n"), *args);
-      g_strfreev (argv_copy);
-      return 1;
-    }
-  poptFreeContext (ctx);
 
+
   option_parsing_results_apply_directory_defaults (results);
   
   gtk_rc_parse_string ("style \"hig-dialog\" {\n"
