[gnome-photos] Use a separate collection for screenshots



commit b883db36b5e6e351511f1bb872668e4726c4d5e8
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Oct 9 16:55:55 2013 +0200

    Use a separate collection for screenshots
    
    Screenshots are placed in a special nfo:DataContainer called
    nfo:image-category-screenshot.
    
    Fixes: https://bugzilla.gnome.org/709368

 src/photos-base-item.c                  |    6 +++++-
 src/photos-fetch-collection-state-job.c |    7 +++++--
 src/photos-organize-collection-view.c   |    3 ++-
 src/photos-query-builder.c              |    3 ++-
 src/photos-search-type-manager.c        |    3 ++-
 src/photos-utils.h                      |    3 +++
 6 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 1bea20e..8a6c645 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -723,7 +723,11 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
   else
     priv->date_created = -1;
 
-  title = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_TITLE, NULL);
+  if (g_strcmp0 (priv->id, PHOTOS_COLLECTION_SCREENSHOT) == 0)
+    title = _("Screenshots");
+  else
+    title = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_TITLE, NULL);
+
   if (title == NULL)
     title = "";
   priv->name = g_strdup (title);
diff --git a/src/photos-fetch-collection-state-job.c b/src/photos-fetch-collection-state-job.c
index 5ee6ec4..8e1f428 100644
--- a/src/photos-fetch-collection-state-job.c
+++ b/src/photos-fetch-collection-state-job.c
@@ -127,6 +127,8 @@ photos_fetch_collection_state_job_emit_callback (PhotosFetchCollectionStateJob *
       g_hash_table_iter_init (&iter2, priv->collections_for_items);
       while (g_hash_table_iter_next (&iter2, (gpointer) &item_idx, (gpointer) &collections_for_item))
         {
+          const gchar *identifier;
+
           item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, item_idx));
 
           /* If one of the selected items is part of this collection… */
@@ -135,10 +137,11 @@ photos_fetch_collection_state_job_emit_callback (PhotosFetchCollectionStateJob *
           else
             not_found = TRUE;
 
+          identifier = photos_base_item_get_identifier (collection);
           if (g_strcmp0 (photos_base_item_get_resource_urn (item),
                          photos_base_item_get_resource_urn (collection)) != 0
-              && !g_str_has_prefix (photos_base_item_get_identifier (collection),
-                                    PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER))
+              && identifier != NULL
+              && !g_str_has_prefix (identifier, PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER))
             hidden = TRUE;
         }
 
diff --git a/src/photos-organize-collection-view.c b/src/photos-organize-collection-view.c
index 49f3531..bd29048 100644
--- a/src/photos-organize-collection-view.c
+++ b/src/photos-organize-collection-view.c
@@ -37,6 +37,7 @@
 #include "photos-query.h"
 #include "photos-source-manager.h"
 #include "photos-set-collection-job.h"
+#include "photos-utils.h"
 
 
 struct _PhotosOrganizeCollectionViewPrivate
@@ -162,7 +163,7 @@ photos_organize_collection_view_detail_cell (GtkTreeViewColumn *tree_column,
       const gchar *identifier;
 
       identifier = photos_base_item_get_identifier (PHOTOS_BASE_ITEM (object));
-      if (!g_str_has_prefix (identifier, PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER))
+      if (identifier != NULL && !g_str_has_prefix (identifier, PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER))
         {
           PhotosSource *source;
           const gchar *name;
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 99476db..f39f22e 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -389,7 +389,8 @@ photos_query_builder_filter_local (void)
   filter = g_strdup_printf ("(fn:contains (nie:url (?urn), \"%s\")"
                             " || fn:contains (nie:url (?urn), \"%s\")"
                             " || fn:contains (nie:url (?urn), \"%s\")"
-                            " || fn:starts-with (nao:identifier (?urn), \"%s\"))",
+                            " || fn:starts-with (nao:identifier (?urn), \"%s\")"
+                            " || (?urn = nfo:image-category-screenshot))",
                             desktop_uri,
                             download_uri,
                             pictures_uri,
diff --git a/src/photos-search-type-manager.c b/src/photos-search-type-manager.c
index 60e730c..fad0dae 100644
--- a/src/photos-search-type-manager.c
+++ b/src/photos-search-type-manager.c
@@ -66,7 +66,8 @@ photos_search_type_manager_init (PhotosSearchTypeManager *self)
   gchar *fav_filter;
 
   item_filter = "fn:contains (rdf:type (?urn), 'nmm#Photo')";
-  col_filter = g_strdup_printf ("fn:starts-with (nao:identifier (?urn), '%s')",
+  col_filter = g_strdup_printf ("(fn:starts-with (nao:identifier (?urn), '%s')"
+                                " || (?urn = nfo:image-category-screenshot))",
                                 PHOTOS_QUERY_COLLECTIONS_IDENTIFIER);
   fav_filter = g_strdup_printf ("(%s || %s)", col_filter, item_filter);
 
diff --git a/src/photos-utils.h b/src/photos-utils.h
index ec36a80..a244739 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -38,6 +38,9 @@ G_BEGIN_DECLS
 #define PHOTOS_FLASH_OFF (photos_utils_flash_off_quark ())
 #define PHOTOS_FLASH_ON (photos_utils_flash_on_quark ())
 
+#define PHOTOS_COLLECTION_SCREENSHOT \
+  "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#image-category-screenshot";
+
 GIcon           *photos_utils_create_collection_icon      (gint base_size, GList *pixbufs);
 
 GdkPixbuf       *photos_utils_create_pixbuf_from_node     (GeglNode *node);


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