[gnome-session] shell: listen for 'Closed' signal



commit 1ff1a167dd89046bbbc00f2594a1af310742a25b
Author: Ray Strode <rstrode redhat com>
Date:   Tue Mar 22 12:53:53 2011 -0400

    shell: listen for 'Closed' signal
    
    Right now we track when the shell end
    session dialog is closed by tracking when the
    user clicks cancel or (e.g.) logout.
    
    The problem is, there are other cases besides
    the user hitting a button on the dialog that leads
    to the dialog getting closed.
    
    This commit tracks the closed state of the dialog
    via the closed signal instead of the button siganls.
    
    Upon getting notification of the dialog closing,
    we immediately stop processing updates to the
    inhibitor list.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645485

 gnome-session/gsm-shell.c |   70 ++++++++++++++++++++++++++++++---------------
 gnome-session/gsm-shell.h |    1 +
 2 files changed, 48 insertions(+), 23 deletions(-)
---
diff --git a/gnome-session/gsm-shell.c b/gnome-session/gsm-shell.c
index 9bbd09f..5e4c9f8 100644
--- a/gnome-session/gsm-shell.c
+++ b/gnome-session/gsm-shell.c
@@ -73,6 +73,7 @@ enum {
 enum {
         END_SESSION_DIALOG_OPENED = 0,
         END_SESSION_DIALOG_OPEN_FAILED,
+        END_SESSION_DIALOG_CLOSED,
         END_SESSION_DIALOG_CANCELED,
         END_SESSION_DIALOG_CONFIRMED,
         NUMBER_OF_SIGNALS
@@ -95,6 +96,7 @@ static void     gsm_shell_on_name_owner_changed (DBusGProxy *bus_proxy,
                                                  const char *prev_owner,
                                                  const char *new_owner,
                                                  GsmShell   *shell);
+static void     queue_end_session_dialog_update (GsmShell *shell);
 
 G_DEFINE_TYPE (GsmShell, gsm_shell, G_TYPE_OBJECT);
 
@@ -159,6 +161,16 @@ gsm_shell_class_init (GsmShellClass *shell_class)
                               g_cclosure_marshal_VOID__VOID,
                               G_TYPE_NONE, 0);
 
+        signals [END_SESSION_DIALOG_CLOSED] =
+                g_signal_new ("end-session-dialog-closed",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_closed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE, 0);
+
         signals [END_SESSION_DIALOG_CANCELED] =
                 g_signal_new ("end-session-dialog-canceled",
                               G_OBJECT_CLASS_TYPE (object_class),
@@ -464,15 +476,26 @@ on_open_finished (DBusGProxy     *proxy,
 }
 
 static void
-on_end_session_dialog_canceled (DBusGProxy *proxy,
-                                GsmShell   *shell)
+on_end_session_dialog_closed (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_handlers_disconnect_by_func (shell->priv->inhibitors,
+                                              G_CALLBACK (queue_end_session_dialog_update),
+                                              shell);
         shell->priv->has_open_dialog = FALSE;
+
+        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CLOSED], 0);
+}
+
+static void
+on_end_session_dialog_canceled (DBusGProxy *proxy,
+                                GsmShell   *shell)
+{
         g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CANCELED], 0);
 }
 
@@ -480,12 +503,6 @@ static void
 on_end_session_dialog_confirmed (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;
-        }
-
-        shell->priv->has_open_dialog = FALSE;
         g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED], 0);
 }
 
@@ -570,6 +587,13 @@ gsm_shell_open_end_session_dialog (GsmShell *shell,
                                   shell);
 
                 dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy,
+                                         "Closed", G_TYPE_INVALID);
+                dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy,
+                                             "Closed",
+                                             G_CALLBACK (on_end_session_dialog_closed),
+                                             shell, NULL);
+
+                dbus_g_proxy_add_signal (shell->priv->end_session_dialog_proxy,
                                          "Canceled", G_TYPE_INVALID);
                 dbus_g_proxy_connect_signal (shell->priv->end_session_dialog_proxy,
                                              "Canceled",
@@ -611,24 +635,24 @@ gsm_shell_open_end_session_dialog (GsmShell *shell,
                 return FALSE;
         }
 
-        if (inhibitors != shell->priv->inhibitors) {
-                if (shell->priv->inhibitors != NULL) {
-                        g_signal_handlers_disconnect_by_func (shell->priv->inhibitors,
-                                                              G_CALLBACK (queue_end_session_dialog_update),
-                                                              shell);
-                        g_object_unref (shell->priv->inhibitors);
-                }
+        g_object_ref (inhibitors);
+
+        if (shell->priv->inhibitors != NULL) {
+                g_signal_handlers_disconnect_by_func (shell->priv->inhibitors,
+                                                      G_CALLBACK (queue_end_session_dialog_update),
+                                                      shell);
+                g_object_unref (shell->priv->inhibitors);
+        }
 
-                shell->priv->inhibitors = g_object_ref (inhibitors);
+        shell->priv->inhibitors = inhibitors;
 
-                g_signal_connect_swapped (inhibitors, "added",
-                                          G_CALLBACK (queue_end_session_dialog_update),
-                                          shell);
+        g_signal_connect_swapped (inhibitors, "added",
+                                  G_CALLBACK (queue_end_session_dialog_update),
+                                  shell);
 
-                g_signal_connect_swapped (inhibitors, "removed",
-                                          G_CALLBACK (queue_end_session_dialog_update),
-                                          shell);
-        }
+        g_signal_connect_swapped (inhibitors, "removed",
+                                  G_CALLBACK (queue_end_session_dialog_update),
+                                  shell);
 
         shell->priv->end_session_open_call = call;
         shell->priv->end_session_dialog_type = type;
diff --git a/gnome-session/gsm-shell.h b/gnome-session/gsm-shell.h
index 74a617d..faafd84 100644
--- a/gnome-session/gsm-shell.h
+++ b/gnome-session/gsm-shell.h
@@ -63,6 +63,7 @@ struct _GsmShellClass
 
         void (* end_session_dialog_opened)        (GsmShell *shell);
         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);
 



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