[gimp] app: fix the image window's thumbnail size and shape



commit 19b984e1df485a38e7405831dd58c0b3cf91651d
Author: Michael Natterer <mitch gimp org>
Date:   Sun Oct 25 21:55:35 2015 +0100

    app: fix the image window's thumbnail size and shape
    
    and render a wilber on top of it, yay! Step one, this can still be
    nicer...

 app/display/gimpdisplayshell-icon.c |   51 ++++++++++++++++++++++++++++------
 app/display/gimpdisplayshell.c      |    3 +-
 app/display/gimpdisplayshell.h      |    3 +-
 3 files changed, 46 insertions(+), 11 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-icon.c b/app/display/gimpdisplayshell-icon.c
index a0675e4..6eb4c0b 100644
--- a/app/display/gimpdisplayshell-icon.c
+++ b/app/display/gimpdisplayshell-icon.c
@@ -17,6 +17,8 @@
 
 #include "config.h"
 
+#include <string.h>
+
 #include <gegl.h>
 #include <gtk/gtk.h>
 
@@ -25,6 +27,8 @@
 #include "core/gimp.h"
 #include "core/gimpimage.h"
 
+#include "widgets/gimpwidgets-utils.h"
+
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-icon.h"
@@ -72,19 +76,20 @@ gimp_display_shell_icon_update_stop (GimpDisplayShell *shell)
 static gboolean
 gimp_display_shell_icon_update_idle (gpointer data)
 {
-  GimpDisplayShell *shell  = GIMP_DISPLAY_SHELL (data);
-  GimpImage        *image  = gimp_display_get_image (shell->display);
-  GdkPixbuf        *pixbuf = NULL;
+  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
+  GimpImage        *image = gimp_display_get_image (shell->display);
+  GdkPixbuf        *icon  = NULL;
 
   shell->icon_idle_id = 0;
 
   if (image)
     {
-      Gimp    *gimp   = gimp_display_get_gimp (shell->display);
-      gint     width;
-      gint     height;
-      gdouble  factor = ((gdouble) gimp_image_get_height (image) /
-                         (gdouble) gimp_image_get_width  (image));
+      Gimp      *gimp = gimp_display_get_gimp (shell->display);
+      GdkPixbuf *pixbuf;
+      gint       width;
+      gint       height;
+      gdouble    factor = ((gdouble) gimp_image_get_height (image) /
+                           (gdouble) gimp_image_get_width  (image));
 
       if (factor >= 1)
         {
@@ -100,9 +105,37 @@ gimp_display_shell_icon_update_idle (gpointer data)
       pixbuf = gimp_viewable_get_pixbuf (GIMP_VIEWABLE (image),
                                          gimp_get_user_context (gimp),
                                          width, height);
+
+      icon = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
+                             shell->icon_size, shell->icon_size);
+
+      memset (gdk_pixbuf_get_pixels (icon), 0,
+              gdk_pixbuf_get_height (icon) *
+              gdk_pixbuf_get_rowstride (icon));
+
+      gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height,
+                            icon,
+                            (shell->icon_size - width)  / 2,
+                            (shell->icon_size - height) / 2);
+
+      pixbuf = gimp_widget_load_icon (GTK_WIDGET (shell), "gimp-wilber",
+                                      shell->icon_size_small);
+
+      width  = gdk_pixbuf_get_width  (pixbuf);
+      height = gdk_pixbuf_get_height (pixbuf);
+
+      gdk_pixbuf_composite (pixbuf, icon,
+                            shell->icon_size - width, 0,
+                            width, height,
+                            0.0, 0.0, 1.0, 1.0,
+                            GDK_INTERP_NEAREST, 255);
+      g_object_unref (pixbuf);
     }
 
-  g_object_set (shell, "icon", pixbuf, NULL);
+  g_object_set (shell, "icon", icon, NULL);
+
+  if (icon)
+    g_object_unref (icon);
 
   return FALSE;
 }
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index ac39f7f..f256810 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -328,7 +328,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
 
   gimp_display_shell_items_init (shell);
 
-  shell->icon_size  = 64;
+  shell->icon_size       = 128;
+  shell->icon_size_small = 96;
 
   shell->cursor_handedness = GIMP_HANDEDNESS_RIGHT;
   shell->current_cursor    = (GimpCursorType) -1;
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 305ec82..6419d19 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -126,7 +126,8 @@ struct _GimpDisplayShell
   gchar             *title;            /*  current title                      */
   gchar             *status;           /*  current default statusbar content  */
 
-  gint               icon_size;        /*  size of the icon pixmap            */
+  gint               icon_size;        /*  size of the icon pixbuf            */
+  gint               icon_size_small;  /*  size of the icon's wilber pixbuf   */
   guint              icon_idle_id;     /*  ID of the idle-function            */
   GdkPixbuf         *icon;             /*  icon                               */
 


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