[Goodies-commits] r3274 - ristretto/trunk/src

Stephan Arts stephan at xfce.org
Sat Sep 29 15:18:52 CEST 2007


Author: stephan
Date: 2007-09-29 13:18:52 +0000 (Sat, 29 Sep 2007)
New Revision: 3274

Modified:
   ristretto/trunk/src/main.c
   ristretto/trunk/src/main_window.c
   ristretto/trunk/src/navigator.c
   ristretto/trunk/src/navigator.h
   ristretto/trunk/src/picture_viewer.c
   ristretto/trunk/src/thumbnail_viewer.c
Log:
Add exif orientation support



Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c	2007-09-29 12:22:06 UTC (rev 3273)
+++ ristretto/trunk/src/main.c	2007-09-29 13:18:52 UTC (rev 3274)
@@ -20,6 +20,7 @@
 #include <string.h>
 
 #include <thunar-vfs/thunar-vfs.h>
+#include <libexif/exif-data.h>
 
 #include "navigator.h"
 #include "picture_viewer.h"

Modified: ristretto/trunk/src/main_window.c
===================================================================
--- ristretto/trunk/src/main_window.c	2007-09-29 12:22:06 UTC (rev 3273)
+++ ristretto/trunk/src/main_window.c	2007-09-29 13:18:52 UTC (rev 3274)
@@ -19,6 +19,7 @@
 #include <gdk/gdkkeysyms.h>
 #include <string.h>
 #include <thunar-vfs/thunar-vfs.h>
+#include <libexif/exif-data.h>
 
 #include "navigator.h"
 #include "thumbnail_viewer.h"

Modified: ristretto/trunk/src/navigator.c
===================================================================
--- ristretto/trunk/src/navigator.c	2007-09-29 12:22:06 UTC (rev 3273)
+++ ristretto/trunk/src/navigator.c	2007-09-29 13:18:52 UTC (rev 3274)
@@ -20,6 +20,7 @@
 #include <string.h>
 
 #include <thunar-vfs/thunar-vfs.h>
+#include <libexif/exif-data.h>
 
 #include "navigator.h"
 
@@ -57,6 +58,7 @@
     GdkPixbuf           *pixbuf;
     gdouble              scale;
     gboolean             fit_to_screen;
+    ExifData            *exif_data;
     GdkPixbufRotation    rotation;
     gboolean             h_flipped;
     gboolean             v_flipped;
@@ -482,6 +484,63 @@
         entry = g_new0(RsttoNavigatorEntry, 1);
 
         entry->info = info;
+        entry->exif_data = exif_data_new_from_file(filename);
+        
+        ExifEntry *exifentry = exif_data_get_entry(entry->exif_data, EXIF_TAG_ORIENTATION);
+        if (exifentry)
+        {
+            gchar *val = g_new0(gchar, 20);
+            exif_entry_get_value(exifentry, val, 20);
+            if (!strcmp(val, "top - left"))
+            {
+                entry->v_flipped = FALSE;
+                entry->h_flipped = FALSE;
+                entry->rotation = GDK_PIXBUF_ROTATE_NONE;
+            }
+            if (!strcmp(val, "top - right"))
+            {
+                entry->v_flipped = FALSE;
+                entry->h_flipped = TRUE;
+                entry->rotation = GDK_PIXBUF_ROTATE_NONE;
+            }
+            if (!strcmp(val, "bottom - left"))
+            {
+                entry->v_flipped = TRUE;
+                entry->h_flipped = FALSE;
+                entry->rotation = GDK_PIXBUF_ROTATE_NONE;
+            }
+            if (!strcmp(val, "bottom - right"))
+            {
+                entry->v_flipped = FALSE;
+                entry->h_flipped = FALSE;
+                entry->rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
+            }
+            if (!strcmp(val, "right - top"))
+            {
+                entry->v_flipped = FALSE;
+                entry->h_flipped = FALSE;
+                entry->rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
+            }
+            if (!strcmp(val, "right - bottom"))
+            {
+                entry->v_flipped = FALSE;
+                entry->h_flipped = TRUE;
+                entry->rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
+            }
+            if (!strcmp(val, "left - top"))
+            {
+                entry->v_flipped = FALSE;
+                entry->h_flipped = TRUE;
+                entry->rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
+            }
+            if (!strcmp(val, "left - bottom"))
+            {
+                entry->v_flipped = FALSE;
+                entry->h_flipped = FALSE;
+                entry->rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
+            }
+            g_free(val);
+        }
 
         g_free(filename);
     }
@@ -554,7 +613,21 @@
     if(!entry->pixbuf)
     {
         gchar *filename = thunar_vfs_path_dup_string(entry->info->path);
-        entry->pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
+        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
+        entry->pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+        gdk_pixbuf_unref(pixbuf);
+        if (entry->v_flipped)
+        {
+            pixbuf = entry->pixbuf;
+            entry->pixbuf = gdk_pixbuf_flip(pixbuf, FALSE);
+            gdk_pixbuf_unref(pixbuf);
+        }
+        if (entry->v_flipped)
+        {
+            pixbuf = entry->pixbuf;
+            entry->pixbuf = gdk_pixbuf_flip(pixbuf, TRUE);
+            gdk_pixbuf_unref(pixbuf);
+        }
         g_free(filename);
     }
     return entry->pixbuf;
@@ -607,3 +680,8 @@
 }
 
 
+ExifData *
+rstto_navigator_entry_get_exif_data (RsttoNavigatorEntry *entry)
+{
+    return entry->exif_data;
+}

Modified: ristretto/trunk/src/navigator.h
===================================================================
--- ristretto/trunk/src/navigator.h	2007-09-29 12:22:06 UTC (rev 3273)
+++ ristretto/trunk/src/navigator.h	2007-09-29 13:18:52 UTC (rev 3274)
@@ -127,6 +127,8 @@
 rstto_navigator_flip_entry(RsttoNavigator *navigator, RsttoNavigatorEntry *entry, gboolean horizontal);
 GdkPixbuf *
 rstto_navigator_entry_get_thumb(RsttoNavigatorEntry *entry, gint max_size);
+ExifData *
+rstto_navigator_entry_get_exif_data (RsttoNavigatorEntry *entry);
 
 G_END_DECLS
 

Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c	2007-09-29 12:22:06 UTC (rev 3273)
+++ ristretto/trunk/src/picture_viewer.c	2007-09-29 13:18:52 UTC (rev 3274)
@@ -19,6 +19,7 @@
 #include <gtk/gtkmarshal.h>
 #include <string.h>
 #include <thunar-vfs/thunar-vfs.h>
+#include <libexif/exif-data.h>
 
 #include "navigator.h"
 #include "picture_viewer.h"
@@ -63,7 +64,7 @@
 rstto_picture_viewer_set_scroll_adjustments(RsttoPictureViewer *, GtkAdjustment *, GtkAdjustment *);
 
 static void
-cb_rstto_picture_viewer_nav_file_changed(RsttoNavigator *, gint , RsttoNavigatorEntry *, RsttoPictureViewer *);
+cb_rstto_picture_viewer_nav_iter_changed(RsttoNavigator *, gint , RsttoNavigatorEntry *, RsttoPictureViewer *);
 static void
 cb_rstto_picture_viewer_value_changed(GtkAdjustment *, RsttoPictureViewer *);
 static void
@@ -440,7 +441,7 @@
 
     widget = g_object_new(RSTTO_TYPE_PICTURE_VIEWER, NULL);
     RSTTO_PICTURE_VIEWER(widget)->priv->navigator = navigator;
-    g_signal_connect(G_OBJECT(navigator), "iter-changed", G_CALLBACK(cb_rstto_picture_viewer_nav_file_changed), widget);
+    g_signal_connect(G_OBJECT(navigator), "iter-changed", G_CALLBACK(cb_rstto_picture_viewer_nav_iter_changed), widget);
 
     return widget;
 }
@@ -665,7 +666,7 @@
 }
 
 static void
-cb_rstto_picture_viewer_nav_file_changed(RsttoNavigator *nav, gint nr, RsttoNavigatorEntry *entry, RsttoPictureViewer *viewer)
+cb_rstto_picture_viewer_nav_iter_changed(RsttoNavigator *nav, gint nr, RsttoNavigatorEntry *entry, RsttoPictureViewer *viewer)
 {
     GtkWidget *widget = GTK_WIDGET(viewer);
     if(entry)
@@ -682,7 +683,17 @@
             {
                 if (viewer->priv->dst_pixbuf)
                 {
-                    gdk_pixbuf_saturate_and_pixelate(viewer->priv->dst_pixbuf, viewer->priv->dst_pixbuf, 0.8, TRUE);
+                    GdkPixbuf *pixbuf = gdk_pixbuf_composite_color_simple (viewer->priv->dst_pixbuf,
+                                                                    gdk_pixbuf_get_width(viewer->priv->dst_pixbuf),
+                                                                    gdk_pixbuf_get_height(viewer->priv->dst_pixbuf),
+                                                                    GDK_INTERP_BILINEAR,
+                                                                    100,
+                                                                    100,
+                                                                    0x000000,
+                                                                    0x000000);
+                    gdk_pixbuf_unref(viewer->priv->dst_pixbuf);
+                    viewer->priv->dst_pixbuf = pixbuf;
+                                                                    
                     rstto_picture_viewer_paint(GTK_WIDGET(viewer));
                 }
                 viewer->priv->timeout_id = g_timeout_add(100, (GSourceFunc)cb_rstto_picture_viewer_update_image, viewer);

Modified: ristretto/trunk/src/thumbnail_viewer.c
===================================================================
--- ristretto/trunk/src/thumbnail_viewer.c	2007-09-29 12:22:06 UTC (rev 3273)
+++ ristretto/trunk/src/thumbnail_viewer.c	2007-09-29 13:18:52 UTC (rev 3274)
@@ -20,6 +20,7 @@
 #include <string.h>
 
 #include <thunar-vfs/thunar-vfs.h>
+#include <libexif/exif-data.h>
 
 #include "navigator.h"
 #include "picture_viewer.h"




More information about the Goodies-commits mailing list