gnome-session r4748 - in branches/dbus_based: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4748 - in branches/dbus_based: . gnome-session
- Date: Mon, 16 Jun 2008 03:14:40 +0000 (UTC)
Author: mccann
Date: Mon Jun 16 03:14:39 2008
New Revision: 4748
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4748&view=rev
Log:
2008-06-15 William Jon McCann <jmccann redhat com>
* configure.in:
* gnome-session/gsm-manager.c (initiate_shutdown),
(logout_dialog_response), (gsm_manager_logout):
* gnome-session/logout-dialog.c (gsm_logout_dialog_set_property),
(gsm_logout_dialog_get_property), (on_ck_request_completed),
(gsm_logout_dialog_destroy), (gsm_logout_supports_reboot),
(gsm_logout_supports_shutdown), (gsm_logout_dialog_timeout),
(gsm_logout_dialog_set_timeout), (gsm_get_logout_dialog):
* gnome-session/logout-dialog.h:
Add config summary. Add some debug spew.
Modified:
branches/dbus_based/ChangeLog
branches/dbus_based/configure.in
branches/dbus_based/gnome-session/gsm-manager.c
branches/dbus_based/gnome-session/logout-dialog.c
branches/dbus_based/gnome-session/logout-dialog.h
Modified: branches/dbus_based/configure.in
==============================================================================
--- branches/dbus_based/configure.in (original)
+++ branches/dbus_based/configure.in Mon Jun 16 03:14:39 2008
@@ -6,7 +6,7 @@
AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-bzip2])
AM_MAINTAINER_MODE
-
+
GNOME_COMMON_INIT
GNOME_DEBUG_CHECK
@@ -60,7 +60,7 @@
POLKIT_GNOME_REQUIRED=0.7
dnl ====================================================================
-dnl Dependency Checks
+dnl Dependency Checks
dnl ====================================================================
PKG_PROG_PKG_CONFIG()
@@ -89,7 +89,7 @@
fi
dnl ====================================================================
-dnl GConf Checks
+dnl GConf Checks
dnl ====================================================================
AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
if test x"$GCONFTOOL" = xno; then
@@ -111,9 +111,9 @@
AC_SUBST(GCONF_SANITY_CHECK)
PATH=$old_path
-
+
dnl ====================================================================
-dnl GNOME Keyring Checks
+dnl GNOME Keyring Checks
dnl ====================================================================
AC_PATH_PROG(GNOME_KEYRING_DAEMON, gnome-keyring-daemon, no)
if test x"$GNOME_KEYRING_DAEMON" = xno; then
@@ -161,7 +161,7 @@
AC_SUBST(X_LIBS)
dnl ====================================================================
-dnl Language Support
+dnl Language Support
dnl ====================================================================
GETTEXT_PACKAGE=gnome-session-2.0
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
@@ -171,7 +171,7 @@
AM_GLIB_GNU_GETTEXT
dnl ====================================================================
-dnl Headers
+dnl Headers
dnl ====================================================================
AC_HEADER_STDC
AC_CHECK_HEADERS(syslog.h tcpd.h sys/param.h)
@@ -277,3 +277,27 @@
data/icons/scalable/Makefile
po/Makefile.in
])
+
+dnl ---------------------------------------------------------------------------
+dnl - Show summary
+dnl ---------------------------------------------------------------------------
+
+echo "
+ gnome-session $VERSION
+ =====================
+
+ prefix: ${prefix}
+ exec_prefix: ${exec_prefix}
+ libdir: ${libdir}
+ bindir: ${bindir}
+ sbindir: ${sbindir}
+ sysconfdir: ${sysconfdir}
+ localstatedir: ${localstatedir}
+ datadir: ${datadir}
+ source code location: ${srcdir}
+ compiler: ${CC}
+ cflags: ${CFLAGS}
+ Maintainer mode: ${USE_MAINTAINER_MODE}
+
+ PolicyKit support : ${have_polkit}
+"
Modified: branches/dbus_based/gnome-session/gsm-manager.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-manager.c (original)
+++ branches/dbus_based/gnome-session/gsm-manager.c Mon Jun 16 03:14:39 2008
@@ -1264,6 +1264,8 @@
{
manager->priv->phase = GSM_MANAGER_PHASE_SHUTDOWN;
+ g_debug ("GsmManager: initiating shutdown");
+
/* lock the client store so no clients may be added */
gsm_client_store_set_locked (manager->priv->store, TRUE);
@@ -1283,6 +1285,8 @@
{
GsmPowerManager *power_manager;
+ g_debug ("GsmManager: Logout dialog response: %d", response_id);
+
gtk_widget_destroy (GTK_WIDGET (logout_dialog));
/* In case of dialog cancel, switch user, hibernate and suspend, we just
@@ -1407,7 +1411,7 @@
gint logout_mode,
GError **error)
{
- g_debug ("GsmManager: Shutdown called");
+ g_debug ("GsmManager: Logout called");
if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) {
g_set_error (error,
Modified: branches/dbus_based/gnome-session/logout-dialog.c
==============================================================================
--- branches/dbus_based/gnome-session/logout-dialog.c (original)
+++ branches/dbus_based/gnome-session/logout-dialog.c Mon Jun 16 03:14:39 2008
@@ -1,4 +1,5 @@
-/* logout-dialog.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
* Copyright (C) 2006 Vincent Untz
*
* This program is free software; you can redistribute it and/or
@@ -34,7 +35,7 @@
#include "gsm-consolekit.h"
#include "gdm.h"
-#define GSM_LOGOUT_DIALOG_GET_PRIVATE(o) \
+#define GSM_LOGOUT_DIALOG_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_LOGOUT_DIALOG, GsmLogoutDialogPrivate))
#define AUTOMATIC_ACTION_TIMEOUT 60
@@ -42,17 +43,17 @@
#define GSM_ICON_LOGOUT "gnome-logout"
#define GSM_ICON_SHUTDOWN "gnome-shutdown"
-struct _GsmLogoutDialogPrivate
+struct _GsmLogoutDialogPrivate
{
- GsmDialogLogoutType type;
-
- GsmPowerManager *power_manager;
- GsmConsolekit *consolekit;
-
- int timeout;
- unsigned int timeout_id;
-
- unsigned int default_response;
+ GsmDialogLogoutType type;
+
+ GsmPowerManager *power_manager;
+ GsmConsolekit *consolekit;
+
+ int timeout;
+ unsigned int timeout_id;
+
+ unsigned int default_response;
};
static GsmLogoutDialog *current_dialog = NULL;
@@ -60,362 +61,353 @@
static void gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog);
static void gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog,
- gpointer data);
+ gpointer data);
static void gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog,
- gpointer data);
+ gpointer data);
enum {
- PROP_0,
- PROP_MESSAGE_TYPE
+ PROP_0,
+ PROP_MESSAGE_TYPE
};
G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_MESSAGE_DIALOG);
-static void
+static void
gsm_logout_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_MESSAGE_TYPE:
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id) {
+ case PROP_MESSAGE_TYPE:
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static void
+static void
gsm_logout_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_MESSAGE_TYPE:
- g_value_set_enum (value, GTK_MESSAGE_WARNING);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id) {
+ case PROP_MESSAGE_TYPE:
+ g_value_set_enum (value, GTK_MESSAGE_WARNING);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gsm_logout_dialog_class_init (GsmLogoutDialogClass *klass)
{
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
-
- /* This is a workaround to avoid a stupid crash: libgnomeui
- * listens for the "show" signal on all GtkMessageDialog and
- * gets the "message-type" of the dialogs. We will crash when
- * it accesses this property if we don't override it since we
- * didn't define it. */
- gobject_class->set_property = gsm_logout_dialog_set_property;
- gobject_class->get_property = gsm_logout_dialog_get_property;
-
- g_object_class_override_property (gobject_class,
- PROP_MESSAGE_TYPE,
- "message-type");
-
- g_type_class_add_private (klass, sizeof (GsmLogoutDialogPrivate));
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+
+ /* This is a workaround to avoid a stupid crash: libgnomeui
+ * listens for the "show" signal on all GtkMessageDialog and
+ * gets the "message-type" of the dialogs. We will crash when
+ * it accesses this property if we don't override it since we
+ * didn't define it. */
+ gobject_class->set_property = gsm_logout_dialog_set_property;
+ gobject_class->get_property = gsm_logout_dialog_get_property;
+
+ g_object_class_override_property (gobject_class,
+ PROP_MESSAGE_TYPE,
+ "message-type");
+
+ g_type_class_add_private (klass, sizeof (GsmLogoutDialogPrivate));
}
static void
on_ck_request_completed (GsmConsolekit *consolekit,
GError *error)
{
- if (error == NULL)
- {
- /* request was successful */
- return;
- }
+ if (error == NULL) {
+ /* request was successful */
+ return;
+ }
}
static void
gsm_logout_dialog_init (GsmLogoutDialog *logout_dialog)
{
- logout_dialog->priv = GSM_LOGOUT_DIALOG_GET_PRIVATE (logout_dialog);
-
- logout_dialog->priv->timeout_id = 0;
- logout_dialog->priv->timeout = 0;
- logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;
-
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
- gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
- gtk_window_stick (GTK_WINDOW (logout_dialog));
-
- logout_dialog->priv->power_manager = gsm_get_power_manager ();
-
- logout_dialog->priv->consolekit = gsm_get_consolekit ();
-
- g_signal_connect (logout_dialog->priv->consolekit,
- "request-completed",
- G_CALLBACK (on_ck_request_completed),
- NULL);
-
- g_signal_connect (logout_dialog,
- "destroy",
- G_CALLBACK (gsm_logout_dialog_destroy),
- NULL);
-
- g_signal_connect (logout_dialog,
- "show",
- G_CALLBACK (gsm_logout_dialog_show),
- NULL);
+ logout_dialog->priv = GSM_LOGOUT_DIALOG_GET_PRIVATE (logout_dialog);
+
+ logout_dialog->priv->timeout_id = 0;
+ logout_dialog->priv->timeout = 0;
+ logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;
+
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
+ gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
+ gtk_window_stick (GTK_WINDOW (logout_dialog));
+
+ logout_dialog->priv->power_manager = gsm_get_power_manager ();
+
+ logout_dialog->priv->consolekit = gsm_get_consolekit ();
+
+ g_signal_connect (logout_dialog->priv->consolekit,
+ "request-completed",
+ G_CALLBACK (on_ck_request_completed),
+ NULL);
+
+ g_signal_connect (logout_dialog,
+ "destroy",
+ G_CALLBACK (gsm_logout_dialog_destroy),
+ NULL);
+
+ g_signal_connect (logout_dialog,
+ "show",
+ G_CALLBACK (gsm_logout_dialog_show),
+ NULL);
}
static void
gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog,
- gpointer data)
+ gpointer data)
{
- if (logout_dialog->priv->timeout_id != 0)
- {
- g_source_remove (logout_dialog->priv->timeout_id);
- logout_dialog->priv->timeout_id = 0;
- }
-
- if (logout_dialog->priv->power_manager)
- {
- g_object_unref (logout_dialog->priv->power_manager);
- logout_dialog->priv->power_manager = NULL;
- }
-
- if (logout_dialog->priv->consolekit)
- {
- g_object_unref (logout_dialog->priv->consolekit);
- logout_dialog->priv->consolekit = NULL;
- }
+ if (logout_dialog->priv->timeout_id != 0) {
+ g_source_remove (logout_dialog->priv->timeout_id);
+ logout_dialog->priv->timeout_id = 0;
+ }
+
+ if (logout_dialog->priv->power_manager) {
+ g_object_unref (logout_dialog->priv->power_manager);
+ logout_dialog->priv->power_manager = NULL;
+ }
+
+ if (logout_dialog->priv->consolekit) {
+ g_object_unref (logout_dialog->priv->consolekit);
+ logout_dialog->priv->consolekit = NULL;
+ }
- current_dialog = NULL;
+ current_dialog = NULL;
}
static gboolean
gsm_logout_supports_reboot (GsmLogoutDialog *logout_dialog)
{
- gboolean ret;
+ gboolean ret;
- ret = gsm_consolekit_can_restart (logout_dialog->priv->consolekit);
- if (!ret)
- {
- ret = gdm_supports_logout_action (GDM_LOGOUT_ACTION_REBOOT);
- }
+ ret = gsm_consolekit_can_restart (logout_dialog->priv->consolekit);
+ if (!ret) {
+ ret = gdm_supports_logout_action (GDM_LOGOUT_ACTION_REBOOT);
+ }
- return ret;
+ return ret;
}
static gboolean
gsm_logout_supports_shutdown (GsmLogoutDialog *logout_dialog)
{
- gboolean ret;
+ gboolean ret;
- ret = gsm_consolekit_can_stop (logout_dialog->priv->consolekit);
+ ret = gsm_consolekit_can_stop (logout_dialog->priv->consolekit);
- if (!ret)
- {
- ret = gdm_supports_logout_action (GDM_LOGOUT_ACTION_SHUTDOWN);
- }
+ if (!ret) {
+ ret = gdm_supports_logout_action (GDM_LOGOUT_ACTION_SHUTDOWN);
+ }
- return ret;
+ return ret;
}
static void
gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, gpointer user_data)
{
- gsm_logout_dialog_set_timeout (logout_dialog);
+ gsm_logout_dialog_set_timeout (logout_dialog);
}
static gboolean
gsm_logout_dialog_timeout (gpointer data)
{
- GsmLogoutDialog *logout_dialog;
- char *secondary_text;
- const char *name;
- int seconds_to_show;
-
- logout_dialog = (GsmLogoutDialog *) data;
-
- if (!logout_dialog->priv->timeout)
- {
- gtk_dialog_response (GTK_DIALOG (logout_dialog),
- logout_dialog->priv->default_response);
-
- return FALSE;
- }
-
- if (logout_dialog->priv->timeout <= 30)
- {
- seconds_to_show = logout_dialog->priv->timeout;
- }
- else
- {
- seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
-
- if (logout_dialog->priv->timeout % 10)
- seconds_to_show += 10;
- }
-
- switch (logout_dialog->priv->type)
- {
- case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
- secondary_text = ngettext ("You are currently logged in as "
- "\"%s\".\n"
- "You will be automatically logged "
- "out in %d second.",
- "You are currently logged in as "
- "\"%s\".\n"
- "You will be automatically logged "
- "out in %d seconds.",
- seconds_to_show);
- break;
-
- case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
- secondary_text = ngettext ("You are currently logged in as "
- "\"%s\".\n"
- "This system will be automatically "
- "shut down in %d second.",
- "You are currently logged in as "
- "\"%s\".\n"
- "This system will be automatically "
- "shut down in %d seconds.",
- seconds_to_show);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- name = g_get_real_name ();
-
- if (!name || name[0] == '\0')
- name = g_get_user_name ();
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog),
- secondary_text,
- name,
- seconds_to_show,
- NULL);
-
- logout_dialog->priv->timeout--;
-
- return TRUE;
+ GsmLogoutDialog *logout_dialog;
+ char *secondary_text;
+ const char *name;
+ int seconds_to_show;
+
+ logout_dialog = (GsmLogoutDialog *) data;
+
+ if (!logout_dialog->priv->timeout) {
+ gtk_dialog_response (GTK_DIALOG (logout_dialog),
+ logout_dialog->priv->default_response);
+
+ return FALSE;
+ }
+
+ if (logout_dialog->priv->timeout <= 30) {
+ seconds_to_show = logout_dialog->priv->timeout;
+ } else {
+ seconds_to_show = (logout_dialog->priv->timeout/10) * 10;
+
+ if (logout_dialog->priv->timeout % 10)
+ seconds_to_show += 10;
+ }
+
+ switch (logout_dialog->priv->type) {
+ case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
+ secondary_text = ngettext ("You are currently logged in as "
+ "\"%s\".\n"
+ "You will be automatically logged "
+ "out in %d second.",
+ "You are currently logged in as "
+ "\"%s\".\n"
+ "You will be automatically logged "
+ "out in %d seconds.",
+ seconds_to_show);
+ break;
+
+ case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
+ secondary_text = ngettext ("You are currently logged in as "
+ "\"%s\".\n"
+ "This system will be automatically "
+ "shut down in %d second.",
+ "You are currently logged in as "
+ "\"%s\".\n"
+ "This system will be automatically "
+ "shut down in %d seconds.",
+ seconds_to_show);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ name = g_get_real_name ();
+
+ if (!name || name[0] == '\0') {
+ name = g_get_user_name ();
+ }
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog),
+ secondary_text,
+ name,
+ seconds_to_show,
+ NULL);
+
+ logout_dialog->priv->timeout--;
+
+ return TRUE;
}
static void
gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog)
{
- logout_dialog->priv->timeout = AUTOMATIC_ACTION_TIMEOUT;
-
- /* Sets the secondary text */
- gsm_logout_dialog_timeout (logout_dialog);
-
- if (logout_dialog->priv->timeout_id != 0)
- g_source_remove (logout_dialog->priv->timeout_id);
-
- logout_dialog->priv->timeout_id = g_timeout_add (1000,
- gsm_logout_dialog_timeout,
- logout_dialog);
+ logout_dialog->priv->timeout = AUTOMATIC_ACTION_TIMEOUT;
+
+ /* Sets the secondary text */
+ gsm_logout_dialog_timeout (logout_dialog);
+
+ if (logout_dialog->priv->timeout_id != 0) {
+ g_source_remove (logout_dialog->priv->timeout_id);
+ }
+
+ logout_dialog->priv->timeout_id = g_timeout_add (1000,
+ gsm_logout_dialog_timeout,
+ logout_dialog);
}
GtkWidget *
gsm_get_logout_dialog (GsmDialogLogoutType type,
- GdkScreen *screen,
- guint32 activate_time)
+ GdkScreen *screen,
+ guint32 activate_time)
{
- GsmLogoutDialog *logout_dialog;
- const char *primary_text;
- const char *icon_name;
-
- if (current_dialog != NULL)
- {
- gtk_widget_destroy (GTK_WIDGET (current_dialog));
- }
-
- logout_dialog = g_object_new (GSM_TYPE_LOGOUT_DIALOG, NULL);
-
- current_dialog = logout_dialog;
-
- gtk_window_set_title (GTK_WINDOW (logout_dialog), "");
-
- logout_dialog->priv->type = type;
-
- icon_name = NULL;
- primary_text = NULL;
-
- switch (type)
- {
- case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
- icon_name = GSM_ICON_LOGOUT;
- primary_text = _("Log out of this system now?");
-
- logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT;
-
- if (gdm_is_available ()) {
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- _("_Switch User"),
- GSM_LOGOUT_RESPONSE_SWITCH_USER);
- }
-
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
-
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- _("_Log Out"),
- GSM_LOGOUT_RESPONSE_LOGOUT);
-
- break;
- case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
- icon_name = GSM_ICON_SHUTDOWN;
- primary_text = _("Shut down this system now?");
-
- logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN;
-
- if (gsm_power_manager_can_suspend (logout_dialog->priv->power_manager))
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- _("S_uspend"),
- GSM_LOGOUT_RESPONSE_STR);
-
- if (gsm_power_manager_can_hibernate (logout_dialog->priv->power_manager))
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- _("_Hibernate"),
- GSM_LOGOUT_RESPONSE_STD);
-
- if (gsm_logout_supports_reboot (logout_dialog))
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- _("_Restart"),
- GSM_LOGOUT_RESPONSE_REBOOT);
-
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
-
- if (gsm_logout_supports_shutdown (logout_dialog))
- gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
- _("_Shut Down"),
- GSM_LOGOUT_RESPONSE_SHUTDOWN);
- break;
- default:
- g_assert_not_reached ();
- }
-
- gtk_image_set_from_icon_name (GTK_IMAGE (GTK_MESSAGE_DIALOG (logout_dialog)->image),
- icon_name, GTK_ICON_SIZE_DIALOG);
-
- gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (logout_dialog)->label),
- primary_text);
-
- gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog),
- logout_dialog->priv->default_response);
-
- gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);
+ GsmLogoutDialog *logout_dialog;
+ const char *primary_text;
+ const char *icon_name;
+
+ if (current_dialog != NULL) {
+ gtk_widget_destroy (GTK_WIDGET (current_dialog));
+ }
+
+ logout_dialog = g_object_new (GSM_TYPE_LOGOUT_DIALOG, NULL);
+
+ current_dialog = logout_dialog;
+
+ gtk_window_set_title (GTK_WINDOW (logout_dialog), "");
+
+ logout_dialog->priv->type = type;
+
+ icon_name = NULL;
+ primary_text = NULL;
+
+ switch (type) {
+ case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
+ icon_name = GSM_ICON_LOGOUT;
+ primary_text = _("Log out of this system now?");
+
+ logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT;
+
+ if (gdm_is_available ()) {
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ _("_Switch User"),
+ GSM_LOGOUT_RESPONSE_SWITCH_USER);
+ }
+
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ _("_Log Out"),
+ GSM_LOGOUT_RESPONSE_LOGOUT);
+
+ break;
+ case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
+ icon_name = GSM_ICON_SHUTDOWN;
+ primary_text = _("Shut down this system now?");
+
+ logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN;
+
+ if (gsm_power_manager_can_suspend (logout_dialog->priv->power_manager)) {
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ _("S_uspend"),
+ GSM_LOGOUT_RESPONSE_STR);
+ }
+
+ if (gsm_power_manager_can_hibernate (logout_dialog->priv->power_manager)) {
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ _("_Hibernate"),
+ GSM_LOGOUT_RESPONSE_STD);
+ }
+
+ if (gsm_logout_supports_reboot (logout_dialog)) {
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ _("_Restart"),
+ GSM_LOGOUT_RESPONSE_REBOOT);
+ }
+
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL);
+
+ if (gsm_logout_supports_shutdown (logout_dialog)) {
+ gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
+ _("_Shut Down"),
+ GSM_LOGOUT_RESPONSE_SHUTDOWN);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ gtk_image_set_from_icon_name (GTK_IMAGE (GTK_MESSAGE_DIALOG (logout_dialog)->image),
+ icon_name, GTK_ICON_SIZE_DIALOG);
+
+ gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (logout_dialog)->label),
+ primary_text);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog),
+ logout_dialog->priv->default_response);
+
+ gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);
- return GTK_WIDGET (logout_dialog);
+ return GTK_WIDGET (logout_dialog);
}
Modified: branches/dbus_based/gnome-session/logout-dialog.h
==============================================================================
--- branches/dbus_based/gnome-session/logout-dialog.h (original)
+++ branches/dbus_based/gnome-session/logout-dialog.h Mon Jun 16 03:14:39 2008
@@ -1,4 +1,5 @@
-/* logout-dialog.h:
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
* Copyright (C) 2006 Vincent Untz
*
* This program is free software; you can redistribute it and/or
@@ -27,14 +28,14 @@
G_BEGIN_DECLS
-enum
+enum
{
- GSM_LOGOUT_RESPONSE_LOGOUT,
- GSM_LOGOUT_RESPONSE_SWITCH_USER,
- GSM_LOGOUT_RESPONSE_SHUTDOWN,
- GSM_LOGOUT_RESPONSE_REBOOT,
- GSM_LOGOUT_RESPONSE_STD,
- GSM_LOGOUT_RESPONSE_STR
+ GSM_LOGOUT_RESPONSE_LOGOUT,
+ GSM_LOGOUT_RESPONSE_SWITCH_USER,
+ GSM_LOGOUT_RESPONSE_SHUTDOWN,
+ GSM_LOGOUT_RESPONSE_REBOOT,
+ GSM_LOGOUT_RESPONSE_STD,
+ GSM_LOGOUT_RESPONSE_STR
};
#define GSM_TYPE_LOGOUT_DIALOG (gsm_logout_dialog_get_type ())
@@ -48,16 +49,16 @@
typedef struct _GsmLogoutDialogClass GsmLogoutDialogClass;
typedef struct _GsmLogoutDialogPrivate GsmLogoutDialogPrivate;
-struct _GsmLogoutDialog
+struct _GsmLogoutDialog
{
- GtkMessageDialog parent;
-
- GsmLogoutDialogPrivate *priv;
+ GtkMessageDialog parent;
+
+ GsmLogoutDialogPrivate *priv;
};
-struct _GsmLogoutDialogClass
+struct _GsmLogoutDialogClass
{
- GtkMessageDialogClass parent_class;
+ GtkMessageDialogClass parent_class;
};
typedef enum {
@@ -68,8 +69,8 @@
GType gsm_logout_dialog_get_type (void) G_GNUC_CONST;
GtkWidget *gsm_get_logout_dialog (GsmDialogLogoutType type,
- GdkScreen *screen,
- guint32 activate_time);
+ GdkScreen *screen,
+ guint32 activate_time);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]