[gnome-photos] base-item: Implement can_trash and get_where
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] base-item: Implement can_trash and get_where
- Date: Thu, 2 Aug 2012 09:50:59 +0000 (UTC)
commit d329e81f79f82209b84509d7c89cfc74a5fea20c
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Aug 1 10:12:30 2012 +0200
base-item: Implement can_trash and get_where
src/photos-base-item.c | 40 ++++++++++++++++++++++++++++++++++++++--
src/photos-base-item.h | 4 ++++
2 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 892ce26..d47d4c3 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -21,6 +21,8 @@
#include "config.h"
+#include <string.h>
+
#include <gio/gio.h>
#include <glib.h>
#include <tracker-sparql.h>
@@ -35,6 +37,7 @@ struct _PhotosBaseItemPrivate
GdkPixbuf *icon;
GdkPixbuf *pristine_icon;
TrackerSparqlCursor *cursor;
+ gboolean collection;
gboolean failed_thumbnailing;
gboolean favorite;
gboolean thumbnailed;
@@ -444,6 +447,18 @@ photos_base_item_refresh_icon (PhotosBaseItem *self)
static void
+photos_base_item_update_info_from_type (PhotosBaseItem *self)
+{
+ PhotosBaseItemPrivate *priv = self->priv;
+
+ if (strstr (priv->rdf_type, "nfo#DataContainer") != NULL)
+ priv->collection = TRUE;
+
+ PHOTOS_BASE_ITEM_GET_CLASS (self)->update_type_description (self);
+}
+
+
+static void
photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor *cursor)
{
PhotosBaseItemPrivate *priv = self->priv;
@@ -472,8 +487,7 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
priv->mime_type = g_strdup (tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_MIME_TYPE, NULL));
priv->rdf_type = g_strdup (tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_RDF_TYPE, NULL));
-
- PHOTOS_BASE_ITEM_GET_CLASS (self)->update_type_description (self);
+ photos_base_item_update_info_from_type (self);
title = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_TITLE, NULL);
if (title == NULL || title[0] == '\0')
@@ -661,6 +675,13 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
}
+gboolean
+photos_base_item_can_trash (PhotosBaseItem *self)
+{
+ return self->priv->collection;
+}
+
+
const gchar *
photos_base_item_get_author (PhotosBaseItem *self)
{
@@ -703,6 +724,21 @@ photos_base_item_get_uri (PhotosBaseItem *self)
}
+gchar *
+photos_base_item_get_where (PhotosBaseItem *self)
+{
+ PhotosBaseItemPrivate *priv = self->priv;
+ gchar *ret_val;
+
+ if (priv->collection)
+ ret_val = g_strconcat ("{ ?urn nie:isPartOf <", priv->id, "> }", NULL);
+ else
+ ret_val = g_strdup ("");
+
+ return ret_val;
+}
+
+
void
photos_base_item_load_async (PhotosBaseItem *self,
GCancellable *cancellable,
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 193003d..68f59e9 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -72,6 +72,8 @@ struct _PhotosBaseItemClass
GType photos_base_item_get_type (void) G_GNUC_CONST;
+gboolean photos_base_item_can_trash (PhotosBaseItem *self);
+
const gchar *photos_base_item_get_author (PhotosBaseItem *self);
GdkPixbuf *photos_base_item_get_icon (PhotosBaseItem *self);
@@ -84,6 +86,8 @@ const gchar *photos_base_item_get_name (PhotosBaseItem *self);
const gchar *photos_base_item_get_uri (PhotosBaseItem *self);
+gchar *photos_base_item_get_where (PhotosBaseItem *self);
+
void photos_base_item_load_async (PhotosBaseItem *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]