[gtk+] menuitem: Remove is_drawable() check
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] menuitem: Remove is_drawable() check
- Date: Sun, 26 Sep 2010 13:37:53 +0000 (UTC)
commit 6f6c81e527d54cc84e4b8b55bd26a4fdb6f566d9
Author: Benjamin Otte <otte redhat com>
Date: Tue Sep 14 13:19:16 2010 +0200
menuitem: Remove is_drawable() check
gtk/gtkmenuitem.c | 177 ++++++++++++++++++++++++++---------------------------
1 files changed, 86 insertions(+), 91 deletions(-)
---
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index dec347b..5bd093c 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -1509,7 +1509,7 @@ static gboolean
gtk_menu_item_draw (GtkWidget *widget,
cairo_t *cr)
{
- GtkMenuItem *menu_item;
+ GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
GtkStateType state_type;
GtkShadowType shadow_type, selected_shadow_type;
GtkStyle *style;
@@ -1518,107 +1518,102 @@ gtk_menu_item_draw (GtkWidget *widget,
gint x, y, w, h, width, height;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- if (gtk_widget_is_drawable (widget))
- {
- menu_item = GTK_MENU_ITEM (widget);
-
- state_type = gtk_widget_get_state (widget);
- style = gtk_widget_get_style (widget);
- window = gtk_widget_get_window (widget);
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
+ state_type = gtk_widget_get_state (widget);
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
- x = border_width;
- y = border_width;
- w = width - border_width * 2;
- h = height - border_width * 2;
+ x = border_width;
+ y = border_width;
+ w = width - border_width * 2;
+ h = height - border_width * 2;
- child = gtk_bin_get_child (GTK_BIN (menu_item));
-
- if (child && state_type == GTK_STATE_PRELIGHT)
- {
- gtk_widget_style_get (widget,
- "selected-shadow-type", &selected_shadow_type,
- NULL);
- gtk_cairo_paint_box (style,
- cr,
- GTK_STATE_PRELIGHT,
- selected_shadow_type,
- widget, "menuitem",
- x, y, w, h);
- }
+ child = gtk_bin_get_child (GTK_BIN (menu_item));
- if (menu_item->submenu && menu_item->show_submenu_indicator)
- {
- gint arrow_x, arrow_y;
- gint arrow_size;
- guint horizontal_padding;
- GtkTextDirection direction;
- GtkArrowType arrow_type;
+ if (child && state_type == GTK_STATE_PRELIGHT)
+ {
+ gtk_widget_style_get (widget,
+ "selected-shadow-type", &selected_shadow_type,
+ NULL);
+ gtk_cairo_paint_box (style,
+ cr,
+ GTK_STATE_PRELIGHT,
+ selected_shadow_type,
+ widget, "menuitem",
+ x, y, w, h);
+ }
- direction = gtk_widget_get_direction (widget);
-
- gtk_widget_style_get (widget,
- "horizontal-padding", &horizontal_padding,
- NULL);
+ if (menu_item->submenu && menu_item->show_submenu_indicator)
+ {
+ gint arrow_x, arrow_y;
+ gint arrow_size;
+ guint horizontal_padding;
+ GtkTextDirection direction;
+ GtkArrowType arrow_type;
- get_arrow_size (widget, child, &arrow_size);
+ direction = gtk_widget_get_direction (widget);
+
+ gtk_widget_style_get (widget,
+ "horizontal-padding", &horizontal_padding,
+ NULL);
- shadow_type = GTK_SHADOW_OUT;
- if (state_type == GTK_STATE_PRELIGHT)
- shadow_type = GTK_SHADOW_IN;
+ get_arrow_size (widget, child, &arrow_size);
- if (direction == GTK_TEXT_DIR_LTR)
- {
- arrow_x = x + w - horizontal_padding - arrow_size;
- arrow_type = GTK_ARROW_RIGHT;
- }
- else
- {
- arrow_x = x + horizontal_padding;
- arrow_type = GTK_ARROW_LEFT;
- }
+ shadow_type = GTK_SHADOW_OUT;
+ if (state_type == GTK_STATE_PRELIGHT)
+ shadow_type = GTK_SHADOW_IN;
- arrow_y = y + (h - arrow_size) / 2;
+ if (direction == GTK_TEXT_DIR_LTR)
+ {
+ arrow_x = x + w - horizontal_padding - arrow_size;
+ arrow_type = GTK_ARROW_RIGHT;
+ }
+ else
+ {
+ arrow_x = x + horizontal_padding;
+ arrow_type = GTK_ARROW_LEFT;
+ }
- gtk_cairo_paint_arrow (style, cr,
- state_type, shadow_type,
- widget, "menuitem",
- arrow_type, TRUE,
- arrow_x, arrow_y,
- arrow_size, arrow_size);
- }
- else if (!child)
- {
- gboolean wide_separators;
- gint separator_height;
- guint horizontal_padding;
+ arrow_y = y + (h - arrow_size) / 2;
- gtk_widget_style_get (widget,
- "wide-separators", &wide_separators,
- "separator-height", &separator_height,
- "horizontal-padding", &horizontal_padding,
- NULL);
-
- if (wide_separators)
- gtk_cairo_paint_box (style, cr,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
- widget, "hseparator",
- horizontal_padding + style->xthickness,
- (height - separator_height - style->ythickness) / 2,
- width - 2 * (horizontal_padding + style->xthickness),
- separator_height);
- else
- gtk_cairo_paint_hline (style, cr,
- GTK_STATE_NORMAL, widget, "menuitem",
- horizontal_padding + style->xthickness,
- width - horizontal_padding - style->xthickness - 1,
- (height - style->ythickness) / 2);
- }
+ gtk_cairo_paint_arrow (style, cr,
+ state_type, shadow_type,
+ widget, "menuitem",
+ arrow_type, TRUE,
+ arrow_x, arrow_y,
+ arrow_size, arrow_size);
+ }
+ else if (!child)
+ {
+ gboolean wide_separators;
+ gint separator_height;
+ guint horizontal_padding;
- GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->draw (widget, cr);
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-height", &separator_height,
+ "horizontal-padding", &horizontal_padding,
+ NULL);
+
+ if (wide_separators)
+ gtk_cairo_paint_box (style, cr,
+ GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
+ widget, "hseparator",
+ horizontal_padding + style->xthickness,
+ (height - separator_height - style->ythickness) / 2,
+ width - 2 * (horizontal_padding + style->xthickness),
+ separator_height);
+ else
+ gtk_cairo_paint_hline (style, cr,
+ GTK_STATE_NORMAL, widget, "menuitem",
+ horizontal_padding + style->xthickness,
+ width - horizontal_padding - style->xthickness - 1,
+ (height - style->ythickness) / 2);
}
+ GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->draw (widget, cr);
+
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]