Index: daemon/seahorse-daemon.c
===================================================================
RCS file: /cvs/gnome/seahorse/daemon/seahorse-daemon.c,v
retrieving revision 1.10
diff -u -r1.10 seahorse-daemon.c
--- daemon/seahorse-daemon.c	20 Mar 2006 07:06:51 -0000	1.10
+++ daemon/seahorse-daemon.c	27 Mar 2006 04:14:48 -0000
@@ -42,7 +42,7 @@
 #include "seahorse-secure-memory.h"
 #endif
 
-static gboolean g_daemonize = TRUE;
+static gboolean g_daemonize = FALSE;
 static gboolean g_quit = FALSE;
 
 static const gchar *daemon_icons[] = {
@@ -51,21 +51,19 @@
 };
 
 
-static const struct poptOption options[] = {
-	{ "no-daemonize", 'd', POPT_ARG_NONE | POPT_ARG_VAL, &g_daemonize, FALSE,
+static GOptionEntry options[] = {
+	{ "no-daemonize", 'd', 0, G_OPTION_ARG_NONE, &g_daemonize,
 	  N_("Do not daemonize seahorse-agent"), NULL },
 
 #ifdef WITH_AGENT
-    { "cshell", 'c', POPT_ARG_NONE | POPT_ARG_VAL, &seahorse_agent_cshell, TRUE,
+    { "cshell", 'c', 0, G_OPTION_ARG_NONE, &seahorse_agent_cshell,
 	  N_("Print variables in for a C type shell"), NULL },
 
-	{ "variables", 'v', POPT_ARG_NONE | POPT_ARG_VAL, &seahorse_agent_displayvars, TRUE,
+	{ "variables", 'v', 0, G_OPTION_ARG_NONE, &seahorse_agent_displayvars,
 	  N_("Display variables instead of editing gpg.conf"), NULL },
 #endif
-      
-	POPT_AUTOHELP
-	
-	POPT_TABLEEND
+
+	{ NULL }      
 };
 
 static void
@@ -79,7 +77,7 @@
     pid_t pid;
     int i;
 
-    if (g_daemonize) {
+    if (!g_daemonize) {
         switch ((pid = fork ())) {
         case -1:
             err (1, _("couldn't fork process"));
@@ -115,7 +113,7 @@
 #endif
     
     /* The parent, or not daemonized */
-    if (g_daemonize)
+    if (!g_daemonize)
         exit (0);
 }
 
@@ -197,6 +195,7 @@
 {
     SeahorseOperation *op;
     GnomeProgram *program = NULL;
+	GOptionContext *option_context = NULL;
 
     seahorse_secure_memory_init (65536);
     
@@ -214,8 +213,14 @@
 #endif
         err (1, _("couldn't drop privileges properly"));
     
+    seahorse_agent_displayvars = FALSE;
+	seahorse_agent_cshell = FALSE;
+
+    option_context = g_option_context_new(_("- Encryption Daemon (Seahorse)"));
+    g_option_context_add_main_entries(option_context, options, PACKAGE);
+    
     program = gnome_program_init(PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
-                    GNOME_PARAM_POPT_TABLE, options,
+                    GNOME_PARAM_GOPTION_CONTEXT, option_context,
                     GNOME_PARAM_HUMAN_READABLE_NAME, _("Encryption Daemon (Seahorse)"),
                     GNOME_PARAM_APP_DATADIR, DATA_DIR, NULL);
 
Index: plugins/nautilus/seahorse-pgp-preferences.c
===================================================================
RCS file: /cvs/gnome/seahorse/plugins/nautilus/seahorse-pgp-preferences.c,v
retrieving revision 1.20
diff -u -r1.20 seahorse-pgp-preferences.c
--- plugins/nautilus/seahorse-pgp-preferences.c	24 Feb 2006 18:10:54 -0000	1.20
+++ plugins/nautilus/seahorse-pgp-preferences.c	27 Mar 2006 04:14:48 -0000
@@ -20,6 +20,7 @@
  */
 
 #include <gnome.h>
+#include <glib.h>
 #include <config.h>
 #include <locale.h>
 
@@ -38,22 +39,21 @@
 static gboolean show_applet = FALSE;
 #endif
 
-static const struct poptOption options[] = {
+static GOptionEntry options[] = {
 #ifdef WITH_AGENT    
-	{ "cache", 'c', POPT_ARG_NONE | POPT_ARG_VAL, &show_cache, TRUE,
+	{ "cache", 'c', 0, G_OPTION_ARG_NONE, &show_cache,
 	    N_("For internal use"), NULL },
 #endif 
 #ifdef WITH_SHARING   
-	{ "sharing", 's', POPT_ARG_NONE | POPT_ARG_VAL, &show_sharing, TRUE,
+	{ "sharing", 's', 0, G_OPTION_ARG_NONE, &show_sharing,
 	    N_("For internal use"), NULL },
 #endif 
 #ifdef WITH_APPLET   
-	{ "applet", 's', POPT_ARG_NONE | POPT_ARG_VAL, &show_applet, TRUE,
+	{ "applet", 's', 0, G_OPTION_ARG_NONE, &show_applet,
 	    N_("For internal use"), NULL },
 #endif 
         
-	POPT_AUTOHELP
-	POPT_TABLEEND
+	{ NULL }
 };
 
 static void
@@ -67,9 +67,13 @@
 {
 	SeahorseWidget *swidget;
     SeahorseOperation *op;
+    GOptionContext *option_context = NULL;
+    
+    option_context = g_option_context_new(_("- Encryption Preferences"));
+    g_option_context_add_main_entries(option_context, options, PACKAGE);
 
     gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
-                GNOME_PARAM_POPT_TABLE, options,
+                GNOME_PARAM_GOPTION_CONTEXT, option_context,
                 GNOME_PARAM_HUMAN_READABLE_NAME, _("Encryption Preferences"),
                 GNOME_PARAM_APP_DATADIR, DATA_DIR, NULL);
 
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/seahorse/src/main.c,v
retrieving revision 1.39
diff -u -r1.39 main.c
--- src/main.c	24 Feb 2006 18:10:54 -0000	1.39
+++ src/main.c	27 Mar 2006 04:14:48 -0000
@@ -46,40 +46,9 @@
     MODE_VERIFY
 } CmdLineMode;
 
-static gboolean read_uris = FALSE;
-static CmdLineMode mode = MODE_NONE; 
-
-static const struct poptOption options[] = {
-	{ "import", 'i', POPT_ARG_NONE | POPT_ARG_VAL, &mode, MODE_IMPORT,
-	  N_("Import keys from the file"), NULL },
-
-	{ "encrypt", 'e', POPT_ARG_NONE | POPT_ARG_VAL, &mode, MODE_ENCRYPT,
-	  N_("Encrypt file"), NULL },
-
-	{ "sign", 's', POPT_ARG_NONE | POPT_ARG_VAL, &mode, MODE_SIGN,
-	  N_("Sign file with default key"), NULL },
-	
-	{ "encrypt-sign", 'n', POPT_ARG_NONE | POPT_ARG_VAL, &mode, MODE_ENCRYPT_SIGN,
-	  N_("Encrypt and sign file with default key"), NULL },
-	
-	{ "decrypt", 'd', POPT_ARG_NONE | POPT_ARG_VAL, &mode, MODE_DECRYPT,
-	  N_("Decrypt encrypted file"), NULL },
-	
-	{ "verify", 'v', POPT_ARG_NONE | POPT_ARG_VAL, &mode, MODE_VERIFY,
-	  N_("Verify signature file"), NULL },
-      
-    { "uri-list", 'T', POPT_ARG_NONE | POPT_ARG_VAL, &read_uris, TRUE,
-      N_("Read list of URIs on standard in"), NULL },
-	
-	POPT_AUTOHELP
-	
-	POPT_TABLEEND
-};
-
-
 /* Returns a null terminated array of uris, use g_strfreev to free */
 static gchar** 
-read_uri_arguments (GnomeProgram *program)
+read_uri_arguments (GnomeProgram *program, gboolean read_uris, gchar **remaining_args)
 {
     /* Read uris from stdin */
     if (read_uris) {
@@ -113,17 +82,7 @@
         
     /* Multiple arguments on command line */
     } else {
-       
-        poptContext ctx;
-        GValue value = { 0, };
-
-        g_value_init (&value, G_TYPE_POINTER);
-        g_object_get_property (G_OBJECT (program), GNOME_PARAM_POPT_CONTEXT, &value);
-        
-        ctx = g_value_get_pointer (&value);
-        g_value_unset (&value);
-
-        return seahorse_util_strvec_dup (poptGetArgs(ctx));
+    	return seahorse_util_strvec_dup ((const gchar**) remaining_args);
     }
 }
 
@@ -418,6 +377,39 @@
     SeahorseOperation *op = NULL;
     GtkWindow* win;
     int ret = 0;
+    gboolean read_uris = FALSE;
+    CmdLineMode mode = MODE_NONE; 
+    GOptionContext *option_context;
+    gboolean import = FALSE, encrypt = FALSE, sign = FALSE, encrypt_sign = FALSE, decrypt = FALSE, verify = FALSE;
+    gchar **remaining_args = NULL;
+
+    const GOptionEntry options[] = {
+    	{ "import", 'i', 0, G_OPTION_ARG_NONE, &import,
+    	  N_("Import keys from the file"), NULL },
+
+    	{ "encrypt", 'e', 0, G_OPTION_ARG_NONE, &encrypt,
+    	  N_("Encrypt file"), NULL },
+
+    	{ "sign", 's', 0, G_OPTION_ARG_NONE, &sign,
+    	  N_("Sign file with default key"), NULL },
+    	
+    	{ "encrypt-sign", 'n', 0, G_OPTION_ARG_NONE, &encrypt_sign,
+    	  N_("Encrypt and sign file with default key"), NULL },
+    	
+    	{ "decrypt", 'd', 0, G_OPTION_ARG_NONE, &decrypt,
+    	  N_("Decrypt encrypted file"), NULL },
+    	
+    	{ "verify", 'v', 0, G_OPTION_ARG_NONE, &verify,
+    	  N_("Verify signature file"), NULL },
+          
+        { "uri-list", 'T', 0, G_OPTION_ARG_STRING, &read_uris,
+          N_("Read list of URIs on standard in"), NULL },
+    	
+    	{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &remaining_args, 
+    	  N_("Collects remaining arguments")},
+    	
+    	{ NULL }
+    };
 
     seahorse_secure_memory_init (65536);
     
@@ -448,8 +440,11 @@
     gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL));
 #endif
 
+    option_context = g_option_context_new(_("- Encryption Key Manager"));
+    g_option_context_add_main_entries(option_context, options, PACKAGE);
+    
     program = gnome_program_init(PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
-                    GNOME_PARAM_POPT_TABLE, options,
+                    GNOME_PARAM_GOPTION_CONTEXT, option_context,
                     GNOME_PARAM_HUMAN_READABLE_NAME, _("Encryption Key Manager"),
                     GNOME_PARAM_APP_DATADIR, DATA_DIR, NULL);
 
@@ -465,6 +460,21 @@
     seahorse_context_new (TRUE, 0);
     op = seahorse_context_load_local_keys (SCTX_APP());
 
+    if (import|encrypt|sign|encrypt_sign|decrypt|verify){
+        if (import == TRUE)
+            mode = MODE_IMPORT;
+        else if (encrypt == TRUE)
+            mode = MODE_ENCRYPT;
+        else if (sign == TRUE)
+            mode = MODE_SIGN;
+        else if (encrypt_sign == TRUE)
+            mode = MODE_ENCRYPT_SIGN;
+        else if (decrypt == TRUE)
+            mode = MODE_DECRYPT;
+        else if (verify == TRUE)
+            mode = MODE_VERIFY;
+    } 
+
     if (mode != MODE_NONE) {
         gchar **uris = NULL;
         
@@ -472,7 +482,7 @@
         g_object_unref (op);
        
         /* Load up all our arguments */
-        uris = read_uri_arguments(program);
+        uris = read_uri_arguments(program, read_uris, remaining_args);
     
         if(uris && uris[0]) {
             switch (mode) {
