[gnome-photos] source: Implement PhotosFilterable



commit a16a65f8b5219a1fe2f4c42f38c08b0cd45a6ebd
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat May 5 14:51:51 2012 +0200

    source: Implement PhotosFilterable

 src/photos-source.c |   45 +++++++++++++++++++++++++++++----------------
 src/photos-source.h |    2 --
 2 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/src/photos-source.c b/src/photos-source.c
index f4b37b9..1bfeb94 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -23,6 +23,7 @@
 
 #include <gio/gio.h>
 
+#include "photos-filterable.h"
 #include "photos-query-builder.h"
 #include "photos-source.h"
 
@@ -44,8 +45,12 @@ enum
   PROP_OBJECT
 };
 
+static void photos_filterable_interface_init (PhotosFilterableInterface *iface);
 
-G_DEFINE_TYPE (PhotosSource, photos_source, G_TYPE_OBJECT);
+
+G_DEFINE_TYPE_WITH_CODE (PhotosSource, photos_source, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_FILTERABLE,
+                                                photos_filterable_interface_init));
 
 
 static gchar *
@@ -63,6 +68,22 @@ photos_source_build_filter_resource (PhotosSource *self)
 }
 
 
+static gchar *
+photos_source_get_filter (PhotosFilterable *iface)
+{
+  PhotosSource *self = PHOTOS_SOURCE (iface);
+  PhotosSourcePrivate *priv = self->priv;
+
+  if (g_strcmp0 (priv->id, PHOTOS_SOURCE_STOCK_LOCAL) == 0)
+    return photos_query_builder_filter_local ();
+
+  if (g_strcmp0 (priv->id, PHOTOS_SOURCE_STOCK_ALL) == 0)
+    return photos_query_builder_filter_local (); /* TODO: Add non local query */
+
+  return photos_source_build_filter_resource (self);
+}
+
+
 static void
 photos_source_dispose (GObject *object)
 {
@@ -192,6 +213,13 @@ photos_source_class_init (PhotosSourceClass *class)
 }
 
 
+static void
+photos_filterable_interface_init (PhotosFilterableInterface *iface)
+{
+  iface->get_filter = photos_source_get_filter;
+}
+
+
 PhotosSource *
 photos_source_new (const gchar *id, const gchar *name, gboolean builtin)
 {
@@ -205,18 +233,3 @@ photos_source_new_from_goa_object (GoaObject *object)
   g_return_val_if_fail (GOA_IS_OBJECT (object), NULL);
   return g_object_new (PHOTOS_TYPE_SOURCE, "object", object, NULL);
 }
-
-
-gchar *
-photos_source_get_filter (PhotosSource *self)
-{
-  PhotosSourcePrivate *priv = self->priv;
-
-  if (g_strcmp0 (priv->id, PHOTOS_SOURCE_STOCK_LOCAL) == 0)
-    return photos_query_builder_filter_local ();
-
-  if (g_strcmp0 (priv->id, PHOTOS_SOURCE_STOCK_ALL) == 0)
-    return photos_query_builder_filter_local (); /* TODO: Add non local query */
-
-  return photos_source_build_filter_resource (self);
-}
diff --git a/src/photos-source.h b/src/photos-source.h
index 6487a86..62eb40c 100644
--- a/src/photos-source.h
+++ b/src/photos-source.h
@@ -71,8 +71,6 @@ PhotosSource       *photos_source_new                    (const gchar *id, const
 
 PhotosSource       *photos_source_new_from_goa_object    (GoaObject *object);
 
-gchar              *photos_source_get_filter             (PhotosSource *self);
-
 G_END_DECLS
 
 #endif /* PHOTOS_SOURCE_H */



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