gnome-session r4750 - in branches/dbus_based: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4750 - in branches/dbus_based: . gnome-session
- Date: Mon, 16 Jun 2008 04:52:39 +0000 (UTC)
Author: mccann
Date: Mon Jun 16 04:52:39 2008
New Revision: 4750
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4750&view=rev
Log:
2008-06-16 William Jon McCann <jmccann redhat com>
* gnome-session/gsm-consolekit.c (get_action_from_error):
* gnome-session/gsm-logout-dialog.c (gsm_get_dialog),
(gsm_get_shutdown_dialog), (gsm_get_logout_dialog):
* gnome-session/gsm-logout-dialog.h:
* gnome-session/gsm-manager.c (on_client_disconnected),
(gsm_manager_init), (manager_request_reboot),
(manager_request_shutdown), (_shutdown_client), (manager_logout),
(manager_request_hibernate), (manager_request_sleep),
(logout_dialog_response), (show_shutdown_dialog),
(show_logout_dialog), (initiate_logout), (gsm_manager_shutdown),
(gsm_manager_logout):
Fix and simplify shutdown handling.
Modified:
branches/dbus_based/ChangeLog
branches/dbus_based/gnome-session/gsm-consolekit.c
branches/dbus_based/gnome-session/gsm-logout-dialog.c
branches/dbus_based/gnome-session/gsm-logout-dialog.h
branches/dbus_based/gnome-session/gsm-manager.c
Modified: branches/dbus_based/gnome-session/gsm-consolekit.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-consolekit.c (original)
+++ branches/dbus_based/gnome-session/gsm-consolekit.c Mon Jun 16 04:52:39 2008
@@ -466,18 +466,28 @@
get_action_from_error (GError *error)
{
PolKitAction *action;
- const char *paction;
+ char *paction;
action = polkit_action_new ();
paction = NULL;
-
if (g_str_has_prefix (error->message, "Not privileged for action: ")) {
- paction = error->message + strlen ("Not privileged for action: ");
+ paction = g_strdup (error->message + strlen ("Not privileged for action: "));
+ if (paction != NULL) {
+ char *p;
+
+ /* after 0.2.10 the error also includes the PK results */
+ p = strchr (paction, ' ');
+ if (p != NULL) {
+ *p = '\0';
+ }
+ }
}
polkit_action_set_action_id (action, paction);
+ g_free (paction);
+
return action;
}
#endif /* HAVE_POLKIT_GNOME */
Modified: branches/dbus_based/gnome-session/gsm-logout-dialog.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-logout-dialog.c (original)
+++ branches/dbus_based/gnome-session/gsm-logout-dialog.c Mon Jun 16 04:52:39 2008
@@ -41,6 +41,11 @@
#define GSM_ICON_LOGOUT "gnome-logout"
#define GSM_ICON_SHUTDOWN "gnome-shutdown"
+typedef enum {
+ GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
+ GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN
+} GsmDialogLogoutType;
+
struct _GsmLogoutDialogPrivate
{
GsmDialogLogoutType type;
@@ -312,10 +317,10 @@
logout_dialog);
}
-GtkWidget *
-gsm_get_logout_dialog (GsmDialogLogoutType type,
- GdkScreen *screen,
- guint32 activate_time)
+static GtkWidget *
+gsm_get_dialog (GsmDialogLogoutType type,
+ GdkScreen *screen,
+ guint32 activate_time)
{
GsmLogoutDialog *logout_dialog;
const char *primary_text;
@@ -409,3 +414,21 @@
return GTK_WIDGET (logout_dialog);
}
+
+GtkWidget *
+gsm_get_shutdown_dialog (GdkScreen *screen,
+ guint32 activate_time)
+{
+ return gsm_get_dialog (GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN,
+ screen,
+ activate_time);
+}
+
+GtkWidget *
+gsm_get_logout_dialog (GdkScreen *screen,
+ guint32 activate_time)
+{
+ return gsm_get_dialog (GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
+ screen,
+ activate_time);
+}
Modified: branches/dbus_based/gnome-session/gsm-logout-dialog.h
==============================================================================
--- branches/dbus_based/gnome-session/gsm-logout-dialog.h (original)
+++ branches/dbus_based/gnome-session/gsm-logout-dialog.h Mon Jun 16 04:52:39 2008
@@ -61,15 +61,11 @@
GtkMessageDialogClass parent_class;
};
-typedef enum {
- GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
- GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN
-} GsmDialogLogoutType;
-
GType gsm_logout_dialog_get_type (void) G_GNUC_CONST;
-GtkWidget *gsm_get_logout_dialog (GsmDialogLogoutType type,
- GdkScreen *screen,
+GtkWidget *gsm_get_logout_dialog (GdkScreen *screen,
+ guint32 activate_time);
+GtkWidget *gsm_get_shutdown_dialog (GdkScreen *screen,
guint32 activate_time);
G_END_DECLS
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 04:52:39 2008
@@ -78,27 +78,10 @@
guint timeout_id;
GSList *pending_apps;
-
- /* When shutdown starts, all clients are put into shutdown_clients.
- * If they request phase2, they are moved from shutdown_clients to
- * phase2_clients. If they request interaction, they are appended
- * to interact_clients (the first client in interact_clients is
- * the one currently interacting). If they report that they're done,
- * they're removed from shutdown_clients/phase2_clients.
- *
- * Once shutdown_clients is empty, phase2 starts. Once phase2_clients
- * is empty, shutdown is complete.
- */
- GSList *shutdown_clients;
- GSList *interact_clients;
- GSList *phase2_clients;
-
/* List of clients which were disconnected due to disabled condition
* and shouldn't be automatically restarted */
GSList *condition_clients;
- int logout_response_id;
-
DBusGProxy *bus_proxy;
DBusGConnection *connection;
};
@@ -483,10 +466,6 @@
gsm_client_store_remove (manager->priv->store, client);
- manager->priv->shutdown_clients = g_slist_remove (manager->priv->shutdown_clients, client);
- manager->priv->interact_clients = g_slist_remove (manager->priv->interact_clients, client);
- manager->priv->phase2_clients = g_slist_remove (manager->priv->phase2_clients, client);
-
if (g_slist_find (manager->priv->condition_clients, client)) {
manager->priv->condition_clients = g_slist_remove (manager->priv->condition_clients, client);
@@ -1094,8 +1073,6 @@
g_str_equal,
g_free,
g_object_unref);
-
- manager->priv->logout_response_id = GTK_RESPONSE_NONE;
}
static void
@@ -1207,44 +1184,24 @@
}
}
-static gboolean
-_stop_client (const char *id,
- GsmClient *client,
- gpointer data)
+static void
+manager_request_reboot (GsmManager *manager)
{
- gsm_client_stop (client);
+ GsmConsolekit *consolekit;
- return FALSE;
+ consolekit = gsm_get_consolekit ();
+ do_request_reboot (consolekit);
+ g_object_unref (consolekit);
}
static void
-manager_shutdown (GsmManager *manager)
+manager_request_shutdown (GsmManager *manager)
{
GsmConsolekit *consolekit;
- /* Emit session over signal */
- g_signal_emit (manager, signals[SESSION_OVER], 0);
-
- /* FIXME: do this in reverse phase order */
- gsm_client_store_foreach (manager->priv->store,
- (GsmClientStoreFunc)_stop_client,
- NULL);
-
- switch (manager->priv->logout_response_id) {
- case GSM_LOGOUT_RESPONSE_SHUTDOWN:
- consolekit = gsm_get_consolekit ();
- do_request_shutdown (consolekit);
- g_object_unref (consolekit);
- break;
- case GSM_LOGOUT_RESPONSE_REBOOT:
- consolekit = gsm_get_consolekit ();
- do_request_reboot (consolekit);
- g_object_unref (consolekit);
- break;
- default:
- gtk_main_quit ();
- break;
- }
+ consolekit = gsm_get_consolekit ();
+ do_request_shutdown (consolekit);
+ g_object_unref (consolekit);
}
static gboolean
@@ -1252,30 +1209,48 @@
GsmClient *client,
GsmManager *manager)
{
- manager->priv->shutdown_clients = g_slist_prepend (manager->priv->shutdown_clients, client);
-
gsm_client_save_yourself (client, FALSE);
-
return FALSE;
}
static void
-initiate_shutdown (GsmManager *manager)
+manager_logout (GsmManager *manager)
{
- manager->priv->phase = GSM_MANAGER_PHASE_SHUTDOWN;
+ /* FIXME: ask clients to delay logout */
- g_debug ("GsmManager: initiating shutdown");
+ gsm_client_store_foreach (manager->priv->store,
+ (GsmClientStoreFunc)_shutdown_client,
+ NULL);
+
+ gtk_main_quit ();
+}
+
+static void
+manager_request_hibernate (GsmManager *manager)
+{
+ GsmPowerManager *power_manager;
- /* lock the client store so no clients may be added */
- gsm_client_store_set_locked (manager->priv->store, TRUE);
+ power_manager = gsm_get_power_manager ();
- if (gsm_client_store_size (manager->priv->store) == 0) {
- manager_shutdown (manager);
+ if (gsm_power_manager_can_hibernate (power_manager)) {
+ gsm_power_manager_attempt_hibernate (power_manager);
}
- gsm_client_store_foreach (manager->priv->store,
- (GsmClientStoreFunc)_shutdown_client,
- NULL);
+ g_object_unref (power_manager);
+}
+
+static void
+manager_request_sleep (GsmManager *manager)
+{
+ GsmPowerManager *power_manager;
+
+ power_manager = gsm_get_power_manager ();
+
+ if (gsm_power_manager_can_suspend (power_manager)) {
+ gsm_power_manager_attempt_suspend (power_manager);
+ }
+
+ g_object_unref (power_manager);
}
static void
@@ -1283,60 +1258,85 @@
guint response_id,
GsmManager *manager)
{
- 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
- * perform the respective action and return, without shutting down the
- * session. */
+ /* In case of dialog cancel, switch user, hibernate and
+ * suspend, we just perform the respective action and return,
+ * without shutting down the session. */
switch (response_id) {
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_NONE:
case GTK_RESPONSE_DELETE_EVENT:
- return;
-
+ break;
case GSM_LOGOUT_RESPONSE_SWITCH_USER:
gdm_new_login ();
- return;
-
+ break;
case GSM_LOGOUT_RESPONSE_STD:
- power_manager = gsm_get_power_manager ();
-
- if (gsm_power_manager_can_hibernate (power_manager)) {
- gsm_power_manager_attempt_hibernate (power_manager);
- }
+ manager_request_hibernate (manager);
+ break;
+ case GSM_LOGOUT_RESPONSE_STR:
+ manager_request_sleep (manager);
+ break;
+ case GSM_LOGOUT_RESPONSE_SHUTDOWN:
+ manager_request_shutdown (manager);
+ break;
+ case GSM_LOGOUT_RESPONSE_REBOOT:
+ manager_request_reboot (manager);
+ break;
+ case GSM_LOGOUT_RESPONSE_LOGOUT:
+ manager_logout (manager);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
- g_object_unref (power_manager);
+static void
+show_shutdown_dialog (GsmManager *manager)
+{
+ GtkWidget *dialog;
+ if (manager->priv->phase == GSM_MANAGER_PHASE_SHUTDOWN) {
+ /* Already shutting down, nothing more to do */
return;
+ }
- case GSM_LOGOUT_RESPONSE_STR:
- power_manager = gsm_get_power_manager ();
+ dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (),
+ gtk_get_current_event_time ());
- if (gsm_power_manager_can_suspend (power_manager)) {
- gsm_power_manager_attempt_suspend (power_manager);
- }
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (logout_dialog_response),
+ manager);
+ gtk_widget_show (dialog);
+}
- g_object_unref (power_manager);
+static void
+show_logout_dialog (GsmManager *manager)
+{
+ GtkWidget *dialog;
+ if (manager->priv->phase == GSM_MANAGER_PHASE_SHUTDOWN) {
+ /* Already shutting down, nothing more to do */
return;
-
- default:
- break;
}
- manager->priv->logout_response_id = response_id;
+ dialog = gsm_get_logout_dialog (gdk_screen_get_default (),
+ gtk_get_current_event_time ());
- initiate_shutdown (manager);
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (logout_dialog_response),
+ manager);
+ gtk_widget_show (dialog);
}
static void
-gsm_manager_initiate_shutdown (GsmManager *manager,
- gboolean show_confirmation,
- GsmManagerLogoutType logout_type)
+initiate_logout (GsmManager *manager,
+ gboolean show_confirmation)
{
gboolean logout_prompt;
GConfClient *client;
@@ -1355,27 +1355,13 @@
/* Global settings overides input parameter in order to disable confirmation
* dialog accordingly. If we're shutting down, we always show the confirmation
* dialog */
- logout_prompt = (logout_prompt && show_confirmation) ||
- (logout_type == GSM_MANAGER_LOGOUT_TYPE_SHUTDOWN);
+ logout_prompt = (logout_prompt && show_confirmation);
if (logout_prompt) {
- GtkWidget *logout_dialog;
-
- logout_dialog = gsm_get_logout_dialog (logout_type,
- gdk_screen_get_default (),
- gtk_get_current_event_time ());
-
- g_signal_connect (G_OBJECT (logout_dialog),
- "response",
- G_CALLBACK (logout_dialog_response),
- manager);
-
- gtk_widget_show (logout_dialog);
-
- return;
+ show_logout_dialog (manager);
+ } else {
+ manager_logout (manager);
}
-
- initiate_shutdown (manager);
}
/*
@@ -1399,9 +1385,7 @@
return FALSE;
}
- gsm_manager_initiate_shutdown (manager,
- TRUE,
- GSM_MANAGER_LOGOUT_TYPE_SHUTDOWN);
+ show_shutdown_dialog (manager);
return TRUE;
}
@@ -1423,11 +1407,11 @@
switch (logout_mode) {
case GSM_MANAGER_LOGOUT_MODE_NORMAL:
- gsm_manager_initiate_shutdown (manager, TRUE, GSM_MANAGER_LOGOUT_TYPE_LOGOUT);
+ initiate_logout (manager, TRUE);
break;
case GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION:
- gsm_manager_initiate_shutdown (manager, FALSE, GSM_MANAGER_LOGOUT_TYPE_LOGOUT);
+ initiate_logout (manager, FALSE);
break;
case GSM_MANAGER_LOGOUT_MODE_FORCE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]