Author: post
Date: 2010-12-04 21:48:50 +0100 (Sat, 04 Dec 2010)
New Revision: 3655

Modified:
   trunk/src/gtk-interface.c
   trunk/src/rs-photo.c
   trunk/src/rs-photo.h
Log:
Add original image size to toolbox.

Modified: trunk/src/gtk-interface.c
===================================================================
--- trunk/src/gtk-interface.c   2010-12-04 16:44:32 UTC (rev 3654)
+++ trunk/src/gtk-interface.c   2010-12-04 20:48:50 UTC (rev 3655)
@@ -142,11 +142,29 @@
        return;
 }
 
+static void
+set_photo_info_label(RS_PHOTO *photo)
+{
+       gchar *label;
+       gchar label_temp[100];
+       gint w,h;
+
+       label = rs_metadata_get_short_description(photo->metadata);
+       if (rs_photo_get_original_size(photo, TRUE, &w, &h))
+       {
+               g_snprintf(label_temp, 100, "%s\n%s: %d, %s: %d",label, 
_("Width"), w, _("Height"),h );
+               gtk_label_set_text(GTK_LABEL(infobox), label_temp);
+       }
+       else
+               gtk_label_set_text(GTK_LABEL(infobox), label);
+
+       g_free(label);
+}
+
 static gboolean
 open_photo(RS_BLOB *rs, const gchar *filename)
 {
        RS_PHOTO *photo;
-       gchar *label;
 
        gui_set_busy(TRUE);
        rs_preview_widget_set_photo(RS_PREVIEW_WIDGET(rs->preview), NULL);
@@ -167,10 +185,7 @@
                return FALSE;
        }
 
-       label = rs_metadata_get_short_description(photo->metadata);
-       gtk_label_set_text(GTK_LABEL(infobox), label);
-       g_free(label);
-
+       set_photo_info_label(photo);
        rs_set_photo(rs, photo);
        rs_toolbox_set_photo(RS_TOOLBOX(rs->tools), photo);
        GTK_CATCHUP();
@@ -1441,6 +1456,8 @@
 
        /* Metadata infobox */
        infobox = gtk_label_new("");
+       gtk_misc_set_alignment(GTK_MISC(infobox), 0.0, 0.0);
+       gtk_misc_set_padding (GTK_MISC(infobox), 7,3);
        rs_toolbox_add_widget(RS_TOOLBOX(rs->tools), infobox, NULL);
 
        /* Catch window state changes (un/fullscreen) */

Modified: trunk/src/rs-photo.c
===================================================================
--- trunk/src/rs-photo.c        2010-12-04 16:44:32 UTC (rev 3654)
+++ trunk/src/rs-photo.c        2010-12-04 20:48:50 UTC (rev 3655)
@@ -242,6 +242,27 @@
        return photo->crop;
 }
 
+gboolean
+rs_photo_get_original_size(RS_PHOTO *photo, gboolean rotated, gint* width, 
gint* height)
+{
+       if (!photo) return FALSE;
+       g_assert(RS_IS_PHOTO(photo));
+       if (!photo->input) return FALSE;
+       g_assert(RS_IS_IMAGE16(photo->input));
+
+       if (rotated && ((photo->orientation&1) == 1))
+       {
+               *width = photo->input->h;
+               *height = photo->input->w;
+       }
+       else
+       {
+               *width = photo->input->w;
+               *height = photo->input->h;
+       }
+       return TRUE;
+}
+
 /**
  * Set the angle of a RS_PHOTO
  * @param photo A RS_PHOTO

Modified: trunk/src/rs-photo.h
===================================================================
--- trunk/src/rs-photo.h        2010-12-04 16:44:32 UTC (rev 3654)
+++ trunk/src/rs-photo.h        2010-12-04 20:48:50 UTC (rev 3655)
@@ -321,4 +321,15 @@
 extern RS_PHOTO *
 rs_photo_load_from_file(const gchar *filename);
 
+/**
+ * Loads a photo in to a RS_PHOTO including metadata
+ * @param photo A RS_PHOTO
+ * @param rotated Set to TRUE to get the rotated sizes, FALSE to get the RAW 
size.
+ * @param width output variable that will be set to the width
+ * @param height output variable that will be set to the height
+ * @return A boolean, TRUE on success, false if no photo has been loaded
+ */
+extern gboolean
+rs_photo_get_original_size(RS_PHOTO *photo, gboolean rotated, gint* width, 
gint* height);
+
 #endif /* RS_PHOTO_H */


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

Reply via email to