Author: post
Date: 2010-11-25 21:42:45 +0100 (Thu, 25 Nov 2010)
New Revision: 3635

Modified:
   trunk/src/application.h
   trunk/src/gtk-interface.c
   trunk/src/rs-photo.c
   trunk/src/rs-preview-widget.c
   trunk/src/rs-store.c
   trunk/src/rs-store.h
Log:
Update thumbnail with current view, when changing to another image.

Modified: trunk/src/application.h
===================================================================
--- trunk/src/application.h     2010-11-25 19:58:44 UTC (rev 3634)
+++ trunk/src/application.h     2010-11-25 20:42:45 UTC (rev 3635)
@@ -51,6 +51,7 @@
        RSDcpFile *dcp;
        RSIccProfile *icc;
        gboolean dispose_has_run;
+       RSFilter *thumbnail_filter;
 } RS_PHOTO;
 
 typedef struct {

Modified: trunk/src/gtk-interface.c
===================================================================
--- trunk/src/gtk-interface.c   2010-11-25 19:58:44 UTC (rev 3634)
+++ trunk/src/gtk-interface.c   2010-11-25 20:42:45 UTC (rev 3635)
@@ -155,7 +155,11 @@
        if (photo)
        {
                if (rs->photo)
+               {
                        rs_photo_close(rs->photo);
+                       if (rs->photo->metadata && 
rs->photo->metadata->thumbnail && rs->photo->thumbnail_filter)
+                               rs_store_update_thumbnail(rs->store, 
rs->photo->filename, rs->photo->metadata->thumbnail);
+               }
        }
        else
        {

Modified: trunk/src/rs-photo.c
===================================================================
--- trunk/src/rs-photo.c        2010-11-25 19:58:44 UTC (rev 3634)
+++ trunk/src/rs-photo.c        2010-11-25 20:42:45 UTC (rev 3635)
@@ -143,6 +143,7 @@
                photo->settings_signal[c] = 
g_signal_connect(photo->settings[c], "settings-changed", 
G_CALLBACK(photo_settings_changed_cb), photo);
        }
        photo->crop = NULL;
+       photo->thumbnail_filter = NULL;
        photo->angle = 0.0;
        photo->exported = FALSE;
 }
@@ -689,7 +690,35 @@
 void
 rs_photo_close(RS_PHOTO *photo)
 {
+       GdkPixbuf *pixbuf=NULL;
+       GdkPixbuf *pixbuf2=NULL;
        if (!photo) return;
 
        rs_cache_save(photo, MASK_ALL);
+       if (photo->metadata && photo->thumbnail_filter)
+       {
+               RSFilterRequest *request = rs_filter_request_new();
+               rs_filter_request_set_roi(request, FALSE);
+               rs_filter_request_set_quick(request, TRUE);
+               rs_filter_param_set_object(RS_FILTER_PARAM(request), 
"colorspace", rs_color_space_new_singleton("RSSrgb"));     
+
+               RSFilterResponse *response = 
rs_filter_get_image8(photo->thumbnail_filter, request);
+               pixbuf = rs_filter_response_get_image8(response);
+
+               /* Scale to a bounding box of 128x128 pixels */
+               gdouble ratio = ((gdouble) 
gdk_pixbuf_get_width(pixbuf))/((gdouble) gdk_pixbuf_get_height(pixbuf));
+               if (ratio>1.0)
+                       pixbuf2 = gdk_pixbuf_scale_simple(pixbuf, 128, (gint) 
(128.0/ratio), GDK_INTERP_BILINEAR);
+               else
+                       pixbuf2 = gdk_pixbuf_scale_simple(pixbuf, (gint) 
(128.0*ratio), 128, GDK_INTERP_BILINEAR);
+               g_object_unref(pixbuf);
+               g_object_unref(request);
+               g_object_unref(response);
+
+               if (photo->metadata->thumbnail)
+                       g_object_unref(photo->metadata->thumbnail);
+
+               photo->metadata->thumbnail = pixbuf2;
+               rs_metadata_cache_save(photo->metadata, photo->filename);
+       }
 }

Modified: trunk/src/rs-preview-widget.c
===================================================================
--- trunk/src/rs-preview-widget.c       2010-11-25 19:58:44 UTC (rev 3634)
+++ trunk/src/rs-preview-widget.c       2010-11-25 20:42:45 UTC (rev 3635)
@@ -663,6 +663,7 @@
 
        if (preview->photo)
        {
+               photo->thumbnail_filter = preview->navigator_filter_end;
                g_signal_connect(G_OBJECT(preview->photo), "settings-changed", 
G_CALLBACK(settings_changed), preview);
                g_signal_connect(G_OBJECT(preview->photo), "lens-changed", 
G_CALLBACK(lens_changed), preview);
                g_signal_connect(G_OBJECT(preview->photo), "profile-changed", 
G_CALLBACK(profile_changed), preview);

Modified: trunk/src/rs-store.c
===================================================================
--- trunk/src/rs-store.c        2010-11-25 19:58:44 UTC (rev 3634)
+++ trunk/src/rs-store.c        2010-11-25 20:42:45 UTC (rev 3635)
@@ -2608,6 +2608,40 @@
        return pixbuf;
 }
 
+void 
+rs_store_update_thumbnail(RSStore *store, const gchar *filename, GdkPixbuf 
*pixbuf)
+{
+       GdkPixbuf *pixbuf_clean;
+       GtkTreeIter i;
+       guint prio;
+       gboolean expo;
+
+       if (!pixbuf || !filename || !store || !store->store)
+               return;
+
+       if (tree_find_filename(GTK_TREE_MODEL(store->store), filename, &i, 
NULL))
+       {
+#if GTK_CHECK_VERSION(2,8,0)
+         pixbuf = get_thumbnail_eyecandy(pixbuf);
+#endif
+               pixbuf_clean = gdk_pixbuf_copy(pixbuf);
+
+               gtk_tree_model_get(GTK_TREE_MODEL(store->store), &i,
+                       PRIORITY_COLUMN, &prio,
+                       EXPORTED_COLUMN, &expo,
+                       -1);
+
+               gdk_threads_enter();
+               thumbnail_update(pixbuf, pixbuf_clean, prio, expo);
+
+               gtk_list_store_set(GTK_LIST_STORE(store->store), &i,
+                       PIXBUF_COLUMN, pixbuf,
+                       PIXBUF_CLEAN_COLUMN, pixbuf_clean,
+                       -1);
+               gdk_threads_leave();
+       }
+}
+
 void
 got_metadata(RSMetadata *metadata, gpointer user_data)
 {

Modified: trunk/src/rs-store.h
===================================================================
--- trunk/src/rs-store.h        2010-11-25 19:58:44 UTC (rev 3634)
+++ trunk/src/rs-store.h        2010-11-25 20:42:45 UTC (rev 3635)
@@ -77,6 +77,15 @@
        const guint *priority, const gboolean *exported);
 
 /**
+ * Update thumbnail of a file in the store
+ * @param store A RSStore
+ * @param filename The name of the thumbnail to remove or NULL
+ * @param thumbnail A pixbuffer containing the updated thumbnail
+ */
+extern void
+rs_store_update_thumbnail(RSStore *store, const gchar *filename, GdkPixbuf 
*thumbnail);
+
+/**
  * Select one image
  * @param store A RSStore
  * @param name The filename to select


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

Reply via email to