gok r2594 - in trunk: . gok



Author: bcameron
Date: Thu Oct 23 06:24:54 2008
New Revision: 2594
URL: http://svn.gnome.org/viewvc/gok?rev=2594&view=rev

Log:
2008-10-22  Brian Cameron  <brian cameron sun com>

        * gok/main.c:  Fix restart logic so that common arguments passed in
          are retained when gok restarts itself on crash.  Also improve the
          logic used to ensure GOK works when the user has a non-writable
          $HOME directory.  Fixes bugs #553676 and #553672.


Modified:
   trunk/ChangeLog
   trunk/gok/main.c

Modified: trunk/gok/main.c
==============================================================================
--- trunk/gok/main.c	(original)
+++ trunk/gok/main.c	Thu Oct 23 06:24:54 2008
@@ -31,6 +31,7 @@
 #include <dirent.h>
 #include <signal.h>
 #include <gnome.h>
+#include <glib/gstdio.h>
 #include <cspi/spi.h>
 #include <libbonobo.h>
 #include <bonobo-activation/bonobo-activation.h>
@@ -363,9 +364,36 @@
 #if ! defined ENABLE_LOGGING_NORMAL
 		if (respawn_on_segv)
 		{
+		    GString *command = g_string_new ("gok");
+
+		    /*
+		     * Add arguments to start GOK in same state.
+		     * Perhaps other arguments should also be
+		     * supported, but this is a good start.
+		     */
+		    if (gok_args.is_login) {
+			g_string_append (command, " --login");
+		    }
+		    if (gok_args.accessmethodname) {
+			g_string_append_printf (command,
+				" --access-method=%s",
+				gok_args.accessmethodname);
+		    }
+		    if (gok_args.scanactionname) {
+			g_string_append_printf (command,
+				" --scan-action=%s",
+				gok_args.scanactionname);
+		    }
+		    if (gok_args.selectactionname) {
+			g_string_append_printf (command,
+				" --select-action=%s",
+				gok_args.selectactionname);
+		    }
+
 		    fprintf (stderr, "Restarting GOK.\n");
-		    g_on_error_stack_trace("gok");
-		    g_spawn_command_line_async ("gok", NULL);
+		    g_on_error_stack_trace ("gok");
+		    g_spawn_command_line_async (command->str, NULL);
+		    g_string_free (command, TRUE);
 		}
 #endif
 		break;
@@ -577,7 +605,7 @@
 {
 	GnomeProgram *gok_program;
 	GOptionContext *context;
-	gboolean create_dirs = TRUE;
+	gboolean create_dirs;
 	int i;
 
 	/* initialize member data */
@@ -593,17 +621,9 @@
 	context	= g_option_context_new (_("The GNOME On-screen Keyboard"));
 	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
 
-	/*
-	 * Preprocess the arguments to see if --login was included.  Need to
-	 * do this before calling gnome_program_init (which normally processes
-	 * the arguments) since this affects how we call gnome_program_init.
-	 */
-	for (i = 0; i < argc; i++) {
-		if (strcmp (argv[i], "--login") == 0) {
-			create_dirs = FALSE;
-			break;
-		}
-	}
+	/* If the user does not have a writable HOME directory, then
+	   avoid creating the directory. */
+	create_dirs = (g_access (g_get_home_dir(), W_OK) == 0);
 
 	/* Initialize Gnome */
 	gok_program = gnome_program_init (PACKAGE, VERSION,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]