From a1045cf3173e431561038908c37b9c6394757c88 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 20 Sep 2007 16:51:16 +0000 Subject: Override draw_layout method in GtkStyle in order to adjust by 2 pixels any 2007-09-20 Cody Russell * modules/engines/ms-windows/msw_style.c: Override draw_layout method in GtkStyle in order to adjust by 2 pixels any labels that are in GtkNotebook tabs using XP theme, so that they appear correctly centered. (#478637) svn path=/trunk/; revision=18848 --- modules/engines/ms-windows/msw_style.c | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'modules') diff --git a/modules/engines/ms-windows/msw_style.c b/modules/engines/ms-windows/msw_style.c index 2b0e822b18..9b61f590ab 100755 --- a/modules/engines/ms-windows/msw_style.c +++ b/modules/engines/ms-windows/msw_style.c @@ -3251,6 +3251,48 @@ draw_focus ( GtkStyle *style, */ } +static void +draw_layout (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + gboolean use_text, + GdkRectangle *area, + GtkWidget *widget, + const gchar *detail, + gint old_x, + gint old_y, + PangoLayout *layout) +{ + GtkNotebook *notebook = NULL; + gint x = old_x; + gint y = old_y; + + /* In the XP theme, labels don't appear correctly centered inside + * notebook tabs, so we give them a gentle nudge two pixels to the + * right. A little hackish, but what are 'ya gonna do? -- Cody + */ + if (xp_theme_is_active () && detail && !strcmp (detail, "label")) + { + if (widget->parent != NULL) + { + if (GTK_IS_NOTEBOOK (widget->parent)) + { + notebook = GTK_NOTEBOOK (widget->parent); + int side = gtk_notebook_get_tab_pos (notebook); + + if (side == GTK_POS_TOP || side == GTK_POS_BOTTOM) + { + x += 2; + } + } + } + } + + parent_class->draw_layout (style, window, state_type, + use_text, area, widget, + detail, x, y, layout); +} + static void msw_style_init_from_rc (GtkStyle * style, GtkRcStyle * rc_style) { @@ -3404,6 +3446,7 @@ msw_style_class_init (MswStyleClass * klass) style_class->draw_resize_grip = draw_resize_grip; style_class->draw_slider = draw_slider; style_class->draw_focus = draw_focus; + style_class->draw_layout = draw_layout; style_class->realize = msw_style_realize; style_class->unrealize = msw_style_unrealize; -- cgit v1.2.1