[gtk+/combo-refactor: 1/56] Removed GtkMenuItem->show_submenu_indicator flag
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/combo-refactor: 1/56] Removed GtkMenuItem->show_submenu_indicator flag
- Date: Thu, 30 Dec 2010 08:26:57 +0000 (UTC)
commit 7e363aa1e74e3b14c061515462bd8ef2140b313b
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Nov 17 16:00:34 2010 +0900
Removed GtkMenuItem->show_submenu_indicator flag
The show_submenu_indicator flag was explicitly set in various
places from GtkMenu/GtkMenuBar at request times, since the
GtkMenuItem already checks the parent type for GTK_IS_MENU_BAR()
in various places, removed this flag in favor of just checking
the parent type (only in the interest of better readable code).
gtk/gtkmenu.c | 1 -
gtk/gtkmenubar.c | 1 -
gtk/gtkmenuitem.c | 67 ++++++++++++++++++++++++++++++-----------------------
3 files changed, 38 insertions(+), 31 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index cb203e8..3a2fc7c 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -3033,7 +3033,6 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
* case the toggle size request depends on the size
* request of a child of the child (e.g. for ImageMenuItem)
*/
- GTK_MENU_ITEM (child)->priv->show_submenu_indicator = TRUE;
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index ed42ec1..5f84425 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -313,7 +313,6 @@ gtk_menu_bar_size_request (GtkWidget *widget,
{
gint toggle_size;
- GTK_MENU_ITEM (child)->priv->show_submenu_indicator = FALSE;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
&toggle_size);
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index b087ebe..125d6df 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -422,10 +422,12 @@ gtk_menu_item_init (GtkMenuItem *menu_item)
gtk_widget_set_has_window (GTK_WIDGET (menu_item), FALSE);
- priv->submenu = NULL;
- priv->toggle_size = 0;
- priv->accelerator_width = 0;
- priv->show_submenu_indicator = FALSE;
+ priv->action = NULL;
+ priv->use_action_appearance = TRUE;
+
+ menu_item->submenu = NULL;
+ menu_item->toggle_size = 0;
+ menu_item->accelerator_width = 0;
if (gtk_widget_get_direction (GTK_WIDGET (menu_item)) == GTK_TEXT_DIR_RTL)
priv->submenu_direction = GTK_DIRECTION_LEFT;
else
@@ -711,10 +713,16 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
- if (priv->submenu && priv->show_submenu_indicator)
- {
- guint arrow_spacing;
- gint arrow_size;
+ if (menu_item->submenu && !GTK_IS_MENU_BAR (parent))
+ {
+ 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,
@@ -806,9 +814,9 @@ gtk_menu_item_get_preferred_height (GtkWidget *widget,
min_height += child_min;
nat_height += child_nat;
- if (priv->submenu && priv->show_submenu_indicator)
- {
- gint arrow_size;
+ if (menu_item->submenu && !GTK_IS_MENU_BAR (parent))
+ {
+ gint arrow_size;
get_arrow_size (widget, child, &arrow_size);
@@ -910,9 +918,9 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget,
{
gint child_min, child_nat;
gint arrow_size = 0;
-
- if (priv->submenu && priv->show_submenu_indicator)
- {
+
+ if (menu_item->submenu && !GTK_IS_MENU_BAR (parent))
+ {
guint arrow_spacing;
gtk_widget_style_get (widget,
@@ -933,11 +941,11 @@ gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget,
min_height += child_min;
nat_height += child_nat;
- if (priv->submenu && priv->show_submenu_indicator)
- {
- min_height = MAX (min_height, arrow_size);
- nat_height = MAX (nat_height, arrow_size);
- }
+ if (menu_item->submenu && !GTK_IS_MENU_BAR (parent))
+ {
+ min_height = MAX (min_height, arrow_size);
+ nat_height = MAX (nat_height, arrow_size);
+ }
}
else /* separator item */
{
@@ -1385,13 +1393,13 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
child_allocation.y += allocation->y;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
- if (priv->submenu && priv->show_submenu_indicator)
- {
- if (direction == GTK_TEXT_DIR_RTL)
- child_allocation.x += child_requisition.height;
- child_allocation.width -= child_requisition.height;
- }
-
+ if (menu_item->submenu && !GTK_IS_MENU_BAR (parent))
+ {
+ if (direction == GTK_TEXT_DIR_RTL)
+ child_allocation.x += child_requisition.height;
+ child_allocation.width -= child_requisition.height;
+ }
+
if (child_allocation.width < 1)
child_allocation.width = 1;
@@ -1509,7 +1517,7 @@ gtk_menu_item_draw (GtkWidget *widget,
GtkStateType state_type;
GtkShadowType shadow_type, selected_shadow_type;
GtkStyle *style;
- GtkWidget *child;
+ GtkWidget *child, *parent;
GdkWindow *window;
gint x, y, w, h, width, height;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -1526,7 +1534,8 @@ gtk_menu_item_draw (GtkWidget *widget,
h = height - border_width * 2;
child = gtk_bin_get_child (GTK_BIN (menu_item));
-
+ parent = gtk_widget_get_parent (widget);
+
if (child && state_type == GTK_STATE_PRELIGHT)
{
gtk_widget_style_get (widget,
@@ -1540,7 +1549,7 @@ gtk_menu_item_draw (GtkWidget *widget,
x, y, w, h);
}
- if (priv->submenu && priv->show_submenu_indicator)
+ if (menu_item->submenu && !GTK_IS_MENU_BAR (parent))
{
gint arrow_x, arrow_y;
gint arrow_size;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]