[gtk+/gtk-style-context: 415/533] GtkRadioButton: Use GtkStyleContext for rendering.



commit eb7286bdd62161c3ee86f729daa561d972112631
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Nov 19 20:14:51 2010 +0100

    GtkRadioButton: Use GtkStyleContext for rendering.

 gtk/gtkradiobutton.c |   52 +++++++++++++++++++++++--------------------------
 1 files changed, 24 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 6a5e209..23e113d 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);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]