[empathy] accounts-dialog: block the selection 'changed' signal while removing a row



commit 0e7074dbf801ca17ab88c15e9d261b244d2ecdd5
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Feb 15 13:28:20 2010 +0000

    accounts-dialog: block the selection 'changed' signal while removing a row
    
    There is no need to call accounts_dialog_model_selection_changed while removing
    as we are going to call accounts_dialog_model_select_first right after which
    will update the selection.
    
    This has the nice side effect of letting the "remove" button sensitive after
    the account has been removed. The callback used to be called recursively twice:
    once during the removal of the row and once when calling
    accounts_dialog_model_select_first in accounts_dialog_update_settings.
    As accounts_dialog_model_selection_changed is checking if a row is selected
    *before* calling accounts_dialog_update_settings, the button was unsensitived
    at the end of the first call of the callback. (#609575)

 src/empathy-accounts-dialog.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 2770c71..ca06e14 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -175,6 +175,10 @@ static void accounts_dialog_presence_changed_cb (TpAccount *account,
     gchar *status_message,
     EmpathyAccountsDialog *dialog);
 
+static void accounts_dialog_model_selection_changed (
+    GtkTreeSelection *selection,
+    EmpathyAccountsDialog *dialog);
+
 static void
 accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
     const gchar *display_name)
@@ -1035,7 +1039,17 @@ accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
           account = NULL;
         }
 
+      /* No need to call accounts_dialog_model_selection_changed while
+       * removing as we are going to call accounts_dialog_model_select_first
+       * right after which will update the selection. */
+      g_signal_handlers_block_by_func (selection,
+          accounts_dialog_model_selection_changed, account_dialog);
+
       gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+
+      g_signal_handlers_unblock_by_func (selection,
+          accounts_dialog_model_selection_changed, account_dialog);
+
       accounts_dialog_model_select_first (account_dialog);
     }
 



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