Index: gnome-session/gsm-manager.c =================================================================== --- gnome-session/gsm-manager.c (révision 5027) +++ gnome-session/gsm-manager.c (copie de travail) @@ -2178,7 +2178,8 @@ logout_dialog_response (GsmLogoutDialog { g_debug ("GsmManager: Logout dialog response: %d", response_id); - gtk_widget_destroy (GTK_WIDGET (logout_dialog)); + if (response_id != GTK_RESPONSE_HELP) + gtk_widget_destroy (GTK_WIDGET (logout_dialog)); /* In case of dialog cancel, switch user, hibernate and * suspend, we just perform the respective action and return, @@ -2188,6 +2189,10 @@ logout_dialog_response (GsmLogoutDialog case GTK_RESPONSE_NONE: case GTK_RESPONSE_DELETE_EVENT: break; + case GTK_RESPONSE_HELP: + gsm_util_help_display (GTK_WINDOW (logout_dialog), + "gosgetstarted-73"); + break; case GSM_LOGOUT_RESPONSE_SWITCH_USER: request_switch_user (manager); break; Index: gnome-session/gsm-util.c =================================================================== --- gnome-session/gsm-util.c (révision 5027) +++ gnome-session/gsm-util.c (copie de travail) @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -288,3 +289,75 @@ gsm_util_setenv (const char *variable, g_error_free (bus_error); } } + +void +gsm_util_help_display (GtkWindow *parent, + const char *link_id) +{ + GError *error = NULL; + char *command; + const char *lang; + char *uri = NULL; + GdkScreen *gscreen; + gboolean found; + + int i; + + const char * const * langs = g_get_language_names (); + + uri = NULL; + found = FALSE; + + for (i = 0; langs[i]; i++) { + lang = langs[i]; + if (strchr (lang, '.')) { + continue; + } + + uri = g_build_filename (DATADIR, + "/gnome/help/user-guide/", + lang, + "/user-guide.xml", + NULL); + + if (g_file_test (uri, G_FILE_TEST_EXISTS)) { + found = TRUE; + break; + } + } + + if (found) { + if (link_id) { + command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL); + } else { + command = g_strconcat ("gnome-open ghelp://", uri, NULL); + } + + gscreen = gdk_screen_get_default (); + gdk_spawn_command_line_on_screen (gscreen, command, &error); + } else + command = NULL; + + if (!found || error != NULL) { + GtkWidget *d; + const char *errmsg; + + if (!found) + errmsg = _("Cannot find help."); + else { + errmsg = error->message; + g_error_free (error); + } + + d = gtk_message_dialog_new (parent, + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + "%s", errmsg); + gtk_widget_show (GTK_WIDGET (d)); + g_signal_connect (d, "response", + G_CALLBACK (gtk_widget_destroy), NULL); + } + + g_free (command); + g_free (uri); +} Index: gnome-session/gsm-util.h =================================================================== --- gnome-session/gsm-util.h (révision 5027) +++ gnome-session/gsm-util.h (copie de travail) @@ -21,6 +21,7 @@ #define __GSM_UTIL_H__ #include +#include G_BEGIN_DECLS @@ -37,6 +38,9 @@ char * gsm_util_generate_startup_id void gsm_util_setenv (const char *variable, const char *value); +void gsm_util_help_display (GtkWindow *parent, + const char * link_id); + G_END_DECLS #endif /* __GSM_UTIL_H__ */ Index: gnome-session/test-logout.c =================================================================== --- gnome-session/test-logout.c (révision 0) +++ gnome-session/test-logout.c (révision 0) @@ -0,0 +1,117 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2008 Novell, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +#include "config.h" + +#include + +#include + +#include "gsm-logout-dialog.h" + +static void +logout_dialog_response (GsmLogoutDialog *logout_dialog, + guint response_id, + gpointer data) +{ + /* In case of dialog cancel, switch user, hibernate and + * suspend, we just perform the respective action and return, + * without shutting down the session. */ + switch (response_id) { + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + case GTK_RESPONSE_DELETE_EVENT: + g_print ("Cancel\n"); + break; + case GTK_RESPONSE_HELP: + g_print ("Help\n"); + break; + case GSM_LOGOUT_RESPONSE_SWITCH_USER: + g_print ("Switch user\n"); + break; + case GSM_LOGOUT_RESPONSE_HIBERNATE: + g_print ("Hibernate\n"); + break; + case GSM_LOGOUT_RESPONSE_SLEEP: + g_print ("Suspend\n"); + break; + case GSM_LOGOUT_RESPONSE_SHUTDOWN: + g_print ("Shutdown\n"); + break; + case GSM_LOGOUT_RESPONSE_REBOOT: + g_print ("Reboot\n"); + break; + case GSM_LOGOUT_RESPONSE_LOGOUT: + g_print ("Logout\n"); + break; + default: + g_assert_not_reached (); + break; + } + + gtk_main_quit (); +} + + +int +main (int argc, + char *argv[]) +{ + GtkWidget *dialog; + GError *error; + + static gboolean logout; + static gboolean shutdown; + + static GOptionEntry entries[] = { + { "logout", 'l', 0, G_OPTION_ARG_NONE, &logout, "Test logout dialog", NULL }, + { "shutdown", 's', 0, G_OPTION_ARG_NONE, &shutdown, "Test shutdown dialog", NULL }, + { NULL, 0, 0, 0, NULL, NULL, NULL } + }; + + logout = shutdown = FALSE; + error = NULL; + + gtk_init_with_args (&argc, &argv, + (char *) " - test logout/shutdown dialogs", + entries, NULL, + &error); + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + exit (1); + } + + if (!shutdown) + dialog = gsm_get_logout_dialog (gdk_screen_get_default (), + GDK_CURRENT_TIME); + else + dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (), + GDK_CURRENT_TIME); + + g_signal_connect (dialog, "response", + G_CALLBACK (logout_dialog_response), NULL); + gtk_widget_show (dialog); + + gtk_main (); + + return 0; +} Index: gnome-session/Makefile.am =================================================================== --- gnome-session/Makefile.am (révision 5027) +++ gnome-session/Makefile.am (copie de travail) @@ -7,6 +7,7 @@ noinst_LTLIBRARIES = libgsmutil.la noinst_PROGRAMS = \ test-client-dbus \ test-inhibit \ + test-logout \ $(NULL) INCLUDES = \ @@ -21,6 +22,7 @@ INCLUDES = \ -DDATA_DIR=\""$(datadir)/gnome-session"\" \ -DDBUS_LAUNCH=\"dbus-launch\" \ -DLIBEXECDIR=\"$(libexecdir)\" \ + -DDATADIR=\""$(datadir)"\" \ -DGLADEDIR=\""$(pkgdatadir)"\" \ -DGCONF_SANITY_CHECK=\""$(GCONF_SANITY_CHECK)"\" \ -DGCONFTOOL_CMD=\"$(GCONFTOOL)\" @@ -42,6 +44,24 @@ test_client_dbus_LDADD = \ $(DBUS_GLIB_LIBS) \ $(NULL) +test_logout_SOURCES = \ + test-logout.c \ + gdm.c \ + gdm.h \ + gsm-consolekit.c \ + gsm-consolekit.h \ + gsm-logout-dialog.c \ + gsm-logout-dialog.h \ + gsm-power-manager.c \ + gsm-power-manager.h \ + $(NULL) + +test_logout_LDADD = \ + $(GNOME_SESSION_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(POLKIT_GNOME_LIBS) \ + $(NULL) + gnome_session_LDADD = \ -lSM -lICE \ libgsmutil.la \ Index: gnome-session/gsm-logout-dialog.c =================================================================== --- gnome-session/gsm-logout-dialog.c (révision 5027) +++ gnome-session/gsm-logout-dialog.c (copie de travail) @@ -37,8 +37,13 @@ #define AUTOMATIC_ACTION_TIMEOUT 60 -#define GSM_ICON_LOGOUT "system-log-out" -#define GSM_ICON_SHUTDOWN "system-shutdown" +#define GSM_ICON_LOGOUT "system-log-out" +#define GSM_ICON_SWITCH "system-users" +#define GSM_ICON_SHUTDOWN "system-shutdown" +#define GSM_ICON_REBOOT "view-refresh" +/* TODO: use gpm icons? */ +#define GSM_ICON_HIBERNATE "drive-harddisk" +#define GSM_ICON_SLEEP "gnome-session-sleep" typedef enum { GSM_DIALOG_LOGOUT_TYPE_LOGOUT, @@ -47,11 +52,12 @@ typedef enum { struct _GsmLogoutDialogPrivate { - GsmDialogLogoutType type; - GsmPowerManager *power_manager; GsmConsolekit *consolekit; + GtkWidget *info_label; + GtkWidget *cancel_button; + int timeout; unsigned int timeout_id; @@ -60,7 +66,8 @@ struct _GsmLogoutDialogPrivate static GsmLogoutDialog *current_dialog = NULL; -static void gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog); +static void gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog, + int seconds); static void gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog, gpointer data); @@ -68,43 +75,10 @@ static void gsm_logout_dialog_destroy ( static void gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, gpointer data); -enum { - PROP_0, - PROP_MESSAGE_TYPE -}; - -G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_MESSAGE_DIALOG); +static void gsm_logout_set_info_text (GsmLogoutDialog *logout_dialog, + int seconds); -static void -gsm_logout_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_MESSAGE_TYPE: - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gsm_logout_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_MESSAGE_TYPE: - g_value_set_enum (value, GTK_MESSAGE_WARNING); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} +G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_DIALOG); static void gsm_logout_dialog_class_init (GsmLogoutDialogClass *klass) @@ -113,18 +87,6 @@ gsm_logout_dialog_class_init (GsmLogoutD gobject_class = G_OBJECT_CLASS (klass); - /* This is a workaround to avoid a stupid crash: libgnomeui - * listens for the "show" signal on all GtkMessageDialog and - * gets the "message-type" of the dialogs. We will crash when - * it accesses this property if we don't override it since we - * didn't define it. */ - gobject_class->set_property = gsm_logout_dialog_set_property; - gobject_class->get_property = gsm_logout_dialog_get_property; - - g_object_class_override_property (gobject_class, - PROP_MESSAGE_TYPE, - "message-type"); - g_type_class_add_private (klass, sizeof (GsmLogoutDialogPrivate)); } @@ -146,11 +108,23 @@ gsm_logout_dialog_init (GsmLogoutDialog logout_dialog->priv->timeout_id = 0; logout_dialog->priv->timeout = 0; logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL; + logout_dialog->priv->info_label = NULL; - gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE); + gtk_window_set_resizable (GTK_WINDOW (logout_dialog), FALSE); + gtk_dialog_set_has_separator (GTK_DIALOG (logout_dialog), FALSE); gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE); gtk_window_stick (GTK_WINDOW (logout_dialog)); + /* use HIG spacings */ + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (logout_dialog)->vbox), 12); + gtk_container_set_border_width (GTK_CONTAINER (logout_dialog), 6); + + gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_HELP, + GTK_RESPONSE_HELP); + logout_dialog->priv->cancel_button = + gtk_dialog_add_button (GTK_DIALOG (logout_dialog), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + logout_dialog->priv->power_manager = gsm_get_power_manager (); logout_dialog->priv->consolekit = gsm_get_consolekit (); @@ -247,17 +221,76 @@ gsm_logout_supports_shutdown (GsmLogoutD } static void -gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, gpointer user_data) +gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, + gpointer user_data) +{ + gsm_logout_set_info_text (logout_dialog, AUTOMATIC_ACTION_TIMEOUT); + + if (logout_dialog->priv->default_response != GTK_RESPONSE_CANCEL) + gsm_logout_dialog_set_timeout (logout_dialog, + AUTOMATIC_ACTION_TIMEOUT); +} + +static void +gsm_logout_set_info_text (GsmLogoutDialog *logout_dialog, + int seconds) { - gsm_logout_dialog_set_timeout (logout_dialog); + const char *info_text; + char *buf; + char *markup; + const char *name; + + switch (logout_dialog->priv->default_response) { + case GSM_LOGOUT_RESPONSE_LOGOUT: + info_text = ngettext ("You are currently logged in as " + "\"%s\".\n" + "You will be automatically logged out " + "in %d second.", + "You are currently logged in as " + "\"%s\".\n" + "You will be automatically logged out " + "in %d seconds.", + seconds); + break; + + case GSM_LOGOUT_RESPONSE_SHUTDOWN: + info_text = ngettext ("You are currently logged in as " + "\"%s\".\n" + "This system will be automatically shut " + "down in %d second.", + "You are currently logged in as " + "\"%s\".\n" + "This system will be automatically shut " + "down in %d seconds.", + seconds); + break; + + case GTK_RESPONSE_CANCEL: + info_text = _("You are currently logged in as \"%s\".\n"); + break; + + default: + g_assert_not_reached (); + } + + name = g_get_real_name (); + + if (!name || name[0] == '\0') { + name = g_get_user_name (); + } + + buf = g_strdup_printf (info_text, name, seconds); + markup = g_markup_printf_escaped ("%s", buf); + g_free (buf); + gtk_label_set_markup (GTK_LABEL (logout_dialog->priv->info_label), + markup); + g_free (markup); } static gboolean gsm_logout_dialog_timeout (gpointer data) { GsmLogoutDialog *logout_dialog; - char *secondary_text; - const char *name; int seconds_to_show; logout_dialog = (GsmLogoutDialog *) data; @@ -278,46 +311,7 @@ gsm_logout_dialog_timeout (gpointer data seconds_to_show += 10; } - switch (logout_dialog->priv->type) { - case GSM_DIALOG_LOGOUT_TYPE_LOGOUT: - secondary_text = ngettext ("You are currently logged in as " - "\"%s\".\n" - "You will be automatically logged " - "out in %d second.", - "You are currently logged in as " - "\"%s\".\n" - "You will be automatically logged " - "out in %d seconds.", - seconds_to_show); - break; - - case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: - secondary_text = ngettext ("You are currently logged in as " - "\"%s\".\n" - "This system will be automatically " - "shut down in %d second.", - "You are currently logged in as " - "\"%s\".\n" - "This system will be automatically " - "shut down in %d seconds.", - seconds_to_show); - break; - - default: - g_assert_not_reached (); - } - - name = g_get_real_name (); - - if (!name || name[0] == '\0') { - name = g_get_user_name (); - } - - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog), - secondary_text, - name, - seconds_to_show, - NULL); + gsm_logout_set_info_text (logout_dialog, seconds_to_show); logout_dialog->priv->timeout--; @@ -325,12 +319,10 @@ gsm_logout_dialog_timeout (gpointer data } static void -gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog) +gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog, + int seconds) { - logout_dialog->priv->timeout = AUTOMATIC_ACTION_TIMEOUT; - - /* Sets the secondary text */ - gsm_logout_dialog_timeout (logout_dialog); + logout_dialog->priv->timeout = seconds; if (logout_dialog->priv->timeout_id != 0) { g_source_remove (logout_dialog->priv->timeout_id); @@ -342,13 +334,118 @@ gsm_logout_dialog_set_timeout (GsmLogout } static GtkWidget * +gsm_logout_tile_new (const char *icon_name, + const char *title, + const char *description) +{ + GtkWidget *button; + GtkWidget *alignment; + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *image; + GtkWidget *label; + char *markup; + + g_assert (title != NULL); + + button = GTK_WIDGET (gtk_button_new ()); + gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); + + alignment = gtk_alignment_new (0, 0.5, 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 6, 6); + gtk_container_add (GTK_CONTAINER (button), alignment); + + hbox = gtk_hbox_new (FALSE, 12); + gtk_container_add (GTK_CONTAINER (alignment), hbox); + if (icon_name != NULL) { + image = gtk_image_new_from_icon_name (icon_name, + GTK_ICON_SIZE_DIALOG); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); + } + + vbox = gtk_vbox_new (FALSE, 2); + + markup = g_markup_printf_escaped ("%s", + title); + label = gtk_label_new (markup); + g_free (markup); + + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_use_underline (GTK_LABEL (label), TRUE); + + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + if (description != NULL) { + gchar *markup; + GdkColor *color; + GtkWidget *label; + + color = >K_WIDGET (button)->style->fg[GTK_STATE_INSENSITIVE]; + markup = g_markup_printf_escaped ("%s", + color->red, + color->green, + color->blue, + description); + label = gtk_label_new (markup); + g_free (markup); + + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_use_underline (GTK_LABEL (label), TRUE); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + } + + gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); + + return button; +} + +static void +gsm_logout_tile_clicked (GtkWidget *tile, + gpointer response_p) +{ + GtkWidget *dialog; + + dialog = gtk_widget_get_toplevel (tile); + g_assert (GTK_IS_DIALOG (dialog)); + gtk_dialog_response (GTK_DIALOG (dialog), + GPOINTER_TO_UINT (response_p)); +} + +static GtkWidget * +gsm_logout_append_tile (GtkWidget *vbox, + unsigned int response, + const char *icon_name, + const char *title, + const char *description) +{ + GtkWidget *tile; + + tile = gsm_logout_tile_new (icon_name, title, description); + gtk_box_pack_start (GTK_BOX (vbox), tile, TRUE, TRUE, 0); + gtk_widget_show_all (tile); + + g_signal_connect (tile, + "clicked", + G_CALLBACK (gsm_logout_tile_clicked), + GUINT_TO_POINTER (response)); + + return tile; +} + +static GtkWidget * gsm_get_dialog (GsmDialogLogoutType type, GdkScreen *screen, guint32 activate_time) { GsmLogoutDialog *logout_dialog; - const char *primary_text; + GtkWidget *vbox; + GtkWidget *tile; const char *icon_name; + const char *title; if (current_dialog != NULL) { gtk_widget_destroy (GTK_WIDGET (current_dialog)); @@ -358,82 +455,119 @@ gsm_get_dialog (GsmDialogLogoutType type current_dialog = logout_dialog; - gtk_window_set_title (GTK_WINDOW (logout_dialog), ""); - - logout_dialog->priv->type = type; + vbox = gtk_vbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (logout_dialog)->vbox), vbox, + FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + gtk_widget_show (vbox); icon_name = NULL; - primary_text = NULL; + title = NULL; switch (type) { case GSM_DIALOG_LOGOUT_TYPE_LOGOUT: icon_name = GSM_ICON_LOGOUT; - primary_text = _("Log out of this system now?"); + title = _("Log Out of the Session"); logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT; - if (gsm_logout_supports_switch_user (logout_dialog)) { - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), + + gsm_logout_append_tile (vbox, GSM_LOGOUT_RESPONSE_LOGOUT, + GSM_ICON_LOGOUT, _("_Log Out"), + _("Ends your session and logs you " + "out.")); + + tile = gsm_logout_append_tile (vbox, + GSM_LOGOUT_RESPONSE_SWITCH_USER, + GSM_ICON_SWITCH, _("_Switch User"), - GSM_LOGOUT_RESPONSE_SWITCH_USER); + _("Suspends your session, " + "allowing another user to " + "log in and use the " + "computer.")); + if (!gsm_logout_supports_switch_user (logout_dialog)) { + gtk_widget_set_sensitive (tile, FALSE); } - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), - _("_Log Out"), - GSM_LOGOUT_RESPONSE_LOGOUT); - break; case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: icon_name = GSM_ICON_SHUTDOWN; - primary_text = _("Shut down this system now?"); + title = _("Shut Down the Computer"); logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN; - if (gsm_logout_supports_system_suspend (logout_dialog)) { - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), - _("S_uspend"), - GSM_LOGOUT_RESPONSE_SLEEP); + tile = gsm_logout_append_tile (vbox, + GSM_LOGOUT_RESPONSE_SHUTDOWN, + GSM_ICON_SHUTDOWN, + _("_Shut Down"), + _("Ends your session and turns " + "off the computer.")); + if (!gsm_logout_supports_shutdown (logout_dialog)) { + gtk_widget_set_sensitive (tile, FALSE); + /* If shutdown is not available, let's just fallback + * on cancel as the default action. We could fallback + * on reboot first, then suspend and then hibernate + * but it's not that useful, really */ + logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL; } - if (gsm_logout_supports_system_hibernate (logout_dialog)) { - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), - _("_Hibernate"), - GSM_LOGOUT_RESPONSE_HIBERNATE); + tile = gsm_logout_append_tile (vbox, + GSM_LOGOUT_RESPONSE_REBOOT, + GSM_ICON_REBOOT, _("_Restart"), + _("Ends your session and " + "restarts the computer.")); + if (!gsm_logout_supports_reboot (logout_dialog)) { + gtk_widget_set_sensitive (tile, FALSE); } - if (gsm_logout_supports_reboot (logout_dialog)) { - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), - _("_Restart"), - GSM_LOGOUT_RESPONSE_REBOOT); + /* We don't set those options insensitive if they are no + * supported (like we do for shutdown/restart) since some + * hardware just don't support suspend/hibernate. So we + * don't show those options in this case. */ + if (gsm_logout_supports_system_suspend (logout_dialog)) { + gsm_logout_append_tile (vbox, + GSM_LOGOUT_RESPONSE_SLEEP, + GSM_ICON_SLEEP, _("S_uspend"), + _("Suspends your session " + "quickly, using minimal " + "power while the computer " + "stands by.")); } - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - - if (gsm_logout_supports_shutdown (logout_dialog)) { - gtk_dialog_add_button (GTK_DIALOG (logout_dialog), - _("_Shut Down"), - GSM_LOGOUT_RESPONSE_SHUTDOWN); + if (gsm_logout_supports_system_hibernate (logout_dialog)) { + gsm_logout_append_tile (vbox, + GSM_LOGOUT_RESPONSE_HIBERNATE, + GSM_ICON_HIBERNATE, + _("_Hibernate"), + _("Suspends your session, " + "using no power until the " + "computer is restarted.")); } + break; default: g_assert_not_reached (); } - gtk_image_set_from_icon_name (GTK_IMAGE (GTK_MESSAGE_DIALOG (logout_dialog)->image), - icon_name, GTK_ICON_SIZE_DIALOG); + logout_dialog->priv->info_label = gtk_label_new (""); + gtk_label_set_line_wrap (GTK_LABEL (logout_dialog->priv->info_label), + TRUE); + gtk_box_pack_start (GTK_BOX (vbox), logout_dialog->priv->info_label, + TRUE, TRUE, 0); + gtk_widget_show (logout_dialog->priv->info_label); + gtk_window_set_icon_name (GTK_WINDOW (logout_dialog), icon_name); - gtk_window_set_position (GTK_WINDOW (logout_dialog), GTK_WIN_POS_CENTER_ALWAYS); - gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (logout_dialog)->label), - primary_text); + gtk_window_set_title (GTK_WINDOW (logout_dialog), title); + gtk_window_set_position (GTK_WINDOW (logout_dialog), + GTK_WIN_POS_CENTER_ALWAYS); gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog), logout_dialog->priv->default_response); + /* Note that focus is on the widget for the default response by default + * (since they're the first widget, except when it's Cancel */ + if (logout_dialog->priv->default_response == GTK_RESPONSE_CANCEL) + gtk_window_set_focus (GTK_WINDOW (logout_dialog), + logout_dialog->priv->cancel_button); gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);