[frogr] Use better thumbnails for pictures, that is, bigger ones (#653994)



commit a596949dbda5c42283857b982eda08ad00dadd71
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Fri Jul 8 17:04:37 2011 +0200

    Use better thumbnails for pictures, that is, bigger ones (#653994)
    
    This fixes #653994 because now thumnails are bigger and better quality
    than before in the details dialog, but also made the most of this
    commit to improve the size and quality of pictures in the icon view.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=653994

 src/frogr-details-dialog.c |   39 +++------------------------------------
 src/frogr-main-view.c      |   15 ++++++++++-----
 src/frogr-picture-loader.c |    4 ++--
 src/frogr-util.c           |   34 ++++++++++++++++++++++++++++++++++
 src/frogr-util.h           |    2 ++
 5 files changed, 51 insertions(+), 43 deletions(-)
---
diff --git a/src/frogr-details-dialog.c b/src/frogr-details-dialog.c
index 3d1bfd0..a9c38c8 100644
--- a/src/frogr-details-dialog.c
+++ b/src/frogr-details-dialog.c
@@ -36,8 +36,8 @@
 #define DIALOG_MIN_WIDTH 640
 #define DIALOG_MIN_HEIGHT 420
 
-#define PICTURE_WIDTH 120
-#define PICTURE_HEIGHT 120
+#define PICTURE_WIDTH 200
+#define PICTURE_HEIGHT 200
 
 #define FROGR_DETAILS_DIALOG_GET_PRIVATE(object)                \
   (G_TYPE_INSTANCE_GET_PRIVATE ((object),                       \
@@ -101,8 +101,6 @@ static gboolean _completion_match_selected_cb (GtkEntryCompletion *widget, GtkTr
 
 static void _update_ui (FrogrDetailsDialog *self);
 
-static GdkPixbuf *_get_scaled_pixbuf (GdkPixbuf *pixbuf);
-
 static void _fill_dialog_with_data (FrogrDetailsDialog *self);
 
 static gboolean _validate_dialog_data (FrogrDetailsDialog *self);
@@ -571,37 +569,6 @@ _update_ui (FrogrDetailsDialog *self)
   gtk_widget_set_sensitive (priv->family_cb, !active);
 }
 
-static GdkPixbuf *
-_get_scaled_pixbuf (GdkPixbuf *pixbuf)
-{
-  GdkPixbuf *scaled_pixbuf = NULL;
-  gint width;
-  gint height;
-  gint new_width;
-  gint new_height;
-
-  /* Look for the right side to reduce */
-  width = gdk_pixbuf_get_width (pixbuf);
-  height = gdk_pixbuf_get_height (pixbuf);
-  if (width > height)
-    {
-      new_width = PICTURE_WIDTH;
-      new_height = (float)new_width * height / width;
-    }
-  else
-    {
-      new_height = PICTURE_HEIGHT;
-      new_width = (float)new_height * width / height;
-    }
-
-  /* Scale the pixbuf to its best size */
-  scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
-                                           new_width, new_height,
-                                           GDK_INTERP_TILES);
-
-  return scaled_pixbuf;
-}
-
 static void
 _fill_dialog_with_data (FrogrDetailsDialog *self)
 {
@@ -843,7 +810,7 @@ _fill_dialog_with_data (FrogrDetailsDialog *self)
     {
       /* Set pixbuf scaled to the right size */
       GdkPixbuf *pixbuf = frogr_picture_get_pixbuf (picture);
-      GdkPixbuf *s_pixbuf = _get_scaled_pixbuf (pixbuf);
+      GdkPixbuf *s_pixbuf = frogr_util_get_scaled_pixbuf (pixbuf, PICTURE_WIDTH, PICTURE_HEIGHT);
       gtk_image_set_from_pixbuf (GTK_IMAGE (priv->picture_img), s_pixbuf);
       g_object_unref (s_pixbuf);
     }
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index f0a2f80..2cd2ed1 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -47,10 +47,11 @@
 /* Paths relative to the icons dir */
 #define MAIN_VIEW_ICON(_s) "/hicolor/" _s "/apps/frogr.png"
 
-#define MINIMUM_WINDOW_WIDTH 800
+#define MINIMUM_WINDOW_WIDTH 840
 #define MINIMUM_WINDOW_HEIGHT 600
 
-#define ITEM_WIDTH 120
+#define ITEM_WIDTH 140
+#define ITEM_HEIGHT 140
 
 /* Path relative to the application data dir */
 #define GTKBUILDER_FILE "/gtkbuilder/frogr-main-view.xml"
@@ -770,21 +771,25 @@ static void
 _add_picture_to_ui (FrogrMainView *self, FrogrPicture *picture)
 {
   FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
-  GdkPixbuf *pixbuf;
+  GdkPixbuf *pixbuf = NULL;
+  GdkPixbuf *s_pixbuf = NULL;
+  const gchar *fileuri = NULL;
   GtkTreeIter iter;
-  const gchar *fileuri;
 
   /* Add to GtkIconView */
   fileuri = frogr_picture_get_fileuri (picture);
   pixbuf = frogr_picture_get_pixbuf (picture);
+  s_pixbuf = frogr_util_get_scaled_pixbuf (pixbuf, ITEM_WIDTH, ITEM_HEIGHT);
 
   gtk_list_store_append (GTK_LIST_STORE (priv->tree_model), &iter);
   gtk_list_store_set (GTK_LIST_STORE (priv->tree_model), &iter,
                       FILEURI_COL, fileuri,
-                      PIXBUF_COL, pixbuf,
+                      PIXBUF_COL, s_pixbuf,
                       FPICTURE_COL, picture,
                       -1);
+
   g_object_ref (picture);
+  g_object_unref (s_pixbuf);
 
   /* Reorder if needed */
   if (priv->sorting_criteria != SORT_AS_LOADED || priv->sorting_reversed)
diff --git a/src/frogr-picture-loader.c b/src/frogr-picture-loader.c
index 789ec42..06e499e 100644
--- a/src/frogr-picture-loader.c
+++ b/src/frogr-picture-loader.c
@@ -36,8 +36,8 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 
-#define PICTURE_WIDTH 100
-#define PICTURE_HEIGHT 100
+#define PICTURE_WIDTH 200
+#define PICTURE_HEIGHT 200
 
 #define FROGR_PICTURE_LOADER_GET_PRIVATE(object)                \
   (G_TYPE_INSTANCE_GET_PRIVATE ((object),                       \
diff --git a/src/frogr-util.c b/src/frogr-util.c
index e447458..dfdaaac 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -228,3 +228,37 @@ frogr_util_show_error_dialog (GtkWindow *parent, const gchar *message)
 {
   _show_message_dialog (parent, message, GTK_MESSAGE_ERROR);
 }
+
+GdkPixbuf *
+frogr_util_get_scaled_pixbuf (GdkPixbuf *pixbuf, gint max_width, gint max_height)
+{
+  GdkPixbuf *scaled_pixbuf = NULL;
+  gint width;
+  gint height;
+  gint new_width;
+  gint new_height;
+
+  g_return_val_if_fail (max_width > 0, NULL);
+  g_return_val_if_fail (max_height > 0, NULL);
+
+  /* Look for the right side to reduce */
+  width = gdk_pixbuf_get_width (pixbuf);
+  height = gdk_pixbuf_get_height (pixbuf);
+  if (width > height)
+    {
+      new_width = max_width;
+      new_height = (float)new_width * height / width;
+    }
+  else
+    {
+      new_height = max_height;
+      new_width = (float)new_height * width / height;
+    }
+
+  /* Scale the pixbuf to its best size */
+  scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+                                           new_width, new_height,
+                                           GDK_INTERP_TILES);
+
+  return scaled_pixbuf;
+}
diff --git a/src/frogr-util.h b/src/frogr-util.h
index a6f6ad2..10bd644 100644
--- a/src/frogr-util.h
+++ b/src/frogr-util.h
@@ -39,6 +39,8 @@ void frogr_util_show_warning_dialog (GtkWindow *parent, const gchar *message);
 
 void frogr_util_show_error_dialog (GtkWindow *parent, const gchar *message);
 
+GdkPixbuf *frogr_util_get_scaled_pixbuf (GdkPixbuf *pixbuf, gint max_width, gint max_height);
+
 G_END_DECLS
 
 #endif /* FROGR_UTIL_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]