1
Index: gnome-session-2.25.91/gnome-session/gsm-manager.c
2
===================================================================
3
--- gnome-session-2.25.91.orig/gnome-session/gsm-manager.c 2009-02-18 00:40:09.000000000 +0000
4
+++ gnome-session-2.25.91/gnome-session/gsm-manager.c 2009-02-18 00:57:17.000000000 +0000
7
g_debug ("GsmManager: Logout dialog response: %d", response_id);
9
- gtk_widget_destroy (GTK_WIDGET (logout_dialog));
10
+ if (response_id != GTK_RESPONSE_HELP)
11
+ gtk_widget_destroy (GTK_WIDGET (logout_dialog));
13
/* In case of dialog cancel, switch user, hibernate and
14
* suspend, we just perform the respective action and return,
15
@@ -2373,6 +2374,10 @@
16
case GTK_RESPONSE_NONE:
17
case GTK_RESPONSE_DELETE_EVENT:
19
+ case GTK_RESPONSE_HELP:
20
+ gsm_util_help_display (GTK_WINDOW (logout_dialog),
21
+ "gosgetstarted-73");
23
case GSM_LOGOUT_RESPONSE_SWITCH_USER:
24
request_switch_user (manager);
26
Index: gnome-session-2.25.91/gnome-session/gsm-util.c
27
===================================================================
28
--- gnome-session-2.25.91.orig/gnome-session/gsm-util.c 2009-02-18 00:40:09.000000000 +0000
29
+++ gnome-session-2.25.91/gnome-session/gsm-util.c 2009-02-18 00:57:17.000000000 +0000
35
#include <sys/types.h>
39
g_error_free (bus_error);
44
+gsm_util_help_display (GtkWindow *parent,
45
+ const char *link_id)
47
+ GError *error = NULL;
56
+ const char * const * langs = g_get_language_names ();
61
+ for (i = 0; langs[i]; i++) {
63
+ if (strchr (lang, '.')) {
67
+ uri = g_build_filename (DATADIR,
68
+ "/gnome/help/user-guide/",
73
+ if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
81
+ command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL);
83
+ command = g_strconcat ("gnome-open ghelp://", uri, NULL);
86
+ gscreen = gdk_screen_get_default ();
87
+ gdk_spawn_command_line_on_screen (gscreen, command, &error);
91
+ if (!found || error != NULL) {
96
+ errmsg = _("Cannot find help.");
98
+ errmsg = error->message;
99
+ g_error_free (error);
102
+ d = gtk_message_dialog_new (parent,
103
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
104
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
106
+ gtk_widget_show (GTK_WIDGET (d));
107
+ g_signal_connect (d, "response",
108
+ G_CALLBACK (gtk_widget_destroy), NULL);
114
Index: gnome-session-2.25.91/gnome-session/gsm-util.h
115
===================================================================
116
--- gnome-session-2.25.91.orig/gnome-session/gsm-util.h 2009-02-18 00:40:09.000000000 +0000
117
+++ gnome-session-2.25.91/gnome-session/gsm-util.h 2009-02-18 00:57:17.000000000 +0000
119
#define __GSM_UTIL_H__
122
+#include <gtk/gtk.h>
127
void gsm_util_setenv (const char *variable,
130
+void gsm_util_help_display (GtkWindow *parent,
131
+ const char * link_id);
135
#endif /* __GSM_UTIL_H__ */
136
Index: gnome-session-2.25.91/gnome-session/Makefile.am
137
===================================================================
138
--- gnome-session-2.25.91.orig/gnome-session/Makefile.am 2009-02-18 00:40:09.000000000 +0000
139
+++ gnome-session-2.25.91/gnome-session/Makefile.am 2009-02-18 00:57:17.000000000 +0000
149
-DDATA_DIR=\""$(datadir)/gnome-session"\" \
150
-DDBUS_LAUNCH=\"dbus-launch\" \
151
-DLIBEXECDIR=\"$(libexecdir)\" \
152
+ -DDATADIR=\""$(datadir)"\" \
153
-DGLADEDIR=\""$(pkgdatadir)"\" \
154
-DGCONF_SANITY_CHECK=\""$(GCONF_SANITY_CHECK)"\" \
155
-DGCONFTOOL_CMD=\"$(GCONFTOOL)\"
160
+test_logout_SOURCES = \
166
+ gsm-logout-dialog.c \
167
+ gsm-logout-dialog.h \
168
+ gsm-power-manager.c \
169
+ gsm-power-manager.h \
172
+test_logout_LDADD = \
173
+ $(GNOME_SESSION_LIBS) \
174
+ $(DBUS_GLIB_LIBS) \
175
+ $(POLKIT_GNOME_LIBS) \
178
gnome_session_LDADD = \
180
$(top_builddir)/egg/libeggdesktopfile.la \
181
Index: gnome-session-2.25.91/gnome-session/Makefile.in
182
===================================================================
183
--- gnome-session-2.25.91.orig/gnome-session/Makefile.in 2009-02-18 00:40:09.000000000 +0000
184
+++ gnome-session-2.25.91/gnome-session/Makefile.in 2009-02-18 00:57:17.000000000 +0000
186
-DDATA_DIR=\""$(datadir)/gnome-session"\" \
187
-DDBUS_LAUNCH=\"dbus-launch\" \
188
-DLIBEXECDIR=\"$(libexecdir)\" \
189
+ -DDATADIR=\""$(datadir)"\" \
190
-DGLADEDIR=\""$(pkgdatadir)"\" \
191
-DGCONF_SANITY_CHECK=\""$(GCONF_SANITY_CHECK)"\" \
192
-DGCONFTOOL_CMD=\"$(GCONFTOOL)\"
193
Index: gnome-session-2.25.91/gnome-session/test-logout.c
194
===================================================================
195
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
196
+++ gnome-session-2.25.91/gnome-session/test-logout.c 2009-02-18 00:57:17.000000000 +0000
198
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
200
+ * Copyright (C) 2008 Novell, Inc.
202
+ * This program is free software; you can redistribute it and/or
203
+ * modify it under the terms of the GNU General Public License as
204
+ * published by the Free Software Foundation; either version 2 of the
205
+ * License, or (at your option) any later version.
207
+ * This program is distributed in the hope that it will be useful, but
208
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
209
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
210
+ * General Public License for more details.
212
+ * You should have received a copy of the GNU General Public License
213
+ * along with this program; if not, write to the Free Software
214
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
223
+#include <gtk/gtk.h>
225
+#include "gsm-logout-dialog.h"
228
+logout_dialog_response (GsmLogoutDialog *logout_dialog,
232
+ /* In case of dialog cancel, switch user, hibernate and
233
+ * suspend, we just perform the respective action and return,
234
+ * without shutting down the session. */
235
+ switch (response_id) {
236
+ case GTK_RESPONSE_CANCEL:
237
+ case GTK_RESPONSE_NONE:
238
+ case GTK_RESPONSE_DELETE_EVENT:
239
+ g_print ("Cancel\n");
241
+ case GTK_RESPONSE_HELP:
242
+ g_print ("Help\n");
244
+ case GSM_LOGOUT_RESPONSE_SWITCH_USER:
245
+ g_print ("Switch user\n");
247
+ case GSM_LOGOUT_RESPONSE_HIBERNATE:
248
+ g_print ("Hibernate\n");
250
+ case GSM_LOGOUT_RESPONSE_SLEEP:
251
+ g_print ("Suspend\n");
253
+ case GSM_LOGOUT_RESPONSE_SHUTDOWN:
254
+ g_print ("Shutdown\n");
256
+ case GSM_LOGOUT_RESPONSE_REBOOT:
257
+ g_print ("Reboot\n");
259
+ case GSM_LOGOUT_RESPONSE_LOGOUT:
260
+ g_print ("Logout\n");
263
+ g_assert_not_reached ();
278
+ static gboolean logout;
279
+ static gboolean shutdown;
281
+ static GOptionEntry entries[] = {
282
+ { "logout", 'l', 0, G_OPTION_ARG_NONE, &logout, "Test logout dialog", NULL },
283
+ { "shutdown", 's', 0, G_OPTION_ARG_NONE, &shutdown, "Test shutdown dialog", NULL },
284
+ { NULL, 0, 0, 0, NULL, NULL, NULL }
287
+ logout = shutdown = FALSE;
290
+ gtk_init_with_args (&argc, &argv,
291
+ (char *) " - test logout/shutdown dialogs",
294
+ if (error != NULL) {
295
+ g_warning ("%s", error->message);
296
+ g_error_free (error);
301
+ dialog = gsm_get_logout_dialog (gdk_screen_get_default (),
304
+ dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (),
307
+ g_signal_connect (dialog, "response",
308
+ G_CALLBACK (logout_dialog_response), NULL);
309
+ gtk_widget_show (dialog);
315
Index: gnome-session-2.25.91/gnome-session/gsm-logout-dialog.c
316
===================================================================
317
--- gnome-session-2.25.91.orig/gnome-session/gsm-logout-dialog.c 2009-02-18 00:40:09.000000000 +0000
318
+++ gnome-session-2.25.91/gnome-session/gsm-logout-dialog.c 2009-02-18 01:02:23.000000000 +0000
321
#define AUTOMATIC_ACTION_TIMEOUT 60
323
-#define GSM_ICON_LOGOUT "system-log-out"
324
-#define GSM_ICON_SHUTDOWN "system-shutdown"
325
+#define GSM_ICON_LOGOUT "system-log-out"
326
+#define GSM_ICON_SWITCH "system-users"
327
+#define GSM_ICON_SHUTDOWN "system-shutdown"
328
+#define GSM_ICON_REBOOT "view-refresh"
329
+/* TODO: use gpm icons? */
330
+#define GSM_ICON_HIBERNATE "drive-harddisk"
331
+#define GSM_ICON_SLEEP "sleep"
334
GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
337
struct _GsmLogoutDialogPrivate
339
- GsmDialogLogoutType type;
341
GsmPowerManager *power_manager;
342
GsmConsolekit *consolekit;
344
+ GtkWidget *info_label;
345
+ GtkWidget *cancel_button;
348
unsigned int timeout_id;
352
static GsmLogoutDialog *current_dialog = NULL;
354
-static void gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog);
355
+static void gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog,
358
static void gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog,
361
static void gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog,
369
-G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_MESSAGE_DIALOG);
370
+static void gsm_logout_set_info_text (GsmLogoutDialog *logout_dialog,
374
-gsm_logout_dialog_set_property (GObject *object,
376
- const GValue *value,
380
- case PROP_MESSAGE_TYPE:
383
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
389
-gsm_logout_dialog_get_property (GObject *object,
395
- case PROP_MESSAGE_TYPE:
396
- g_value_set_enum (value, GTK_MESSAGE_WARNING);
399
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
403
+G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_DIALOG);
406
gsm_logout_dialog_class_init (GsmLogoutDialogClass *klass)
409
gobject_class = G_OBJECT_CLASS (klass);
411
- /* This is a workaround to avoid a stupid crash: libgnomeui
412
- * listens for the "show" signal on all GtkMessageDialog and
413
- * gets the "message-type" of the dialogs. We will crash when
414
- * it accesses this property if we don't override it since we
415
- * didn't define it. */
416
- gobject_class->set_property = gsm_logout_dialog_set_property;
417
- gobject_class->get_property = gsm_logout_dialog_get_property;
419
- g_object_class_override_property (gobject_class,
423
g_type_class_add_private (klass, sizeof (GsmLogoutDialogPrivate));
426
@@ -146,11 +108,23 @@
427
logout_dialog->priv->timeout_id = 0;
428
logout_dialog->priv->timeout = 0;
429
logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;
430
+ logout_dialog->priv->info_label = NULL;
432
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
433
+ gtk_window_set_resizable (GTK_WINDOW (logout_dialog), FALSE);
434
+ gtk_dialog_set_has_separator (GTK_DIALOG (logout_dialog), FALSE);
435
gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
436
gtk_window_stick (GTK_WINDOW (logout_dialog));
438
+ /* use HIG spacings */
439
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (logout_dialog)->vbox), 12);
440
+ gtk_container_set_border_width (GTK_CONTAINER (logout_dialog), 6);
442
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_HELP,
443
+ GTK_RESPONSE_HELP);
444
+ logout_dialog->priv->cancel_button =
445
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
446
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
448
logout_dialog->priv->power_manager = gsm_get_power_manager ();
450
logout_dialog->priv->consolekit = gsm_get_consolekit ();
451
@@ -247,59 +221,49 @@
455
-gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, gpointer user_data)
456
+gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog,
457
+ gpointer user_data)
459
- gsm_logout_dialog_set_timeout (logout_dialog);
460
+ gsm_logout_set_info_text (logout_dialog, AUTOMATIC_ACTION_TIMEOUT);
462
+ if (logout_dialog->priv->default_response != GTK_RESPONSE_CANCEL)
463
+ gsm_logout_dialog_set_timeout (logout_dialog,
464
+ AUTOMATIC_ACTION_TIMEOUT);
468
-gsm_logout_dialog_timeout (gpointer data)
470
+gsm_logout_set_info_text (GsmLogoutDialog *logout_dialog,
473
- GsmLogoutDialog *logout_dialog;
474
- char *seconds_warning;
475
- char *secondary_text;
476
- int seconds_to_show;
477
+ const char *info_text;
479
static char *session_type = NULL;
481
- logout_dialog = (GsmLogoutDialog *) data;
483
- if (!logout_dialog->priv->timeout) {
484
- gtk_dialog_response (GTK_DIALOG (logout_dialog),
485
- logout_dialog->priv->default_response);
490
- if (logout_dialog->priv->timeout <= 30) {
491
- seconds_to_show = logout_dialog->priv->timeout;
493
- seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
495
- if (logout_dialog->priv->timeout % 10)
496
- seconds_to_show += 10;
498
+ switch (logout_dialog->priv->default_response) {
499
+ case GSM_LOGOUT_RESPONSE_LOGOUT:
500
+ info_text = ngettext ("You will be automatically logged "
501
+ "out in %d second.",
502
+ "You will be automatically logged "
503
+ "out in %d seconds.",
507
- switch (logout_dialog->priv->type) {
508
- case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
509
- seconds_warning = ngettext ("You will be automatically logged "
510
- "out in %d second.",
511
- "You will be automatically logged "
512
- "out in %d seconds.",
514
+ case GSM_LOGOUT_RESPONSE_SHUTDOWN:
515
+ info_text = ngettext ("This system will be automatically "
516
+ "shut down in %d second.",
517
+ "This system will be automatically "
518
+ "shut down in %d seconds.",
522
- case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
523
- seconds_warning = ngettext ("This system will be automatically "
524
- "shut down in %d second.",
525
- "This system will be automatically "
526
- "shut down in %d seconds.",
528
+ case GTK_RESPONSE_CANCEL:
529
+ info_text = _("You are currently logged in as \"%s\".\n");
533
g_assert_not_reached ();
537
if (session_type == NULL) {
538
GsmConsolekit *consolekit;
540
@@ -307,48 +271,71 @@
541
session_type = gsm_consolekit_get_current_session_type (consolekit);
542
g_object_unref (consolekit);
546
if (g_strcmp0 (session_type, GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW) != 0) {
549
+ char *name, *buf, *buf2;
550
name = g_locale_to_utf8 (g_get_real_name (), -1, NULL, NULL, NULL);
552
if (!name || name[0] == '\0' || strcmp (name, "Unknown") == 0) {
553
- name = g_locale_to_utf8 (g_get_user_name (), -1 , NULL, NULL, NULL);
554
+ name = g_locale_to_utf8 (g_get_user_name (), -1 , NULL, NULL, NULL);
559
name = g_strdup (g_get_user_name ());
562
- tmp = g_strdup_printf (_("You are currently logged in as \"%s\"."), name);
563
- secondary_text = g_strconcat (tmp, "\n", seconds_warning, NULL);
566
+ buf = g_strdup_printf (_("You are currently logged in as \"%s\"."), name);
567
+ buf2 = g_strdup_printf (info_text, seconds);
568
+ markup = g_markup_printf_escaped ("<i>%s</i>", g_strconcat (buf, "\n", buf2, NULL));
573
- secondary_text = g_strdup (seconds_warning);
574
+ markup = g_strdup (info_text);
577
+ gtk_label_set_markup (GTK_LABEL (logout_dialog->priv->info_label),
583
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog),
588
+gsm_logout_dialog_timeout (gpointer data)
590
+ GsmLogoutDialog *logout_dialog;
591
+ int seconds_to_show;
593
- logout_dialog->priv->timeout--;
594
+ logout_dialog = (GsmLogoutDialog *) data;
596
- g_free (secondary_text);
597
+ if (!logout_dialog->priv->timeout) {
598
+ gtk_dialog_response (GTK_DIALOG (logout_dialog),
599
+ logout_dialog->priv->default_response);
604
+ if (logout_dialog->priv->timeout <= 30) {
605
+ seconds_to_show = logout_dialog->priv->timeout;
607
+ seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
609
+ if (logout_dialog->priv->timeout % 10)
610
+ seconds_to_show += 10;
613
+ gsm_logout_set_info_text (logout_dialog, seconds_to_show);
615
+ logout_dialog->priv->timeout--;
621
-gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog)
622
+gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog,
625
- logout_dialog->priv->timeout = AUTOMATIC_ACTION_TIMEOUT;
627
- /* Sets the secondary text */
628
- gsm_logout_dialog_timeout (logout_dialog);
629
+ logout_dialog->priv->timeout = seconds;
631
if (logout_dialog->priv->timeout_id != 0) {
632
g_source_remove (logout_dialog->priv->timeout_id);
633
@@ -360,13 +347,118 @@
637
+gsm_logout_tile_new (const char *icon_name,
639
+ const char *description)
642
+ GtkWidget *alignment;
649
+ g_assert (title != NULL);
651
+ button = GTK_WIDGET (gtk_button_new ());
652
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
654
+ alignment = gtk_alignment_new (0, 0.5, 0, 0);
655
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 6, 6);
656
+ gtk_container_add (GTK_CONTAINER (button), alignment);
658
+ hbox = gtk_hbox_new (FALSE, 12);
659
+ gtk_container_add (GTK_CONTAINER (alignment), hbox);
660
+ if (icon_name != NULL) {
661
+ image = gtk_image_new_from_icon_name (icon_name,
662
+ GTK_ICON_SIZE_DIALOG);
663
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
666
+ vbox = gtk_vbox_new (FALSE, 2);
668
+ markup = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
670
+ label = gtk_label_new (markup);
673
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
674
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
675
+ gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
677
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
679
+ if (description != NULL) {
684
+ color = >K_WIDGET (button)->style->fg[GTK_STATE_INSENSITIVE];
685
+ markup = g_markup_printf_escaped ("<span size=\"small\" foreground=\"#%.2x%.2x%.2x\">%s</span>",
690
+ label = gtk_label_new (markup);
693
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
694
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
695
+ gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
696
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
698
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
701
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
707
+gsm_logout_tile_clicked (GtkWidget *tile,
708
+ gpointer response_p)
712
+ dialog = gtk_widget_get_toplevel (tile);
713
+ g_assert (GTK_IS_DIALOG (dialog));
714
+ gtk_dialog_response (GTK_DIALOG (dialog),
715
+ GPOINTER_TO_UINT (response_p));
719
+gsm_logout_append_tile (GtkWidget *vbox,
720
+ unsigned int response,
721
+ const char *icon_name,
723
+ const char *description)
727
+ tile = gsm_logout_tile_new (icon_name, title, description);
728
+ gtk_box_pack_start (GTK_BOX (vbox), tile, TRUE, TRUE, 0);
729
+ gtk_widget_show_all (tile);
731
+ g_signal_connect (tile,
733
+ G_CALLBACK (gsm_logout_tile_clicked),
734
+ GUINT_TO_POINTER (response));
740
gsm_get_dialog (GsmDialogLogoutType type,
742
guint32 activate_time)
744
GsmLogoutDialog *logout_dialog;
745
- const char *primary_text;
748
const char *icon_name;
751
if (current_dialog != NULL) {
752
gtk_widget_destroy (GTK_WIDGET (current_dialog));
753
@@ -376,82 +468,118 @@
755
current_dialog = logout_dialog;
757
- gtk_window_set_title (GTK_WINDOW (logout_dialog), "");
759
- logout_dialog->priv->type = type;
760
+ vbox = gtk_vbox_new (FALSE, 12);
761
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (logout_dialog)->vbox), vbox,
763
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
764
+ gtk_widget_show (vbox);
767
- primary_text = NULL;
771
case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
772
icon_name = GSM_ICON_LOGOUT;
773
- primary_text = _("Log out of this system now?");
774
+ title = _("Log Out of the Session");
776
logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT;
778
- if (gsm_logout_supports_switch_user (logout_dialog)) {
779
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
781
+ gsm_logout_append_tile (vbox, GSM_LOGOUT_RESPONSE_LOGOUT,
782
+ GSM_ICON_LOGOUT, _("_Log Out"),
783
+ _("Ends your session and logs you "
786
+ tile = gsm_logout_append_tile (vbox,
787
+ GSM_LOGOUT_RESPONSE_SWITCH_USER,
790
- GSM_LOGOUT_RESPONSE_SWITCH_USER);
791
+ _("Suspends your session, "
792
+ "allowing another user to "
793
+ "log in and use the "
795
+ if (!gsm_logout_supports_switch_user (logout_dialog)) {
796
+ gtk_widget_set_sensitive (tile, FALSE);
799
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
801
- GTK_RESPONSE_CANCEL);
803
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
805
- GSM_LOGOUT_RESPONSE_LOGOUT);
808
case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
809
icon_name = GSM_ICON_SHUTDOWN;
810
- primary_text = _("Shut down this system now?");
811
+ title = _("Shut Down the Computer");
813
logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN;
815
- if (gsm_logout_supports_system_suspend (logout_dialog)) {
816
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
818
- GSM_LOGOUT_RESPONSE_SLEEP);
819
+ tile = gsm_logout_append_tile (vbox,
820
+ GSM_LOGOUT_RESPONSE_SHUTDOWN,
823
+ _("Ends your session and turns "
824
+ "off the computer."));
825
+ if (!gsm_logout_supports_shutdown (logout_dialog)) {
826
+ gtk_widget_set_sensitive (tile, FALSE);
827
+ /* If shutdown is not available, let's just fallback
828
+ * on cancel as the default action. We could fallback
829
+ * on reboot first, then suspend and then hibernate
830
+ * but it's not that useful, really */
831
+ logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;
834
- if (gsm_logout_supports_system_hibernate (logout_dialog)) {
835
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
837
- GSM_LOGOUT_RESPONSE_HIBERNATE);
838
+ tile = gsm_logout_append_tile (vbox,
839
+ GSM_LOGOUT_RESPONSE_REBOOT,
840
+ GSM_ICON_REBOOT, _("_Restart"),
841
+ _("Ends your session and "
842
+ "restarts the computer."));
843
+ if (!gsm_logout_supports_reboot (logout_dialog)) {
844
+ gtk_widget_set_sensitive (tile, FALSE);
847
- if (gsm_logout_supports_reboot (logout_dialog)) {
848
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
850
- GSM_LOGOUT_RESPONSE_REBOOT);
851
+ /* We don't set those options insensitive if they are no
852
+ * supported (like we do for shutdown/restart) since some
853
+ * hardware just don't support suspend/hibernate. So we
854
+ * don't show those options in this case. */
855
+ if (gsm_logout_supports_system_suspend (logout_dialog)) {
856
+ gsm_logout_append_tile (vbox,
857
+ GSM_LOGOUT_RESPONSE_SLEEP,
858
+ GSM_ICON_SLEEP, _("S_uspend"),
859
+ _("Suspends your session "
860
+ "quickly, using minimal "
861
+ "power while the computer "
865
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
867
- GTK_RESPONSE_CANCEL);
869
- if (gsm_logout_supports_shutdown (logout_dialog)) {
870
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
872
- GSM_LOGOUT_RESPONSE_SHUTDOWN);
873
+ if (gsm_logout_supports_system_hibernate (logout_dialog)) {
874
+ gsm_logout_append_tile (vbox,
875
+ GSM_LOGOUT_RESPONSE_HIBERNATE,
876
+ GSM_ICON_HIBERNATE,
878
+ _("Suspends your session, "
879
+ "using no power until the "
880
+ "computer is restarted."));
885
g_assert_not_reached ();
888
- gtk_image_set_from_icon_name (GTK_IMAGE (GTK_MESSAGE_DIALOG (logout_dialog)->image),
889
- icon_name, GTK_ICON_SIZE_DIALOG);
890
+ logout_dialog->priv->info_label = gtk_label_new ("");
891
+ gtk_label_set_line_wrap (GTK_LABEL (logout_dialog->priv->info_label),
893
+ gtk_box_pack_start (GTK_BOX (vbox), logout_dialog->priv->info_label,
895
+ gtk_widget_show (logout_dialog->priv->info_label);
896
gtk_window_set_icon_name (GTK_WINDOW (logout_dialog), icon_name);
897
- gtk_window_set_position (GTK_WINDOW (logout_dialog), GTK_WIN_POS_CENTER_ALWAYS);
898
- gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (logout_dialog)->label),
900
+ gtk_window_set_title (GTK_WINDOW (logout_dialog), title);
901
+ gtk_window_set_position (GTK_WINDOW (logout_dialog),
902
+ GTK_WIN_POS_CENTER_ALWAYS);
904
gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog),
905
logout_dialog->priv->default_response);
906
+ /* Note that focus is on the widget for the default response by default
907
+ * (since they're the first widget, except when it's Cancel */
908
+ if (logout_dialog->priv->default_response == GTK_RESPONSE_CANCEL)
909
+ gtk_window_set_focus (GTK_WINDOW (logout_dialog),
910
+ logout_dialog->priv->cancel_button);
912
gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);