[gimp/gtk3-port: 90/236] app: GtkEntry turned into a no-window widget



commit e8ca7f1409cc909ad65d05859e423078f28a5e3c
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 22 16:45:36 2010 +0200

    app: GtkEntry turned into a no-window widget
    
    Therefore, use the new get_area() functions to figure where to draw
    from instead of the removed get_window() ones. Also adjust the tag
    popup positioning code accordingly.

 app/widgets/gimpcombotagentry.c |   37 ++++++++++++++++++-------------------
 app/widgets/gimptagentry.c      |   24 ++++++++----------------
 app/widgets/gimptagpopup.c      |    6 ++++++
 3 files changed, 32 insertions(+), 35 deletions(-)
---
diff --git a/app/widgets/gimpcombotagentry.c b/app/widgets/gimpcombotagentry.c
index d2ed3bb..97ab485 100644
--- a/app/widgets/gimpcombotagentry.c
+++ b/app/widgets/gimpcombotagentry.c
@@ -142,32 +142,31 @@ static gboolean
 gimp_combo_tag_entry_draw (GtkWidget *widget,
                            cairo_t   *cr)
 {
-  GdkWindow *icon_window;
+  GtkStyle     *style = gtk_widget_get_style (widget);
+  GdkRectangle  icon_area;
+  gint          x, y;
 
+  cairo_save (cr);
   GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+  cairo_restore (cr);
 
-  icon_window = gtk_entry_get_icon_window (GTK_ENTRY (widget),
-                                           GTK_ENTRY_ICON_SECONDARY);
+  gtk_entry_get_icon_area (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY,
+                           &icon_area);
 
-  if (gtk_cairo_should_draw_window (cr, icon_window))
-    {
-      GtkStyle *style = gtk_widget_get_style (widget);
-      gint      x, y;
-
-      gtk_cairo_transform_to_window (cr, widget, icon_window);
+  gdk_cairo_rectangle (cr, &icon_area);
+  cairo_clip (cr);
 
-      gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]);
-      cairo_paint (cr);
+  gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]);
+  cairo_paint (cr);
 
-      x = (gdk_window_get_width  (icon_window) - 8) / 2;
-      y = (gdk_window_get_height (icon_window) - 8) / 2;
+  x = icon_area.x + (icon_area.width  - 8) / 2;
+  y = icon_area.y + (icon_area.height - 8) / 2;
 
-      gtk_paint_arrow (style, cr,
-                       GTK_STATE_NORMAL,
-                       GTK_SHADOW_NONE, widget, NULL,
-                       GTK_ARROW_DOWN, TRUE,
-                       x, y, 8, 8);
-    }
+  gtk_paint_arrow (style, cr,
+                   GTK_STATE_NORMAL,
+                   GTK_SHADOW_NONE, widget, NULL,
+                   GTK_ARROW_DOWN, TRUE,
+                   x, y, 8, 8);
 
   return FALSE;
 }
diff --git a/app/widgets/gimptagentry.c b/app/widgets/gimptagentry.c
index c9e12c5..6126c56 100644
--- a/app/widgets/gimptagentry.c
+++ b/app/widgets/gimptagentry.c
@@ -1249,25 +1249,20 @@ gimp_tag_entry_draw (GtkWidget *widget,
                      cairo_t   *cr)
 {
   GimpTagEntry   *tag_entry = GIMP_TAG_ENTRY (widget);
-  GdkWindow      *window;
+  GdkRectangle    text_area;
   PangoLayout    *layout;
   PangoAttrList  *attr_list;
   PangoAttribute *attribute;
   gint            layout_width;
   gint            layout_height;
-  gint            window_width;
-  gint            window_height;
   gint            offset;
   const char     *display_text;
 
-  window = gtk_entry_get_text_window (GTK_ENTRY (widget));
-
-  if (! gtk_cairo_should_draw_window (cr, window))
-    return FALSE;
-
   if (! GIMP_TAG_ENTRY (widget)->description_shown)
     return FALSE;
 
+  gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
+
   if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_QUERY)
     {
       display_text = GIMP_TAG_ENTRY_QUERY_DESC;
@@ -1286,11 +1281,8 @@ gimp_tag_entry_draw (GtkWidget *widget,
   pango_layout_set_attributes (layout, attr_list);
   pango_attr_list_unref (attr_list);
 
-  window_width  = gdk_window_get_width  (window);
-  window_height = gdk_window_get_height (window);
-  pango_layout_get_size (layout,
-                         &layout_width, &layout_height);
-  offset = (window_height - PANGO_PIXELS (layout_height)) / 2;
+  pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
+  offset = (text_area.height - layout_height) / 2;
 
   gtk_paint_layout (gtk_widget_get_style (widget),
                     cr,
@@ -1299,9 +1291,9 @@ gimp_tag_entry_draw (GtkWidget *widget,
                     widget,
                     NULL,
                     (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
-                    window_width - PANGO_PIXELS (layout_width) - offset :
-                    offset,
-                    offset,
+                    text_area.width - layout_width - offset :
+                    text_area.x + offset,
+                    text_area.y + offset,
                     layout);
 
   g_object_unref (layout);
diff --git a/app/widgets/gimptagpopup.c b/app/widgets/gimptagpopup.c
index a717cdd..a8d8d9b 100644
--- a/app/widgets/gimptagpopup.c
+++ b/app/widgets/gimptagpopup.c
@@ -297,6 +297,12 @@ gimp_tag_popup_constructed (GObject *object)
 
   gdk_window_get_origin (gtk_widget_get_window (entry), &x, &y);
 
+  if (! gtk_widget_get_has_window (entry))
+    {
+      x += entry_allocation.x;
+      y += entry_allocation.y;
+    }
+
   max_height = entry_allocation.height * 10;
 
   screen_height = gdk_screen_get_height (gtk_widget_get_screen (entry));



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