From 55642822fed69f1dd93e034065963f634a837d4b Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 25 Jan 2013 16:57:10 -0500 Subject: [PATCH] spinbutton: paint an additional slice of background Normally, the xthickness in the style maps to the space on the sides of the widget, to accommodate for its border - GtkEntry's text area background width is calculated as (allocation->width - 2 * xthickness), and the border is rendered in that area. GtkSpinButton has an additional panel for the buttons though, which will render the right-side (left-side for RTL) border itself, taking xthickness into account. This results in the xthickness for that side being applied twice, both to the spinbutton panel and to the entry's text area. Visually, a slice with no painted background can be seen in spinbuttons on the right side (left side when RTL) of the text area, where the border would be rendered by the entry, which looks bad. This patch makes GtkSpinButton render the same background of the entry in that slice, to compensate for the xthickness being allocated to the button panel instead. https://bugzilla.gnome.org/show_bug.cgi?id=683511 --- gtk/gtkspinbutton.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 1bfa03516e..9f74f7a610 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -766,7 +766,34 @@ gtk_spin_button_expose (GtkWidget *widget, gtk_spin_button_draw_arrow (spin, &event->area, GTK_ARROW_DOWN); } else - GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event); + { + if (event->window == widget->window) + { + gint text_x, text_y, text_width, text_height, slice_x; + + /* Since we reuse xthickness for the buttons panel on one side, and GtkEntry + * always sizes its background to (allocation->width - 2 * xthickness), we + * have to manually render the missing slice of the background on the panel + * side. + */ + GTK_ENTRY_GET_CLASS (spin)->get_text_area_size (GTK_ENTRY (spin), + &text_x, &text_y, + &text_width, &text_height); + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + slice_x = text_x - widget->style->xthickness; + else + slice_x = text_x + text_width; + + gtk_paint_flat_box (widget->style, widget->window, + gtk_widget_get_state (widget), GTK_SHADOW_NONE, + &event->area, widget, "entry_bg", + slice_x, text_y, + widget->style->xthickness, text_height); + } + + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event); + } } return FALSE;