Index: configure.in
===================================================================
--- configure.in	(révision 2323)
+++ configure.in	(copie de travail)
@@ -31,6 +31,8 @@ GCONF_REQUIRED=2.14.0
 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
@@ -39,9 +41,11 @@ PKG_CHECK_MODULES(TERM, dnl
  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-2.0 >= $GLIB_REQUIRED)
 
 TERM_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $TERM_LIBS"
 TERM_CFLAGS="$X_CFLAGS $TERM_CFLAGS"
Index: src/terminal.c
===================================================================
--- src/terminal.c	(révision 2323)
+++ src/terminal.c	(copie de travail)
@@ -37,7 +37,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>
@@ -82,24 +81,31 @@ struct _TerminalApp
 
 static GConfClient *conf = NULL;
 static TerminalApp *app = NULL;
-static gboolean terminal_factory_disabled = FALSE;
 static gboolean initialization_complete = FALSE;
 static GSList *pending_new_terminal_events = NULL;
 
 #define TERMINAL_STOCK_EDIT "terminal-edit"
 typedef struct
 {
-  char *startup_id;
-  char *display_name;
-  int screen_number;
-  GList *initial_windows;
+  char    *startup_id;
+  char    *display_name;
+  int      screen_number;
+  GList   *initial_windows;
   gboolean default_window_menubar_forced;
   gboolean default_window_menubar_state;
   gboolean default_start_fullscreen;
-  char *default_geometry;
-  char *default_working_dir;
-  char **post_execute_args;
-} OptionParsingResults;
+  char    *default_geometry;
+  char    *default_working_dir;
+  char   **post_execute_args;
+
+  gboolean  execute;
+  char     *geometry;
+  gboolean  use_factory;
+  char     *zoom;
+}
+  OptionParsingResults;
+
+OptionParsingResults parsing_results;
 
 static void         sync_profile_list            (gboolean use_this_list,
                                                   GSList  *this_list);
@@ -133,239 +139,215 @@ static gboolean save_yourself_callback (
 static gboolean terminal_invoke_factory (int argc, char **argv);
 static void option_parsing_results_free (OptionParsingResults *results);
 
+/* callbacks for GOption command line parsing */
+static gboolean digest_options_callback (GOptionContext *context,
+                                         GOptionGroup *group,
+                                         gpointer data,
+                                         GError **error);
+
+static gboolean immediate_options_callback (const gchar *option_name,
+                                            const gchar *value,
+                                            gpointer data,
+                                            GError **error);
+
+static gboolean unsupported_option_callback  (const gchar *option_name,
+                                              const gchar *value,
+                                              gpointer data,
+                                              GError **error);
+
 
-static void parse_options_callback (poptContext              ctx,
-                                    enum poptCallbackReason  reason,
-                                    const struct poptOption *opt,
-                                    const char              *arg,
-                                    void                    *data);
 static void client_die_cb          (GnomeClient             *client,
                                     gpointer                 data);
 
 static void handle_new_terminal_events (void);
 
-enum {
-  OPTION_COMMAND = 1,
-  OPTION_EXECUTE,
-  OPTION_WINDOW,
-  OPTION_WINDOW_WITH_PROFILE,
-  OPTION_TAB,
-  OPTION_TAB_WITH_PROFILE,
-  OPTION_WINDOW_WITH_PROFILE_ID,
-  OPTION_TAB_WITH_PROFILE_ID,
-  OPTION_ROLE,
-  OPTION_SHOW_MENUBAR,
-  OPTION_HIDE_MENUBAR,
-  OPTION_FULLSCREEN,
-  OPTION_GEOMETRY,
-  OPTION_DISABLE_FACTORY,
-  OPTION_USE_FACTORY,
-  OPTION_STARTUP_ID,
-  OPTION_TITLE,
-  OPTION_WORKING_DIRECTORY,
-  OPTION_DEFAULT_WORKING_DIRECTORY,
-  OPTION_ZOOM,
-  OPTION_ACTIVE,
-  OPTION_COMPAT,
-  OPTION_LAST
-};  
-
-struct poptOption options[] = {  
-  {
-    NULL, 
-    '\0', 
-    POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
-    parse_options_callback, 
-    0, 
-    NULL, 
-    NULL
-  },
+const GOptionEntry goptions[] = {  
   {
     "command",
     'e',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_COMMAND,
+    G_OPTION_FLAG_FILENAME,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     N_("Execute the argument to this option inside the terminal."),
     NULL
   },
   {
     "execute",
     'x',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_EXECUTE,
+    0,
+    G_OPTION_ARG_NONE,
+    &parsing_results.execute,
     N_("Execute the remainder of the command line inside the terminal."),
     NULL
   },
   {
     "window",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_WINDOW,
+    0,
+    G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     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_CALLBACK,
+    immediate_options_callback,
     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,
+    G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     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_CALLBACK,
+    immediate_options_callback,
     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_CALLBACK,
+    immediate_options_callback,
     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_CALLBACK,
+    immediate_options_callback,
     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_CALLBACK,
+    immediate_options_callback,
     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,
+    G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     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,
+    G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     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,
+    G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     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,
+    &parsing_results.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,
+    G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     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,
+    &parsing_results.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,
+    &parsing_results.startup_id,
     N_("ID for startup notification protocol."),
     NULL
   },
   {
     "title",
     't',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_TITLE,
+    0,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     N_("Set the terminal's title"),
     N_("TITLE")
   },
   {
     "working-directory",
-    '\0',
-    POPT_ARG_STRING,
-    NULL,
-    OPTION_WORKING_DIRECTORY,
+    0,
+    G_OPTION_FLAG_FILENAME,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     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_FILENAME,
+    &parsing_results.default_working_dir,
     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,
+    &parsing_results.zoom,
     N_("Set the terminal's zoom factor (1.0 = normal size)"),
     N_("ZOOMFACTOR")
   },
   {
     "active",
-    '\0',
-    POPT_ARG_NONE,
-    NULL,
-    OPTION_ACTIVE,
+    0,
+    G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    immediate_options_callback,
     N_("Set the last specified tab as the active one in its window"),
     N_("ZOOMFACTOR")
   },
@@ -375,179 +357,173 @@ struct poptOption options[] = {  
    */
   {
     "tclass",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "font",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "nologin",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "login",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "foreground",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "background",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "solid",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "bgscroll",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "bgnoscroll",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "shaded",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "noshaded",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "transparent",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "utmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "noutmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "wtmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "nowtmp",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "lastlog",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "nolastlog",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "icon",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },  
   {
     "termname",
-    '\0',
-    POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
     "start-factory-server",
-    '\0',
-    POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
-    NULL,
-    OPTION_COMPAT,
+    0,
+    G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
+    G_OPTION_ARG_CALLBACK,
+    unsupported_option_callback,
     NULL, NULL
   },
   {
-    NULL,
-    '\0',
-    0,
-    NULL,
-    0,
-    NULL,
     NULL
   }
 };
@@ -741,446 +717,337 @@ add_new_window (OptionParsingResults *re
   return iw;
 }
 
-static void
-parse_options_callback (poptContext              ctx,
-                        enum poptCallbackReason  reason,
-                        const struct poptOption *opt,
-                        const char              *arg,
-                        void                    *data)
+/* handle deprecated command line options */
+static gboolean
+unsupported_option_callback (const gchar *option_name,
+                             const gchar *value,
+                             gpointer     data,
+                             GError     **error)
+{
+  g_printerr (_("Option '%s' is no longer supported in this version of gnome-terminal;"
+               " you might want to create a profile with the desired setting, and use"
+               " the new '--window-with-profile' option\n"), option_name);
+  return TRUE; /* we do not want to bail out here but continue */
+}
+
+/* handle options that need to be evaluated immediately */
+static gboolean 
+immediate_options_callback (const gchar *option_name,
+                            const gchar *value,
+                            gpointer     data,
+                            GError     **error)
 {
   OptionParsingResults *results;
+  InitialTab *it;
+  InitialWindow *iw;
 
   results = data;
 
-  if (reason == POPT_CALLBACK_REASON_POST)
-    {
-      /* Make sure we have some window */
-      if (results->initial_windows == NULL)
-        ensure_top_window (results);
 
-      return;
-    }
-  else if (reason != POPT_CALLBACK_REASON_OPTION)
-    return;
 
-  switch (opt->val & POPT_ARG_MASK)
+  if (strcmp (option_name, "-e") == 0 ||
+      strcmp (option_name, "--command") == 0)
     {
-    case OPTION_COMMAND:
-      {
-        GError *err;
-        InitialTab *it;
-        char **exec_argv;
-            
-
-        if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires specifying the command to run\n"), "--command/-e");
-            exit (1);
-          }
-            
-        err = NULL;
-        exec_argv = NULL;
-        if (!g_shell_parse_argv (arg, NULL, &exec_argv, &err))
-          {
-            g_printerr (_("Argument to \"%s\" is not a valid command: %s\n"),
-                        "--command/-e", err->message);
-            g_error_free (err);
-            exit (1);
-          }
-
-        it = ensure_top_tab (results);
-
-        if (it->exec_argv != NULL)
-          {
-            g_printerr (_("\"%s\" specified more than once for the same window or tab\n"),
-                        "--command/-e/--execute/-x");
-            exit (1);
-          }
+      GError *err;
+      char   **exec_argv;
+      error = NULL;
+      exec_argv = NULL;
 
-        it->exec_argv = exec_argv;
-      }
-      break;
+      if (!g_shell_parse_argv (value, NULL, &exec_argv, &err))
+        {
+          g_set_error(error,
+                      G_OPTION_ERROR,
+                      G_OPTION_ERROR_BAD_VALUE,
+                      _("Argument to \"%s\" is not a valid command: %s\n"),
+                      "--command/-e",
+                      err->message);
+          g_error_free (err);
+          return FALSE;
+        }
 
-    case OPTION_EXECUTE:
-      {
-        InitialTab *it;
-            
-        if (results->post_execute_args == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires specifying the command to run on the rest of the command line\n"),
-                        "--execute/-x");
-            exit (1);
-          }
+      it = ensure_top_tab (results);
+      it->exec_argv = exec_argv;
+    }
 
-        it = ensure_top_tab (results);
 
-        if (it->exec_argv != NULL)
-          {
-            g_printerr (_("\"%s\" specified more than once for the same window or tab\n"),
-                        "--command/-e/--execute/-x");
-            exit (1);
-          }
+  else if (strcmp (option_name, "--window") == 0)
+    {
+      iw = add_new_window (results, NULL, FALSE);
+    }
 
-        it->exec_argv = results->post_execute_args;
-        results->post_execute_args = NULL;
-      }
-      break;
-          
-    case OPTION_WINDOW:
-    case OPTION_WINDOW_WITH_PROFILE:
-    case OPTION_WINDOW_WITH_PROFILE_ID:
-      {
-        InitialWindow *iw;
-        const char *profile;
 
+  else if (strcmp (option_name, "--window-with-profile") == 0)
+    {
+      const char *profile;
+      profile = value;
 
-        if (opt->val == OPTION_WINDOW)
-          profile = NULL;
-        else if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires an argument specifying what profile to use\n"),
-                        "--window-with-profile");
-            exit (1);
-          }
-        else
-          profile = arg;
+      iw = add_new_window (results, profile, FALSE);
+    }
 
-        iw = add_new_window (results, profile,
-                             opt->val == OPTION_WINDOW_WITH_PROFILE_ID);
-      }
-      break;
 
-    case OPTION_TAB:
-    case OPTION_TAB_WITH_PROFILE:
-    case OPTION_TAB_WITH_PROFILE_ID:
-      {
-        InitialWindow *iw;
-        const char *profile;
+  else if (strcmp (option_name, "--tab") == 0)
+    {
+      const char *profile;
 
+      profile = NULL;
+                
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
 
-        if (opt->val == OPTION_TAB)
-          profile = NULL;
-        else if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires an argument specifying what profile to use\n"),
-                        "--tab-with-profile");
-            exit (1);
-          }
-        else
-          profile = arg;
+          iw->tabs = 
+          g_list_append (iw->tabs, initial_tab_new (profile, FALSE));
+        }
+      else
+        {
+          iw = add_new_window (results, profile, FALSE);
+        }
+    }
 
-                
-        if (results->initial_windows)
-          {
-            iw = g_list_last (results->initial_windows)->data;
 
-            iw->tabs = g_list_append (iw->tabs,
-                                      initial_tab_new (profile,
-                                                       opt->val == OPTION_TAB_WITH_PROFILE_ID));
-          }
-        else
-          {
-            iw = add_new_window (results, profile, 
-                                 opt->val == OPTION_TAB_WITH_PROFILE_ID);
-          }
-      }
-      break;
-          
-    case OPTION_SHOW_MENUBAR:
-      {
-        InitialWindow *iw;
-            
-        if (results->initial_windows)
-          {
-            iw = g_list_last (results->initial_windows)->data;
+  else if (strcmp (option_name, "--tab-with-profile") == 0)
+    {
+      const gchar *profile;
+      profile = value;
 
-            if (iw->force_menubar_state)
-              {
-                g_printerr (_("\"%s\" option given twice for the same window\n"), "--show-menubar");
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
 
-                exit (1);
-              }
-                
-            iw->force_menubar_state = TRUE;
-            iw->menubar_state = TRUE;
-          }
-        else
-          {
-            results->default_window_menubar_forced = TRUE;
-            results->default_window_menubar_state = TRUE;
-          }
-      }
-      break;
+          iw->tabs = 
+          g_list_append (iw->tabs, initial_tab_new (profile, FALSE));
+        }
+      else
+        {
+          iw = add_new_window (results, profile, FALSE);
+        }
           
-    case OPTION_HIDE_MENUBAR:
-      {
-        InitialWindow *iw;
-            
-        if (results->initial_windows)
-          {
-            iw = g_list_last (results->initial_windows)->data;
+    }
 
-            if (iw->force_menubar_state)
-              {
-                g_printerr (_("\"%s\" option given twice for the same window\n"), "--hide-menubar");
 
-                exit (1);
-              }
-                
-            iw->force_menubar_state = TRUE;
-            iw->menubar_state = FALSE;                
-          }
-        else
-          {
-            results->default_window_menubar_forced = TRUE;
-            results->default_window_menubar_state = FALSE;
-          }
-      }
-      break;
+  else if (strcmp (option_name, "--window-with-profile-internal-id") == 0)
+    {
+      const char *profile;
+      profile = value;
+      iw = add_new_window (results, profile, TRUE);
+    }                       
 
-    case OPTION_FULLSCREEN:
-      {
-        InitialWindow *iw;
-            
-        if (results->initial_windows)
-          {
-            iw = g_list_last (results->initial_windows)->data;
 
-            iw->start_fullscreen = TRUE;
-          }
-        else
-          {
-            results->default_start_fullscreen = TRUE;
-          }
-      }
-      break;
+  else if (strcmp (option_name, "--tab-with-profile-internal-id") == 0)
+    {
+      const char *profile;
+      profile = value;
 
-    case OPTION_ROLE:
-      {
-        InitialWindow *iw;
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
 
+          iw->tabs = 
+          g_list_append (iw->tabs, initial_tab_new (profile, TRUE));
+        }
+      else
+        iw = add_new_window (results, profile, TRUE);
+     }
 
-        if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires an argument giving the role\n"), "--role");
-            exit (1);
-          }
-            
-        if (results->initial_windows)
-          {
-            iw = g_list_last (results->initial_windows)->data;
-            if (iw->role)
-              {
-                g_printerr (_("Two roles given for one window\n"));
-                exit (1);
-              }
 
-            iw->role = g_strdup (arg);
-          }
-      }
-      break;
+  else if (strcmp (option_name, "--role") == 0)
+    {
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
+          iw->role = g_strdup (value);
+        }
+    }
 
-    case OPTION_GEOMETRY:
-      {
-        InitialWindow *iw;
 
+  else if (strcmp (option_name, "--show-menubar") == 0)
+    {
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
+          if (iw->force_menubar_state && iw->menubar_state == TRUE)
+            {
+              g_printerr (_("\"%s\" option given twice for the same window\n"),
+                            "--show-menubar");
 
-        if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires an argument giving the geometry\n"), "--geometry");
-            exit (1);
-          }
-            
-        if (results->initial_windows)
-          {
-            iw = g_list_last (results->initial_windows)->data;
-            if (iw->geometry)
-              {
-                g_printerr (_("Two \"%s\" options given for one window\n"), "--geometry");
-                exit (1);
-              }
+              return TRUE;
+            }
+                
+          iw->force_menubar_state = TRUE;
+          iw->menubar_state = TRUE;
+        }
+      else
+        {
+          results->default_window_menubar_forced = TRUE;
+          results->default_window_menubar_state = TRUE;
+        }
+    }
 
-            iw->geometry = g_strdup (arg);
-          }
-        else
-          {
-            if (results->default_geometry)
-              {
-                g_printerr (_("Two geometries given for one window\n"));
-                exit (1);
-              }
-            else
-              {
-                results->default_geometry = g_strdup (arg);
-              }
-          }
-      }
-      break;
 
-    case OPTION_DISABLE_FACTORY:
-      terminal_factory_disabled = TRUE;
-      break;
+  else if (strcmp (option_name, "--hide-menubar") == 0)
+    {
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
+ 
+          if (iw->force_menubar_state && iw->menubar_state == FALSE)
+            {
+              g_printerr (_("\"%s\" option given twice for the same window\n"),
+                            "--hide-menubar");
+              return TRUE;
+            }
 
-    case OPTION_USE_FACTORY:
-      terminal_factory_disabled = FALSE;
-      break;
+          iw->force_menubar_state = TRUE;
+          iw->menubar_state = FALSE;                
+        }
+      else
+        {
+          results->default_window_menubar_forced = TRUE;
+          results->default_window_menubar_state = FALSE;
+        }
+    }
 
-    case OPTION_TITLE:
-      {
-        InitialTab *it;
-            
 
-        if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires an argument giving the title\n"), "--title");
-            exit (1);
-          }
+  else if (strcmp (option_name, "--fullscreen") == 0)
+    {
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
+          iw->start_fullscreen = TRUE;
+        }
+      else
+        results->default_start_fullscreen = TRUE;
+    }      
 
-        it = ensure_top_tab (results);
 
-        if (it->title)
-          {
-            g_printerr (_("Two \"%s\" options given for one tab\n"), "--title");
-            exit (1);
-          }
+  else if (strcmp (option_name, "--disable-factory") == 0)
+    {
+      results->use_factory = FALSE;
+    }
 
-        it->title = g_strdup (arg);
-      }
-      break;
 
-    case OPTION_WORKING_DIRECTORY:
-      {
-        InitialTab *it;
-            
+  else if (strcmp (option_name, "-t") == 0 ||
+      strcmp (option_name, "--title") == 0)
+    {
+      it = ensure_top_tab (results);
+      it->title = g_strdup (value);
+    }
 
-        if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires an argument giving the directory\n"), "--working-directory");
-            exit (1);
-          }
 
-        it = ensure_top_tab (results);
+  else if (strcmp (option_name, "--working-directory") == 0)
+    {
+      it = ensure_top_tab (results);
+      it->working_dir = g_strdup (value);
+    }
 
-        if (it->working_dir)
-          {
-            g_printerr (_("Two \"%s\" options given for one tab\n"), "--working-directory");
-            exit (1);
-          }
 
-        it->working_dir = g_strdup (arg);
-      }
-      break;
+  else if (strcmp (option_name, "--active") == 0)
+    {
+      it = ensure_top_tab (results);
+      it->active = TRUE;
+    }
 
-    case OPTION_DEFAULT_WORKING_DIRECTORY:
-      {
-        if (arg == NULL)
-          {
-            g_printerr (_("Option --default-working-directory requires an argument giving the directory\n"));
-            exit (1);
-          }
 
-        if (results->default_working_dir)
-          {
-            g_printerr (_("Two --default-working-directories given\n"));
-            exit (1);
-          }
+  return TRUE;
+} 
 
-        results->default_working_dir = g_strdup (arg);
-      }
-      break;
+/* Evaluation of the arguments given to the command line options */
+static gboolean
+digest_options_callback (GOptionContext *context,
+                         GOptionGroup *group,
+                         gpointer      data,
+                         GError      **error)
+{
+  OptionParsingResults *results;
+  InitialTab    *it;
+  InitialWindow *iw;
 
-    case OPTION_ZOOM:
-      {
-        InitialTab *it;            
-        double val;
-        char *end;
-        
-        if (arg == NULL)
-          {
-            g_printerr (_("Option \"%s\" requires an argument giving the zoom factor\n"), "--zoom");
-            exit (1);
-          }
+  results = data;
 
-        it = ensure_top_tab (results);
+  /* make sure we have some window in case no options were given */
+  if (results->initial_windows == NULL)
+    it = ensure_top_tab (results);
 
-        if (it->zoom_set)
-          {
-            g_printerr (_("Two \"%s\" options given for one tab\n"), "--zoom");
-            exit (1);
-          }
 
-        /* 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')
-          {
-            val = g_ascii_strtod (arg, &end);
-            if (end == NULL || *end != '\0')
-              {
-                g_printerr (_("\"%s\" is not a valid zoom factor\n"),
-                            arg);
-                exit (1);
-              }
-          }
+  if (results->execute)
+    {         
+      if (results->post_execute_args == NULL)
+        {
+          g_set_error (error,
+                       G_OPTION_ERROR,
+                       G_OPTION_ERROR_BAD_VALUE,
+                       _("Option \"%s\" requires specifying the command to run"
+                       " on the rest of the command line\n"),
+                       "--execute/-x");
+          return FALSE;
+        }
 
-        if (val < (TERMINAL_SCALE_MINIMUM + 1e-6))
-          {
-            g_printerr (_("Zoom factor \"%g\" is too small, using %g\n"),
-                        val, TERMINAL_SCALE_MINIMUM);
-            val = TERMINAL_SCALE_MINIMUM;
-          }
+      it = ensure_top_tab (results);
+      it->exec_argv = results->post_execute_args;
+      results->post_execute_args = NULL;
+    } 
+         
 
-        if (val > (TERMINAL_SCALE_MAXIMUM - 1e-6))
-          {
-            g_printerr (_("Zoom factor \"%g\" is too large, using %g\n"),
-                        val, TERMINAL_SCALE_MAXIMUM);
-            val = TERMINAL_SCALE_MAXIMUM;
-          }
-        
-        it->zoom = val;
-        it->zoom_set = TRUE;
-      }
-      break;
+  if (results->geometry)
+    {
+      if (results->initial_windows)
+        {
+          iw = g_list_last (results->initial_windows)->data;
+          iw->geometry = g_strdup (results->geometry);
+        }
+      else
+          results->default_geometry = g_strdup (results->geometry);
+    }
 
-    case OPTION_ACTIVE:
-      {
-        InitialTab *it;
 
-        it = ensure_top_tab (results);
+  if (results->zoom)
+    {
+      double val;
+      char *end;
 
-        it->active = TRUE;
-      }
-      break;
-      
-    case OPTION_COMPAT:
-      g_printerr (_("Option --%s is no longer supported in this version of gnome-terminal; you might want to create a profile with the desired setting, and use the new --window-with-profile option\n"), opt->longName);
-      break;
+      it = ensure_top_tab (results);
 
-    case OPTION_STARTUP_ID:
-      if (results->startup_id != NULL)
+      /* 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 (results->zoom, &end);
+      if (end == NULL || *end != '\0')
         {
-          g_printerr (_("\"%s\" option given twice\n"), "--startup-id");
-          exit (1);
+          val = g_ascii_strtod (results->zoom, &end);
+          if (end == NULL || *end != '\0')
+            {
+              g_set_error (error,
+                           G_OPTION_ERROR,
+                           G_OPTION_ERROR_BAD_VALUE,
+                           _("\"%s\" is not a valid zoom factor\n"),
+                           results->zoom);
+              return FALSE;
+            }
         }
-      else if (arg == NULL)
+
+      if (val < (TERMINAL_SCALE_MINIMUM + 1e-6))
         {
-          g_printerr (_("\"%s\" option requires an argument\n"), "--startup-id");
-          exit (1);
+          g_printerr (_("Zoom factor \"%g\" is too small, using %g\n"),
+                      val,
+                      TERMINAL_SCALE_MINIMUM);
+          val = TERMINAL_SCALE_MINIMUM;
         }
-      else
+
+      if (val > (TERMINAL_SCALE_MAXIMUM - 1e-6))
         {
-          results->startup_id = g_strdup (arg);
+          g_printerr (_("Zoom factor \"%g\" is too large, using %g\n"),
+                      val, 
+                      TERMINAL_SCALE_MAXIMUM);
+          val = TERMINAL_SCALE_MAXIMUM;
         }
-      break;
-      
-    case OPTION_LAST:
-      g_assert_not_reached ();
-      break;
-      /* no default so we get warnings on missing items */
+        
+      it->zoom = val;
+      it->zoom_set = TRUE;
     }
+
+  return TRUE;
 }
 
 static void
@@ -1197,30 +1064,29 @@ option_parsing_results_free (OptionParsi
 
   g_free (results->display_name);
   g_free (results->startup_id);
-  
-  g_free (results);
-}
+  g_free (results->geometry);
+  g_free (results->zoom);
 
-static GnomeModuleInfo module_info = {
-  PACKAGE, VERSION, N_("Terminal"),
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  NULL
-};
+}
 
 static OptionParsingResults *
-option_parsing_results_init (int *argc, char **argv)
+option_parsing_results_init (OptionParsingResults *results, int *argc, char **argv)
 {
   int i;
-  OptionParsingResults *results;
 
-  results = g_new0 (OptionParsingResults, 1);
+  results->default_window_menubar_forced = 0;
+  results->default_window_menubar_state = 1;
+  results->default_start_fullscreen = 0;
+  results->execute = 0;
+  results->use_factory = 1;
+
+  results->startup_id = NULL;
+  results->display_name = NULL;
+  results->initial_windows = NULL;
+  results->default_geometry = NULL;
+  results->geometry = NULL;
+  results->zoom = NULL;
+
   results->screen_number = -1;
   results->default_working_dir = NULL;
   
@@ -1287,7 +1153,7 @@ option_parsing_results_check_for_display
           if ((i + 1) >= *argc)
             {
               g_printerr (_("No argument given to \"%s\" option\n"), "--display");
-              return; /* popt will die on this later, plus it shouldn't happen
+              return; /* popt (GOption?) will die on this later, plus it shouldn't happen
                        * because normally gtk_init() parses --display
                        * when not using factory mode.
                        */
@@ -1533,14 +1399,14 @@ slowly_and_stupidly_obtain_timestamp (Di
 
     xwindow =
       XCreateWindow (xdisplay,
-		     RootWindow (xdisplay, 0),
-		     -100, -100, 1, 1,
-		     0,
-		     CopyFromParent,
-		     CopyFromParent,
-		     CopyFromParent,
-		     CWOverrideRedirect | CWEventMask,
-		     &attrs);
+                     RootWindow (xdisplay, 0),
+                     -100, -100, 1, 1,
+                     0,
+                     CopyFromParent,
+                     CopyFromParent,
+                     CopyFromParent,
+                     CWOverrideRedirect | CWEventMask,
+                     &attrs);
 
     atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE);
     g_assert (atom_name != None);
@@ -1549,15 +1415,15 @@ slowly_and_stupidly_obtain_timestamp (Di
 
     name = "Fake Window";
     XChangeProperty (xdisplay, 
-		     xwindow, atom_name,
-		     atom_type,
-		     8, PropModeReplace, (unsigned char *)name, strlen (name));
+                     xwindow, atom_name,
+                     atom_type,
+                     8, PropModeReplace, (unsigned char *)name, strlen (name));
   }
 
   XWindowEvent (xdisplay,
-		xwindow,
-		PropertyChangeMask,
-		&event);
+                xwindow,
+                PropertyChangeMask,
+                &event);
 
   XDestroyWindow(xdisplay, xwindow);
 
@@ -1568,26 +1434,22 @@ int
 main (int argc, char **argv)
 {
   GError *err;
-  poptContext ctx;
+  GOptionContext *context;
+  GOptionGroup *option_group;
   int i;
   int argc_copy;
   char **argv_copy;
-  const char **args;
   const char *startup_id;
   const char *display_name;
   GdkDisplay *display;
-  GnomeModuleRequirement reqs[] = {
-    { "2.0.0", NULL },
-    { NULL, NULL }
-  };
   GnomeClient *sm_client;
-  OptionParsingResults *results;
   GnomeProgram *program;
 
-  reqs[0].module_info = LIBGNOMEUI_MODULE;
+  OptionParsingResults *results = &parsing_results;
 
   if (setlocale (LC_ALL, "") == NULL)
-    g_printerr ("GNOME Terminal: locale not understood by C library, internationalization will not work\n");
+    g_printerr ("GNOME Terminal: locale not understood by C library, "
+                "internationalization will not work\n");
 
 #if 0
   {
@@ -1610,7 +1472,7 @@ main (int argc, char **argv)
     argv_copy [i] = g_strdup (argv [i]);
   argv_copy [i] = NULL;
 
-  results = option_parsing_results_init (&argc, argv);
+  results = option_parsing_results_init (results, &argc, argv);
   startup_id = g_getenv ("DESKTOP_STARTUP_ID");
   if (startup_id != NULL && *startup_id != '\0')
     {
@@ -1621,10 +1483,35 @@ main (int argc, char **argv)
   gtk_window_set_auto_startup_notification (FALSE); /* we'll do it ourselves due
                                                      * to complicated factory setup
                                                      */
-  
-  gtk_init (&argc, &argv);
 
-  /* Do this here so that gdk_display is initialized */
+  context = g_option_context_new (N_("- GNOME Terminal Emulator"));
+
+  g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
+
+  option_group = g_option_group_new ("gnome-terminal",
+                                     N_("GNOME Terminal Emulator"),
+                                     N_("Show GNOME Terminal options"),
+                                     results,
+                                     NULL);
+  g_option_group_add_entries (option_group, goptions);
+  g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+  g_option_group_set_parse_hooks (option_group, NULL, digest_options_callback);
+  g_option_context_set_main_group (context, option_group);
+
+
+  /* This automagically makes GOption parse */
+  program = gnome_program_init (PACKAGE, VERSION,
+                                LIBGNOMEUI_MODULE,
+                                argc,
+                                argv,
+                                GNOME_PARAM_GOPTION_CONTEXT, context,
+                                GNOME_PARAM_APP_PREFIX, TERM_PREFIX,
+                                GNOME_PARAM_APP_SYSCONFDIR, TERM_SYSCONFDIR,
+                                GNOME_PARAM_APP_DATADIR, TERM_DATADIR,
+                                GNOME_PARAM_APP_LIBDIR, TERM_LIBDIR,
+                                NULL); 
+
+ /* Do this here so that gdk_display is initialized */
   if (results->startup_id == NULL)
     {
       /* Create a fake one containing a timestamp that we can use */
@@ -1640,34 +1527,6 @@ main (int argc, char **argv)
   display_name = gdk_display_get_name (display);
   results->display_name = g_strdup (display_name);
   
-  module_info.requirements = reqs;
-
-  options[0].descrip = (void*) results; /* I hate GnomeProgram, popt, and their
-                                         * mutant spawn
-                                         */
-  program = gnome_program_init (PACKAGE, VERSION,
-                                &module_info,
-                                argc,
-                                argv,
-                                GNOME_PARAM_POPT_TABLE, options,
-                                GNOME_PARAM_APP_PREFIX, TERM_PREFIX,
-                                GNOME_PARAM_APP_SYSCONFDIR, TERM_SYSCONFDIR,
-                                GNOME_PARAM_APP_DATADIR, TERM_DATADIR,
-                                GNOME_PARAM_APP_LIBDIR, TERM_LIBDIR,
-                                NULL); 
-  
-  g_object_get (G_OBJECT (program),
-                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);
   
@@ -1676,7 +1535,7 @@ main (int argc, char **argv)
                          "GtkDialog::button-spacing = 12\n"
                          "}\n");
 
-  if (!terminal_factory_disabled)
+  if (results->use_factory)
     {
       char *cwd;
       
@@ -1763,6 +1622,7 @@ main (int argc, char **argv)
       return 1;
     }
 
+
   option_parsing_results_free (results);
   results = NULL;
 
@@ -1963,11 +1823,11 @@ terminal_app_new_terminal (TerminalApp  
       terminal_screen_set_profile (screen, profile);
     
       if (title)
-	{
+        {
           terminal_screen_set_title (screen, title);
-	  terminal_screen_set_dynamic_title (screen, title, FALSE);
-	  terminal_screen_set_dynamic_icon_title (screen, title, FALSE);
-	}
+          terminal_screen_set_dynamic_title (screen, title, FALSE);
+          terminal_screen_set_dynamic_icon_title (screen, title, FALSE);
+        }
 
       if (working_dir)
         terminal_screen_set_working_dir (screen, working_dir);
@@ -2357,10 +2217,10 @@ new_profile_response_callback (GtkWidget
       if (tmp)
         {
           confirm_dialog = gtk_message_dialog_new (GTK_WINDOW (new_profile_dialog), 
-						   GTK_DIALOG_DESTROY_WITH_PARENT,
-                	 			   GTK_MESSAGE_QUESTION, 
-						   GTK_BUTTONS_YES_NO, 
-			 			   _("You already have a profile called \"%s\". Do you want to create another profile with the same name?"), name);
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   GTK_MESSAGE_QUESTION, 
+                                                   GTK_BUTTONS_YES_NO, 
+                                                   _("You already have a profile called \"%s\". Do you want to create another profile with the same name?"), name);
           retval = gtk_dialog_run (GTK_DIALOG (confirm_dialog));
           gtk_widget_destroy (confirm_dialog);
           if (retval == GTK_RESPONSE_NO)   
@@ -2622,7 +2482,7 @@ create_profile_list (void)
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
 
   gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
-			       GTK_SELECTION_MULTIPLE);
+                               GTK_SELECTION_MULTIPLE);
 
   refill_profile_treeview (tree_view);
   
@@ -2633,12 +2493,12 @@ create_profile_list (void)
                 NULL);
   
   column = gtk_tree_view_column_new_with_attributes (NULL,
-						     cell,
-						     "text", COLUMN_NAME,
-						     NULL);
+                                                     cell,
+                                                     "text", COLUMN_NAME,
+                                                     NULL);
   
   gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
-			       GTK_TREE_VIEW_COLUMN (column));
+                               GTK_TREE_VIEW_COLUMN (column));
 
   gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
   
@@ -2703,10 +2563,10 @@ profile_list_delete_selection (GtkWidget
     {
       str = g_string_new (NULL);
       g_string_printf (str,
-		       ngettext ("Delete this profile?\n",
-				 "Delete these %d profiles?\n",
-				 count),
-		       count);
+                       ngettext ("Delete this profile?\n",
+                       "Delete these %d profiles?\n",
+                       count),
+                       count);
 
       tmp = deleted_profiles;
       while (tmp != NULL)
@@ -2739,7 +2599,7 @@ profile_list_delete_selection (GtkWidget
   gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                           GTK_STOCK_CANCEL,
                           GTK_RESPONSE_REJECT,
-			  GTK_STOCK_DELETE,
+                          GTK_STOCK_DELETE,
                           GTK_RESPONSE_ACCEPT,
                           NULL);
 
@@ -3283,7 +3143,7 @@ terminal_app_get_clone_command (Terminal
 
    g_ptr_array_add (args, g_strdup (EXECUTABLE_NAME));
 
-  if (terminal_factory_disabled)
+  if (!parsing_results.use_factory)
     {
        g_ptr_array_add (args, g_strdup ("--disable-factory"));
     }
@@ -3620,42 +3480,47 @@ static void
 handle_new_terminal_event (int          argc,
                            char       **argv)
 {
-  int nextopt;
-  poptContext ctx;
-  const void *store;
+  GOptionContext *context;
+  GOptionGroup *option_group;
   OptionParsingResults *results;
+  GError *error = NULL;
+
+  results = &parsing_results;
 
   g_assert (initialization_complete);
   
-  results = option_parsing_results_init (&argc, argv);
+  results = option_parsing_results_init (results, &argc, argv);
   
   /* Find and parse --display */
   option_parsing_results_check_for_display_name (results,
                                                  &argc,
                                                  argv);
-  
-  store = options[0].descrip;
-  options[0].descrip = (void*) results; /* I hate GnomeProgram, popt, and their
-                                         * mutant spawn
-                                         */
-  ctx = poptGetContext (PACKAGE,
-                        argc,
-                        (const char**)argv,
-			options, 0);
+
+  context = g_option_context_new (N_("GNOME Terminal Emulator"));
+  option_group = g_option_group_new ("gnome-terminal",
+                                     N_("GNOME Terminal Emulator"),
+                                     N_("Show GNOME Terminal options"),
+                                     results,
+                                     NULL);
+  g_option_group_add_entries (option_group, goptions);
+  g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+  g_option_group_set_parse_hooks (option_group, NULL, digest_options_callback);
+  g_option_context_set_main_group (context, option_group);
   
   g_return_if_fail (app != NULL);
 
-  while ((nextopt = poptGetNextOpt (ctx)) > 0 ||
-	 nextopt == POPT_ERROR_BADOPT)
-    /* do nothing */ ;
-
-  if (nextopt != -1)
-    g_warning ("Error on option %s: %s, passed from terminal child",
-	       poptBadOption (ctx, 0),
-	       poptStrerror (nextopt));
+  if(!g_option_context_parse (context, &argc, &argv, &error))
+  {
+      g_warning ("Error parsing options: %s, passed from terminal child",
+                 error->message);
+      g_error_free (error);
+      g_option_context_free (context);
+      option_parsing_results_free (results);
+      g_free (results);
+      exit(1);
+  }
 
-  poptFreeContext (ctx);
-  options[0].descrip = store;
+  g_option_context_free (context);
 
   option_parsing_results_apply_directory_defaults (results);
 
Index: ChangeLog
===================================================================
--- ChangeLog	(révision 2323)
+++ ChangeLog	(copie de travail)
@@ -1,3 +1,9 @@
+2007-12-20  Christian Kirbach  <Christian.Kirbach@googlemail.com>
+ 
+ 	* src/terminal.c: Migrate from popt to GOption (bug #336155).
+ 	* configure.in: require glib-2 >= 2.12.0, libgnome-2 >= 2.14.0.
+	  Suggestions taken from Michael Plumb, Christian Persch.
+
 2007-12-20  Christian Persch  <chpe@gnome.org>
 
 	* src/skey/md5.c: (MD5Keycrunch), (MD5SKey):
