[gimp/gtk3-port: 72/451] app: GtkEntry turned into a no-window widget
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 72/451] app: GtkEntry turned into a no-window widget
- Date: Wed, 16 May 2018 01:10:19 +0000 (UTC)
commit 7b3618494a4741206017a53ef870b2406974dbd4
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 86a85c3..b2e34a7 100644
--- a/app/widgets/gimpcombotagentry.c
+++ b/app/widgets/gimpcombotagentry.c
@@ -144,32 +144,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 8d30a73..27b6ff5 100644
--- a/app/widgets/gimptagentry.c
+++ b/app/widgets/gimptagentry.c
@@ -1287,25 +1287,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;
@@ -1324,11 +1319,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,
@@ -1337,9 +1329,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 0099676..699f045 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]