Index: gnome-panel/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/ChangeLog,v
retrieving revision 1.2630
diff -p -u -r1.2630 ChangeLog
--- gnome-panel/ChangeLog	4 May 2005 14:52:22 -0000	1.2630
+++ gnome-panel/ChangeLog	4 May 2005 19:04:30 -0000
@@ -1,3 +1,20 @@
+2005-05-04  William Jon McCann  <mccann@jhu.edu>
+
+	* panel-util.[ch] (panel_lock_screen_action_get_command)
+	(panel_lock_screen_action_enabled, panel_lock_screen_action) 
+	(panel_lock_screen): Consolidate all the screensaver handling into
+	these functions.  Add gnome-screensaver support.  Check if command
+	is in the path.
+
+	* panel-menu-items.c (panel_menu_items_append_lock_logout): Don't
+	check for screensaver command in the path.  Let is_disabled handle
+	that.
+
+	* panel-action-button.c (screensaver_properties_enabled)
+	(screensaver_enabled, panel_action_lock_is_disabled): Only enable
+	actions if the command exists.
+	(panel_action_lock_invoke_menu): Move functionality to utils.
+
 2005-05-04  Mark McLoughlin  <mark@skynet.ie>
 
 	Fix crasher with recent items menu - bug #170660
Index: gnome-panel/panel-action-button.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-action-button.c,v
retrieving revision 1.41
diff -p -u -r1.41 panel-action-button.c
--- gnome-panel/panel-action-button.c	29 Jan 2005 20:39:01 -0000	1.41
+++ gnome-panel/panel-action-button.c	4 May 2005 19:04:30 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * panel-action-button.c: panel "Action Button" module
  *
  * Copyright (C) 2002 Sun Microsystems, Inc.
@@ -90,13 +91,22 @@ screensaver_properties_enabled (void)
 	    panel_lockdown_get_disable_lock_screen ())
 		return FALSE;
 
-	return TRUE;
+	return panel_lock_screen_action_enabled ("prefs");
 }
 
 static gboolean
 screensaver_enabled (void)
 {
-  return !panel_lockdown_get_disable_lock_screen ();
+	if (panel_lockdown_get_disable_lock_screen ())
+		return FALSE;
+
+	return panel_lock_screen_action_enabled ("lock");
+}
+
+static gboolean
+panel_action_lock_is_disabled (void)
+{
+	return !screensaver_enabled ();
 }
 
 static void
@@ -137,24 +147,11 @@ static void
 panel_action_lock_invoke_menu (PanelActionButton *button,
 			       const char *callback_name)
 {
-	char *command = NULL;
-
-	if (!strcmp (callback_name, "prefs"))
-		command = g_strdup ("xscreensaver-demo");
-
-	else if (!strcmp (callback_name, "activate") ||
-		 !strcmp (callback_name, "lock") ||
-		 !strcmp (callback_name, "exit") ||
-		 !strcmp (callback_name, "restart"))
-		command = g_strdup_printf ("xscreensaver-command -%s", callback_name);
-
-	if (command)
-		gdk_spawn_command_line_on_screen (
-			gtk_widget_get_screen (GTK_WIDGET (button)),
-			command,
-			NULL);
+	g_return_if_fail (PANEL_IS_ACTION_BUTTON (button));
+	g_return_if_fail (callback_name != NULL);
 
-	g_free (command);
+	panel_lock_screen_action (gtk_widget_get_screen (GTK_WIDGET (button)),
+				  callback_name);
 }
 
 /* Log Out
@@ -317,7 +314,7 @@ static PanelAction actions [] = {
 		panel_action_lock_screen,
 		panel_action_lock_setup_menu,
 		panel_action_lock_invoke_menu,
-		panel_lockdown_get_disable_lock_screen
+		panel_action_lock_is_disabled
 	},
 	{
 		PANEL_ACTION_LOGOUT,
Index: gnome-panel/panel-menu-items.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-menu-items.c,v
retrieving revision 1.5
diff -p -u -r1.5 panel-menu-items.c
--- gnome-panel/panel-menu-items.c	2 May 2005 14:53:34 -0000	1.5
+++ gnome-panel/panel-menu-items.c	4 May 2005 19:04:30 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * Copyright (C) 2005 Vincent Untz
  *
  * This program is free software; you can redistribute it and/or
@@ -962,16 +963,14 @@ panel_menu_items_append_lock_logout (Gtk
 		separator_inserted = GTK_IS_SEPARATOR (GTK_WIDGET (children->data));
 	}
 
-	if (panel_is_program_in_path ("xscreensaver")) {
-		item = panel_menu_items_create_action_item (PANEL_ACTION_LOCK);
-		if (item != NULL) {
-			if (!separator_inserted) {
-				add_menu_separator (menu);
-				separator_inserted = TRUE;
-			}
-
-			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	item = panel_menu_items_create_action_item (PANEL_ACTION_LOCK);
+	if (item != NULL) {
+		if (!separator_inserted) {
+			add_menu_separator (menu);
+			separator_inserted = TRUE;
 		}
+
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 
 	item = panel_menu_items_create_action_item (PANEL_ACTION_LOGOUT);
Index: gnome-panel/panel-util.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-util.c,v
retrieving revision 1.156
diff -p -u -r1.156 panel-util.c
--- gnome-panel/panel-util.c	27 Mar 2005 16:27:15 -0000	1.156
+++ gnome-panel/panel-util.c	4 May 2005 19:04:30 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * GNOME panel utils
  * (C) 1997, 1998, 1999, 2000 The Free Software Foundation
  * Copyright 2000 Helix Code, Inc.
@@ -649,27 +650,87 @@ missing_pixbuf (int size)
 	return pb;
 }
 
-void
-panel_lock_screen (GdkScreen *screen)
+static char *
+panel_lock_screen_action_get_command (const char *action)
 {
-#define XSCREENSAVER_LOCK_COMMAND "xscreensaver-command -lock"
+	char    *command          = NULL;
+	gboolean use_gscreensaver = FALSE;
 
-	GError *error = NULL;
+	if (panel_is_program_in_path ("gnome-screensaver-command"))
+		use_gscreensaver = TRUE;
+	else if (!panel_is_program_in_path ("xscreensaver-command"))
+		return NULL;
+
+	if (strcmp (action, "prefs") == 0) {
+		if (use_gscreensaver) {
+			command = g_strdup ("gnome-screensaver-preferences");
+		} else {
+			command = g_strdup ("xscreensaver-demo");
+		}
+	} else if (strcmp (action, "activate") == 0
+		   || strcmp (action, "lock") == 0
+		   || strcmp (action, "exit") == 0
+		   || strcmp (action, "restart") == 0) {
+		if (use_gscreensaver) {
+			command = g_strdup_printf ("gnome-screensaver-command --%s", action);
+		} else {
+			command = g_strdup_printf ("xscreensaver-command -%s", action);
+		}
+	}
+
+	return command;
+}
+
+gboolean
+panel_lock_screen_action_enabled (const char *action)
+{
+	char    *command;
+	gboolean enabled = FALSE;
+
+	g_return_val_if_fail (action != NULL, FALSE);
+
+	command = panel_lock_screen_action_get_command (action);
+	if (command)
+		enabled = TRUE;
+
+	g_free (command);
+
+	return enabled;
+}
+
+void
+panel_lock_screen_action (GdkScreen  *screen,
+			  const char *action)
+{
+	GError  *error            = NULL;
+	char    *command          = NULL;
 
 	g_return_if_fail (GDK_IS_SCREEN (screen));
+	g_return_if_fail (action != NULL);
+
+	command = panel_lock_screen_action_get_command (action);
 
-	if (!gdk_spawn_command_line_on_screen (screen, XSCREENSAVER_LOCK_COMMAND, &error)) {
+	if (!command)
+		return;
+
+	if (!gdk_spawn_command_line_on_screen (screen, command, &error)) {
 		panel_error_dialog (screen,
-				    "cannot_exec_xscreensaver",
+				    "cannot_exec_screensaver",
 				    TRUE,
 				    _("Cannot execute '%s'"),
 				    "%s",
-				    XSCREENSAVER_LOCK_COMMAND,
+				    command,
 				    error->message);
 		g_error_free (error);
 	}
-	
-#undef XSCREENSAVER_LOCK_COMMAND
+
+	g_free (command);
+}
+
+void
+panel_lock_screen (GdkScreen *screen)
+{
+	panel_lock_screen_action (screen, "lock");
 }
 
 
Index: gnome-panel/panel-util.h
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-util.h,v
retrieving revision 1.86
diff -p -u -r1.86 panel-util.h
--- gnome-panel/panel-util.h	27 Mar 2005 16:27:15 -0000	1.86
+++ gnome-panel/panel-util.h	4 May 2005 19:04:30 -0000
@@ -58,7 +58,10 @@ gboolean	panel_is_program_in_path (const
 gboolean	panel_is_uri_writable	(const char *uri);
 gboolean	panel_uri_exists	(const char *uri);
 
-void            panel_lock_screen       (GdkScreen *screen);
+void            panel_lock_screen                (GdkScreen    *screen);
+void            panel_lock_screen_action         (GdkScreen    *screen,
+                                                  const char   *action);
+gboolean        panel_lock_screen_action_enabled (const char   *action);
 
 char *          panel_find_icon         (GtkIconTheme  *icon_theme,
 					 const char    *icon_name,
