[empathy] account-widget: delay 'close' signal if enabling the account



commit 852af596dcc11e104a5565e953240af2f83b4cc2
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue May 8 13:46:48 2012 +0200

    account-widget: delay 'close' signal if enabling the account
    
    The whole point of this signal is to tell to user when it can be destroyed, so
    we shouldn't fire it if we are still pending on an async call.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675667

 libempathy-gtk/empathy-account-widget.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 6848c87..96e6a88 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -903,6 +903,8 @@ account_widget_account_enabled_cb (GObject *source_object,
       empathy_connect_new_account (account, self->priv->account_manager);
     }
 
+  g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY);
+
   /* unref self - part of the workaround */
   g_object_unref (self);
 }
@@ -917,6 +919,7 @@ account_widget_applied_cb (GObject *source_object,
   EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
   EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (user_data);
   gboolean reconnect_required;
+  gboolean fire_close = TRUE;
 
   empathy_account_settings_apply_finish (settings, res, &reconnect_required,
       &error);
@@ -942,6 +945,9 @@ account_widget_applied_cb (GObject *source_object,
           tp_account_set_enabled_async (account, TRUE,
               account_widget_account_enabled_cb, self);
           g_signal_emit (self, signals[ACCOUNT_CREATED], 0, account);
+
+          /* Will be fired in account_widget_account_enabled_cb */
+          fire_close = FALSE;
         }
       else
         {
@@ -969,8 +975,11 @@ account_widget_applied_cb (GObject *source_object,
 
   self->priv->contains_pending_changes = FALSE;
 
-  /* announce the widget can be closed */
-  g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY);
+  if (fire_close)
+    {
+      /* announce the widget can be closed */
+      g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY);
+    }
 
   /* unref the widget - part of the workaround */
   g_object_unref (self);



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