applied modified patch from maemo-gtk which adds a "horizontal-padding"

2005-12-02  Michael Natterer  <mitch@imendio.com>

	* gtk/gtkmenu.c: applied modified patch from maemo-gtk which
	adds a "horizontal-padding" style property. Fixes bug #323036.
This commit is contained in:
Michael Natterer 2005-12-02 19:49:10 +00:00 committed by Michael Natterer
parent dd7c0d77b1
commit b3f1be3b56
3 changed files with 43 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2005-12-02 Michael Natterer <mitch@imendio.com>
* gtk/gtkmenu.c: applied modified patch from maemo-gtk which
adds a "horizontal-padding" style property. Fixes bug #323036.
2005-12-01 Michael Natterer <mitch@imendio.com>
Merged modified patch from maemo-gtk that allows to disable

View File

@ -1,3 +1,8 @@
2005-12-02 Michael Natterer <mitch@imendio.com>
* gtk/gtkmenu.c: applied modified patch from maemo-gtk which
adds a "horizontal-padding" style property. Fixes bug #323036.
2005-12-01 Michael Natterer <mitch@imendio.com>
Merged modified patch from maemo-gtk that allows to disable

View File

@ -532,6 +532,15 @@ gtk_menu_class_init (GtkMenuClass *class)
1,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal-padding",
P_("Horizontal Padding"),
P_("Extra space at the left and right edges of the menu"),
0,
G_MAXINT,
0,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-offset",
P_("Vertical Offset"),
@ -2000,7 +2009,8 @@ gtk_menu_realize (GtkWidget *widget)
GtkWidget *child;
GList *children;
guint vertical_padding;
guint horizontal_padding;
g_return_if_fail (GTK_IS_MENU (widget));
menu = GTK_MENU (widget);
@ -2029,9 +2039,10 @@ gtk_menu_realize (GtkWidget *widget)
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
attributes.x = border_width + widget->style->xthickness;
attributes.x = border_width + widget->style->xthickness + horizontal_padding;
attributes.y = border_width + widget->style->ythickness + vertical_padding;
attributes.width = MAX (1, widget->allocation.width - attributes.x * 2);
attributes.height = MAX (1, widget->allocation.height - attributes.y * 2);
@ -2049,6 +2060,7 @@ gtk_menu_realize (GtkWidget *widget)
attributes.x = 0;
attributes.y = 0;
attributes.width = MAX (1, widget->allocation.width - (border_width + widget->style->xthickness + horizontal_padding) * 2);
attributes.height = MAX (1, widget->requisition.height - (border_width + widget->style->ythickness + vertical_padding) * 2);
menu->bin_window = gdk_window_new (menu->view_window, &attributes, attributes_mask);
@ -2166,6 +2178,7 @@ gtk_menu_size_request (GtkWidget *widget,
guint max_toggle_size;
guint max_accel_width;
guint vertical_padding;
guint horizontal_padding;
GtkRequisition child_requisition;
GtkMenuPrivate *priv;
@ -2227,12 +2240,14 @@ gtk_menu_size_request (GtkWidget *widget,
requisition->width += max_toggle_size + max_accel_width;
requisition->width *= gtk_menu_get_n_columns (menu);
requisition->width += (GTK_CONTAINER (menu)->border_width +
widget->style->xthickness) * 2;
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
requisition->width += (GTK_CONTAINER (menu)->border_width + horizontal_padding +
widget->style->xthickness) * 2;
requisition->height += (GTK_CONTAINER (menu)->border_width + vertical_padding +
widget->style->ythickness) * 2;
@ -2258,6 +2273,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
gint x, y;
gint width, height;
guint vertical_padding;
guint horizontal_padding;
g_return_if_fail (GTK_IS_MENU (widget));
g_return_if_fail (allocation != NULL);
@ -2271,9 +2287,10 @@ gtk_menu_size_allocate (GtkWidget *widget,
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness;
x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness + horizontal_padding;
y = GTK_CONTAINER (menu)->border_width + widget->style->ythickness + vertical_padding;
width = MAX (1, allocation->width - x * 2);
@ -2414,16 +2431,18 @@ gtk_menu_paint (GtkWidget *widget,
gint width, height;
gint border_x, border_y;
guint vertical_padding;
guint horizontal_padding;
g_return_if_fail (GTK_IS_MENU (widget));
menu = GTK_MENU (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
border_x = GTK_CONTAINER (widget)->border_width + widget->style->xthickness;
border_x = GTK_CONTAINER (widget)->border_width + widget->style->xthickness + horizontal_padding;
border_y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness + vertical_padding;
gdk_drawable_get_size (widget->window, &width, &height);
@ -3656,6 +3675,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
gboolean last_visible;
gint menu_height;
guint vertical_padding;
guint horizontal_padding;
widget = GTK_WIDGET (menu);
@ -3675,15 +3695,16 @@ gtk_menu_scroll_to (GtkMenu *menu,
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
border_width = GTK_CONTAINER (menu)->border_width;
view_width -= (border_width + widget->style->xthickness) * 2;
view_width -= (border_width + widget->style->xthickness + horizontal_padding) * 2;
view_height -= (border_width + widget->style->ythickness + vertical_padding) * 2;
menu_height = widget->requisition.height -
(border_width + widget->style->ythickness + vertical_padding) * 2;
x = border_width + widget->style->xthickness;
x = border_width + widget->style->xthickness + horizontal_padding;
y = border_width + widget->style->ythickness + vertical_padding;
if (!menu->tearoff_active)