[gnome-photos] utils: Add photos_utils_set_edited_name



commit 45e64181eab84e8dceac16e4406c6a515ad4f06f
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Nov 14 18:25:40 2012 +0100

    utils: Add photos_utils_set_edited_name
    
    Original patch from Meg Ford for gnome-documents.

 src/photos-utils.c |   20 +++++++++++++++++---
 src/photos-utils.h |    2 ++
 2 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 9a3bf9a..4534df1 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -520,7 +520,7 @@ photos_utils_queue_thumbnail_job_for_file_finish (GAsyncResult *res)
 
 
 static void
-photos_utils_set_favorite_executed (GObject *source_object, GAsyncResult *res, gpointer user_data)
+photos_utils_update_executed (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   TrackerSparqlConnection *connection = TRACKER_SPARQL_CONNECTION (source_object);
   const gchar *urn = (gchar *) user_data;
@@ -530,13 +530,27 @@ photos_utils_set_favorite_executed (GObject *source_object, GAsyncResult *res, g
   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_warning ("Unable to update %s: %s", urn, error->message);
       g_error_free (error);
     }
 }
 
 
 void
+photos_utils_set_edited_name (const gchar *urn, const gchar *title)
+{
+  PhotosTrackerQueue *queue;
+  gchar *sparql;
+
+  sparql = g_strdup_printf ("INSERT OR REPLACE { <%s> nfo:fileName\"%s\" }", urn, title);
+  queue = photos_tracker_queue_new ();
+  photos_tracker_queue_update (queue, sparql, NULL, photos_utils_update_executed, g_strdup (urn), g_free);
+  g_object_unref (queue);
+  g_free (sparql);
+}
+
+
+void
 photos_utils_set_favorite (const gchar *urn, gboolean is_favorite)
 {
   PhotosTrackerQueue *queue;
@@ -547,6 +561,6 @@ photos_utils_set_favorite (const gchar *urn, gboolean is_favorite)
                             urn);
 
   queue = photos_tracker_queue_new ();
-  photos_tracker_queue_update (queue, sparql, NULL, photos_utils_set_favorite_executed, g_strdup (urn), g_free);
+  photos_tracker_queue_update (queue, sparql, NULL, photos_utils_update_executed, g_strdup (urn), g_free);
   g_object_unref (queue);
 }
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 8e86deb..77d6efc 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -66,6 +66,8 @@ 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_edited_name             (const gchar *urn, const gchar *title);
+
 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]