[Xfce4-commits] <xfce4-screenshooter:master> Improve the creation of the save dialog's thumbnail.

Jérôme Guelfucci jeromeg at xfce.org
Fri Aug 14 00:26:09 CEST 2009


Updating branch refs/heads/master
         to 38afa7b699e52bfc321f0edc6d5ae5420ca3a8c8 (commit)
       from 8e59b71a19516f17d09dddb279b766df0b548746 (commit)

commit 38afa7b699e52bfc321f0edc6d5ae5420ca3a8c8
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Mon Aug 3 11:41:22 2009 +0200

    Improve the creation of the save dialog's thumbnail.
    
    The thumbnail's width and height now have a maximum of 150 pixels, if
    they are less than 150 pixels, use the screenshot itself as a
    thumbnail.

 ChangeLog                   |   12 ++++++++++++
 lib/screenshooter-dialogs.c |   37 +++++++++++++++++++++++++++++++------
 2 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3b2c2c9..a2e66a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,18 @@ Fixed the Indonesian documentation sub-directory, the autotools scripts were
 incomplete.
 Updated Italian and Galician documentation translation.
 
+2009-08-03 jeromeg
+
+Improve the creation of the save dialog's thumbnail.
+
+The thumbnail's width and height now have a maximum of 150 pixels, if
+they are less than 150 pixels, use the screenshot itself as a
+thumbnail.
+
+2009-08-02 jeromeg
+
+Always show the save dialog when we save a screenshot.
+
 2009-08-02 jeromeg
 
 Remove the option to take several screenshots in a row.
diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c
index 868e72a..2f109e4 100644
--- a/lib/screenshooter-dialogs.c
+++ b/lib/screenshooter-dialogs.c
@@ -72,6 +72,8 @@ populate_liststore                 (GtkListStore       *liststore);
 static void
 set_default_item                   (GtkWidget          *combobox,
                                     ScreenshotData     *sd);
+static GdkPixbuf
+*screenshot_get_thumbnail          (GdkPixbuf          *screenshot);
 static void
 cb_progress_upload                 (goffset             current_num_bytes,
                                     goffset             total_num_bytes,
@@ -92,7 +94,7 @@ save_screenshot_to_remote_location (GdkPixbuf          *screenshot,
                                     GFile              *save_file);
 static gchar
 *save_screenshot_to                (GdkPixbuf          *screenshot,
-                                    gchar *save_uri);
+                                    gchar              *save_uri);
 
 
 
@@ -449,6 +451,33 @@ static void set_default_item (GtkWidget *combobox, ScreenshotData *sd)
 
 
 
+static GdkPixbuf
+*screenshot_get_thumbnail (GdkPixbuf *screenshot)
+{
+  gint width, height, i;
+  GdkPixbuf *thumbnail;
+
+  width = gdk_pixbuf_get_width (screenshot);
+  height = gdk_pixbuf_get_height (screenshot);
+
+  if (width > height)
+    i = width / 150;
+  else
+    i = height / 150;
+
+  if (i == 0)
+    return gdk_pixbuf_copy (screenshot);
+
+  thumbnail = gdk_pixbuf_scale_simple (screenshot,
+                                       width/i,
+                                       height/i,
+                                       GDK_INTERP_BILINEAR);
+
+  return thumbnail;
+}
+
+
+
 static void cb_progress_upload (goffset current_num_bytes,
                                 goffset total_num_bytes,
                                 gpointer user_data)
@@ -1154,11 +1183,7 @@ gchar
 
       gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (chooser), preview);
 
-      thumbnail =
-        gdk_pixbuf_scale_simple (screenshot,
-                                 gdk_pixbuf_get_width(screenshot)/5,
-                                 gdk_pixbuf_get_height(screenshot)/5,
-                                 GDK_INTERP_BILINEAR);
+      thumbnail = screenshot_get_thumbnail (screenshot);
 
       gtk_image_set_from_pixbuf (GTK_IMAGE (preview), thumbnail);
 



More information about the Xfce4-commits mailing list