From 0c01605d4d7537d2416de5918429b388a86a2194 Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Thu, 7 Feb 2008 01:27:27 -0800 Subject: [PATCH] Bug 406140 - "The inner-border style property of GtkButton is not read" [p=twanno@lycos.nl (Teune van Steeg) r+sr=roc a1.9=schrep] --- widget/src/gtk2/gtk2drawing.c | 44 ++++++++++++++++++++++++----------- widget/src/gtk2/gtkdrawing.h | 10 ++++++++ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/widget/src/gtk2/gtk2drawing.c b/widget/src/gtk2/gtk2drawing.c index 475e9fd4156e..72dd011b0e22 100644 --- a/widget/src/gtk2/gtk2drawing.c +++ b/widget/src/gtk2/gtk2drawing.c @@ -716,6 +716,24 @@ moz_gtk_splitter_get_metrics(gint orientation, gint* size) return MOZ_GTK_SUCCESS; } +gint +moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border) +{ + static const GtkBorder default_inner_border = { 1, 1, 1, 1 }; + GtkBorder *tmp_border; + + gtk_widget_style_get (widget, "inner-border", &tmp_border, NULL); + + if (tmp_border) { + *inner_border = *tmp_border; + gtk_border_free(tmp_border); + } + else + *inner_border = default_inner_border; + + return MOZ_GTK_SUCCESS; +} + static gint moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, @@ -2197,8 +2215,7 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, switch (widget) { case MOZ_GTK_BUTTON: { - /* Constant in gtkbutton.c */ - static const gint child_spacing = 1; + GtkBorder inner_border; gboolean interior_focus; gint focus_width, focus_pad; @@ -2209,10 +2226,11 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, become too big and stuff the layout. */ if (!inhtml) { moz_gtk_widget_get_focus(gButtonWidget, &interior_focus, &focus_width, &focus_pad); - *left += focus_width + focus_pad + child_spacing; - *right += focus_width + focus_pad + child_spacing; - *top += focus_width + focus_pad + child_spacing; - *bottom += focus_width + focus_pad + child_spacing; + moz_gtk_button_get_inner_border(gButtonWidget, &inner_border); + *left += focus_width + focus_pad + inner_border.left; + *right += focus_width + focus_pad + inner_border.right; + *top += focus_width + focus_pad + inner_border.top; + *bottom += focus_width + focus_pad + inner_border.bottom; } *left += gButtonWidget->style->xthickness; @@ -2242,19 +2260,19 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, * That is why the following code is the same as for MOZ_GTK_BUTTON. * */ - /* Constant in gtkbutton.c */ - static const gint child_spacing = 1; + GtkBorder inner_border; gboolean interior_focus; gint focus_width, focus_pad; ensure_tree_header_cell_widget(); *left = *top = *right = *bottom = GTK_CONTAINER(gTreeHeaderCellWidget)->border_width; - moz_gtk_widget_get_focus(gTreeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad); - *left += focus_width + focus_pad; - *right += focus_width + focus_pad; - *top += focus_width + focus_pad + child_spacing; - *bottom += focus_width + focus_pad + child_spacing; + moz_gtk_widget_get_focus(gTreeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad); + moz_gtk_button_get_inner_border(gTreeHeaderCellWidget, &inner_border); + *left += focus_width + focus_pad + inner_border.left; + *right += focus_width + focus_pad + inner_border.right; + *top += focus_width + focus_pad + inner_border.top; + *bottom += focus_width + focus_pad + inner_border.bottom; *left += gTreeHeaderCellWidget->style->xthickness; *right += gTreeHeaderCellWidget->style->xthickness; diff --git a/widget/src/gtk2/gtkdrawing.h b/widget/src/gtk2/gtkdrawing.h index ee797460c571..20f6ec85610a 100644 --- a/widget/src/gtk2/gtkdrawing.h +++ b/widget/src/gtk2/gtkdrawing.h @@ -289,6 +289,16 @@ moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing); gint moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing); +/** + * Get the inner-border value for a GtkButton widget (button or tree header) + * widget: [IN] the widget to get the border value for + * inner_border: [OUT] the inner border + * + * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise + */ +gint +moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border); + /** Get the focus metrics for a treeheadercell, button, checkbox, or radio button. * widget: [IN] the widget to get the focus metrics for * interior_focus: [OUT] whether the focus is drawn around the