~ubuntu-branches/ubuntu/oneiric/gnome-session/oneiric-proposed

« back to all changes in this revision

Viewing changes to gnome-session/gsm-logout-dialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-07-11 16:39:56 UTC
  • Revision ID: james.westby@ubuntu.com-20110711163956-16xi409pbfc58ox4
Tags: 3.1.3-0ubuntu2
* 03_display_session_capplet.patch: display the session properties capplet, 
  the list is cleaned from the system services now and it can be useful 
  for users who want to start softwares with the session (lp: #802218)
* series: comment 80_new_upstream_session_dialog, the modified version never
  went in upstream git and has issues with gtk3, if the upstream dialog is
  not working fine in our desktop we should discuss how to maintain a custom
  session dialog in a better way (lp:807503)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#define LOCKDOWN_SCHEMA            "org.gnome.desktop.lockdown"
44
44
#define KEY_DISABLE_USER_SWITCHING "disable-user-switching"
45
45
 
46
 
#define GSM_ICON_LOGOUT    "system-log-out"
47
 
#define GSM_ICON_SWITCH    "system-users"
48
 
#define GSM_ICON_SHUTDOWN  "system-shutdown"
49
 
#define GSM_ICON_REBOOT    "view-refresh"
50
 
/* TODO: use gpm icons? */
51
 
#define GSM_ICON_HIBERNATE "drive-harddisk"
52
 
#define GSM_ICON_SLEEP     "gnome-session-sleep"
53
 
 
54
46
typedef enum {
55
47
        GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
56
48
        GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN
58
50
 
59
51
struct _GsmLogoutDialogPrivate
60
52
{
 
53
        GsmDialogLogoutType  type;
 
54
 
61
55
        UpClient            *up_client;
62
56
        GsmConsolekit       *consolekit;
63
57
 
64
 
        GtkWidget           *info_label;
65
 
        GtkWidget           *cancel_button;
66
 
 
67
58
        int                  timeout;
68
59
        unsigned int         timeout_id;
69
60
 
72
63
 
73
64
static GsmLogoutDialog *current_dialog = NULL;
74
65
 
75
 
static void gsm_logout_dialog_set_timeout  (GsmLogoutDialog *logout_dialog,
76
 
                                            int              seconds);
 
66
static void gsm_logout_dialog_set_timeout  (GsmLogoutDialog *logout_dialog);
77
67
 
78
68
static void gsm_logout_dialog_destroy  (GsmLogoutDialog *logout_dialog,
79
69
                                        gpointer         data);
81
71
static void gsm_logout_dialog_show     (GsmLogoutDialog *logout_dialog,
82
72
                                        gpointer         data);
83
73
 
84
 
static void gsm_logout_set_info_text   (GsmLogoutDialog *logout_dialog,
85
 
                                        int              seconds);
86
 
 
87
 
G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_DIALOG);
 
74
enum {
 
75
        PROP_0,
 
76
        PROP_MESSAGE_TYPE
 
77
};
 
78
 
 
79
G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_MESSAGE_DIALOG);
 
80
 
 
81
static void
 
82
gsm_logout_dialog_set_property (GObject      *object,
 
83
                                guint         prop_id,
 
84
                                const GValue *value,
 
85
                                GParamSpec   *pspec)
 
86
{
 
87
        switch (prop_id) {
 
88
        case PROP_MESSAGE_TYPE:
 
89
                break;
 
90
        default:
 
91
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
92
                break;
 
93
        }
 
94
}
 
95
 
 
96
static void
 
97
gsm_logout_dialog_get_property (GObject     *object,
 
98
                                guint        prop_id,
 
99
                                GValue      *value,
 
100
                                GParamSpec  *pspec)
 
101
{
 
102
        switch (prop_id) {
 
103
        case PROP_MESSAGE_TYPE:
 
104
                g_value_set_enum (value, GTK_MESSAGE_WARNING);
 
105
                break;
 
106
        default:
 
107
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
108
                break;
 
109
        }
 
110
}
88
111
 
89
112
static void
90
113
gsm_logout_dialog_class_init (GsmLogoutDialogClass *klass)
93
116
 
94
117
        gobject_class = G_OBJECT_CLASS (klass);
95
118
 
 
119
        /* This is a workaround to avoid a stupid crash: libgnomeui
 
120
         * listens for the "show" signal on all GtkMessageDialog and
 
121
         * gets the "message-type" of the dialogs. We will crash when
 
122
         * it accesses this property if we don't override it since we
 
123
         * didn't define it. */
 
124
        gobject_class->set_property = gsm_logout_dialog_set_property;
 
125
        gobject_class->get_property = gsm_logout_dialog_get_property;
 
126
 
 
127
        g_object_class_override_property (gobject_class,
 
128
                                          PROP_MESSAGE_TYPE,
 
129
                                          "message-type");
 
130
 
96
131
        g_type_class_add_private (klass, sizeof (GsmLogoutDialogPrivate));
97
132
}
98
133
 
104
139
        logout_dialog->priv->timeout_id = 0;
105
140
        logout_dialog->priv->timeout = 0;
106
141
        logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;
107
 
        logout_dialog->priv->info_label = NULL;
108
142
 
109
 
        gtk_window_set_resizable (GTK_WINDOW (logout_dialog), FALSE);
 
143
        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
110
144
        gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
111
145
        gtk_window_stick (GTK_WINDOW (logout_dialog));
112
146
 
113
 
        /* use HIG spacings */
114
 
        gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (logout_dialog))), 12);
115
 
        gtk_container_set_border_width (GTK_CONTAINER (logout_dialog), 6);
116
 
 
117
 
        gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_HELP,
118
 
                               GTK_RESPONSE_HELP);
119
 
        logout_dialog->priv->cancel_button =
120
 
                gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
121
 
                                       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
122
 
 
123
147
        logout_dialog->priv->up_client = up_client_new ();
124
148
 
125
149
        logout_dialog->priv->consolekit = gsm_get_consolekit ();
215
239
static void
216
240
gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, gpointer user_data)
217
241
{
218
 
        gsm_logout_set_info_text (logout_dialog, AUTOMATIC_ACTION_TIMEOUT);
219
 
 
220
 
        if (logout_dialog->priv->default_response != GTK_RESPONSE_CANCEL)
221
 
                gsm_logout_dialog_set_timeout (logout_dialog,
222
 
                                               AUTOMATIC_ACTION_TIMEOUT);
 
242
        gsm_logout_dialog_set_timeout (logout_dialog);
223
243
}
224
244
 
225
 
 
226
 
static void
227
 
gsm_logout_set_info_text (GsmLogoutDialog *logout_dialog,
228
 
                          int              seconds_to_show)
 
245
static gboolean
 
246
gsm_logout_dialog_timeout (gpointer data)
229
247
{
230
 
        const char  *seconds_warning;
231
 
        char        *secondary_text;
232
 
        char        *buf;
233
 
        char        *markup;
234
 
        static char *session_type = NULL;
235
 
 
236
 
        switch (logout_dialog->priv->default_response) {
237
 
        case GSM_LOGOUT_RESPONSE_LOGOUT:
 
248
        GsmLogoutDialog *logout_dialog;
 
249
        char            *seconds_warning;
 
250
        char            *secondary_text;
 
251
        int              seconds_to_show;
 
252
        static char     *session_type = NULL;
 
253
 
 
254
        logout_dialog = (GsmLogoutDialog *) data;
 
255
 
 
256
        if (!logout_dialog->priv->timeout) {
 
257
                gtk_dialog_response (GTK_DIALOG (logout_dialog),
 
258
                                     logout_dialog->priv->default_response);
 
259
 
 
260
                return FALSE;
 
261
        }
 
262
 
 
263
        if (logout_dialog->priv->timeout <= 30) {
 
264
                seconds_to_show = logout_dialog->priv->timeout;
 
265
        } else {
 
266
                seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
 
267
 
 
268
                if (logout_dialog->priv->timeout % 10)
 
269
                        seconds_to_show += 10;
 
270
        }
 
271
 
 
272
        switch (logout_dialog->priv->type) {
 
273
        case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
238
274
                /* This string is shared with gsm-fail-whale-dialog.c */
239
275
                seconds_warning = ngettext ("You will be automatically logged "
240
276
                                            "out in %d second.",
243
279
                                            seconds_to_show);
244
280
                break;
245
281
 
246
 
        case GSM_LOGOUT_RESPONSE_SHUTDOWN:
 
282
        case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
247
283
                seconds_warning = ngettext ("This system will be automatically "
248
284
                                            "shut down in %d second.",
249
285
                                            "This system will be automatically "
251
287
                                            seconds_to_show);
252
288
                break;
253
289
 
254
 
        case GTK_RESPONSE_CANCEL:
255
 
                seconds_warning = "";
256
 
                break;
257
 
 
258
290
        default:
259
291
                g_assert_not_reached ();
260
292
        }
289
321
                secondary_text = g_strdup (seconds_warning);
290
322
        }
291
323
 
292
 
        buf = g_strdup_printf (secondary_text, seconds_to_show);
293
 
        markup = g_markup_printf_escaped ("<i>%s</i>", buf);
294
 
        g_free (buf);
295
 
        gtk_label_set_markup (GTK_LABEL (logout_dialog->priv->info_label),
296
 
                              markup);
297
 
        g_free (markup);
298
 
}
299
 
 
300
 
static gboolean
301
 
gsm_logout_dialog_timeout (gpointer data)
302
 
{
303
 
        GsmLogoutDialog *logout_dialog;
304
 
        int              seconds_to_show;
305
 
 
306
 
        logout_dialog = (GsmLogoutDialog *) data;
307
 
 
308
 
        if (!logout_dialog->priv->timeout) {
309
 
                gtk_dialog_response (GTK_DIALOG (logout_dialog),
310
 
                                     logout_dialog->priv->default_response);
311
 
 
312
 
                return FALSE;
313
 
        }
314
 
 
315
 
        if (logout_dialog->priv->timeout <= 30) {
316
 
                seconds_to_show = logout_dialog->priv->timeout;
317
 
        } else {
318
 
                seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
319
 
 
320
 
                if (logout_dialog->priv->timeout % 10)
321
 
                        seconds_to_show += 10;
322
 
        }
323
 
 
324
 
        gsm_logout_set_info_text (logout_dialog, seconds_to_show);
 
324
        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog),
 
325
                                                  secondary_text,
 
326
                                                  seconds_to_show,
 
327
                                                  NULL);
325
328
 
326
329
        logout_dialog->priv->timeout--;
327
330
 
 
331
        g_free (secondary_text);
 
332
 
328
333
        return TRUE;
329
334
}
330
335
 
331
336
static void
332
 
gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog,
333
 
                               int              seconds)
 
337
gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog)
334
338
{
335
 
        logout_dialog->priv->timeout = seconds;
 
339
        logout_dialog->priv->timeout = AUTOMATIC_ACTION_TIMEOUT;
 
340
 
 
341
        /* Sets the secondary text */
 
342
        gsm_logout_dialog_timeout (logout_dialog);
336
343
 
337
344
        if (logout_dialog->priv->timeout_id != 0) {
338
345
                g_source_remove (logout_dialog->priv->timeout_id);
344
351
}
345
352
 
346
353
static GtkWidget *
347
 
gsm_logout_tile_new (const char *icon_name,
348
 
                     const char *title,
349
 
                     const char *description)
350
 
{
351
 
        GtkWidget *button;
352
 
        GtkWidget *alignment;
353
 
        GtkWidget *hbox;
354
 
        GtkWidget *vbox;
355
 
        GtkWidget *image;
356
 
        GtkWidget *label;
357
 
        char      *markup;
358
 
 
359
 
        g_assert (title != NULL);
360
 
 
361
 
        button = GTK_WIDGET (gtk_button_new ());
362
 
        gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
363
 
 
364
 
        alignment = gtk_alignment_new (0, 0.5, 0, 0);
365
 
        gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 6, 6);
366
 
        gtk_container_add (GTK_CONTAINER (button), alignment);
367
 
 
368
 
        hbox = gtk_hbox_new (FALSE, 12);
369
 
        gtk_container_add (GTK_CONTAINER (alignment), hbox);
370
 
        if (icon_name != NULL) {
371
 
                image = gtk_image_new_from_icon_name (icon_name,
372
 
                                                      GTK_ICON_SIZE_DIALOG);
373
 
                gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
374
 
        }
375
 
 
376
 
        vbox = gtk_vbox_new (FALSE, 2);
377
 
 
378
 
        markup = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
379
 
                                          title);
380
 
        label = gtk_label_new (markup);
381
 
        g_free (markup);
382
 
 
383
 
        gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
384
 
        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
385
 
        gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
386
 
 
387
 
        gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
388
 
 
389
 
        if (description != NULL) {
390
 
                gchar     *markup;
391
 
                GdkColor  *color;
392
 
                GtkWidget *label;
393
 
                GtkStyle  *style;
394
 
 
395
 
                style = gtk_widget_get_style (GTK_WIDGET (button));
396
 
                color = &style->fg[GTK_STATE_INSENSITIVE];
397
 
                markup = g_markup_printf_escaped ("<span size=\"small\" foreground=\"#%.2x%.2x%.2x\">%s</span>",
398
 
                                                  color->red,
399
 
                                                  color->green,
400
 
                                                  color->blue,
401
 
                                                  description);
402
 
                label = gtk_label_new (markup);
403
 
                g_free (markup);
404
 
 
405
 
                gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
406
 
                gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
407
 
                gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
408
 
                gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
409
 
 
410
 
                gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
411
 
        }
412
 
 
413
 
        gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
414
 
 
415
 
        return button;
416
 
}
417
 
 
418
 
static void
419
 
gsm_logout_tile_clicked (GtkWidget *tile,
420
 
                         gpointer   response_p)
421
 
{
422
 
        GtkWidget *dialog;
423
 
 
424
 
        dialog = gtk_widget_get_toplevel (tile);
425
 
        g_assert (GTK_IS_DIALOG (dialog));
426
 
        gtk_dialog_response (GTK_DIALOG (dialog),
427
 
                             GPOINTER_TO_UINT (response_p));
428
 
}
429
 
 
430
 
static GtkWidget *
431
 
gsm_logout_append_tile (GtkWidget    *vbox,
432
 
                        unsigned int  response,
433
 
                        const char   *icon_name,
434
 
                        const char   *title,
435
 
                        const char   *description)
436
 
{
437
 
        GtkWidget *tile;
438
 
 
439
 
        tile = gsm_logout_tile_new (icon_name, title, description);
440
 
        gtk_box_pack_start (GTK_BOX (vbox), tile, TRUE, TRUE, 0);
441
 
        gtk_widget_show_all (tile);
442
 
 
443
 
        g_signal_connect (tile,
444
 
                          "clicked",
445
 
                          G_CALLBACK (gsm_logout_tile_clicked),
446
 
                          GUINT_TO_POINTER (response));
447
 
 
448
 
        return tile;
449
 
}
450
 
 
451
 
static GtkWidget *
452
354
gsm_get_dialog (GsmDialogLogoutType type,
453
355
                GdkScreen          *screen,
454
356
                guint32             activate_time)
455
357
{
456
358
        GsmLogoutDialog *logout_dialog;
457
 
        GtkWidget       *vbox;
458
 
        GtkWidget       *tile;
 
359
        GtkWidget       *dialog_image;
 
360
        const char      *primary_text;
459
361
        const char      *icon_name;
460
 
        const char      *title;
461
362
 
462
363
        if (current_dialog != NULL) {
463
364
                gtk_widget_destroy (GTK_WIDGET (current_dialog));
467
368
 
468
369
        current_dialog = logout_dialog;
469
370
 
470
 
        vbox = gtk_vbox_new (FALSE, 12);
471
 
        gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (logout_dialog))), vbox,
472
 
                            FALSE, FALSE, 0);
473
 
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
474
 
        gtk_widget_show (vbox);
 
371
        gtk_window_set_title (GTK_WINDOW (logout_dialog), "");
 
372
 
 
373
        logout_dialog->priv->type = type;
475
374
 
476
375
        icon_name = NULL;
477
 
        title = NULL;
 
376
        primary_text = NULL;
478
377
 
479
378
        switch (type) {
480
379
        case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
481
380
                icon_name    = GSM_ICON_LOGOUT;
482
 
                title        = _("Log Out of the Session");
 
381
                primary_text = _("Log out of this system now?");
483
382
 
484
383
                logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT;
485
384
 
486
 
 
487
 
                gsm_logout_append_tile (vbox, GSM_LOGOUT_RESPONSE_LOGOUT,
488
 
                                        GSM_ICON_LOGOUT, _("_Log Out"),
489
 
                                        _("Ends your session and logs you "
490
 
                                          "out."));
491
 
 
492
 
                tile = gsm_logout_append_tile (vbox,
493
 
                                               GSM_LOGOUT_RESPONSE_SWITCH_USER,
494
 
                                               GSM_ICON_SWITCH,
 
385
                if (gsm_logout_supports_switch_user (logout_dialog)) {
 
386
                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
495
387
                                               _("_Switch User"),
496
 
                                               _("Suspends your session, "
497
 
                                                 "allowing another user to "
498
 
                                                 "log in and use the "
499
 
                                                 "computer."));
500
 
                if (!gsm_logout_supports_switch_user (logout_dialog)) {
501
 
                        gtk_widget_set_sensitive (tile, FALSE);
 
388
                                               GSM_LOGOUT_RESPONSE_SWITCH_USER);
502
389
                }
503
390
 
 
391
                gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
392
                                       GTK_STOCK_CANCEL,
 
393
                                       GTK_RESPONSE_CANCEL);
 
394
 
 
395
                gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
396
                                       _("_Log Out"),
 
397
                                       GSM_LOGOUT_RESPONSE_LOGOUT);
 
398
 
504
399
                break;
505
400
        case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
506
401
                icon_name    = GSM_ICON_SHUTDOWN;
507
 
                title        = _("Shut Down the Computer");
 
402
                primary_text = _("Shut down this system now?");
508
403
 
509
404
                logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN;
510
405
 
511
 
                tile = gsm_logout_append_tile (vbox,
512
 
                                               GSM_LOGOUT_RESPONSE_SHUTDOWN,
513
 
                                               GSM_ICON_SHUTDOWN,
514
 
                                               _("_Shut Down"),
515
 
                                               _("Ends your session and turns "
516
 
                                                 "off the computer."));
517
 
                if (!gsm_logout_supports_shutdown (logout_dialog)) {
518
 
                        gtk_widget_set_sensitive (tile, FALSE);
519
 
                        /* If shutdown is not available, let's just fallback
520
 
                         * on cancel as the default action. We could fallback
521
 
                         * on reboot first, then suspend and then hibernate
522
 
                         * but it's not that useful, really */
523
 
                        logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;
524
 
                }
525
 
 
526
 
                tile = gsm_logout_append_tile (vbox,
527
 
                                               GSM_LOGOUT_RESPONSE_REBOOT,
528
 
                                               GSM_ICON_REBOOT, _("_Restart"),
529
 
                                               _("Ends your session and "
530
 
                                                 "restarts the computer."));
531
 
                if (!gsm_logout_supports_reboot (logout_dialog)) {
532
 
                        gtk_widget_set_sensitive (tile, FALSE);
533
 
                }
534
 
 
535
 
                /* We don't set those options insensitive if they are no
536
 
                 * supported (like we do for shutdown/restart) since some
537
 
                 * hardware just don't support suspend/hibernate. So we
538
 
                 * don't show those options in this case. */
539
406
                if (gsm_logout_supports_system_suspend (logout_dialog)) {
540
 
                        gsm_logout_append_tile (vbox,
541
 
                                                GSM_LOGOUT_RESPONSE_SLEEP,
542
 
                                                GSM_ICON_SLEEP, _("S_uspend"),
543
 
                                                _("Suspends your session "
544
 
                                                  "quickly, using minimal "
545
 
                                                  "power while the computer "
546
 
                                                  "stands by."));
 
407
                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
408
                                               _("S_uspend"),
 
409
                                               GSM_LOGOUT_RESPONSE_SLEEP);
547
410
                }
548
411
 
549
412
                if (gsm_logout_supports_system_hibernate (logout_dialog)) {
550
 
                        gsm_logout_append_tile (vbox,
551
 
                                                GSM_LOGOUT_RESPONSE_HIBERNATE,
552
 
                                                GSM_ICON_HIBERNATE,
553
 
                                                _("_Hibernate"),
554
 
                                                _("Suspends your session, "
555
 
                                                  "using no power until the "
556
 
                                                  "computer is restarted."));
557
 
                }
558
 
 
 
413
                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
414
                                               _("_Hibernate"),
 
415
                                               GSM_LOGOUT_RESPONSE_HIBERNATE);
 
416
                }
 
417
 
 
418
                if (gsm_logout_supports_reboot (logout_dialog)) {
 
419
                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
420
                                               _("_Restart"),
 
421
                                               GSM_LOGOUT_RESPONSE_REBOOT);
 
422
                }
 
423
 
 
424
                gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
425
                                       GTK_STOCK_CANCEL,
 
426
                                       GTK_RESPONSE_CANCEL);
 
427
 
 
428
                if (gsm_logout_supports_shutdown (logout_dialog)) {
 
429
                        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
 
430
                                               _("_Shut Down"),
 
431
                                               GSM_LOGOUT_RESPONSE_SHUTDOWN);
 
432
                }
559
433
                break;
560
434
        default:
561
435
                g_assert_not_reached ();
562
436
        }
563
437
 
564
 
        logout_dialog->priv->info_label = gtk_label_new ("");
565
 
        gtk_label_set_line_wrap (GTK_LABEL (logout_dialog->priv->info_label),
566
 
                                 TRUE);
567
 
        gtk_box_pack_start (GTK_BOX (vbox), logout_dialog->priv->info_label,
568
 
                            TRUE, TRUE, 0);
569
 
        gtk_widget_show (logout_dialog->priv->info_label);
 
438
        dialog_image = gtk_message_dialog_get_image (GTK_MESSAGE_DIALOG (logout_dialog));
570
439
 
 
440
        gtk_image_set_from_icon_name (GTK_IMAGE (dialog_image),
 
441
                                      icon_name, GTK_ICON_SIZE_DIALOG);
571
442
        gtk_window_set_icon_name (GTK_WINDOW (logout_dialog), icon_name);
572
 
        gtk_window_set_title (GTK_WINDOW (logout_dialog), title);
573
 
        gtk_window_set_position (GTK_WINDOW (logout_dialog),
574
 
                                 GTK_WIN_POS_CENTER_ALWAYS);
 
443
        gtk_window_set_position (GTK_WINDOW (logout_dialog), GTK_WIN_POS_CENTER_ALWAYS);
 
444
        gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (logout_dialog), primary_text);
575
445
 
576
446
        gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog),
577
447
                                         logout_dialog->priv->default_response);
578
 
        /* Note that focus is on the widget for the default response by default
579
 
         * (since they're the first widget, except when it's Cancel */
580
 
        if (logout_dialog->priv->default_response == GTK_RESPONSE_CANCEL)
581
 
                gtk_window_set_focus (GTK_WINDOW (logout_dialog),
582
 
                                      logout_dialog->priv->cancel_button);
583
448
 
584
449
        gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);
585
450