[evolution/gnome-3-10] Bug #707518 - Deleting a local address book triggers error "Unable to open address book"



commit d90cd8b67ef62e1994dd7bf080bde96035834bdf
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jan 27 14:51:26 2014 +0100

    Bug #707518 - Deleting a local address book triggers error "Unable to open address book"

 e-util/e-source-selector.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-source-selector.c b/e-util/e-source-selector.c
index e84566d..a68556f 100644
--- a/e-util/e-source-selector.c
+++ b/e-util/e-source-selector.c
@@ -104,6 +104,9 @@ G_DEFINE_TYPE (
        e_cell_renderer_safe_toggle,
        GTK_TYPE_CELL_RENDERER_TOGGLE)
 
+static void selection_changed_callback (GtkTreeSelection *selection,
+                                       ESourceSelector *selector);
+
 static gboolean
 safe_toggle_activate (GtkCellRenderer *cell,
                       GdkEvent *event,
@@ -299,6 +302,7 @@ source_selector_build_model (ESourceSelector *selector)
        GQueue queue = G_QUEUE_INIT;
        GHashTable *source_index;
        GtkTreeView *tree_view;
+       GtkTreeSelection *selection;
        GtkTreeModel *model;
        ESource *selected;
        const gchar *extension_name;
@@ -316,6 +320,12 @@ source_selector_build_model (ESourceSelector *selector)
 
        source_index = selector->priv->source_index;
        selected = e_source_selector_ref_primary_selection (selector);
+       selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector));
+
+       /* Signal is blocked to avoid "primary-selection-changed" signal on model clear */
+       g_signal_handlers_block_matched (
+               selection, G_SIGNAL_MATCH_FUNC,
+               0, 0, NULL, selection_changed_callback, NULL);
 
        /* Save expanded sources to restore later. */
        gtk_tree_view_map_expanded_rows (
@@ -361,6 +371,12 @@ source_selector_build_model (ESourceSelector *selector)
                g_object_unref (selected);
        }
 
+       /* If the first succeeded, then there is no selection change, thus no need
+          for notification; notify about the change in ay other cases */
+       g_signal_handlers_unblock_matched (
+               selection, G_SIGNAL_MATCH_FUNC,
+               0, 0, NULL, selection_changed_callback, NULL);
+
        /* Make sure we have a primary selection.  If not, pick one. */
        selected = e_source_selector_ref_primary_selection (selector);
        if (selected == NULL) {


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