[gimp/gtk3-port: 97/137] app: port popup arrow drawing to cairo and get rid of the arrow_pixbuf



commit 627e49409a9a12e4bd8aaf6b7a0c39a47af11697
Author: Michael Natterer <mitch gimp org>
Date:   Wed Oct 20 19:38:20 2010 +0200

    app: port popup arrow drawing to cairo and get rid of the arrow_pixbuf

 app/widgets/gimpcombotagentry.c |   52 ++++++++++++--------------------------
 app/widgets/gimpcombotagentry.h |    2 -
 2 files changed, 17 insertions(+), 37 deletions(-)
---
diff --git a/app/widgets/gimpcombotagentry.c b/app/widgets/gimpcombotagentry.c
index 0a3154f..0ce1057 100644
--- a/app/widgets/gimpcombotagentry.c
+++ b/app/widgets/gimpcombotagentry.c
@@ -127,12 +127,6 @@ gimp_combo_tag_entry_dispose (GObject *object)
 {
   GimpComboTagEntry *combo_entry = GIMP_COMBO_TAG_ENTRY (object);
 
-  if (combo_entry->arrow_pixbuf)
-    {
-      g_object_unref (combo_entry->arrow_pixbuf);
-      combo_entry->arrow_pixbuf = NULL;
-    }
-
   if (combo_entry->normal_item_attr)
     {
       pango_attr_list_unref (combo_entry->normal_item_attr);
@@ -158,40 +152,34 @@ static gboolean
 gimp_combo_tag_entry_draw (GtkWidget *widget,
                            cairo_t   *cr)
 {
-  GimpComboTagEntry *entry = GIMP_COMBO_TAG_ENTRY (widget);
+  GdkWindow *icon_window;
 
-  if (! entry->arrow_pixbuf)
+  GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+
+  icon_window = gtk_entry_get_icon_window (GTK_ENTRY (widget),
+                                           GTK_ENTRY_ICON_SECONDARY);
+
+  if (gtk_cairo_should_draw_window (cr, icon_window))
     {
-#if 0
-      GtkStyle  *style = gtk_widget_get_style (widget);
-      GdkPixmap *pixmap;
-      cairo_t   *cr;
+      GtkStyle *style = gtk_widget_get_style (widget);
+      gint      x, y;
 
-      pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), 8, 8, -1);
+      gtk_cairo_transform_to_window (cr, widget, icon_window);
 
-      cr = gdk_cairo_create (pixmap);
       gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]);
       cairo_paint (cr);
-      cairo_destroy (cr);
 
-      gtk_paint_arrow (style, pixmap,
+      x = (gdk_window_get_width  (icon_window) - 8) / 2;
+      y = (gdk_window_get_height (icon_window) - 8) / 2;
+
+      gtk_paint_arrow (style, cr,
                        GTK_STATE_NORMAL,
-                       GTK_SHADOW_NONE, NULL, widget, NULL,
+                       GTK_SHADOW_NONE, widget, NULL,
                        GTK_ARROW_DOWN, TRUE,
-                       0, 0, 8, 8);
-
-      entry->arrow_pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL,
-                                                          0, 0, 0, 0, 8, 8);
-
-      g_object_unref (pixmap);
-
-      gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry),
-                                      GTK_ENTRY_ICON_SECONDARY,
-                                      entry->arrow_pixbuf);
-#endif
+                       x, y, 8, 8);
     }
 
-  return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+  return FALSE;
 }
 
 static void
@@ -242,12 +230,6 @@ gimp_combo_tag_entry_style_set (GtkWidget *widget,
   pango_attr_list_insert (entry->insensitive_item_attr, attribute);
 
   entry->selected_item_color = style->base[GTK_STATE_SELECTED];
-
-  if (entry->arrow_pixbuf)
-    {
-      g_object_unref (entry->arrow_pixbuf);
-      entry->arrow_pixbuf = NULL;
-    }
 }
 
 /**
diff --git a/app/widgets/gimpcombotagentry.h b/app/widgets/gimpcombotagentry.h
index 96d099f..4f47303 100644
--- a/app/widgets/gimpcombotagentry.h
+++ b/app/widgets/gimpcombotagentry.h
@@ -37,8 +37,6 @@ struct _GimpComboTagEntry
 {
   GimpTagEntry    parent_instance;
 
-  GdkPixbuf      *arrow_pixbuf;
-
   GtkWidget      *popup;
   PangoAttrList  *normal_item_attr;
   PangoAttrList  *selected_item_attr;



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