mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 03:10:09 +00:00
GtkRadioButton: Use GtkStyleContext for rendering.
This commit is contained in:
parent
756e20f58c
commit
be4a616e6e
@ -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);
|
||||
|
||||
gtk_paint_option (style, cr,
|
||||
state_type, shadow_type,
|
||||
widget, "radiobutton",
|
||||
x, y, indicator_size, indicator_size);
|
||||
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_style_context_restore (context);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user