Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gdm2/ChangeLog,v
retrieving revision 1.1221
diff -p -u -r1.1221 ChangeLog
--- ChangeLog	27 Sep 2005 06:44:24 -0000	1.1221
+++ ChangeLog	27 Sep 2005 19:19:07 -0000
@@ -1,3 +1,10 @@
+2005-09-27  William Jon McCann  <mccann@jhu.edu>
+
+	* gui/gdmflexiserver.c (is_program_in_path, maybe_lock_screen) 
+	(run_logged_in_dialogue, main): Consolidate screensaver
+	activation code.  Don't use deprecated gnome-exec.
+	Fixes #311497.
+	
 2005-09-27  Brian Cameron <Brian.Cameron@sun.com>
 
         * gui/greeter/greeter_item_ulist.c: Now print syslog
Index: gui/gdmflexiserver.c
===================================================================
RCS file: /cvs/gnome/gdm2/gui/gdmflexiserver.c,v
retrieving revision 1.34
diff -p -u -r1.34 gdmflexiserver.c
--- gui/gdmflexiserver.c	27 Sep 2005 02:28:24 -0000	1.34
+++ gui/gdmflexiserver.c	27 Sep 2005 19:19:07 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  *    GDMflexiserver - run a flexible server
  *    (c)2001 Queen of England
  *    
@@ -19,9 +20,6 @@
  */
 
 #include "config.h"
-#include <libgnome/libgnome.h>
-#include <libgnomeui/libgnomeui.h>
-#include <gdk/gdkx.h>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -35,6 +33,12 @@
 #include <errno.h>
 #include <pwd.h>
 
+#include <glib/gi18n.h>
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+#include <libgnome/libgnome.h> /* for gnome_config */
+#include <libgnomeui/libgnomeui.h> /* for gnome_program */
+
 #include <viciousui.h>
 
 #include "gdm.h"
@@ -295,6 +299,60 @@ row_activated (GtkTreeView *view, GtkTre
 	gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_OPEN_EXISTING_DISPLAY);
 }
 
+static gboolean
+is_program_in_path (const char *program)
+{
+	char *tmp = g_find_program_in_path (program);
+	if (tmp != NULL) {
+		g_free (tmp);
+		return TRUE;
+	} else {
+		return FALSE;
+	}
+}
+
+static void
+maybe_lock_screen (void)
+{
+	gboolean   use_gscreensaver = FALSE;
+	GError    *error            = NULL;
+	char      *command;
+	GdkScreen *screen;
+
+	if (is_program_in_path ("gnome-screensaver-command"))
+		use_gscreensaver = TRUE;
+	else if (! is_program_in_path ("xscreensaver-command"))
+		return;
+
+	if (use_gscreensaver) {
+		command = g_strdup ("gnome-screensaver-command --lock");
+	} else {
+		command = g_strdup ("xscreensaver-command -lock");
+	}
+
+	screen = gdk_screen_get_default ();
+
+	if (! gdk_spawn_command_line_on_screen (screen, command, &error)) {
+		g_warning ("Cannot lock screen: %s", error->message);
+		g_error_free (error);
+	}
+
+	g_free (command);
+
+	if (use_gscreensaver) {
+		command = g_strdup ("gnome-screensaver-command --throttle");
+	} else {
+		command = g_strdup ("xscreensaver-command -throttle");
+	}
+
+	if (! gdk_spawn_command_line_on_screen (screen, command, &error)) {
+		g_warning ("Cannot disable screensaver engines: %s", error->message);
+		g_error_free (error);
+	}
+
+	g_free (command);
+}
+
 static void
 run_logged_in_dialogue (char **vec)
 {
@@ -393,30 +451,7 @@ run_again:
 			/* we switched to a different screen as a result of this,
 			 * lock the current screen */
 			if ( ! no_lock && vt != get_cur_vt () && vt >= 0) {
-				char *argv[3], *path, *throttle_arg;
-
-				if ((path = g_find_program_in_path ("gnome-screensaver-command"))) {
-					argv[0] = "gnome-screensaver-command";
-					argv[1] = "--lock";
-					argv[2] = NULL;
-					throttle_arg = "--throttle";
-					g_free (path);
-				} else {
-					argv[0] = "xscreensaver-command";
-					argv[1] = "-lock";
-					argv[2] = NULL;
-					throttle_arg = "-throttle";
-				}
-
-				if (gnome_execute_async (g_get_home_dir (),
-				    2, argv) < 0)
-					g_warning (_("Can't lock screen"));
-
-				argv[1] = throttle_arg;
-
-				if (gnome_execute_async (g_get_home_dir (),
-				    2, argv) < 0)
-					g_warning (_("Can't disable xscreensaver display hacks"));
+				maybe_lock_screen ();
 			}
 
 			change_vt (vt);
@@ -819,26 +854,7 @@ main (int argc, char *argv[])
 		/* if we switched to a different screen as a result of this,
 		 * lock the current screen */
 		if ( ! no_lock && ! use_xnest) {
-			char *argv[3], *path, *throttle_arg;
-
-			if ((path = g_find_program_in_path ("gnome-screensaver-command"))) {
-				argv[0] = "gnome-screensaver-command";
-				argv[1] = "--lock";
-				argv[2] = NULL;
-				throttle_arg = "--throttle";
-				g_free (path);
-			} else {
-				argv[0] = "xscreensaver-command";
-				argv[1] = "-lock";
-				argv[2] = NULL;
-				throttle_arg = "-throttle";
-			}
-
-			if (gnome_execute_async (g_get_home_dir (), 2, argv) < 0)
-				g_warning (_("Can't lock screen"));
-			argv[1] = "-throttle";
-			if (gnome_execute_async (g_get_home_dir (), 2, argv) < 0)
-				g_warning (_("Can't disable xscreensaver display hacks"));
+			maybe_lock_screen ();
 		}
 
 		/* all fine and dandy */
