summaryrefslogtreecommitdiff
path: root/gtk/gtkradiobutton.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2010-11-19 20:14:51 +0100
committerCarlos Garnacho <carlosg@gnome.org>2010-12-04 15:39:20 +0100
commitbe4a616e6e415201c766d2850fb2737199df4b11 (patch)
tree8c1ddd9db9e754c11ba49b23c49c0f61cf854222 /gtk/gtkradiobutton.c
parent756e20f58c59c606d3bf62e1369127fa96538b54 (diff)
downloadgtk+-be4a616e6e415201c766d2850fb2737199df4b11.tar.gz
GtkRadioButton: Use GtkStyleContext for rendering.
Diffstat (limited to 'gtk/gtkradiobutton.c')
-rw-r--r--gtk/gtkradiobutton.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 6a5e2095d9..23e113da5d 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -891,9 +891,8 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
GtkWidget *child;
GtkButton *button;
GtkToggleButton *toggle_button;
- GtkStateType state_type;
- GtkShadowType shadow_type;
- GtkStyle *style;
+ GtkStyleContext *context;
+ GtkStateFlags state;
GdkWindow *window;
gint x, y;
gint indicator_size, indicator_spacing;
@@ -905,10 +904,10 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
widget = GTK_WIDGET (check_button);
button = GTK_BUTTON (check_button);
toggle_button = GTK_TOGGLE_BUTTON (check_button);
+ context = gtk_widget_get_style_context (widget);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"interior-focus", &interior_focus,
"focus-line-width", &focus_width,
@@ -929,37 +928,34 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
x += focus_width + focus_pad;
if (gtk_toggle_button_get_inconsistent (toggle_button))
- shadow_type = GTK_SHADOW_ETCHED_IN;
+ state |= GTK_STATE_FLAG_INCONSISTENT;
else if (gtk_toggle_button_get_active (toggle_button))
- shadow_type = GTK_SHADOW_IN;
- else
- shadow_type = GTK_SHADOW_OUT;
+ state |= GTK_STATE_FLAG_ACTIVE;
if (button->priv->activate_timeout || (button->priv->button_down && button->priv->in_button))
- state_type = GTK_STATE_ACTIVE;
- else if (button->priv->in_button)
- state_type = GTK_STATE_PRELIGHT;
+ state |= GTK_STATE_FLAG_SELECTED;
+
+ if (button->priv->in_button)
+ state |= GTK_STATE_FLAG_PRELIGHT;
else if (!gtk_widget_is_sensitive (widget))
- state_type = GTK_STATE_INSENSITIVE;
- else
- state_type = GTK_STATE_NORMAL;
+ state |= GTK_STATE_FLAG_INSENSITIVE;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
x = allocation.width - (indicator_size + x);
- if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_PRELIGHT)
- {
- gtk_paint_flat_box (style, cr,
- GTK_STATE_PRELIGHT,
- GTK_SHADOW_ETCHED_OUT,
- widget, "checkbutton",
- border_width, border_width,
- allocation.width - (2 * border_width),
- allocation.height - (2 * border_width));
- }
+ gtk_style_context_set_state (context, state);
+
+ if (state & GTK_STATE_FLAG_PRELIGHT)
+ gtk_render_background (context, cr,
+ border_width, border_width,
+ allocation.width - (2 * border_width),
+ allocation.height - (2 * border_width));
+
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_CHECK);
+
+ gtk_render_option (context, cr,
+ x, y, indicator_size, indicator_size);
- gtk_paint_option (style, cr,
- state_type, shadow_type,
- widget, "radiobutton",
- x, y, indicator_size, indicator_size);
+ gtk_style_context_restore (context);
}