[evolution] I#22 - Hide "Birthdays & Anniverseries" calendar from conflict search list



commit 67bb510ba56b37d8cf8383d72170d86d7824d673
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 5 11:00:34 2020 +0100

    I#22 - Hide "Birthdays & Anniverseries" calendar from conflict search list
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/22

 src/e-util/e-conflict-search-selector.c | 18 ++++++++++++++++++
 src/e-util/e-source-selector.c          | 17 +++++++++++++++++
 src/e-util/e-source-selector.h          |  6 +++---
 3 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/e-util/e-conflict-search-selector.c b/src/e-util/e-conflict-search-selector.c
index 481e360dbb..1d114e4bd3 100644
--- a/src/e-util/e-conflict-search-selector.c
+++ b/src/e-util/e-conflict-search-selector.c
@@ -70,6 +70,22 @@ conflict_search_selector_set_source_selected (ESourceSelector *selector,
        return FALSE;
 }
 
+static gboolean
+conflict_search_selector_filter_source_cb (ESourceSelector *selector,
+                                          ESource *source,
+                                          gpointer user_data)
+{
+       gboolean hidden = FALSE;
+
+       if (E_IS_SOURCE (source) && (
+           g_strcmp0 (e_source_get_uid (source), "contacts-stub") == 0 ||
+           g_strcmp0 (e_source_get_uid (source), "birthdays") == 0)) {
+               hidden = TRUE;
+       }
+
+       return hidden;
+}
+
 static void
 e_conflict_search_selector_class_init (EConflictSearchSelectorClass *class)
 {
@@ -87,6 +103,8 @@ e_conflict_search_selector_class_init (EConflictSearchSelectorClass *class)
 static void
 e_conflict_search_selector_init (EConflictSearchSelector *selector)
 {
+       g_signal_connect (selector, "filter-source",
+               G_CALLBACK (conflict_search_selector_filter_source_cb), NULL);
 }
 
 GtkWidget *
diff --git a/src/e-util/e-source-selector.c b/src/e-util/e-source-selector.c
index 83f23507b9..f32e2c9a7b 100644
--- a/src/e-util/e-source-selector.c
+++ b/src/e-util/e-source-selector.c
@@ -85,6 +85,7 @@ enum {
        DATA_DROPPED,
        SOURCE_SELECTED,
        SOURCE_UNSELECTED,
+       FILTER_SOURCE,
        NUM_SIGNALS
 };
 
@@ -432,11 +433,18 @@ source_selector_node_is_hidden (ESourceSelector *selector,
        /* Check the path to the root, any is hidden, this one can be also hidden */
        node = main_node;
        while (node) {
+               gboolean hidden_by_filter = FALSE;
+
                source = node->data;
 
                if (!source || G_NODE_IS_ROOT (node))
                        break;
 
+               g_signal_emit (selector, signals[FILTER_SOURCE], 0, source, &hidden_by_filter);
+
+               if (hidden_by_filter)
+                       return TRUE;
+
                if (data.show_toggles && source_selector_source_is_enabled_and_selected (source, 
extension_name)) {
                        hidden = FALSE;
                        break;
@@ -1849,6 +1857,15 @@ e_source_selector_class_init (ESourceSelectorClass *class)
                G_STRUCT_OFFSET (ESourceSelectorClass, source_unselected),
                NULL, NULL, NULL,
                G_TYPE_NONE, 1, E_TYPE_SOURCE);
+
+       /* Return TRUE when the source should be hidden, FALSE when not. */
+       signals[FILTER_SOURCE] = g_signal_new (
+               "filter-source",
+               G_OBJECT_CLASS_TYPE (object_class),
+               G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+               G_STRUCT_OFFSET (ESourceSelectorClass, filter_source),
+               NULL, NULL, NULL,
+               G_TYPE_BOOLEAN, 1, E_TYPE_SOURCE);
 }
 
 static void
diff --git a/src/e-util/e-source-selector.h b/src/e-util/e-source-selector.h
index 776ccce303..d1daa32207 100644
--- a/src/e-util/e-source-selector.h
+++ b/src/e-util/e-source-selector.h
@@ -86,10 +86,10 @@ struct _ESourceSelectorClass {
                                                 ESource *source);
        void            (*source_unselected)    (ESourceSelector *selector,
                                                 ESource *source);
+       gboolean        (*filter_source)        (ESourceSelector *selector,
+                                                ESource *source);
 
-       gpointer padding1;
-       gpointer padding2;
-       gpointer padding3;
+       gpointer padding[2];
 };
 
 GType          e_source_selector_get_type      (void) G_GNUC_CONST;


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