? docs/C/gdm.xml.new
Index: gui/gdmflexiserver.c
===================================================================
RCS file: /cvs/gnome/gdm2/gui/gdmflexiserver.c,v
retrieving revision 1.28
diff -p -u -r1.28 gdmflexiserver.c
--- gui/gdmflexiserver.c	23 Jul 2005 04:17:36 -0000	1.28
+++ gui/gdmflexiserver.c	25 Jul 2005 15:19:39 -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)
 {
@@ -385,12 +443,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] = {"xscreensaver-command", "-lock", NULL};
-				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 ();
 			}
 
 			change_vt (vt);
@@ -699,17 +752,16 @@ main (int argc, char *argv[])
 			g_free (config_file);
 			return 0;
 		} else {
-			dialog = ve_hig_dialog_new
-				(NULL /* parent */,
-				 GTK_DIALOG_MODAL /* flags */,
-				 GTK_MESSAGE_ERROR,
-				 GTK_BUTTONS_OK,
-				 FALSE /* markup */,
-				 _("Cannot communicate with GDM "
-				   "(The GNOME Display Manager)"),
-				 "%s",
-				 _("Perhaps you have an old version "
-				   "of GDM running."));
+			dialog = ve_hig_dialog_new (NULL /* parent */,
+						    GTK_DIALOG_MODAL /* flags */,
+						    GTK_MESSAGE_ERROR,
+						    GTK_BUTTONS_OK,
+						    FALSE /* markup */,
+						    _("Cannot communicate with GDM "
+						      "(The GNOME Display Manager)"),
+						    "%s",
+						    _("Perhaps you have an old version "
+						      "of GDM running."));
 			gtk_widget_show_all (dialog);
 			gtk_dialog_run (GTK_DIALOG (dialog));
 			gtk_widget_destroy (dialog);
@@ -728,18 +780,17 @@ main (int argc, char *argv[])
 	if (use_xnest) {
 		char *cookie = gdmcomm_get_a_cookie (FALSE /* binary */);
 		if (cookie == NULL) {
-			dialog = ve_hig_dialog_new
-				(NULL /* parent */,
-				 GTK_DIALOG_MODAL /* flags */,
-				 GTK_MESSAGE_ERROR,
-				 GTK_BUTTONS_OK,
-				 FALSE /* markup */,
-				 _("You do not seem to have the "
-				   "authentication needed for this "
-				   "operation"),
-				 "%s",
-				 _("Perhaps your .Xauthority "
-				   "file is not set up correctly."));
+			dialog = ve_hig_dialog_new (NULL /* parent */,
+						    GTK_DIALOG_MODAL /* flags */,
+						    GTK_MESSAGE_ERROR,
+						    GTK_BUTTONS_OK,
+						    FALSE /* markup */,
+						    _("You do not seem to have the "
+						      "authentication needed for this "
+						      "operation"),
+						    "%s",
+						    _("Perhaps your .Xauthority "
+						      "file is not set up correctly."));
 
 			gtk_widget_show_all (dialog);
 			gtk_dialog_run (GTK_DIALOG (dialog));
@@ -757,17 +808,16 @@ main (int argc, char *argv[])
 		auth_cookie = NULL;
 	} else {
 		if (auth_cookie == NULL) {
-			dialog = ve_hig_dialog_new
-				(NULL /* parent */,
-				 GTK_DIALOG_MODAL /* flags */,
-				 GTK_MESSAGE_ERROR,
-				 GTK_BUTTONS_OK,
-				 FALSE /* markup */,
-				 _("You do not seem to be logged in on the "
-				   "console"),
-				 "%s",
-				 _("Starting a new login only "
-				   "works correctly on the console."));
+			dialog = ve_hig_dialog_new (NULL /* parent */,
+						    GTK_DIALOG_MODAL /* flags */,
+						    GTK_MESSAGE_ERROR,
+						    GTK_BUTTONS_OK,
+						    FALSE /* markup */,
+						    _("You do not seem to be logged in on the "
+						      "console"),
+						    "%s",
+						    _("Starting a new login only "
+						      "works correctly on the console."));
 			gtk_dialog_set_has_separator (GTK_DIALOG (dialog),
 						      FALSE);
 			gtk_widget_show_all (dialog);
@@ -798,12 +848,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] = {"xscreensaver-command", "-lock", NULL};
-			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 */
@@ -812,14 +857,13 @@ main (int argc, char *argv[])
 
 	message = gdmcomm_get_error_message (ret, use_xnest);
 
-	dialog = ve_hig_dialog_new
-		(NULL /* parent */,
-		 GTK_DIALOG_MODAL /* flags */,
-		 GTK_MESSAGE_ERROR,
-		 GTK_BUTTONS_OK,
-		 FALSE /* markup */,
-		 _("Cannot start new display"),
-		 "%s", message);
+	dialog = ve_hig_dialog_new (NULL /* parent */,
+				    GTK_DIALOG_MODAL /* flags */,
+				    GTK_MESSAGE_ERROR,
+				    GTK_BUTTONS_OK,
+				    FALSE /* markup */,
+				    _("Cannot start new display"),
+				    "%s", message);
 
 	gtk_widget_show_all (dialog);
 	gtk_dialog_run (GTK_DIALOG (dialog));
Index: docs/C/gdm.xml
===================================================================
RCS file: /cvs/gnome/gdm2/docs/C/gdm.xml,v
retrieving revision 1.71
diff -p -u -r1.71 gdm.xml
--- docs/C/gdm.xml	23 Jul 2005 04:25:17 -0000	1.71
+++ docs/C/gdm.xml	25 Jul 2005 15:19:39 -0000
@@ -269,7 +269,8 @@
         <filename>gdmflexiserver -n</filename>.  These servers
         are not restarted when the user session ends.  
         <filename>gdmflexiserver</filename> normally also locks the users
-        screen before running a new server with xscreensaver.
+        screen before running a new server with xscreensaver or
+        gnome-screensaver.
       </para>
 
       <para>
@@ -3368,15 +3369,16 @@ Language=cs_CZ.UTF-8
       </para>
 
       <para>
-        The <filename>gdmflexiserver</filename> command can be used to start
-        new flexible (on demand) servers.  Run
-        <filename>gdmflexiserver --help</filename> to get a listing of possible
-        options.  This command will also lock the current screen with
-        xscreensaver so that the user can safely walk away from the computer and
-        let someone else log in.  XFree86 will automatically switch back to the
-        same virtual terminal (if your operating system supports it), after the
-        new session has ended, so this should work quite transparently to the
-        users.
+        The <filename>gdmflexiserver</filename> command can be used to
+        start new flexible (on demand) servers.  Run
+        <filename>gdmflexiserver --help</filename> to get a listing of
+        possible options.  This command will also lock the current
+        screen with xscreensaver or gnome-screensaver so that the user
+        can safely walk away from the computer and let someone else
+        log in.  XFree86 will automatically switch back to the same
+        virtual terminal (if your operating system supports it), after
+        the new session has ended, so this should work quite
+        transparently to the users.
       </para>
     </sect2>
 
