Author: post
Date: 2010-12-30 00:05:37 +0100 (Thu, 30 Dec 2010)
New Revision: 3728

Modified:
   trunk/librawstudio/rs-io-job-tagging.c
   trunk/librawstudio/rs-io-job-tagging.h
   trunk/librawstudio/rs-io.c
   trunk/librawstudio/rs-io.h
   trunk/src/rs-actions.c
   trunk/src/rs-tethered-shooting.c
Log:
Add delayed saving of tagging information. This will save tagging in the 
background - much better for a huge number of taggings.

Modified: trunk/librawstudio/rs-io-job-tagging.c
===================================================================
--- trunk/librawstudio/rs-io-job-tagging.c      2010-12-29 22:25:57 UTC (rev 
3727)
+++ trunk/librawstudio/rs-io-job-tagging.c      2010-12-29 23:05:37 UTC (rev 
3728)
@@ -25,16 +25,30 @@
        gboolean dispose_has_run;
 
        gchar *path;
+       gint tag_id;
+       gboolean autotag;
 } RSIoJobTagging;
 
 G_DEFINE_TYPE(RSIoJobTagging, rs_io_job_tagging, RS_TYPE_IO_JOB)
+static RSLibrary *library;
 
 static void
 execute(RSIoJob *job)
 {
        RSIoJobTagging *tagging = RS_IO_JOB_TAGGING(job);
 
-       rs_library_restore_tags(tagging->path);
+       if (tagging->tag_id == -2)
+       {
+               rs_library_backup_tags(library,tagging->path);
+       }
+       else if (tagging->tag_id == -1)
+       {
+               rs_library_restore_tags(tagging->path);
+       }
+       else
+       {
+               rs_library_photo_add_tag(library, tagging->path, 
tagging->tag_id, tagging->autotag);
+       }
 }
 
 static void
@@ -63,14 +77,18 @@
 static void
 rs_io_job_tagging_init(RSIoJobTagging *tagging)
 {
+       if (!library)
+               library = rs_library_get_singleton();
 }
 
 RSIoJob *
-rs_io_job_tagging_new(const gchar *path)
+rs_io_job_tagging_new(const gchar *path, gint tag_id, gboolean autotag)
 {
        RSIoJobTagging *tagging = g_object_new (RS_TYPE_IO_JOB_TAGGING, NULL);
 
        tagging->path = g_strdup(path);
+       tagging->tag_id = tag_id;
+       tagging->autotag = autotag;
 
        return RS_IO_JOB(tagging);
 }

Modified: trunk/librawstudio/rs-io-job-tagging.h
===================================================================
--- trunk/librawstudio/rs-io-job-tagging.h      2010-12-29 22:25:57 UTC (rev 
3727)
+++ trunk/librawstudio/rs-io-job-tagging.h      2010-12-29 23:05:37 UTC (rev 
3728)
@@ -39,7 +39,11 @@
 
 GType rs_io_job_tagging_get_type(void);
 
-RSIoJob *rs_io_job_tagging_new(const gchar *path);
+/* Do delayed loading of tags, or add tags to an image */
+/* To load tagging data delayed set tag_id to -1 */
+/* To backup tagging data delayed set tag_id to -2 */
+/* To add a tag to an image, provide the image name as path and set the tag_id 
*/
+RSIoJob *rs_io_job_tagging_new(const gchar *path, gint tag_id, gboolean 
autotag);
 
 G_END_DECLS
 

Modified: trunk/librawstudio/rs-io.c
===================================================================
--- trunk/librawstudio/rs-io.c  2010-12-29 22:25:57 UTC (rev 3727)
+++ trunk/librawstudio/rs-io.c  2010-12-29 23:05:37 UTC (rev 3728)
@@ -154,7 +154,26 @@
 }
 
 /**
- * Restore tags of a new directory
+ * Restore tags of a new directory or add tags to a photo
+ * @param filename Absolute path to a file to tags to
+ * @param tag_id The id of the tag to add.
+ * @param auto_tag Is the tag an automatically generated tag
+ * @param idle_class A user defined variable, this can be used with 
rs_io_idle_cancel_class() to cancel a batch of queued reads
+ * @return A pointer to a RSIoJob, this can be used with rs_io_idle_cancel()
+ */
+const RSIoJob *
+rs_io_idle_add_tag(const gchar *filename, gint tag_id, gboolean auto_tag, gint 
idle_class)
+{
+       init();
+
+       RSIoJob *job = rs_io_job_tagging_new(filename, tag_id, auto_tag);
+       rs_io_idle_add_job(job, idle_class, 50, NULL);
+
+       return job;
+}
+
+/**
+ * Restore tags of a new directory or add tags to a photo
  * @param path Absolute path to a directory to restore tags to
  * @param idle_class A user defined variable, this can be used with 
rs_io_idle_cancel_class() to cancel a batch of queued reads
  * @return A pointer to a RSIoJob, this can be used with rs_io_idle_cancel()
@@ -164,7 +183,7 @@
 {
        init();
 
-       RSIoJob *job = rs_io_job_tagging_new(path);
+       RSIoJob *job = rs_io_job_tagging_new(path, -1, FALSE);
        rs_io_idle_add_job(job, idle_class, 50, NULL);
 
        return job;

Modified: trunk/librawstudio/rs-io.h
===================================================================
--- trunk/librawstudio/rs-io.h  2010-12-29 22:25:57 UTC (rev 3727)
+++ trunk/librawstudio/rs-io.h  2010-12-29 23:05:37 UTC (rev 3728)
@@ -64,6 +64,17 @@
 rs_io_idle_read_checksum(const gchar *path, gint idle_class, RSGotChecksumCB 
callback, gpointer user_data);
 
 /**
+ * Restore tags of a new directory or add tags to a photo
+ * @param filename Absolute path to a file to tags to
+ * @param tag_id The id of the tag to add.
+ * @param auto_tag Is the tag an automatically generated tag
+ * @param idle_class A user defined variable, this can be used with 
rs_io_idle_cancel_class() to cancel a batch of queued reads
+ * @return A pointer to a RSIoJob, this can be used with rs_io_idle_cancel()
+ */
+const RSIoJob *
+rs_io_idle_add_tag(const gchar *filename, gint tag_id, gboolean auto_tag, gint 
idle_class);
+
+/**
  * Restore tags of a new directory
  * @param path Absolute path to a directory to restore tags to
  * @param idle_class A user defined variable, this can be used with 
rs_io_idle_cancel_class() to cancel a batch of queued reads

Modified: trunk/src/rs-actions.c
===================================================================
--- trunk/src/rs-actions.c      2010-12-29 22:25:57 UTC (rev 3727)
+++ trunk/src/rs-actions.c      2010-12-29 23:05:37 UTC (rev 3728)
@@ -825,12 +825,12 @@
                {
                        gchar *tag = (gchar *) g_list_nth_data(tags, i);
                        gint tag_id = rs_library_add_tag(library, tag);
+                       g_free(tag);
 
                        for(cur=0;cur<num_selected;cur++)
-                               rs_library_photo_add_tag(library, 
g_list_nth_data(selected, cur), tag_id, FALSE);
-                       g_free(tag);
+                               rs_io_idle_add_tag(g_list_nth_data(selected, 
cur), tag_id, FALSE, -1);
                }
-               rs_library_backup_tags(library, g_list_nth_data(selected, 
num_selected-1));
+               rs_io_idle_add_tag(g_list_nth_data(selected, num_selected-1), 
-2, FALSE, -1);
                g_list_free(tags);
        }
        GdkWindow *window = gtk_widget_get_parent_window(GTK_WIDGET(entry));

Modified: trunk/src/rs-tethered-shooting.c
===================================================================
--- trunk/src/rs-tethered-shooting.c    2010-12-29 22:25:57 UTC (rev 3727)
+++ trunk/src/rs-tethered-shooting.c    2010-12-29 23:05:37 UTC (rev 3728)
@@ -410,9 +410,10 @@
        while (split_tags[i] != NULL)
        {
                gint tag_id = rs_library_add_tag(lib, split_tags[i]);
-               rs_library_photo_add_tag(lib, photo->filename, tag_id, FALSE);
+               rs_io_idle_add_tag(photo->filename, tag_id, FALSE, -1);
                i++;
        }
+       rs_io_idle_add_tag(photo->filename, -2, FALSE, -1);
        g_strfreev(split_tags);
 }
 


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to