[gtk+] menuitem: cleanup arrow-spacing fetch code
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] menuitem: cleanup arrow-spacing fetch code
- Date: Thu, 15 Dec 2011 17:54:53 +0000 (UTC)
commit 69a5b3af94c0e3b11ca0360ec846c5c8a8187580
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Dec 15 18:49:16 2011 +0100
menuitem: cleanup arrow-spacing fetch code
Refactor get_arrow_size() to return the spacing as well, since basically
we always need both.
gtk/gtkmenuitem.c | 48 +++++++++++++++---------------------------------
1 files changed, 15 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 3aeb1aa..727c7d6 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -674,20 +674,26 @@ gtk_menu_item_detacher (GtkWidget *widget,
static void
get_arrow_size (GtkWidget *widget,
GtkWidget *child,
- gint *size)
+ gint *size,
+ gint *spacing)
{
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
PangoFontMetrics *metrics;
gfloat arrow_scaling;
+ gint arrow_spacing;
g_assert (size);
gtk_widget_style_get (widget,
"arrow-scaling", &arrow_scaling,
+ "arrow-spacing", &arrow_spacing,
NULL);
+ if (spacing != NULL)
+ *spacing = arrow_spacing;
+
context = gtk_widget_get_pango_context (child);
style_context = gtk_widget_get_style_context (child);
state = gtk_widget_get_state_flags (child);
@@ -816,20 +822,9 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
if ((menu_item->priv->submenu && !GTK_IS_MENU_BAR (parent)) || priv->reserve_indicator)
{
- guint arrow_spacing;
- gint arrow_size;
-
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
-
- get_arrow_size (widget, child, &arrow_size);
-
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
+ gint arrow_spacing, arrow_size;
- get_arrow_size (widget, child, &arrow_size);
+ get_arrow_size (widget, child, &arrow_size, &arrow_spacing);
min_width += arrow_size;
min_width += arrow_spacing;
@@ -925,22 +920,14 @@ gtk_menu_item_real_get_height (GtkWidget *widget,
if (child != NULL && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
- gint arrow_size = 0;
- guint arrow_spacing = 0;
+ gint arrow_size = 0, arrow_spacing = 0;
if ((priv->submenu && !GTK_IS_MENU_BAR (parent)) || priv->reserve_indicator)
- {
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
- get_arrow_size (widget, child, &arrow_size);
- }
+ get_arrow_size (widget, child, &arrow_size, &arrow_spacing);
if (for_size != -1)
{
- avail_size -= arrow_size;
- avail_size -= arrow_spacing;
-
+ avail_size -= (arrow_size + arrow_spacing);
gtk_widget_get_preferred_height_for_width (child,
avail_size,
&child_min,
@@ -1475,14 +1462,9 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
if ((priv->submenu && !GTK_IS_MENU_BAR (parent)) || priv->reserve_indicator)
{
- guint arrow_spacing;
- gint arrow_size;
-
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
+ gint arrow_spacing, arrow_size;
- get_arrow_size (widget, child, &arrow_size);
+ get_arrow_size (widget, child, &arrow_size, &arrow_spacing);
if (direction == GTK_TEXT_DIR_RTL)
child_allocation.x += arrow_size + arrow_spacing;
@@ -1649,7 +1631,7 @@ gtk_menu_item_draw (GtkWidget *widget,
"horizontal-padding", &horizontal_padding,
NULL);
- get_arrow_size (widget, child, &arrow_size);
+ get_arrow_size (widget, child, &arrow_size, NULL);
if (direction == GTK_TEXT_DIR_LTR)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]