diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2011-05-17 14:20:31 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2011-05-18 10:27:21 -0400 |
commit | c8a59a6f92e79461622ebd6da058d29094d696ef (patch) | |
tree | e56f5c7c78601976d092b43d174bdcf6adfd903e /gtk/gtkmenubar.c | |
parent | 61e49e159a0eb366251e921882392f01729fdf0d (diff) | |
download | gtk+-c8a59a6f92e79461622ebd6da058d29094d696ef.tar.gz |
all: avoid boxed structs copying where possible
Use the GtkStyleContext accessors for boxed properties where possible,
to reduce allocations.
https://bugzilla.gnome.org/show_bug.cgi?id=650420
Diffstat (limited to 'gtk/gtkmenubar.c')
-rw-r--r-- | gtk/gtkmenubar.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 7c07aa63b1..521f814d52 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -398,25 +398,22 @@ gtk_menu_bar_size_request (GtkWidget *widget, if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { GtkStyleContext *context; - GtkBorder *border; + GtkBorder border; context = gtk_widget_get_style_context (widget); - - gtk_style_context_get (context, 0, - "border-width", &border, - NULL); + gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget), + &border); if (orientation == GTK_ORIENTATION_HORIZONTAL) { - *minimum += border->left + border->right; - *natural += border->left + border->right; + *minimum += border.left + border.right; + *natural += border.left + border.right; } else { - *minimum += border->top + border->bottom; - *natural += border->top + border->bottom; + *minimum += border.top + border.bottom; + *natural += border.top + border.bottom; } - gtk_border_free (border); } } @@ -503,19 +500,16 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { GtkStyleContext *context; - GtkBorder *border; + GtkBorder border; context = gtk_widget_get_style_context (widget); - gtk_style_context_get (context, 0, - "border-width", &border, - NULL); - - remaining_space.x += border->left; - remaining_space.y += border->top; - remaining_space.width -= border->left + border->right; - remaining_space.height -= border->top + border->bottom; + gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget), + &border); - gtk_border_free (border); + remaining_space.x += border.left; + remaining_space.y += border.top; + remaining_space.width -= border.left + border.right; + remaining_space.height -= border.top + border.bottom; } requested_sizes = g_array_new (FALSE, FALSE, sizeof (GtkRequestedSize)); |