[gnome-photos/wip/search: 19/23] search-provider: use context



commit 2fe0a674f3706d480ea3f97f848d269498e5ab79
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 18 16:58:46 2014 +0100

    search-provider: use context

 src/photos-search-provider.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-search-provider.c b/src/photos-search-provider.c
index 7ba495a..def5b35 100644
--- a/src/photos-search-provider.c
+++ b/src/photos-search-provider.c
@@ -29,6 +29,7 @@
 
 #include "photos-fetch-ids-job.h"
 #include "photos-fetch-metas-job.h"
+#include "photos-search-context.h"
 #include "photos-search-provider.h"
 #include "photos-shell-search-provider2.h"
 
@@ -38,6 +39,7 @@ struct _PhotosSearchProvider
   GObject parent_instance;
   GCancellable *cancellable;
   GHashTable *cache;
+  PhotosSearchContextState *state;
   ShellSearchProvider2 *skeleton;
 };
 
@@ -55,8 +57,12 @@ enum
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
+static void photos_search_provider_search_context_iface_init (PhotosSearchContextInterface *iface);
 
-G_DEFINE_TYPE (PhotosSearchProvider, photos_search_provider, G_TYPE_OBJECT);
+
+G_DEFINE_TYPE_WITH_CODE (PhotosSearchProvider, photos_search_provider, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_SEARCH_CONTEXT,
+                                                photos_search_provider_search_context_iface_init));
 
 
 static gboolean
@@ -88,6 +94,14 @@ photos_search_provider_fetch_ids_executed (const gchar *const *ids, gpointer use
 }
 
 
+static PhotosSearchContextState *
+photos_search_provider_get_state (PhotosSearchContext *context)
+{
+  PhotosSearchProvider *self = PHOTOS_SEARCH_PROVIDER (context);
+  return self->state;
+}
+
+
 static void
 photos_search_provider_return_metas_from_cache (PhotosSearchProvider *self,
                                                 const gchar *const *identifiers,
@@ -269,6 +283,12 @@ photos_search_provider_dispose (GObject *object)
   g_clear_object (&self->cancellable);
   g_clear_object (&self->skeleton);
 
+  if (self->state != NULL)
+    {
+      photos_search_context_state_free (self->state);
+      self->state = NULL;
+    }
+
   G_OBJECT_CLASS (photos_search_provider_parent_class)->dispose (object);
 }
 
@@ -289,6 +309,7 @@ photos_search_provider_init (PhotosSearchProvider *self)
 {
   self->cancellable = g_cancellable_new ();
   self->cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) 
photos_fetch_meta_free);
+  self->state = photos_search_context_state_new ();
   self->skeleton = shell_search_provider2_skeleton_new ();
 
   g_signal_connect_swapped (self->skeleton,
@@ -349,6 +370,13 @@ photos_search_provider_class_init (PhotosSearchProviderClass *class)
 }
 
 
+static void
+photos_search_provider_search_context_iface_init (PhotosSearchContextInterface *iface)
+{
+  iface->get_state = photos_search_provider_get_state;
+}
+
+
 PhotosSearchProvider *
 photos_search_provider_new (void)
 {


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