~raof/gnome-session/fix-bug-623700

« back to all changes in this revision

Viewing changes to debian/patches/80_new_upstream_session_dialog.patch

  • Committer: chrisccoulson at googlemail
  • Date: 2009-03-03 20:30:59 UTC
  • Revision ID: chrisccoulson@googlemail.com-20090303203059-hyfc1qt1wccyqsf3
Initial gnome-session import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
@@ -2363,7 +2363,8 @@
 
6
 {
 
7
         g_debug ("GsmManager: Logout dialog response: %d", response_id);
 
8
 
 
9
-        gtk_widget_destroy (GTK_WIDGET (logout_dialog));
 
10
+        if (response_id != GTK_RESPONSE_HELP)
 
11
+                gtk_widget_destroy (GTK_WIDGET (logout_dialog));
 
12
 
 
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:
 
18
                 break;
 
19
+        case GTK_RESPONSE_HELP:
 
20
+                gsm_util_help_display (GTK_WINDOW (logout_dialog),
 
21
+                                       "gosgetstarted-73");
 
22
+                break;
 
23
         case GSM_LOGOUT_RESPONSE_SWITCH_USER:
 
24
                 request_switch_user (manager);
 
25
                 break;
 
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
 
30
@@ -21,6 +21,7 @@
 
31
 #include <config.h>
 
32
 #include <stdlib.h>
 
33
 #include <ctype.h>
 
34
+#include <string.h>
 
35
 #include <sys/types.h>
 
36
 #include <unistd.h>
 
37
 #include <sys/time.h>
 
38
@@ -292,3 +293,75 @@
 
39
                 g_error_free (bus_error);
 
40
         }
 
41
 }
 
42
+
 
43
+void
 
44
+gsm_util_help_display (GtkWindow  *parent,
 
45
+                       const char *link_id)
 
46
+{
 
47
+        GError *error = NULL;
 
48
+        char *command;
 
49
+        const char *lang;
 
50
+        char *uri = NULL;
 
51
+        GdkScreen *gscreen;
 
52
+        gboolean found;
 
53
+
 
54
+        int i;
 
55
+
 
56
+        const char * const * langs = g_get_language_names ();
 
57
+
 
58
+        uri = NULL;
 
59
+        found = FALSE;
 
60
+
 
61
+        for (i = 0; langs[i]; i++) {
 
62
+                lang = langs[i];
 
63
+                if (strchr (lang, '.')) {
 
64
+                        continue;
 
65
+                }
 
66
+
 
67
+                uri = g_build_filename (DATADIR,
 
68
+                                        "/gnome/help/user-guide/",
 
69
+                                        lang,
 
70
+                                        "/user-guide.xml",
 
71
+                                        NULL);
 
72
+
 
73
+                if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
 
74
+                        found = TRUE;
 
75
+                        break;
 
76
+                }
 
77
+        }
 
78
+
 
79
+        if (found) {
 
80
+                if (link_id) {
 
81
+                        command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL);
 
82
+                } else {
 
83
+                        command = g_strconcat ("gnome-open ghelp://", uri,  NULL);
 
84
+                }
 
85
+
 
86
+                gscreen = gdk_screen_get_default ();
 
87
+                gdk_spawn_command_line_on_screen (gscreen, command, &error);
 
88
+        } else
 
89
+                command = NULL;
 
90
+
 
91
+        if (!found || error != NULL) {
 
92
+                GtkWidget *d;
 
93
+                const char *errmsg;
 
94
+
 
95
+                if (!found)
 
96
+                        errmsg = _("Cannot find help.");
 
97
+                else {
 
98
+                        errmsg = error->message;
 
99
+                        g_error_free (error);
 
100
+                }
 
101
+
 
102
+                d = gtk_message_dialog_new (parent,
 
103
+                                            GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
 
104
+                                            GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
 
105
+                                            "%s", errmsg);
 
106
+                gtk_widget_show (GTK_WIDGET (d));
 
107
+                g_signal_connect (d, "response",
 
108
+                                  G_CALLBACK (gtk_widget_destroy), NULL);
 
109
+        }
 
110
+
 
111
+        g_free (command);
 
112
+        g_free (uri);
 
113
+}
 
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
 
118
@@ -21,6 +21,7 @@
 
119
 #define __GSM_UTIL_H__
 
120
 
 
121
 #include <glib.h>
 
122
+#include <gtk/gtk.h>
 
123
 
 
124
 G_BEGIN_DECLS
 
125
 
 
126
@@ -37,6 +38,9 @@
 
127
 void      gsm_util_setenv               (const char *variable,
 
128
                                          const char *value);
 
129
 
 
130
+void      gsm_util_help_display         (GtkWindow  *parent,
 
131
+                                         const char * link_id);
 
132
+
 
133
 G_END_DECLS
 
134
 
 
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
 
140
@@ -7,6 +7,7 @@
 
141
 noinst_PROGRAMS =              \
 
142
        test-client-dbus        \
 
143
        test-inhibit            \
 
144
+       test-logout             \
 
145
        $(NULL)
 
146
 
 
147
 INCLUDES =                                     \
 
148
@@ -22,6 +23,7 @@
 
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)\"
 
156
@@ -42,6 +44,24 @@
 
157
        $(DBUS_GLIB_LIBS)                       \
 
158
        $(NULL)
 
159
 
 
160
+test_logout_SOURCES =  \
 
161
+       test-logout.c                           \
 
162
+       gdm.c                                   \
 
163
+       gdm.h                                   \
 
164
+       gsm-consolekit.c                        \
 
165
+       gsm-consolekit.h                        \
 
166
+       gsm-logout-dialog.c                     \
 
167
+       gsm-logout-dialog.h                     \
 
168
+       gsm-power-manager.c                     \
 
169
+       gsm-power-manager.h                     \
 
170
+       $(NULL)
 
171
+
 
172
+test_logout_LDADD =                            \
 
173
+       $(GNOME_SESSION_LIBS)                   \
 
174
+       $(DBUS_GLIB_LIBS)                       \
 
175
+       $(POLKIT_GNOME_LIBS)                    \
 
176
+       $(NULL)
 
177
+
 
178
 gnome_session_LDADD =                          \
 
179
        libgsmutil.la                           \
 
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
 
185
@@ -295,6 +295,7 @@
 
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
 
197
@@ -0,0 +1,117 @@
 
198
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 
199
+ *
 
200
+ * Copyright (C) 2008 Novell, Inc.
 
201
+ *
 
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.
 
206
+ *
 
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.
 
211
+ *
 
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
 
215
+ * 02111-1307, USA.
 
216
+ *
 
217
+ */
 
218
+
 
219
+#include "config.h"
 
220
+
 
221
+#include <stdlib.h>
 
222
+
 
223
+#include <gtk/gtk.h>
 
224
+
 
225
+#include "gsm-logout-dialog.h"
 
226
+
 
227
+static void
 
228
+logout_dialog_response (GsmLogoutDialog *logout_dialog,
 
229
+                        guint            response_id,
 
230
+                        gpointer         data)
 
231
+{
 
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");
 
240
+                break;
 
241
+        case GTK_RESPONSE_HELP:
 
242
+                g_print ("Help\n");
 
243
+                break;
 
244
+        case GSM_LOGOUT_RESPONSE_SWITCH_USER:
 
245
+                g_print ("Switch user\n");
 
246
+                break;
 
247
+        case GSM_LOGOUT_RESPONSE_HIBERNATE:
 
248
+                g_print ("Hibernate\n");
 
249
+                break;
 
250
+        case GSM_LOGOUT_RESPONSE_SLEEP:
 
251
+                g_print ("Suspend\n");
 
252
+                break;
 
253
+        case GSM_LOGOUT_RESPONSE_SHUTDOWN:
 
254
+                g_print ("Shutdown\n");
 
255
+                break;
 
256
+        case GSM_LOGOUT_RESPONSE_REBOOT:
 
257
+                g_print ("Reboot\n");
 
258
+                break;
 
259
+        case GSM_LOGOUT_RESPONSE_LOGOUT:
 
260
+                g_print ("Logout\n");
 
261
+                break;
 
262
+        default:
 
263
+                g_assert_not_reached ();
 
264
+                break;
 
265
+        }
 
266
+
 
267
+        gtk_main_quit ();
 
268
+}
 
269
+
 
270
+
 
271
+int
 
272
+main (int   argc,
 
273
+      char *argv[])
 
274
+{
 
275
+        GtkWidget *dialog;
 
276
+        GError    *error;
 
277
+
 
278
+        static gboolean logout;
 
279
+        static gboolean shutdown;
 
280
+
 
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 }
 
285
+        };
 
286
+
 
287
+        logout = shutdown = FALSE;
 
288
+        error = NULL;
 
289
+
 
290
+        gtk_init_with_args (&argc, &argv,
 
291
+                            (char *) " - test logout/shutdown dialogs",
 
292
+                            entries, NULL,
 
293
+                            &error);
 
294
+        if (error != NULL) {
 
295
+                g_warning ("%s", error->message);
 
296
+                g_error_free (error);
 
297
+                exit (1);
 
298
+        }
 
299
+
 
300
+        if (!shutdown)
 
301
+                dialog = gsm_get_logout_dialog (gdk_screen_get_default (),
 
302
+                                                GDK_CURRENT_TIME);
 
303
+        else
 
304
+                dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (),
 
305
+                                                  GDK_CURRENT_TIME);
 
306
+
 
307
+        g_signal_connect (dialog, "response",
 
308
+                          G_CALLBACK (logout_dialog_response), NULL);
 
309
+        gtk_widget_show (dialog);
 
310
+
 
311
+        gtk_main ();
 
312
+
 
313
+        return 0;
 
314
+}
 
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
 
319
@@ -37,8 +37,13 @@
 
320
 
 
321
 #define AUTOMATIC_ACTION_TIMEOUT 60
 
322
 
 
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"
 
332
 
 
333
 typedef enum {
 
334
         GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
 
335
@@ -47,11 +52,12 @@
 
336
 
 
337
 struct _GsmLogoutDialogPrivate
 
338
 {
 
339
-        GsmDialogLogoutType  type;
 
340
-
 
341
         GsmPowerManager     *power_manager;
 
342
         GsmConsolekit       *consolekit;
 
343
 
 
344
+        GtkWidget           *info_label;
 
345
+        GtkWidget           *cancel_button;
 
346
+
 
347
         int                  timeout;
 
348
         unsigned int         timeout_id;
 
349
 
 
350
@@ -60,7 +66,8 @@
 
351
 
 
352
 static GsmLogoutDialog *current_dialog = NULL;
 
353
 
 
354
-static void gsm_logout_dialog_set_timeout  (GsmLogoutDialog *logout_dialog);
 
355
+static void gsm_logout_dialog_set_timeout  (GsmLogoutDialog *logout_dialog,
 
356
+                                            int              seconds);
 
357
 
 
358
 static void gsm_logout_dialog_destroy  (GsmLogoutDialog *logout_dialog,
 
359
                                         gpointer         data);
 
360
@@ -68,43 +75,10 @@
 
361
 static void gsm_logout_dialog_show     (GsmLogoutDialog *logout_dialog,
 
362
                                         gpointer         data);
 
363
 
 
364
-enum {
 
365
-        PROP_0,
 
366
-        PROP_MESSAGE_TYPE
 
367
-};
 
368
-
 
369
-G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_MESSAGE_DIALOG);
 
370
+static void gsm_logout_set_info_text   (GsmLogoutDialog *logout_dialog,
 
371
+                                        int              seconds);
 
372
 
 
373
-static void
 
374
-gsm_logout_dialog_set_property (GObject      *object,
 
375
-                                guint         prop_id,
 
376
-                                const GValue *value,
 
377
-                                GParamSpec   *pspec)
 
378
-{
 
379
-        switch (prop_id) {
 
380
-        case PROP_MESSAGE_TYPE:
 
381
-                break;
 
382
-        default:
 
383
-                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
384
-                break;
 
385
-        }
 
386
-}
 
387
-
 
388
-static void
 
389
-gsm_logout_dialog_get_property (GObject     *object,
 
390
-                                guint        prop_id,
 
391
-                                GValue      *value,
 
392
-                                GParamSpec  *pspec)
 
393
-{
 
394
-        switch (prop_id) {
 
395
-        case PROP_MESSAGE_TYPE:
 
396
-                g_value_set_enum (value, GTK_MESSAGE_WARNING);
 
397
-                break;
 
398
-        default:
 
399
-                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
400
-                break;
 
401
-        }
 
402
-}
 
403
+G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_DIALOG);
 
404
 
 
405
 static void
 
406
 gsm_logout_dialog_class_init (GsmLogoutDialogClass *klass)
 
407
@@ -113,18 +87,6 @@
 
408
 
 
409
         gobject_class = G_OBJECT_CLASS (klass);
 
410
 
 
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;
 
418
-
 
419
-        g_object_class_override_property (gobject_class,
 
420
-                                          PROP_MESSAGE_TYPE,
 
421
-                                          "message-type");
 
422
-
 
423
         g_type_class_add_private (klass, sizeof (GsmLogoutDialogPrivate));
 
424
 }
 
425
 
 
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;
 
431
 
 
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));
 
437
 
 
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);
 
441
+
 
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);
 
447
+
 
448
         logout_dialog->priv->power_manager = gsm_get_power_manager ();
 
449
 
 
450
         logout_dialog->priv->consolekit = gsm_get_consolekit ();
 
451
@@ -247,59 +221,49 @@
 
452
 }
 
453
 
 
454
 static void
 
455
-gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, gpointer user_data)
 
456
+gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog,
 
457
+                        gpointer         user_data)
 
458
 {
 
459
-        gsm_logout_dialog_set_timeout (logout_dialog);
 
460
+        gsm_logout_set_info_text (logout_dialog, AUTOMATIC_ACTION_TIMEOUT);
 
461
+
 
462
+        if (logout_dialog->priv->default_response != GTK_RESPONSE_CANCEL)
 
463
+                gsm_logout_dialog_set_timeout (logout_dialog,
 
464
+                                               AUTOMATIC_ACTION_TIMEOUT);
 
465
 }
 
466
 
 
467
-static gboolean
 
468
-gsm_logout_dialog_timeout (gpointer data)
 
469
+static void
 
470
+gsm_logout_set_info_text (GsmLogoutDialog *logout_dialog,
 
471
+                          int              seconds)
 
472
 {
 
473
-        GsmLogoutDialog *logout_dialog;
 
474
-        char            *seconds_warning;
 
475
-        char            *secondary_text;
 
476
-        int              seconds_to_show;
 
477
+        const char *info_text;
 
478
+        char       *markup;
 
479
         static char     *session_type = NULL;
 
480
 
 
481
-        logout_dialog = (GsmLogoutDialog *) data;
 
482
-
 
483
-        if (!logout_dialog->priv->timeout) {
 
484
-                gtk_dialog_response (GTK_DIALOG (logout_dialog),
 
485
-                                     logout_dialog->priv->default_response);
 
486
-
 
487
-                return FALSE;
 
488
-        }
 
489
-
 
490
-        if (logout_dialog->priv->timeout <= 30) {
 
491
-                seconds_to_show = logout_dialog->priv->timeout;
 
492
-        } else {
 
493
-                seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
 
494
-
 
495
-                if (logout_dialog->priv->timeout % 10)
 
496
-                        seconds_to_show += 10;
 
497
-        }
 
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.",
 
504
+                                      seconds);
 
505
+                break;
 
506
 
 
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.",
 
513
-                                            seconds_to_show);
 
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.",
 
519
+                                      seconds);
 
520
                 break;
 
521
 
 
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.",
 
527
-                                            seconds_to_show);
 
528
+        case GTK_RESPONSE_CANCEL:
 
529
+                info_text = _("You are currently logged in as \"%s\".\n");
 
530
                 break;
 
531
 
 
532
         default:
 
533
                 g_assert_not_reached ();
 
534
         }
 
535
-
 
536
+        
 
537
         if (session_type == NULL) {
 
538
                GsmConsolekit *consolekit;
 
539
 
 
540
@@ -307,48 +271,71 @@
 
541
                 session_type = gsm_consolekit_get_current_session_type (consolekit);
 
542
                 g_object_unref (consolekit);
 
543
         }
 
544
-
 
545
+        
 
546
         if (g_strcmp0 (session_type, GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW) != 0) {
 
547
-                char *name, *tmp;
 
548
-
 
549
+                char *name, *buf, *buf2;
 
550
                 name = g_locale_to_utf8 (g_get_real_name (), -1, NULL, NULL, NULL);
 
551
 
 
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);
 
555
                 }
 
556
-
 
557
+        
 
558
                 if (!name) {
 
559
                         name = g_strdup (g_get_user_name ());
 
560
                 }
 
561
 
 
562
-                tmp = g_strdup_printf (_("You are currently logged in as \"%s\"."), name);
 
563
-                secondary_text = g_strconcat (tmp, "\n", seconds_warning, NULL);
 
564
-                g_free (tmp);
 
565
-
 
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));
 
569
+                g_free (buf);
 
570
+                g_free (buf2);
 
571
                 g_free (name);
 
572
        } else {
 
573
-               secondary_text = g_strdup (seconds_warning);
 
574
+               markup = g_strdup (info_text);
 
575
        }
 
576
+        
 
577
+        gtk_label_set_markup (GTK_LABEL (logout_dialog->priv->info_label),
 
578
+                              markup);
 
579
+            
 
580
+        g_free (markup);
 
581
+}
 
582
 
 
583
-        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog),
 
584
-                                                  secondary_text,
 
585
-                                                  seconds_to_show,
 
586
-                                                  NULL);
 
587
+static gboolean
 
588
+gsm_logout_dialog_timeout (gpointer data)
 
589
+{
 
590
+        GsmLogoutDialog *logout_dialog;
 
591
+        int              seconds_to_show;
 
592
 
 
593
-        logout_dialog->priv->timeout--;
 
594
+        logout_dialog = (GsmLogoutDialog *) data;
 
595
 
 
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);
 
600
+
 
601
+                return FALSE;
 
602
+        }
 
603
+
 
604
+        if (logout_dialog->priv->timeout <= 30) {
 
605
+                seconds_to_show = logout_dialog->priv->timeout;
 
606
+        } else {
 
607
+                seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
 
608
+
 
609
+                if (logout_dialog->priv->timeout % 10)
 
610
+                        seconds_to_show += 10;
 
611
+        }
 
612
+
 
613
+        gsm_logout_set_info_text (logout_dialog, seconds_to_show);
 
614
 
 
615
+        logout_dialog->priv->timeout--;
 
616
+        
 
617
         return TRUE;
 
618
 }
 
619
 
 
620
 static void
 
621
-gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog)
 
622
+gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog,
 
623
+                               int              seconds)
 
624
 {
 
625
-        logout_dialog->priv->timeout = AUTOMATIC_ACTION_TIMEOUT;
 
626
-
 
627
-        /* Sets the secondary text */
 
628
-        gsm_logout_dialog_timeout (logout_dialog);
 
629
+        logout_dialog->priv->timeout = seconds;
 
630
 
 
631
         if (logout_dialog->priv->timeout_id != 0) {
 
632
                 g_source_remove (logout_dialog->priv->timeout_id);
 
633
@@ -360,13 +347,118 @@
 
634
 }
 
635
 
 
636
 static GtkWidget *
 
637
+gsm_logout_tile_new (const char *icon_name,
 
638
+                     const char *title,
 
639
+                     const char *description)
 
640
+{
 
641
+        GtkWidget *button;
 
642
+        GtkWidget *alignment;
 
643
+        GtkWidget *hbox;
 
644
+        GtkWidget *vbox;
 
645
+        GtkWidget *image;
 
646
+        GtkWidget *label;
 
647
+        char      *markup;
 
648
+
 
649
+        g_assert (title != NULL);
 
650
+
 
651
+        button = GTK_WIDGET (gtk_button_new ());
 
652
+        gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 
653
+
 
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);
 
657
+
 
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);
 
664
+        }
 
665
+
 
666
+        vbox = gtk_vbox_new (FALSE, 2);
 
667
+
 
668
+        markup = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
 
669
+                                          title);
 
670
+        label = gtk_label_new (markup);
 
671
+        g_free (markup);
 
672
+
 
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);
 
676
+
 
677
+        gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
 
678
+
 
679
+        if (description != NULL) {
 
680
+                gchar     *markup;
 
681
+                GdkColor  *color;
 
682
+                GtkWidget *label;
 
683
+
 
684
+                color = &GTK_WIDGET (button)->style->fg[GTK_STATE_INSENSITIVE];
 
685
+                markup = g_markup_printf_escaped ("<span size=\"small\" foreground=\"#%.2x%.2x%.2x\">%s</span>", 
 
686
+                                                  color->red,
 
687
+                                                  color->green,
 
688
+                                                  color->blue,
 
689
+                                                  description);
 
690
+                label = gtk_label_new (markup);
 
691
+                g_free (markup);
 
692
+
 
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);
 
697
+
 
698
+                gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
 
699
+        }
 
700
+
 
701
+        gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
 
702
+
 
703
+        return button;
 
704
+}
 
705
+
 
706
+static void
 
707
+gsm_logout_tile_clicked (GtkWidget *tile,
 
708
+                         gpointer   response_p)
 
709
+{
 
710
+        GtkWidget *dialog;
 
711
+
 
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));
 
716
+}
 
717
+
 
718
+static GtkWidget *
 
719
+gsm_logout_append_tile (GtkWidget    *vbox,
 
720
+                        unsigned int  response,
 
721
+                        const char   *icon_name,
 
722
+                        const char   *title,
 
723
+                        const char   *description)
 
724
+{
 
725
+        GtkWidget *tile;
 
726
+
 
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);
 
730
+
 
731
+        g_signal_connect (tile,
 
732
+                          "clicked",
 
733
+                          G_CALLBACK (gsm_logout_tile_clicked),
 
734
+                          GUINT_TO_POINTER (response));
 
735
+
 
736
+        return tile;
 
737
+}
 
738
+
 
739
+static GtkWidget *
 
740
 gsm_get_dialog (GsmDialogLogoutType type,
 
741
                 GdkScreen          *screen,
 
742
                 guint32             activate_time)
 
743
 {
 
744
         GsmLogoutDialog *logout_dialog;
 
745
-        const char      *primary_text;
 
746
+        GtkWidget       *vbox;
 
747
+        GtkWidget       *tile;
 
748
         const char      *icon_name;
 
749
+        const char      *title;
 
750
 
 
751
         if (current_dialog != NULL) {
 
752
                 gtk_widget_destroy (GTK_WIDGET (current_dialog));
 
753
@@ -376,82 +468,118 @@
 
754
 
 
755
         current_dialog = logout_dialog;
 
756
 
 
757
-        gtk_window_set_title (GTK_WINDOW (logout_dialog), "");
 
758
-
 
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,
 
762
+                            FALSE, FALSE, 0);
 
763
+        gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
 
764
+        gtk_widget_show (vbox);
 
765
 
 
766
         icon_name = NULL;
 
767
-        primary_text = NULL;
 
768
+        title = NULL;
 
769
 
 
770
         switch (type) {
 
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");
 
775
 
 
776
                 logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT;
 
777
 
 
778
-                if (gsm_logout_supports_switch_user (logout_dialog)) {
 
779
-                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
780
+
 
781
+                gsm_logout_append_tile (vbox, GSM_LOGOUT_RESPONSE_LOGOUT,
 
782
+                                        GSM_ICON_LOGOUT, _("_Log Out"),
 
783
+                                        _("Ends your session and logs you "
 
784
+                                          "out."));
 
785
+
 
786
+                tile = gsm_logout_append_tile (vbox,
 
787
+                                               GSM_LOGOUT_RESPONSE_SWITCH_USER,
 
788
+                                               GSM_ICON_SWITCH,
 
789
                                                _("_Switch User"),
 
790
-                                               GSM_LOGOUT_RESPONSE_SWITCH_USER);
 
791
+                                               _("Suspends your session, "
 
792
+                                                 "allowing another user to "
 
793
+                                                 "log in and use the "
 
794
+                                                 "computer."));
 
795
+                if (!gsm_logout_supports_switch_user (logout_dialog)) {
 
796
+                        gtk_widget_set_sensitive (tile, FALSE);
 
797
                 }
 
798
 
 
799
-                gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
800
-                                       GTK_STOCK_CANCEL,
 
801
-                                       GTK_RESPONSE_CANCEL);
 
802
-
 
803
-                gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
804
-                                       _("_Log Out"),
 
805
-                                       GSM_LOGOUT_RESPONSE_LOGOUT);
 
806
-
 
807
                 break;
 
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");
 
812
 
 
813
                 logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN;
 
814
 
 
815
-                if (gsm_logout_supports_system_suspend (logout_dialog)) {
 
816
-                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
817
-                                               _("S_uspend"),
 
818
-                                               GSM_LOGOUT_RESPONSE_SLEEP);
 
819
+                tile = gsm_logout_append_tile (vbox,
 
820
+                                               GSM_LOGOUT_RESPONSE_SHUTDOWN,
 
821
+                                               GSM_ICON_SHUTDOWN,
 
822
+                                               _("_Shut Down"),
 
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;
 
832
                 }
 
833
 
 
834
-                if (gsm_logout_supports_system_hibernate (logout_dialog)) {
 
835
-                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
836
-                                               _("_Hibernate"),
 
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);
 
845
                 }
 
846
 
 
847
-                if (gsm_logout_supports_reboot (logout_dialog)) {
 
848
-                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
849
-                                               _("_Restart"),
 
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 "
 
862
+                                                  "stands by."));      
 
863
                 }
 
864
 
 
865
-                gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
866
-                                       GTK_STOCK_CANCEL,
 
867
-                                       GTK_RESPONSE_CANCEL);
 
868
-
 
869
-                if (gsm_logout_supports_shutdown (logout_dialog)) {
 
870
-                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
871
-                                               _("_Shut Down"),
 
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,
 
877
+                                                _("_Hibernate"),
 
878
+                                                _("Suspends your session, "
 
879
+                                                  "using no power until the "
 
880
+                                                  "computer is restarted."));
 
881
                 }
 
882
+                
 
883
                 break;
 
884
         default:
 
885
                 g_assert_not_reached ();
 
886
         }
 
887
 
 
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),
 
892
+                                 TRUE);
 
893
+        gtk_box_pack_start (GTK_BOX (vbox), logout_dialog->priv->info_label,
 
894
+                            TRUE, TRUE, 0);
 
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),
 
899
-                            primary_text);
 
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);
 
903
 
 
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);
 
911
 
 
912
         gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);
 
913