gnome-session/gnome-session-suspend.patch

112 lines
3.5 KiB
Diff

Index: gnome-session/logout.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/logout.c,v
retrieving revision 1.60
diff -u -p -r1.60 logout.c
--- gnome-session/logout.c 26 Apr 2005 10:56:50 -0000 1.60
+++ gnome-session/logout.c 9 Feb 2006 12:16:45 -0000
@@ -43,14 +43,16 @@ enum
{
OPTION_LOGOUT,
OPTION_HALT,
- OPTION_REBOOT
+ OPTION_REBOOT,
+ OPTION_SUSPEND
};
static GConfEnumStringPair logout_options_lookup_table[] =
{
- { OPTION_LOGOUT, "logout" },
- { OPTION_HALT, "shutdown" },
- { OPTION_REBOOT, "restart" },
+ { OPTION_LOGOUT, "logout" },
+ { OPTION_HALT, "shutdown" },
+ { OPTION_REBOOT, "restart" },
+ { OPTION_SUSPEND, "suspend" },
{ 0, NULL }
};
@@ -329,13 +331,16 @@ display_gui (void)
gint response;
GtkWidget *halt = NULL;
GtkWidget *reboot = NULL;
+ GtkWidget *suspend = NULL;
GtkWidget *invisible;
gboolean halt_supported = FALSE;
gboolean reboot_supported = FALSE;
+ gboolean suspend_supported = FALSE;
gboolean retval = FALSE;
gboolean save_active = FALSE;
gboolean halt_active = FALSE;
gboolean reboot_active = FALSE;
+ gboolean suspend_active = FALSE;
GdmLogoutAction logout_action = GDM_LOGOUT_ACTION_NONE;
gboolean a11y_enabled;
GError *error = NULL;
@@ -431,8 +436,9 @@ display_gui (void)
halt_supported = gdm_supports_logout_action (GDM_LOGOUT_ACTION_SHUTDOWN);
reboot_supported = gdm_supports_logout_action (GDM_LOGOUT_ACTION_REBOOT);
+ suspend_supported = gdm_supports_logout_action (GDM_LOGOUT_ACTION_SUSPEND);
- if (halt_supported || reboot_supported)
+ if (halt_supported || reboot_supported || suspend_supported)
{
GtkWidget *title, *spacer;
GtkWidget *action_vbox, *hbox;
@@ -482,6 +488,13 @@ display_gui (void)
gtk_box_pack_start (GTK_BOX (action_vbox), r, FALSE, FALSE, 0);
gtk_widget_show (r);
}
+ if (suspend_supported)
+ {
+ r = suspend = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (r), _("_Suspend the computer"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (r), (selected_option == OPTION_SUSPEND));
+ gtk_box_pack_start (GTK_BOX (action_vbox), r, FALSE, FALSE, 0);
+ gtk_widget_show (r);
+ }
}
gsm_center_window_on_screen (GTK_WINDOW (box), screen, monitor);
@@ -517,6 +530,9 @@ display_gui (void)
if (reboot)
reboot_active = GTK_TOGGLE_BUTTON (reboot)->active;
+ if (suspend)
+ suspend_active = GTK_TOGGLE_BUTTON (suspend)->active;
+
if (toggle_button)
save_active = GTK_TOGGLE_BUTTON (toggle_button)->active;
@@ -524,6 +540,8 @@ display_gui (void)
selected_option = OPTION_REBOOT;
else if (halt_active)
selected_option = OPTION_HALT;
+ else if (suspend_active)
+ selected_option = OPTION_SUSPEND;
else
selected_option = OPTION_LOGOUT;
@@ -545,14 +563,20 @@ display_gui (void)
case GTK_RESPONSE_OK:
/* We want to know if we should trash changes (and lose forever)
* or save them */
+ retval = TRUE;
if(save_active)
save_selected = save_active;
if (halt_active)
logout_action = GDM_LOGOUT_ACTION_SHUTDOWN;
else if (reboot_active)
logout_action = GDM_LOGOUT_ACTION_REBOOT;
+ else if (suspend_active)
+ {
+ logout_action = GDM_LOGOUT_ACTION_SUSPEND;
+ g_spawn_command_line_async ("powersave --suspend-to-disk", NULL);
+ retval = FALSE;
+ }
set_default_option (selected_option);
- retval = TRUE;
break;
default:
case GTK_RESPONSE_CANCEL: