Bugzilla #507391

Index: gnome-panel-2.20.3/gnome-panel/gnome-panel-logout.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gnome-panel-2.20.3/gnome-panel/gnome-panel-logout.c	2008-02-16 17:47:32.099271109 +0100
@@ -0,0 +1,49 @@
+/* GNOME panel : logout/shutdown request standalone binary
+ *
+ * (C) 2007 Josselin Mouette
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <libgnomeui/libgnomeui.h>
+
+#include "panel-logout.h"
+
+static gboolean shutdown_requested;
+
+static const GOptionEntry options[] = {
+  { "shutdown", 0, 0, G_OPTION_ARG_NONE, &shutdown_requested, "Request a shutdown or reboot", NULL },
+  { NULL }
+};
+
+int
+main (int argc, char **argv)
+{
+	GOptionContext *context;
+	GnomeProgram   *program;
+
+	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	context = g_option_context_new ("");
+
+	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+
+	program = gnome_program_init ("gnome-panel-logout", VERSION,
+				      LIBGNOMEUI_MODULE,
+				      argc, argv,
+				      GNOME_PARAM_GOPTION_CONTEXT, context,
+				      GNOME_PROGRAM_STANDARD_PROPERTIES,
+				      NULL);
+	gnome_client_set_restart_style (gnome_master_client (), GNOME_RESTART_NEVER);
+
+	panel_logout_new (shutdown_requested?PANEL_LOGOUT_DIALOG_SHUTDOWN:PANEL_LOGOUT_DIALOG_LOGOUT,
+			  NULL,
+			  GDK_CURRENT_TIME);
+
+	gtk_main ();
+	g_object_unref (program);
+	return 0;
+}
Index: gnome-panel-2.20.3/gnome-panel/panel-session.c
===================================================================
--- gnome-panel-2.20.3.orig/gnome-panel/panel-session.c	2008-01-07 23:26:25.000000000 +0100
+++ gnome-panel-2.20.3/gnome-panel/panel-session.c	2008-02-16 17:47:32.099271109 +0100
@@ -29,8 +29,10 @@
 
 #include <stdlib.h>
 
+#ifndef BUILDING_STANDALONE_LOGOUT
 #include "panel-profile.h"
 #include "panel-shell.h"
+#endif // BUILDING_STANDALONE_LOGOUT
 
 void
 panel_session_request_logout (void)
@@ -60,6 +62,7 @@ panel_session_request_logout (void)
 	recursion_guard--;
 }
 
+#ifndef BUILDING_STANDALONE_LOGOUT
 static void
 panel_session_handle_die_request (GnomeClient *client)
 {
@@ -107,3 +110,4 @@ panel_session_init (void)
 	g_signal_connect (client, "die",
 			  G_CALLBACK (panel_session_handle_die_request), NULL);
 }
+#endif // BUILDING_STANDALONE_LOGOUT
Index: gnome-panel-2.20.3/gnome-panel/panel-util.c
===================================================================
--- gnome-panel-2.20.3.orig/gnome-panel/panel-util.c	2008-01-07 23:26:25.000000000 +0100
+++ gnome-panel-2.20.3/gnome-panel/panel-util.c	2008-02-16 17:47:32.099271109 +0100
@@ -31,6 +31,7 @@
 #include <libgnomevfs/gnome-vfs-uri.h>
 #include <libgnomevfs/gnome-vfs-ops.h>
 
+#ifndef BUILDING_STANDALONE_LOGOUT
 #include "applet.h"
 #include "nothing.h"
 #include "xstuff.h"
@@ -468,6 +469,7 @@ panel_pop_window_busy (GtkWidget *window
 				   GINT_TO_POINTER (busy));
 	}
 }
+#endif // BUILDING_STANDALONE_LOGOUT
 
 gboolean
 panel_is_program_in_path (const char *program)
@@ -481,6 +483,7 @@ panel_is_program_in_path (const char *pr
 	}
 }
 
+#ifndef BUILDING_STANDALONE_LOGOUT
 static gboolean
 panel_ensure_dir (const char *dirname)
 {
@@ -732,6 +735,7 @@ panel_load_icon (GtkIconTheme  *icon_the
 
 	return retval;
 }
+#endif // BUILDING_STANDALONE_LOGOUT
 
 static char *
 panel_lock_screen_action_get_command (const char *action)
@@ -804,6 +808,7 @@ panel_lock_screen_action (GdkScreen  *sc
 		return;
 
 	if (!gdk_spawn_command_line_on_screen (screen, command, &error)) {
+#ifndef BUILDING_STANDALONE_LOGOUT
 		char *primary;
 
 		primary = g_strdup_printf (_("Could not execute '%s'"),
@@ -812,6 +817,7 @@ panel_lock_screen_action (GdkScreen  *sc
 				    "cannot_exec_screensaver", TRUE,
 				    primary, error->message);
 		g_free (primary);
+#endif // BUILDING_STANDALONE_LOGOUT
 		g_error_free (error);
 	}
 
@@ -825,6 +831,7 @@ panel_lock_screen (GdkScreen *screen)
 }
 
 
+#ifndef BUILDING_STANDALONE_LOGOUT
 char *
 panel_make_full_path (const char *dir,
 		      const char *filename)
@@ -1579,3 +1586,4 @@ panel_util_set_tooltip_text (GtkWidget  
 			       G_CALLBACK (panel_util_query_tooltip_cb),
 			       g_strdup (text), (GClosureNotify) g_free, 0);
 }
+#endif // BUILDING_STANDALONE_LOGOUT
Index: gnome-panel-2.20.3/configure.in
===================================================================
--- gnome-panel-2.20.3.orig/configure.in	2008-01-07 23:33:56.000000000 +0100
+++ gnome-panel-2.20.3/configure.in	2008-02-16 17:47:32.099271109 +0100
@@ -72,6 +72,10 @@ PKG_CHECK_MODULES(PANEL, ORBit-2.0 >= $O
 AC_SUBST(PANEL_CFLAGS)
 AC_SUBST(PANEL_LIBS)
 
+PKG_CHECK_MODULES(LOGOUT, gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED)
+AC_SUBST(LOGOUT_CFLAGS)
+AC_SUBST(LOGOUT_LIBS)
+
 PKG_CHECK_MODULES(LIBPANEL_APPLET, ORBit-2.0 >= $ORBIT_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED)
 AC_SUBST(LIBPANEL_APPLET_CFLAGS)
 AC_SUBST(LIBPANEL_APPLET_LIBS)
Index: gnome-panel-2.20.3/gnome-panel/Makefile.am
===================================================================
--- gnome-panel-2.20.3.orig/gnome-panel/Makefile.am	2008-01-07 23:26:25.000000000 +0100
+++ gnome-panel-2.20.3/gnome-panel/Makefile.am	2008-02-16 17:47:32.099271109 +0100
@@ -29,6 +29,7 @@ STANDARD_PROPERTIES_CFLAGS = 					\
 
 bin_PROGRAMS = \
 	gnome-panel 			\
+	gnome-panel-logout		\
 	gnome-desktop-item-edit
 
 $(gnome_panel_OBJECTS): $(BUILT_SOURCES)
@@ -163,6 +164,22 @@ gnome_panel_LDADD =		\
 
 gnome_panel_LDFLAGS = -export-dynamic
 
+gnome_panel_logout_SOURCES =  \
+	gnome-panel-logout.c  \
+	panel-logout.c        \
+	panel-gdm.c	      \
+	panel-power-manager.c \
+	panel-session.c       \
+	panel-util.c
+
+gnome_panel_logout_CFLAGS = -DBUILDING_STANDALONE_LOGOUT
+
+gnome_panel_logout_LDADD = \
+	$(LOGOUT_LIBS)	   \
+	$(X_LIBS)
+
+gnome_panel_logout_LDFLAGS = -export-dynamic
+
 gnome_desktop_item_edit_SOURCES = \
 	gnome-desktop-item-edit.c \
 	panel-ditem-editor.c	  \
Index: gnome-panel-2.20.3/gnome-panel/panel-logout.c
===================================================================
--- gnome-panel-2.20.3.orig/gnome-panel/panel-logout.c	2008-02-16 17:47:30.959270722 +0100
+++ gnome-panel-2.20.3/gnome-panel/panel-logout.c	2008-02-16 17:50:26.587269360 +0100
@@ -177,8 +177,6 @@ panel_logout_response (PanelLogoutDialog
 	gtk_widget_destroy (GTK_WIDGET (logout_dialog));
 
 	switch (response_id) {
-	case GTK_RESPONSE_CANCEL:
-		break;
 	case PANEL_LOGOUT_RESPONSE_LOGOUT:
 		gdm_set_logout_action (GDM_LOGOUT_ACTION_NONE);
 		panel_session_request_logout ();
@@ -203,6 +201,7 @@ panel_logout_response (PanelLogoutDialog
 		if (panel_power_manager_can_suspend (power_manager))
 			panel_power_manager_attempt_suspend (power_manager);
 		break;
+	case GTK_RESPONSE_CANCEL:
 	case GTK_RESPONSE_NONE:
 	case GTK_RESPONSE_DELETE_EVENT:
 		break;
@@ -211,6 +210,9 @@ panel_logout_response (PanelLogoutDialog
 	}
 	g_object_unref (power_manager);
 	g_object_unref (screen);
+#ifdef BUILDING_STANDALONE_LOGOUT
+	gtk_main_quit ();
+#endif
 }
 
 static gboolean
@@ -307,8 +309,10 @@ panel_logout_new (PanelLogoutDialogType 
 
 	if (current_dialog != NULL) {
 		if (current_dialog->priv->type == type) {
-			gtk_window_set_screen (GTK_WINDOW (current_dialog),
-					       screen);
+			if (screen) {
+				gtk_window_set_screen (GTK_WINDOW (current_dialog),
+						       screen);
+			}
 			gtk_window_present_with_time (GTK_WINDOW (current_dialog),
 						      activate_time);
 			panel_logout_set_timeout (current_dialog);
@@ -391,6 +395,8 @@ panel_logout_new (PanelLogoutDialogType 
 
 	panel_logout_set_timeout (logout_dialog);
 
-	gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);
+	if (screen) {
+		gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);
+	}
 	gtk_widget_show (GTK_WIDGET (logout_dialog));
 }
