[gnome-photos/wip/search: 21/32] base-manager: Add a get_where virtual method



commit e452134f4782e5cc8796194010a482116520f596
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jan 24 11:51:25 2014 +0100

    base-manager: Add a get_where virtual method
    
    ... and make PhotosCollectionManager and PhotosSearchTypeManager
    override it instead of having their own.

 src/photos-base-manager.c        |   15 +++++++++++++++
 src/photos-base-manager.h        |    3 +++
 src/photos-collection-manager.c  |   31 +++++++++++++++++--------------
 src/photos-collection-manager.h  |    2 --
 src/photos-query-builder.c       |    4 ++--
 src/photos-search-type-manager.c |   22 ++++++++++++----------
 src/photos-search-type-manager.h |    2 --
 7 files changed, 49 insertions(+), 30 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index 65fba9a..47d8604 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -59,6 +59,13 @@ static guint signals[LAST_SIGNAL] = { 0 };
 G_DEFINE_TYPE_WITH_PRIVATE (PhotosBaseManager, photos_base_manager, G_TYPE_OBJECT);
 
 
+static gchar *
+photos_base_manager_default_get_where (PhotosBaseManager *self)
+{
+  return g_strdup ("");
+}
+
+
 static gboolean
 photos_base_manager_default_set_active_object (PhotosBaseManager *self, GObject *object)
 {
@@ -198,6 +205,7 @@ photos_base_manager_class_init (PhotosBaseManagerClass *class)
   object_class->dispose = photos_base_manager_dispose;
   object_class->finalize = photos_base_manager_finalize;
   object_class->set_property = photos_base_manager_set_property;
+  class->get_where = photos_base_manager_default_get_where;
   class->set_active_object = photos_base_manager_default_set_active_object;
 
   g_object_class_install_property (object_class,
@@ -352,6 +360,13 @@ photos_base_manager_get_title (PhotosBaseManager *self)
 }
 
 
+gchar *
+photos_base_manager_get_where (PhotosBaseManager *self)
+{
+  return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_where (self);
+}
+
+
 void
 photos_base_manager_process_new_objects (PhotosBaseManager *self, GHashTable *new_objects)
 {
diff --git a/src/photos-base-manager.h b/src/photos-base-manager.h
index 1987cec..f371d49 100644
--- a/src/photos-base-manager.h
+++ b/src/photos-base-manager.h
@@ -66,6 +66,7 @@ struct _PhotosBaseManagerClass
   GObjectClass parent_class;
 
   /* virtual methods */
+  gchar *(*get_where)    (PhotosBaseManager *self);
   gboolean (*set_active_object)    (PhotosBaseManager *self, GObject *object);
 
   /* signals */
@@ -93,6 +94,8 @@ guint               photos_base_manager_get_objects_count        (PhotosBaseMana
 
 const gchar        *photos_base_manager_get_title                (PhotosBaseManager *self);
 
+gchar              *photos_base_manager_get_where                (PhotosBaseManager *self);
+
 void                photos_base_manager_process_new_objects      (PhotosBaseManager *self, GHashTable 
*new_objects);
 
 void                photos_base_manager_remove_object            (PhotosBaseManager *self, GObject *object);
diff --git a/src/photos-collection-manager.c b/src/photos-collection-manager.c
index 62e3289..7017edd 100644
--- a/src/photos-collection-manager.c
+++ b/src/photos-collection-manager.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -34,6 +34,19 @@
 G_DEFINE_TYPE (PhotosCollectionManager, photos_collection_manager, PHOTOS_TYPE_BASE_MANAGER);
 
 
+static gchar *
+photos_collection_manager_get_where (PhotosBaseManager *mngr)
+{
+  GObject *collection;
+
+  collection = photos_base_manager_get_active_object (mngr);
+  if (collection == NULL)
+    return g_strdup ("");
+
+  return photos_base_item_get_where (PHOTOS_BASE_ITEM (collection));
+}
+
+
 static GObject *
 photos_collection_manager_constructor (GType                  type,
                                        guint                  n_construct_params,
@@ -64,7 +77,10 @@ static void
 photos_collection_manager_class_init (PhotosCollectionManagerClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
+  PhotosBaseManagerClass *base_manager_class = PHOTOS_BASE_MANAGER_CLASS (class);
+
   object_class->constructor = photos_collection_manager_constructor;
+  base_manager_class->get_where = photos_collection_manager_get_where;
 }
 
 
@@ -73,16 +89,3 @@ photos_collection_manager_dup_singleton (void)
 {
   return g_object_new (PHOTOS_TYPE_COLLECTION_MANAGER, NULL);
 }
-
-
-gchar *
-photos_collection_manager_get_where (PhotosCollectionManager *self)
-{
-  GObject *collection;
-
-  collection = photos_base_manager_get_active_object (PHOTOS_BASE_MANAGER (self));
-  if (collection == NULL)
-    return g_strdup ("");
-
-  return photos_base_item_get_where (PHOTOS_BASE_ITEM (collection));
-}
diff --git a/src/photos-collection-manager.h b/src/photos-collection-manager.h
index e49c86e..e8e5045 100644
--- a/src/photos-collection-manager.h
+++ b/src/photos-collection-manager.h
@@ -70,8 +70,6 @@ GType                     photos_collection_manager_get_type           (void) G_
 
 PhotosBaseManager        *photos_collection_manager_dup_singleton      (void);
 
-gchar                    *photos_collection_manager_get_where          (PhotosCollectionManager *self);
-
 G_END_DECLS
 
 #endif /* PHOTOS_COLLECTION_MANAGER_H */
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index de07ef9..3cd12cb 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -123,7 +123,7 @@ photos_query_builder_where (gboolean global, gint flags)
 
   srch_typ_mngr = photos_search_type_manager_dup_singleton ();
   photos_query_builder_set_search_type (flags);
-  srch_typ_mngr_where = photos_search_type_manager_get_where (PHOTOS_SEARCH_TYPE_MANAGER (srch_typ_mngr));
+  srch_typ_mngr_where = photos_base_manager_get_where (srch_typ_mngr);
 
   optional = photos_query_builder_optional ();
 
@@ -133,7 +133,7 @@ photos_query_builder_where (gboolean global, gint flags)
         {
           /* TODO: SearchCategoryManager */
 
-          col_mngr_where = photos_collection_manager_get_where (PHOTOS_COLLECTION_MANAGER (col_mngr));
+          col_mngr_where = photos_base_manager_get_where (col_mngr);
         }
 
       filter = photos_query_builder_filter (flags);
diff --git a/src/photos-search-type-manager.c b/src/photos-search-type-manager.c
index 9e8127f..71b2d4d 100644
--- a/src/photos-search-type-manager.c
+++ b/src/photos-search-type-manager.c
@@ -37,6 +37,16 @@
 G_DEFINE_TYPE (PhotosSearchTypeManager, photos_search_type_manager, PHOTOS_TYPE_BASE_MANAGER);
 
 
+static gchar *
+photos_search_type_manager_get_where (PhotosBaseManager *mngr)
+{
+  GObject *search_type;
+
+  search_type = photos_base_manager_get_active_object (mngr);
+  return photos_filterable_get_where (PHOTOS_FILTERABLE (search_type));
+}
+
+
 static GObject *
 photos_search_type_manager_constructor (GType                  type,
                                         guint                  n_construct_params,
@@ -110,8 +120,10 @@ static void
 photos_search_type_manager_class_init (PhotosSearchTypeManagerClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
+  PhotosBaseManagerClass *base_manager_class = PHOTOS_BASE_MANAGER_CLASS (class);
 
   object_class->constructor = photos_search_type_manager_constructor;
+  base_manager_class->get_where = photos_search_type_manager_get_where;
 }
 
 
@@ -123,13 +135,3 @@ photos_search_type_manager_dup_singleton (void)
    */
   return g_object_new (PHOTOS_TYPE_SEARCH_TYPE_MANAGER, "title", C_("Search Filter", "Type"), NULL);
 }
-
-
-gchar *
-photos_search_type_manager_get_where (PhotosSearchTypeManager *self)
-{
-  GObject *search_type;
-
-  search_type = photos_base_manager_get_active_object (PHOTOS_BASE_MANAGER (self));
-  return photos_filterable_get_where (PHOTOS_FILTERABLE (search_type));
-}
diff --git a/src/photos-search-type-manager.h b/src/photos-search-type-manager.h
index 6fafe65..0b0dc41 100644
--- a/src/photos-search-type-manager.h
+++ b/src/photos-search-type-manager.h
@@ -70,8 +70,6 @@ GType                     photos_search_type_manager_get_type           (void) G
 
 PhotosBaseManager        *photos_search_type_manager_dup_singleton      (void);
 
-gchar                    *photos_search_type_manager_get_where          (PhotosSearchTypeManager *self);
-
 G_END_DECLS
 
 #endif /* PHOTOS_SEARCH_TYPE_MANAGER_H */


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