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



commit 47e7e0cc937ddfcbeb0d5d02a1f837be9cd5a979
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 4403f97..d2ed3bb 100644
--- a/app/widgets/gimpcombotagentry.c
+++ b/app/widgets/gimpcombotagentry.c
@@ -117,12 +117,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);
@@ -148,40 +142,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
@@ -232,12 +220,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 1dcbcb4..01e136e 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]