[gnome-photos] Detect creation of collections and show albums within albums



commit f92a2c9d4f364e26b13c0aadca8cdf1d386f4fbc
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 14 08:33:28 2014 +0100

    Detect creation of collections and show albums within albums
    
    Our use of PhotosQueryFlags was becoming too convoluted. We were using
    PHOTOS_QUERY_FLAGS_NONE for quite a few subtly different cases:
     - Queries where we only want nmm:Photo items
     - Queries where we want any item that is a nmm:Photo or a collection
    
    Let us not do that. We will now use PHOTOS_QUERY_FLAGS_OVERVIEW for the
    former and PHOTOS_QUERY_FLAGS_NONE for the later.
    
    It turns out that we do need a builtin "all" PhotosSearchType, even
    though we will always have the distinction between collections, photos
    and favorites in the main application modes. We need it to represent
    PHOTOS_QUERY_FLAGS_NONE queries where we want any item that is a
    nmm:Photo or a collection:
     - To find out the contents of a collection, which can have nmm:Photo
       items or other collections inside it
     - To catch newly created Tracker objects that could be a nmm:Photo or
       a collection
    
    However, this does clean up how the builtin "all" PhotosSearchType was
    handled.
    
    Fallout from 3d4f17a87a4da426c861057e989602387ece83fb
    
    Fixes: https://bugzilla.gnome.org/709367

 src/photos-offset-overview-controller.c  |    2 +-
 src/photos-query-builder.c               |    4 +++-
 src/photos-query.h                       |    5 +++--
 src/photos-search-type-manager.c         |    9 ++++++++-
 src/photos-search-type.h                 |    3 ++-
 src/photos-tracker-overview-controller.c |    2 +-
 6 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/photos-offset-overview-controller.c b/src/photos-offset-overview-controller.c
index 4ea41f0..d953dfe 100644
--- a/src/photos-offset-overview-controller.c
+++ b/src/photos-offset-overview-controller.c
@@ -35,7 +35,7 @@ G_DEFINE_TYPE (PhotosOffsetOverviewController, photos_offset_overview_controller
 static PhotosQuery *
 photos_offset_overview_controller_get_query (PhotosOffsetController *offset_cntrlr)
 {
-  return photos_query_builder_count_query (PHOTOS_QUERY_FLAGS_NONE);
+  return photos_query_builder_count_query (PHOTOS_QUERY_FLAGS_OVERVIEW);
 }
 
 
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index d25d147..de07ef9 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -62,8 +62,10 @@ photos_query_builder_set_search_type (gint flags)
     photos_base_manager_set_active_object_by_id (srch_typ_mngr, PHOTOS_SEARCH_TYPE_STOCK_COLLECTIONS);
   else if (flags & PHOTOS_QUERY_FLAGS_FAVORITES)
     photos_base_manager_set_active_object_by_id (srch_typ_mngr, PHOTOS_SEARCH_TYPE_STOCK_FAVORITES);
-  else
+  else if (flags & PHOTOS_QUERY_FLAGS_OVERVIEW)
     photos_base_manager_set_active_object_by_id (srch_typ_mngr, PHOTOS_SEARCH_TYPE_STOCK_PHOTOS);
+  else
+    photos_base_manager_set_active_object_by_id (srch_typ_mngr, PHOTOS_SEARCH_TYPE_STOCK_ALL);
 
   g_object_unref (srch_typ_mngr);
 }
diff --git a/src/photos-query.h b/src/photos-query.h
index 5dc2d60..107d161 100644
--- a/src/photos-query.h
+++ b/src/photos-query.h
@@ -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
@@ -62,7 +62,8 @@ typedef enum
   PHOTOS_QUERY_FLAGS_NONE = 0,
   PHOTOS_QUERY_FLAGS_UNFILTERED = 1 << 0,
   PHOTOS_QUERY_FLAGS_COLLECTIONS = 1 << 1,
-  PHOTOS_QUERY_FLAGS_FAVORITES = 1 << 2
+  PHOTOS_QUERY_FLAGS_FAVORITES = 1 << 2,
+  PHOTOS_QUERY_FLAGS_OVERVIEW = 1 << 3
 } PhotosQueryFlags;
 
 extern const gchar *PHOTOS_QUERY_COLLECTIONS_IDENTIFIER;
diff --git a/src/photos-search-type-manager.c b/src/photos-search-type-manager.c
index fad0dae..ce44ea0 100644
--- a/src/photos-search-type-manager.c
+++ b/src/photos-search-type-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
@@ -71,6 +71,13 @@ photos_search_type_manager_init (PhotosSearchTypeManager *self)
                                 PHOTOS_QUERY_COLLECTIONS_IDENTIFIER);
   fav_filter = g_strdup_printf ("(%s || %s)", col_filter, item_filter);
 
+  search_type = photos_search_type_new_full (PHOTOS_SEARCH_TYPE_STOCK_ALL,
+                                             _("All"),
+                                             "?urn a rdfs:Resource",
+                                             "(false)");
+  photos_base_manager_add_object (PHOTOS_BASE_MANAGER (self), G_OBJECT (search_type));
+  g_object_unref (search_type);
+
   search_type = photos_search_type_new_full (PHOTOS_SEARCH_TYPE_STOCK_COLLECTIONS,
                                              _("Albums"),
                                              "?urn a nfo:DataContainer",
diff --git a/src/photos-search-type.h b/src/photos-search-type.h
index 1fadb16..69e8136 100644
--- a/src/photos-search-type.h
+++ b/src/photos-search-type.h
@@ -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
@@ -51,6 +51,7 @@ G_BEGIN_DECLS
   (G_TYPE_INSTANCE_GET_CLASS ((obj), \
    PHOTOS_TYPE_SEARCH_TYPE, PhotosSearchTypeClass))
 
+#define PHOTOS_SEARCH_TYPE_STOCK_ALL "all"
 #define PHOTOS_SEARCH_TYPE_STOCK_COLLECTIONS "collections"
 #define PHOTOS_SEARCH_TYPE_STOCK_FAVORITES "favorites"
 #define PHOTOS_SEARCH_TYPE_STOCK_PHOTOS "photos"
diff --git a/src/photos-tracker-overview-controller.c b/src/photos-tracker-overview-controller.c
index 3ff9dde..3cb7dfe 100644
--- a/src/photos-tracker-overview-controller.c
+++ b/src/photos-tracker-overview-controller.c
@@ -54,7 +54,7 @@ static PhotosQuery *
 photos_tracker_overview_controller_get_query (PhotosTrackerController *trk_cntrlr)
 {
   PhotosTrackerOverviewController *self = PHOTOS_TRACKER_OVERVIEW_CONTROLLER (trk_cntrlr);
-  return photos_query_builder_global_query (PHOTOS_QUERY_FLAGS_NONE, self->priv->offset_cntrlr);
+  return photos_query_builder_global_query (PHOTOS_QUERY_FLAGS_OVERVIEW, self->priv->offset_cntrlr);
 }
 
 


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