diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-11-27 09:14:20 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-11-28 10:09:16 -0500 |
commit | 1a79ee4d3e559f01e79e8cd3ee5470791b552e30 (patch) | |
tree | 1a737b10d39a5665b90630e513af7bd7fd71a3c1 /gtk/gtkmenubar.c | |
parent | 01dc23cdec377c9d9897cc32bf28ec1d241b29fa (diff) | |
download | gtk+-1a79ee4d3e559f01e79e8cd3ee5470791b552e30.tar.gz |
menubar: add support for CSS padding
In preparation for the removal of the internal-padding style property.
https://bugzilla.gnome.org/show_bug.cgi?id=689168
Diffstat (limited to 'gtk/gtkmenubar.c')
-rw-r--r-- | gtk/gtkmenubar.c | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index b90e4b8921..c86094476b 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -336,6 +336,9 @@ gtk_menu_bar_size_request (GtkWidget *widget, guint border_width; gboolean use_toggle_size, use_maximize; gint child_minimum, child_natural; + GtkStyleContext *context; + GtkBorder border; + GtkStateFlags flags; *minimum = 0; *natural = 0; @@ -391,6 +394,21 @@ gtk_menu_bar_size_request (GtkWidget *widget, } } + context = gtk_widget_get_style_context (widget); + flags = gtk_widget_get_state_flags (widget); + gtk_style_context_get_padding (context, flags, &border); + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + *minimum += border.left + border.right; + *natural += border.left + border.right; + } + else + { + *minimum += border.top + border.bottom; + *natural += border.top + border.bottom; + } + gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar)); *minimum += (border_width + ipadding + BORDER_SPACING) * 2; @@ -398,12 +416,7 @@ gtk_menu_bar_size_request (GtkWidget *widget, if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { - GtkStyleContext *context; - GtkBorder border; - - context = gtk_widget_get_style_context (widget); - gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget), - &border); + gtk_style_context_get_border (context, flags, &border); if (orientation == GTK_ORIENTATION_HORIZONTAL) { @@ -484,28 +497,35 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, if (menu_shell->priv->children) { + GtkStyleContext *context; + GtkStateFlags flags; + GtkBorder border; + + context = gtk_widget_get_style_context (widget); + flags = gtk_widget_get_state_flags (widget); + gtk_style_context_get_padding (context, flags, &border); + gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL); - border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar)); + remaining_space.x = (border_width + - ipadding + - BORDER_SPACING); + ipadding + + BORDER_SPACING + + border.left); remaining_space.y = (border_width + - ipadding + - BORDER_SPACING); + ipadding + + BORDER_SPACING + + border.top); remaining_space.width = allocation->width - - 2 * (border_width + ipadding + BORDER_SPACING); + 2 * (border_width + ipadding + BORDER_SPACING) - + border.left - border.right; remaining_space.height = allocation->height - - 2 * (border_width + ipadding + BORDER_SPACING); - + 2 * (border_width + ipadding + BORDER_SPACING) - + border.top - border.bottom; + if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { - GtkStyleContext *context; - GtkBorder border; - - context = gtk_widget_get_style_context (widget); - gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget), - &border); + gtk_style_context_get_border (context, flags, &border); remaining_space.x += border.left; remaining_space.y += border.top; |