[gnome-calendar/search-improvements] search-view: run the search when the sources changes
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/search-improvements] search-view: run the search when the sources changes
- Date: Wed, 7 Jan 2015 20:50:46 +0000 (UTC)
commit bee1e2ed5d808aef3b4158f19cc882e568e6d82c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jan 7 18:50:37 2015 -0200
search-view: run the search when the sources changes
src/gcal-search-view.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-search-view.c b/src/gcal-search-view.c
index fb515b2..7b2d64d 100644
--- a/src/gcal-search-view.c
+++ b/src/gcal-search-view.c
@@ -44,6 +44,8 @@ typedef struct
/* misc */
gint no_results_timeout_id;
gint num_results;
+ gchar *field;
+ gchar *query;
/* property */
icaltimetype *date;
@@ -92,6 +94,15 @@ static void display_header_func (GtkListBoxRow
GtkListBoxRow *before,
gpointer user_data);
+static void source_added (GcalManager *manager,
+ ESource *source,
+ gboolean enable,
+ gpointer user_data);
+
+static void source_removed (GcalManager *manager,
+ ESource *source,
+ gpointer user_data);
+
static void gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface);
static void gcal_search_view_constructed (GObject *object);
@@ -431,6 +442,26 @@ display_header_func (GtkListBoxRow *row,
}
static void
+source_added (GcalManager *manager,
+ ESource *source,
+ gboolean enable,
+ gpointer user_data)
+{
+ GcalSearchViewPrivate *priv;
+
+ priv = gcal_search_view_get_instance_private (GCAL_SEARCH_VIEW (user_data));
+ gcal_search_view_search (GCAL_SEARCH_VIEW (user_data), priv->field, priv->query);
+}
+
+static void
+source_removed (GcalManager *manager,
+ ESource *source,
+ gpointer user_data)
+{
+ source_added (manager, source, FALSE, user_data);
+}
+
+static void
gcal_search_view_class_init (GcalSearchViewClass *klass)
{
GObjectClass *object_class;
@@ -552,6 +583,9 @@ gcal_search_view_set_property (GObject *object,
case PROP_MANAGER:
{
priv->manager = g_value_get_pointer (value);
+ g_signal_connect (priv->manager, "source-added", G_CALLBACK (source_added), object);
+ g_signal_connect (priv->manager, "source-activated", G_CALLBACK (source_added), object);
+ g_signal_connect (priv->manager, "source-removed", G_CALLBACK (source_removed), object);
break;
}
default:
@@ -747,6 +781,14 @@ gcal_search_view_search (GcalSearchView *view,
priv = gcal_search_view_get_instance_private (view);
+ if (priv->query != NULL)
+ g_free (priv->query);
+ if (priv->field != NULL)
+ g_free (priv->field);
+
+ priv->query = g_strdup (query);
+ priv->field = g_strdup (field);
+
/* Only perform search on valid non-empty strings */
if (query && g_utf8_strlen (query, -1) > 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]