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



commit 6e4d677f63d43a7a969374cb61ed04401bb00b49
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 de41b97..7b8d392 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 b10f561..3db23b8 100644
--- a/app/widgets/gimptagentry.c
+++ b/app/widgets/gimptagentry.c
@@ -1272,25 +1272,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;
@@ -1309,11 +1304,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,
@@ -1322,9 +1314,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 70b9e7e..e55ac7a 100644
--- a/app/widgets/gimptagpopup.c
+++ b/app/widgets/gimptagpopup.c
@@ -296,6 +296,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]