Commit 091a4d7f authored by Cosimo Cecchi's avatar Cosimo Cecchi

menu: don't use the border as a padding value

Borders should be rendered inside the allocation, not act as a second
padding.

https://bugzilla.gnome.org/show_bug.cgi?id=650418
parent c8a59a6f
...@@ -2501,23 +2501,16 @@ get_arrows_border (GtkMenu *menu, ...@@ -2501,23 +2501,16 @@ get_arrows_border (GtkMenu *menu,
} }
static void static void
get_menu_border (GtkWidget *widget, get_menu_padding (GtkWidget *widget,
GtkBorder *border) GtkBorder *padding)
{ {
GtkStyleContext *context; GtkStyleContext *context;
GtkStateFlags state; GtkStateFlags state;
GtkBorder padding, border_width;
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget); state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding); gtk_style_context_get_padding (context, state, padding);
gtk_style_context_get_border (context, state, &border_width);
border->left = border_width.left + padding.left;
border->right = border_width.right + padding.right;
border->top = border_width.top + padding.top;
border->bottom = border_width.bottom + padding.bottom;
} }
static void static void
...@@ -2535,7 +2528,7 @@ gtk_menu_realize (GtkWidget *widget) ...@@ -2535,7 +2528,7 @@ gtk_menu_realize (GtkWidget *widget)
GList *children; GList *children;
guint vertical_padding; guint vertical_padding;
guint horizontal_padding; guint horizontal_padding;
GtkBorder arrow_border, border; GtkBorder arrow_border, padding;
g_return_if_fail (GTK_IS_MENU (widget)); g_return_if_fail (GTK_IS_MENU (widget));
...@@ -2561,7 +2554,7 @@ gtk_menu_realize (GtkWidget *widget) ...@@ -2561,7 +2554,7 @@ gtk_menu_realize (GtkWidget *widget)
gtk_widget_set_window (widget, window); gtk_widget_set_window (widget, window);
gdk_window_set_user_data (window, widget); gdk_window_set_user_data (window, widget);
get_menu_border (widget, &border); get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
...@@ -2572,12 +2565,12 @@ gtk_menu_realize (GtkWidget *widget) ...@@ -2572,12 +2565,12 @@ gtk_menu_realize (GtkWidget *widget)
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
attributes.x = border_width + border.left + horizontal_padding; attributes.x = border_width + padding.left + horizontal_padding;
attributes.y = border_width + border.top + vertical_padding; attributes.y = border_width + padding.top + vertical_padding;
attributes.width = allocation.width - attributes.width = allocation.width -
(2 * (border_width + horizontal_padding)) - border.left - border.right; (2 * (border_width + horizontal_padding)) - padding.left - padding.right;
attributes.height = allocation.height - attributes.height = allocation.height -
(2 * (border_width + vertical_padding)) - border.top - border.bottom; (2 * (border_width + vertical_padding)) - padding.top - padding.bottom;
get_arrows_border (menu, &arrow_border); get_arrows_border (menu, &arrow_border);
attributes.y += arrow_border.top; attributes.y += arrow_border.top;
...@@ -2596,9 +2589,9 @@ gtk_menu_realize (GtkWidget *widget) ...@@ -2596,9 +2589,9 @@ gtk_menu_realize (GtkWidget *widget)
attributes.x = 0; attributes.x = 0;
attributes.y = 0; attributes.y = 0;
attributes.width = allocation.width + (2 * (border_width + horizontal_padding)) + attributes.width = allocation.width + (2 * (border_width + horizontal_padding)) +
border.left + border.right; padding.left + padding.right;
attributes.height = priv->requested_height - (2 * (border_width + vertical_padding)) + attributes.height = priv->requested_height - (2 * (border_width + vertical_padding)) +
border.top + border.bottom; padding.top + padding.bottom;
attributes.width = MAX (1, attributes.width); attributes.width = MAX (1, attributes.width);
attributes.height = MAX (1, attributes.height); attributes.height = MAX (1, attributes.height);
...@@ -2708,8 +2701,6 @@ calculate_line_heights (GtkMenu *menu, ...@@ -2708,8 +2701,6 @@ calculate_line_heights (GtkMenu *menu,
guint **ret_min_heights, guint **ret_min_heights,
guint **ret_nat_heights) guint **ret_nat_heights)
{ {
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding; GtkBorder padding;
GtkMenuPrivate *priv; GtkMenuPrivate *priv;
GtkMenuShell *menu_shell; GtkMenuShell *menu_shell;
...@@ -2736,10 +2727,7 @@ calculate_line_heights (GtkMenu *menu, ...@@ -2736,10 +2727,7 @@ calculate_line_heights (GtkMenu *menu,
gtk_widget_style_get (GTK_WIDGET (menu), gtk_widget_style_get (GTK_WIDGET (menu),
"horizontal-padding", &horizontal_padding, "horizontal-padding", &horizontal_padding,
NULL); NULL);
get_menu_padding (widget, &padding);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
avail_width -= (border_width + horizontal_padding) * 2 + padding.left + padding.right; avail_width -= (border_width + horizontal_padding) * 2 + padding.left + padding.right;
...@@ -2800,7 +2788,7 @@ gtk_menu_size_allocate (GtkWidget *widget, ...@@ -2800,7 +2788,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
guint border_width; guint border_width;
guint vertical_padding; guint vertical_padding;
guint horizontal_padding; guint horizontal_padding;
GtkBorder border; GtkBorder padding;
g_return_if_fail (GTK_IS_MENU (widget)); g_return_if_fail (GTK_IS_MENU (widget));
g_return_if_fail (allocation != NULL); g_return_if_fail (allocation != NULL);
...@@ -2816,7 +2804,7 @@ gtk_menu_size_allocate (GtkWidget *widget, ...@@ -2816,7 +2804,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
"horizontal-padding", &horizontal_padding, "horizontal-padding", &horizontal_padding,
NULL); NULL);
get_menu_border (widget, &border); get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
g_free (priv->heights); g_free (priv->heights);
...@@ -2827,16 +2815,16 @@ gtk_menu_size_allocate (GtkWidget *widget, ...@@ -2827,16 +2815,16 @@ gtk_menu_size_allocate (GtkWidget *widget,
/* refresh our cached height request */ /* refresh our cached height request */
priv->requested_height = (2 * (border_width + vertical_padding)) + priv->requested_height = (2 * (border_width + vertical_padding)) +
border.top + border.bottom; padding.top + padding.bottom;
for (i = 0; i < priv->heights_length; i++) for (i = 0; i < priv->heights_length; i++)
priv->requested_height += priv->heights[i]; priv->requested_height += priv->heights[i];
x = border_width + border.left + horizontal_padding; x = border_width + padding.left + horizontal_padding;
y = border_width + border.top + vertical_padding; y = border_width + padding.top + vertical_padding;
width = allocation->width - (2 * (border_width + horizontal_padding)) - width = allocation->width - (2 * (border_width + horizontal_padding)) -
border.left - border.right; padding.left - padding.right;
height = allocation->height - (2 * (border_width + vertical_padding)) - height = allocation->height - (2 * (border_width + vertical_padding)) -
border.top - border.bottom; padding.top - padding.bottom;
if (menu_shell->priv->active) if (menu_shell->priv->active)
gtk_menu_scroll_to (menu, priv->scroll_offset); gtk_menu_scroll_to (menu, priv->scroll_offset);
...@@ -2968,7 +2956,7 @@ get_arrows_visible_area (GtkMenu *menu, ...@@ -2968,7 +2956,7 @@ get_arrows_visible_area (GtkMenu *menu,
guint vertical_padding; guint vertical_padding;
guint horizontal_padding; guint horizontal_padding;
gint scroll_arrow_height; gint scroll_arrow_height;
GtkBorder menu_border; GtkBorder menu_padding;
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding, "vertical-padding", &vertical_padding,
...@@ -2977,10 +2965,10 @@ get_arrows_visible_area (GtkMenu *menu, ...@@ -2977,10 +2965,10 @@ get_arrows_visible_area (GtkMenu *menu,
"arrow-placement", &arrow_placement, "arrow-placement", &arrow_placement,
NULL); NULL);
get_menu_border (widget, &menu_border); get_menu_padding (widget, &menu_padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
border->x = border_width + menu_border.left + horizontal_padding; border->x = border_width + menu_padding.left + horizontal_padding;
border->y = border_width + menu_border.top + vertical_padding; border->y = border_width + menu_padding.top + vertical_padding;
border->width = gdk_window_get_width (gtk_widget_get_window (widget)); border->width = gdk_window_get_width (gtk_widget_get_window (widget));
border->height = gdk_window_get_height (gtk_widget_get_window (widget)); border->height = gdk_window_get_height (gtk_widget_get_window (widget));
...@@ -3028,7 +3016,7 @@ get_arrows_visible_area (GtkMenu *menu, ...@@ -3028,7 +3016,7 @@ get_arrows_visible_area (GtkMenu *menu,
lower->x = lower->y = lower->width = lower->height = 0; lower->x = lower->y = lower->width = lower->height = 0;
} }
*arrow_space = scroll_arrow_height - menu_border.top - menu_border.bottom; *arrow_space = scroll_arrow_height - menu_padding.top - menu_padding.bottom;
} }
static gboolean static gboolean
...@@ -3042,14 +3030,14 @@ gtk_menu_draw (GtkWidget *widget, ...@@ -3042,14 +3030,14 @@ gtk_menu_draw (GtkWidget *widget,
GdkRectangle upper; GdkRectangle upper;
GdkRectangle lower; GdkRectangle lower;
gint arrow_space; gint arrow_space;
GtkBorder menu_border; GtkBorder menu_padding;
menu = GTK_MENU (widget); menu = GTK_MENU (widget);
priv = menu->priv; priv = menu->priv;
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
get_arrows_visible_area (menu, &border, &upper, &lower, &arrow_space); get_arrows_visible_area (menu, &border, &upper, &lower, &arrow_space);
get_menu_border (widget, &menu_border); get_menu_padding (widget, &menu_padding);
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget))) if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
{ {
...@@ -3083,7 +3071,7 @@ gtk_menu_draw (GtkWidget *widget, ...@@ -3083,7 +3071,7 @@ gtk_menu_draw (GtkWidget *widget,
gtk_render_arrow (context, cr, 0, gtk_render_arrow (context, cr, 0,
upper.x + (upper.width - arrow_size) / 2, upper.x + (upper.width - arrow_size) / 2,
upper.y + menu_border.top + (arrow_space - arrow_size) / 2, upper.y + menu_padding.top + (arrow_space - arrow_size) / 2,
arrow_size); arrow_size);
gtk_style_context_restore (context); gtk_style_context_restore (context);
...@@ -3103,7 +3091,7 @@ gtk_menu_draw (GtkWidget *widget, ...@@ -3103,7 +3091,7 @@ gtk_menu_draw (GtkWidget *widget,
gtk_render_arrow (context, cr, G_PI, gtk_render_arrow (context, cr, G_PI,
lower.x + (lower.width - arrow_size) / 2, lower.x + (lower.width - arrow_size) / 2,
lower.y + menu_border.top + (arrow_space - arrow_size) / 2, lower.y + menu_padding.bottom + (arrow_space - arrow_size) / 2,
arrow_size); arrow_size);
gtk_style_context_restore (context); gtk_style_context_restore (context);
...@@ -3169,7 +3157,7 @@ gtk_menu_get_preferred_width (GtkWidget *widget, ...@@ -3169,7 +3157,7 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
guint border_width; guint border_width;
gint child_min, child_nat; gint child_min, child_nat;
gint min_width, nat_width; gint min_width, nat_width;
GtkBorder border; GtkBorder padding;
menu = GTK_MENU (widget); menu = GTK_MENU (widget);
menu_shell = GTK_MENU_SHELL (widget); menu_shell = GTK_MENU_SHELL (widget);
...@@ -3260,12 +3248,12 @@ gtk_menu_get_preferred_width (GtkWidget *widget, ...@@ -3260,12 +3248,12 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
"horizontal-padding", &horizontal_padding, "horizontal-padding", &horizontal_padding,
NULL); NULL);
get_menu_border (widget, &border); get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
min_width += (2 * (border_width + horizontal_padding)) + min_width += (2 * (border_width + horizontal_padding)) +
border.left + border.right; padding.left + padding.right;
nat_width += (2 * (border_width + horizontal_padding)) + nat_width += (2 * (border_width + horizontal_padding)) +
border.top + border.bottom; padding.left + padding.right;
priv->toggle_size = max_toggle_size; priv->toggle_size = max_toggle_size;
priv->accel_size = max_accel_width; priv->accel_size = max_accel_width;
...@@ -3303,9 +3291,7 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget, ...@@ -3303,9 +3291,7 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
gint *minimum_size, gint *minimum_size,
gint *natural_size) gint *natural_size)
{ {
GtkStyleContext *context; GtkBorder padding;
GtkStateFlags state;
GtkBorder padding, border;
GtkMenu *menu = GTK_MENU (widget); GtkMenu *menu = GTK_MENU (widget);
GtkMenuPrivate *priv = menu->priv; GtkMenuPrivate *priv = menu->priv;
guint *min_heights, *nat_heights; guint *min_heights, *nat_heights;
...@@ -3315,14 +3301,10 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget, ...@@ -3315,14 +3301,10 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
gtk_widget_style_get (widget, "vertical-padding", &vertical_padding, NULL); gtk_widget_style_get (widget, "vertical-padding", &vertical_padding, NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
get_menu_padding (widget, &padding);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_get_border (context, state, &border);
min_height = nat_height = (border_width + vertical_padding) * 2 + min_height = nat_height = (border_width + vertical_padding) * 2 +
padding.left + padding.right + border.left + border.right; padding.top + padding.bottom;
n_heights = n_heights =
calculate_line_heights (menu, for_size, &min_heights, &nat_heights); calculate_line_heights (menu, for_size, &min_heights, &nat_heights);
...@@ -3995,8 +3977,6 @@ get_arrows_sensitive_area (GtkMenu *menu, ...@@ -3995,8 +3977,6 @@ get_arrows_sensitive_area (GtkMenu *menu,
guint vertical_padding; guint vertical_padding;
gint win_x, win_y; gint win_x, win_y;
gint scroll_arrow_height; gint scroll_arrow_height;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding; GtkBorder padding;
window = gtk_widget_get_window (widget); window = gtk_widget_get_window (widget);
...@@ -4010,10 +3990,7 @@ get_arrows_sensitive_area (GtkMenu *menu, ...@@ -4010,10 +3990,7 @@ get_arrows_sensitive_area (GtkMenu *menu,
NULL); NULL);
border = gtk_container_get_border_width (GTK_CONTAINER (menu)) + vertical_padding; border = gtk_container_get_border_width (GTK_CONTAINER (menu)) + vertical_padding;
get_menu_padding (widget, &padding);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
gdk_window_get_position (window, &win_x, &win_y); gdk_window_get_position (window, &win_x, &win_y);
...@@ -4718,10 +4695,10 @@ gtk_menu_position (GtkMenu *menu, ...@@ -4718,10 +4695,10 @@ gtk_menu_position (GtkMenu *menu,
gint space_left, space_right, space_above, space_below; gint space_left, space_right, space_above, space_below;
gint needed_width; gint needed_width;
gint needed_height; gint needed_height;
GtkBorder border; GtkBorder padding;
gboolean rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); gboolean rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
get_menu_border (widget, &border); get_menu_padding (widget, &padding);
/* The placement of popup menus horizontally works like this (with /* The placement of popup menus horizontally works like this (with
* RTL in parentheses) * RTL in parentheses)
...@@ -4753,7 +4730,7 @@ gtk_menu_position (GtkMenu *menu, ...@@ -4753,7 +4730,7 @@ gtk_menu_position (GtkMenu *menu,
/* the amount of space we need to position the menu. /* the amount of space we need to position the menu.
* Note the menu is offset "thickness" pixels * Note the menu is offset "thickness" pixels
*/ */
needed_width = requisition.width - border.left; needed_width = requisition.width - padding.left;
if (needed_width <= space_left || if (needed_width <= space_left ||
needed_width <= space_right) needed_width <= space_right)
...@@ -4762,12 +4739,12 @@ gtk_menu_position (GtkMenu *menu, ...@@ -4762,12 +4739,12 @@ gtk_menu_position (GtkMenu *menu,
(!rtl && needed_width > space_right)) (!rtl && needed_width > space_right))
{ {
/* position left */ /* position left */
x = x + border.left - requisition.width + 1; x = x + padding.left - requisition.width + 1;
} }
else else
{ {
/* position right */ /* position right */
x = x - border.right; x = x - padding.right;
} }
/* x is clamped on-screen further down */ /* x is clamped on-screen further down */
...@@ -4807,15 +4784,15 @@ gtk_menu_position (GtkMenu *menu, ...@@ -4807,15 +4784,15 @@ gtk_menu_position (GtkMenu *menu,
* The algorithm is the same as above, but simpler * The algorithm is the same as above, but simpler
* because we don't have to take RTL into account. * because we don't have to take RTL into account.
*/ */
needed_height = requisition.height - border.top; needed_height = requisition.height - padding.top;
if (needed_height <= space_above || if (needed_height <= space_above ||
needed_height <= space_below) needed_height <= space_below)
{ {
if (needed_height <= space_below) if (needed_height <= space_below)
y = y - border.top; y = y - padding.top;
else else
y = y + border.bottom - requisition.height + 1; y = y + padding.bottom - requisition.height + 1;
y = CLAMP (y, monitor.y, y = CLAMP (y, monitor.y,
monitor.y + monitor.height - requisition.height); monitor.y + monitor.height - requisition.height);
...@@ -4930,7 +4907,7 @@ gtk_menu_scroll_to (GtkMenu *menu, ...@@ -4930,7 +4907,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
{ {
GtkMenuPrivate *priv = menu->priv; GtkMenuPrivate *priv = menu->priv;
GtkAllocation allocation; GtkAllocation allocation;
GtkBorder arrow_border, border; GtkBorder arrow_border, padding;
GtkWidget *widget; GtkWidget *widget;
gint x, y; gint x, y;
gint view_width, view_height; gint view_width, view_height;
...@@ -4955,18 +4932,18 @@ gtk_menu_scroll_to (GtkMenu *menu, ...@@ -4955,18 +4932,18 @@ gtk_menu_scroll_to (GtkMenu *menu,
"horizontal-padding", &horizontal_padding, "horizontal-padding", &horizontal_padding,
NULL); NULL);
get_menu_border (widget, &border); get_menu_padding (widget, &padding);
double_arrows = get_double_arrows (menu); double_arrows = get_double_arrows (menu);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
view_width -= (2 * (border_width + horizontal_padding)) + border.left + border.right; view_width -= (2 * (border_width + horizontal_padding)) + padding.left + padding.right;
view_height -= (2 * (border_width + vertical_padding)) + border.top + border.bottom; view_height -= (2 * (border_width + vertical_padding)) + padding.top + padding.bottom;
menu_height = priv->requested_height - (2 * (border_width + vertical_padding)) - menu_height = priv->requested_height - (2 * (border_width + vertical_padding)) -
border.top - border.bottom; padding.top - padding.bottom;
x = border_width + border.left + horizontal_padding; x = border_width + padding.left + horizontal_padding;
y = border_width + border.top + vertical_padding; y = border_width + padding.top + vertical_padding;
if (double_arrows && !priv->tearoff_active) if (double_arrows && !priv->tearoff_active)
{ {
...@@ -5165,8 +5142,6 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell, ...@@ -5165,8 +5142,6 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
{ {
guint vertical_padding; guint vertical_padding;
gboolean double_arrows; gboolean double_arrows;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding; GtkBorder padding;
y = priv->scroll_offset; y = priv->scroll_offset;
...@@ -5177,10 +5152,7 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell, ...@@ -5177,10 +5152,7 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
NULL); NULL);
double_arrows = get_double_arrows (menu); double_arrows = get_double_arrows (menu);
get_menu_padding (widget, &padding);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
height -= 2 * gtk_container_get_border_width (GTK_CONTAINER (menu)) + height -= 2 * gtk_container_get_border_width (GTK_CONTAINER (menu)) +
padding.top + padding.bottom + padding.top + padding.bottom +
...@@ -5560,16 +5532,11 @@ get_visible_size (GtkMenu *menu) ...@@ -5560,16 +5532,11 @@ get_visible_size (GtkMenu *menu)
GtkAllocation allocation; GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (menu); GtkWidget *widget = GTK_WIDGET (menu);
GtkContainer *container = GTK_CONTAINER (menu); GtkContainer *container = GTK_CONTAINER (menu);
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding; GtkBorder padding;
gint menu_height; gint menu_height;
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
get_menu_padding (widget, &padding);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
menu_height = (allocation.height - menu_height = (allocation.height -
(2 * gtk_container_get_border_width (container)) - (2 * gtk_container_get_border_width (container)) -
...@@ -5639,21 +5606,15 @@ get_menu_height (GtkMenu *menu) ...@@ -5639,21 +5606,15 @@ get_menu_height (GtkMenu *menu)
GtkMenuPrivate *priv = menu->priv; GtkMenuPrivate *priv = menu->priv;
GtkAllocation allocation; GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (menu); GtkWidget *widget = GTK_WIDGET (menu);
GtkStyleContext *context; GtkBorder padding;
GtkStateFlags state;
GtkBorder padding, border;
gint height; gint height;
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
get_menu_padding (widget, &padding);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_get_border (context, state, &border);
height = allocation.height; height = allocation.height;
height -= (gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2) + height -= (gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2) +
padding.top + padding.bottom + border.top + border.bottom; padding.top + padding.bottom;
if (!priv->tearoff_active) if (!priv->tearoff_active)
{ {
......
...@@ -758,7 +758,7 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget, ...@@ -758,7 +758,7 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
gint min_width, nat_width; gint min_width, nat_width;
GtkStyleContext *context; GtkStyleContext *context;
GtkStateFlags state; GtkStateFlags state;
GtkBorder padding, border; GtkBorder padding;
min_width = nat_width = 0; min_width = nat_width = 0;
...@@ -785,10 +785,8 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget, ...@@ -785,10 +785,8 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget); state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding); gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_get_border (context, state, &border);
min_width = (border_width * 2) + padding.left + padding.right + min_width = (border_width * 2) + padding.left + padding.right;
border.left + border.right;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) && if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL)) (child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
...@@ -856,7 +854,7 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget, ...@@ -856,7 +854,7 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget,
GtkBin *bin; GtkBin *bin;
GtkStyleContext *context; GtkStyleContext *context;
GtkStateFlags state; GtkStateFlags state;
GtkBorder padding, border; GtkBorder padding;
GtkWidget *child; GtkWidget *child;
GtkWidget *parent; GtkWidget *parent;
guint accel_width; guint accel_width;
...@@ -871,7 +869,6 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget, ...@@ -871,7 +869,6 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget,
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget); state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding); gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_get_border (context, state, &border);
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding, "horizontal-padding", &horizontal_padding,
...@@ -892,7 +889,7 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget, ...@@ -892,7 +889,7 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget,
} }
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
min_height = (border_width * 2) + padding.top + padding.bottom + border.top + border.bottom; min_height = (border_width * 2) + padding.top + padding.bottom;
if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) && if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT)) (child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))
...@@ -933,9 +930,9 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget, ...@@ -933,9 +930,9 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget,
NULL); NULL);
if (wide_separators) if (wide_separators)
min_height += separator_height + padding.top + border.top; min_height += separator_height + padding.top;
else else
min_height += padding.top + padding.bottom + border.top + border.bottom; min_height += padding.top + padding.bottom;
nat_height = min_height; nat_height = min_height;
} }
...@@ -964,7 +961,7 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget, ...@@ -964,7 +961,7 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget,
GtkBin *bin; GtkBin *bin;
GtkStyleContext *context; GtkStyleContext *context;
GtkStateFlags state; GtkStateFlags state;
GtkBorder padding, border; GtkBorder padding;
GtkWidget *child; GtkWidget *child;
GtkWidget *parent; GtkWidget *parent;
guint horizontal_padding; guint horizontal_padding;
...@@ -979,7 +976,6 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget, ...@@ -979,7 +976,6 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget,
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget); state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding); gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_get_border (context, state, &border);
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding, "horizontal-padding", &horizontal_padding,
...@@ -1000,10 +996,10 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget, ...@@ -1000,10 +996,10 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget,
} }
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
min_height = (border_width * 2) + padding.top + padding.bottom + border.top + border.bottom; min_height = (border_width * 2) + padding.top + padding.bottom;
avail_size = for_size; avail_size = for_size;
avail_size -= (border_width * 2) + padding.left + padding.right + border.left + border.right; avail_size -= (border_width * 2) + padding.left + padding.right;
if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) && if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT)) (child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))