[gnome-photos] base-manager: Let the PhotosQueryFlags be passed to get_where



commit 961152a2b66f362ad1e698a368adce1e13f98ff4
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jan 24 14:26:48 2014 +0100

    base-manager: Let the PhotosQueryFlags be passed to get_where
    
    We want to have a separate mode for showing the search results. We do
    not want to filter the existing modes (ie. overview, collections and
    favorites) during search.
    
    Therefore, the where clause should only be dynamic (based on the
    current active object) in the search mode. Otherwise it should be
    static. Having the access to the PhotosQueryFlags lets us do that.

 src/photos-base-manager.c        |    6 +++---
 src/photos-base-manager.h        |    4 ++--
 src/photos-collection-manager.c  |    2 +-
 src/photos-query-builder.c       |    6 ++----
 src/photos-search-type-manager.c |   14 ++++++++++++--
 5 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index 47d8604..54b163f 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -60,7 +60,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (PhotosBaseManager, photos_base_manager, G_TYPE_OBJEC
 
 
 static gchar *
-photos_base_manager_default_get_where (PhotosBaseManager *self)
+photos_base_manager_default_get_where (PhotosBaseManager *self, gint flags)
 {
   return g_strdup ("");
 }
@@ -361,9 +361,9 @@ photos_base_manager_get_title (PhotosBaseManager *self)
 
 
 gchar *
-photos_base_manager_get_where (PhotosBaseManager *self)
+photos_base_manager_get_where (PhotosBaseManager *self, gint flags)
 {
-  return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_where (self);
+  return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_where (self, flags);
 }
 
 
diff --git a/src/photos-base-manager.h b/src/photos-base-manager.h
index f371d49..2e0cfcd 100644
--- a/src/photos-base-manager.h
+++ b/src/photos-base-manager.h
@@ -66,7 +66,7 @@ struct _PhotosBaseManagerClass
   GObjectClass parent_class;
 
   /* virtual methods */
-  gchar *(*get_where)    (PhotosBaseManager *self);
+  gchar *(*get_where)    (PhotosBaseManager *self, gint flags);
   gboolean (*set_active_object)    (PhotosBaseManager *self, GObject *object);
 
   /* signals */
@@ -94,7 +94,7 @@ 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);
+gchar              *photos_base_manager_get_where                (PhotosBaseManager *self, gint flags);
 
 void                photos_base_manager_process_new_objects      (PhotosBaseManager *self, GHashTable 
*new_objects);
 
diff --git a/src/photos-collection-manager.c b/src/photos-collection-manager.c
index 7017edd..bece01f 100644
--- a/src/photos-collection-manager.c
+++ b/src/photos-collection-manager.c
@@ -35,7 +35,7 @@ G_DEFINE_TYPE (PhotosCollectionManager, photos_collection_manager, PHOTOS_TYPE_B
 
 
 static gchar *
-photos_collection_manager_get_where (PhotosBaseManager *mngr)
+photos_collection_manager_get_where (PhotosBaseManager *mngr, gint flags)
 {
   GObject *collection;
 
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 3cd12cb..fb78eb7 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -122,8 +122,7 @@ photos_query_builder_where (gboolean global, gint flags)
   col_mngr = photos_collection_manager_dup_singleton ();
 
   srch_typ_mngr = photos_search_type_manager_dup_singleton ();
-  photos_query_builder_set_search_type (flags);
-  srch_typ_mngr_where = photos_base_manager_get_where (srch_typ_mngr);
+  srch_typ_mngr_where = photos_base_manager_get_where (srch_typ_mngr, flags);
 
   optional = photos_query_builder_optional ();
 
@@ -133,7 +132,7 @@ photos_query_builder_where (gboolean global, gint flags)
         {
           /* TODO: SearchCategoryManager */
 
-          col_mngr_where = photos_base_manager_get_where (col_mngr);
+          col_mngr_where = photos_base_manager_get_where (col_mngr, flags);
         }
 
       filter = photos_query_builder_filter (flags);
@@ -145,7 +144,6 @@ photos_query_builder_where (gboolean global, gint flags)
                             (col_mngr_where != NULL) ? col_mngr_where : "",
                             (filter != NULL) ? filter : "");
 
-  photos_query_builder_set_search_type (PHOTOS_QUERY_FLAGS_NONE);
   g_free (col_mngr_where);
   g_free (filter);
   g_free (srch_typ_mngr_where);
diff --git a/src/photos-search-type-manager.c b/src/photos-search-type-manager.c
index 3a7ac8d..461b695 100644
--- a/src/photos-search-type-manager.c
+++ b/src/photos-search-type-manager.c
@@ -38,11 +38,21 @@ G_DEFINE_TYPE (PhotosSearchTypeManager, photos_search_type_manager, PHOTOS_TYPE_
 
 
 static gchar *
-photos_search_type_manager_get_where (PhotosBaseManager *mngr)
+photos_search_type_manager_get_where (PhotosBaseManager *mngr, gint flags)
 {
   GObject *search_type;
 
-  search_type = photos_base_manager_get_active_object (mngr);
+  if (flags & PHOTOS_QUERY_FLAGS_COLLECTIONS)
+    search_type = photos_base_manager_get_object_by_id (mngr, PHOTOS_SEARCH_TYPE_STOCK_COLLECTIONS);
+  else if (flags & PHOTOS_QUERY_FLAGS_FAVORITES)
+    search_type = photos_base_manager_get_object_by_id (mngr, PHOTOS_SEARCH_TYPE_STOCK_FAVORITES);
+  else if (flags & PHOTOS_QUERY_FLAGS_OVERVIEW)
+    search_type = photos_base_manager_get_object_by_id (mngr, PHOTOS_SEARCH_TYPE_STOCK_PHOTOS);
+  else if (flags & PHOTOS_QUERY_FLAGS_SEARCH)
+    search_type = photos_base_manager_get_active_object (mngr);
+  else
+    search_type = photos_base_manager_get_object_by_id (mngr, PHOTOS_SEARCH_TYPE_STOCK_ALL);
+
   return photos_filterable_get_where (PHOTOS_FILTERABLE (search_type));
 }
 


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