[gnome-photos] utils: Add set_favorite
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] utils: Add set_favorite
- Date: Thu, 16 Aug 2012 18:07:23 +0000 (UTC)
commit f1a22d6df0a6785c1ff9209afe858ffca097c8ee
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Aug 15 01:02:35 2012 +0200
utils: Add set_favorite
src/photos-utils.c | 35 +++++++++++++++++++++++++++++++++++
src/photos-utils.h | 1 +
2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 5a1cb55..d959472 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -29,8 +29,10 @@
#include <cairo.h>
#include <glib.h>
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
+#include <tracker-sparql.h>
#include "gd-main-view.h"
+#include "photos-tracker-queue.h"
#include "photos-utils.h"
@@ -348,3 +350,36 @@ photos_utils_queue_thumbnail_job_for_file_finish (GAsyncResult *res)
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
return g_simple_async_result_get_op_res_gboolean (simple);
}
+
+
+static void
+photos_utils_set_favorite_executed (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ TrackerSparqlConnection *connection = TRACKER_SPARQL_CONNECTION (source_object);
+ const gchar *urn = (gchar *) user_data;
+ GError *error;
+
+ error = NULL;
+ tracker_sparql_connection_update_finish (connection, res, &error);
+ if (error != NULL)
+ {
+ g_warning ("Unable to set the favorite property on %s: %s", urn, error->message);
+ g_error_free (error);
+ }
+}
+
+
+void
+photos_utils_set_favorite (const gchar *urn, gboolean is_favorite)
+{
+ PhotosTrackerQueue *queue;
+ gchar *sparql;
+
+ sparql = g_strdup_printf ("%s { <%s> nao:hasTag nao:predefined-tag-favorite }",
+ (is_favorite) ? "INSERT OR REPLACE" : "DELETE",
+ urn);
+
+ queue = photos_tracker_queue_new ();
+ photos_tracker_queue_update (queue, sparql, NULL, photos_utils_set_favorite_executed, g_strdup (urn), g_free);
+ g_object_unref (queue);
+}
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 35e021f..0cba2d9 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -54,6 +54,7 @@ void photos_utils_queue_thumbnail_job_for_file_async (GFile *file,
gboolean photos_utils_queue_thumbnail_job_for_file_finish (GAsyncResult *res);
+void photos_utils_set_favorite (const gchar *urn, gboolean is_favorite);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]