[gnome-session] manager: port to latest shell api



commit 3e66149916912ccbd07d3981730ddc16673fd9c8
Author: Ray Strode <rstrode redhat com>
Date:   Mon Mar 21 14:03:55 2011 -0400

    manager: port to latest shell api
    
    The shell API changed to support multiple
    buttons on the log out dialog (see bug 641375)
    
    This commit brings gnome-session up to speed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645432

 gnome-session/gsm-manager.c |   68 ++++++++++++++++++++++++++++++-----
 gnome-session/gsm-shell.c   |   85 +++++++++++++++++++++++++++++++++++++------
 gnome-session/gsm-shell.h   |    5 ++-
 3 files changed, 136 insertions(+), 22 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index bdea3d6..6dfcd09 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -151,7 +151,9 @@ struct GsmManagerPrivate
         GsmShell               *shell;
         guint                   shell_end_session_dialog_canceled_id;
         guint                   shell_end_session_dialog_open_failed_id;
-        guint                   shell_end_session_dialog_confirmed_id;
+        guint                   shell_end_session_dialog_confirmed_logout_id;
+        guint                   shell_end_session_dialog_confirmed_shutdown_id;
+        guint                   shell_end_session_dialog_confirmed_reboot_id;
 };
 
 enum {
@@ -3086,10 +3088,22 @@ disconnect_shell_dialog_signals (GsmManager *manager)
                 manager->priv->shell_end_session_dialog_canceled_id = 0;
         }
 
-        if (manager->priv->shell_end_session_dialog_confirmed_id != 0) {
+        if (manager->priv->shell_end_session_dialog_confirmed_logout_id != 0) {
                 g_signal_handler_disconnect (manager->priv->shell,
-                                             manager->priv->shell_end_session_dialog_confirmed_id);
-                manager->priv->shell_end_session_dialog_confirmed_id = 0;
+                                             manager->priv->shell_end_session_dialog_confirmed_logout_id);
+                manager->priv->shell_end_session_dialog_confirmed_logout_id = 0;
+        }
+
+        if (manager->priv->shell_end_session_dialog_confirmed_shutdown_id != 0) {
+                g_signal_handler_disconnect (manager->priv->shell,
+                                             manager->priv->shell_end_session_dialog_confirmed_shutdown_id);
+                manager->priv->shell_end_session_dialog_confirmed_shutdown_id = 0;
+        }
+
+        if (manager->priv->shell_end_session_dialog_confirmed_reboot_id != 0) {
+                g_signal_handler_disconnect (manager->priv->shell,
+                                             manager->priv->shell_end_session_dialog_confirmed_reboot_id);
+                manager->priv->shell_end_session_dialog_confirmed_reboot_id = 0;
         }
 
         if (manager->priv->shell_end_session_dialog_open_failed_id != 0) {
@@ -3108,8 +3122,8 @@ on_shell_end_session_dialog_canceled (GsmShell   *shell,
 }
 
 static void
-on_shell_end_session_dialog_confirmed (GsmShell   *shell,
-                                       GsmManager *manager)
+_handle_end_session_dialog_response (GsmManager           *manager,
+                                     GsmManagerLogoutType  logout_type)
 {
         /* Note we're checking for END_SESSION here and
          * QUERY_END_SESSION in the fallback cases elsewhere.
@@ -3126,7 +3140,31 @@ on_shell_end_session_dialog_confirmed (GsmShell   *shell,
         }
 
         manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_FORCE;
+        manager->priv->logout_type = logout_type;
         end_phase (manager);
+}
+
+static void
+on_shell_end_session_dialog_confirmed_logout (GsmShell   *shell,
+                                              GsmManager *manager)
+{
+        _handle_end_session_dialog_response (manager, GSM_MANAGER_LOGOUT_LOGOUT);
+        disconnect_shell_dialog_signals (manager);
+}
+
+static void
+on_shell_end_session_dialog_confirmed_shutdown (GsmShell   *shell,
+                                                GsmManager *manager)
+{
+        _handle_end_session_dialog_response (manager, GSM_MANAGER_LOGOUT_SHUTDOWN);
+        disconnect_shell_dialog_signals (manager);
+}
+
+static void
+on_shell_end_session_dialog_confirmed_reboot (GsmShell   *shell,
+                                              GsmManager *manager)
+{
+        _handle_end_session_dialog_response (manager, GSM_MANAGER_LOGOUT_REBOOT);
         disconnect_shell_dialog_signals (manager);
 }
 
@@ -3148,10 +3186,22 @@ connect_shell_dialog_signals (GsmManager *manager)
                                   G_CALLBACK (on_shell_end_session_dialog_canceled),
                                   manager);
 
-        manager->priv->shell_end_session_dialog_confirmed_id =
+        manager->priv->shell_end_session_dialog_confirmed_logout_id =
+                g_signal_connect (manager->priv->shell,
+                                  "end-session-dialog-confirmed-logout",
+                                  G_CALLBACK (on_shell_end_session_dialog_confirmed_logout),
+                                  manager);
+
+        manager->priv->shell_end_session_dialog_confirmed_shutdown_id =
+                g_signal_connect (manager->priv->shell,
+                                  "end-session-dialog-confirmed-shutdown",
+                                  G_CALLBACK (on_shell_end_session_dialog_confirmed_shutdown),
+                                  manager);
+
+        manager->priv->shell_end_session_dialog_confirmed_reboot_id =
                 g_signal_connect (manager->priv->shell,
-                                  "end-session-dialog-confirmed",
-                                  G_CALLBACK (on_shell_end_session_dialog_confirmed),
+                                  "end-session-dialog-confirmed-reboot",
+                                  G_CALLBACK (on_shell_end_session_dialog_confirmed_reboot),
                                   manager);
 }
 
diff --git a/gnome-session/gsm-shell.c b/gnome-session/gsm-shell.c
index fc2501b..0b26f09 100644
--- a/gnome-session/gsm-shell.c
+++ b/gnome-session/gsm-shell.c
@@ -74,7 +74,9 @@ enum {
         END_SESSION_DIALOG_OPEN_FAILED,
         END_SESSION_DIALOG_CLOSED,
         END_SESSION_DIALOG_CANCELED,
-        END_SESSION_DIALOG_CONFIRMED,
+        END_SESSION_DIALOG_CONFIRMED_LOGOUT,
+        END_SESSION_DIALOG_CONFIRMED_SHUTDOWN,
+        END_SESSION_DIALOG_CONFIRMED_REBOOT,
         NUMBER_OF_SIGNALS
 };
 
@@ -180,11 +182,31 @@ gsm_shell_class_init (GsmShellClass *shell_class)
                               g_cclosure_marshal_VOID__VOID,
                               G_TYPE_NONE, 0);
 
-        signals [END_SESSION_DIALOG_CONFIRMED] =
-                g_signal_new ("end-session-dialog-confirmed",
+        signals [END_SESSION_DIALOG_CONFIRMED_LOGOUT] =
+                g_signal_new ("end-session-dialog-confirmed-logout",
                               G_OBJECT_CLASS_TYPE (object_class),
                               G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed),
+                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_logout),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_CONFIRMED_SHUTDOWN] =
+                g_signal_new ("end-session-dialog-confirmed-shutdown",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_shutdown),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_CONFIRMED_REBOOT] =
+                g_signal_new ("end-session-dialog-confirmed-reboot",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_reboot),
                               NULL,
                               NULL,
                               g_cclosure_marshal_VOID__VOID,
@@ -497,10 +519,39 @@ on_end_session_dialog_canceled (DBusGProxy *proxy,
 }
 
 static void
-on_end_session_dialog_confirmed (DBusGProxy *proxy,
-                                 GsmShell   *shell)
+on_end_session_dialog_confirmed_logout (DBusGProxy *proxy,
+                                        GsmShell   *shell)
 {
-        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED], 0);
+        if (shell->priv->update_idle_id != 0) {
+                g_source_remove (shell->priv->update_idle_id);
+                shell->priv->update_idle_id = 0;
+        }
+
+        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_LOGOUT], 0);
+}
+
+static void
+on_end_session_dialog_confirmed_shutdown (DBusGProxy *proxy,
+                                          GsmShell   *shell)
+{
+        if (shell->priv->update_idle_id != 0) {
+                g_source_remove (shell->priv->update_idle_id);
+                shell->priv->update_idle_id = 0;
+        }
+
+        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_SHUTDOWN], 0);
+}
+
+static void
+on_end_session_dialog_confirmed_reboot (DBusGProxy *proxy,
+                                        GsmShell   *shell)
+{
+        if (shell->priv->update_idle_id != 0) {
+                g_source_remove (shell->priv->update_idle_id);
+                shell->priv->update_idle_id = 0;
+        }
+
+        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_REBOOT], 0);
 }
 
 static void
@@ -591,14 +642,24 @@ gsm_shell_open_end_session_dialog (GsmShell *shell,
                                              "Canceled",
                                              G_CALLBACK (on_end_session_dialog_canceled),
                                              shell, NULL);
-
                 dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy,
-                                         "Confirmed", G_TYPE_INVALID);
+                                         "ConfirmedLogout", G_TYPE_INVALID);
                 dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy,
-                                             "Confirmed",
-                                             G_CALLBACK (on_end_session_dialog_confirmed),
+                                             "ConfirmedLogout",
+                                             G_CALLBACK (on_end_session_dialog_confirmed_logout),
+                                             shell, NULL);
+                dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy,
+                                         "ConfirmedShutdown", G_TYPE_INVALID);
+                dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy,
+                                             "ConfirmedShutdown",
+                                             G_CALLBACK (on_end_session_dialog_confirmed_shutdown),
+                                             shell, NULL);
+                dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy,
+                                         "ConfirmedReboot", G_TYPE_INVALID);
+                dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy,
+                                             "ConfirmedReboot",
+                                             G_CALLBACK (on_end_session_dialog_confirmed_reboot),
                                              shell, NULL);
-
         }
 
         inhibitor_array = get_array_from_store (inhibitors);
diff --git a/gnome-session/gsm-shell.h b/gnome-session/gsm-shell.h
index faafd84..785236a 100644
--- a/gnome-session/gsm-shell.h
+++ b/gnome-session/gsm-shell.h
@@ -65,7 +65,10 @@ struct _GsmShellClass
         void (* end_session_dialog_open_failed)   (GsmShell *shell);
         void (* end_session_dialog_closed)        (GsmShell *shell);
         void (* end_session_dialog_canceled)      (GsmShell *shell);
-        void (* end_session_dialog_confirmed)     (GsmShell *shell);
+
+        void (* end_session_dialog_confirmed_logout)   (GsmShell *shell);
+        void (* end_session_dialog_confirmed_shutdown) (GsmShell *shell);
+        void (* end_session_dialog_confirmed_reboot)   (GsmShell *shell);
 
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]