[gtk+/treeview-style: 5/8] Make GtkCellRendererToggle use GtkStyleContext
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-style: 5/8] Make GtkCellRendererToggle use GtkStyleContext
- Date: Mon, 17 Jan 2011 11:20:50 +0000 (UTC)
commit 34298b104dc691bb7ea3c663a23528e707af89be
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jan 12 21:27:25 2011 +0100
Make GtkCellRendererToggle use GtkStyleContext
gtk/gtkcellrenderertoggle.c | 62 +++++++++++++++++++-----------------------
1 files changed, 28 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index 177cafd..6e28ec2 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -331,12 +331,13 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
{
GtkCellRendererToggle *celltoggle = GTK_CELL_RENDERER_TOGGLE (cell);
GtkCellRendererTogglePrivate *priv = celltoggle->priv;
+ GtkStyleContext *context;
gint width, height;
gint x_offset, y_offset;
gint xpad, ypad;
- GtkShadowType shadow;
- GtkStateType state = 0;
+ GtkStateFlags state = 0;
+ context = gtk_widget_get_style_context (widget);
gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
&x_offset, &y_offset,
&width, &height);
@@ -348,28 +349,21 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
return;
if (priv->inconsistent)
- shadow = GTK_SHADOW_ETCHED_IN;
- else
- shadow = priv->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
+ state |= GTK_STATE_FLAG_INCONSISTENT;
+ else if (priv->active)
+ state |= GTK_STATE_FLAG_ACTIVE;
- if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE ||
+ if (!priv->activatable ||
+ !gtk_widget_get_sensitive (widget) ||
!gtk_cell_renderer_get_sensitive (cell))
- {
- state = GTK_STATE_INSENSITIVE;
- }
- else if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
- {
- if (gtk_widget_has_focus (widget))
- state = GTK_STATE_SELECTED;
- else
- state = GTK_STATE_ACTIVE;
- }
+ state |= GTK_STATE_FLAG_INSENSITIVE;
else
{
- if (priv->activatable)
- state = GTK_STATE_NORMAL;
- else
- state = GTK_STATE_INSENSITIVE;
+ if (flags & GTK_CELL_RENDERER_SELECTED)
+ state |= GTK_STATE_FLAG_SELECTED;
+
+ if (gtk_widget_has_focus (widget))
+ state |= GTK_STATE_FLAG_FOCUSED;
}
cairo_save (cr);
@@ -377,27 +371,27 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
gdk_cairo_rectangle (cr, cell_area);
cairo_clip (cr);
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
+
if (priv->radio)
{
- gtk_paint_option (gtk_widget_get_style (widget),
- cr,
- state, shadow,
- widget, "cellradio",
- cell_area->x + x_offset + xpad,
- cell_area->y + y_offset + ypad,
- width, height);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_RADIO);
+ gtk_render_option (context, cr,
+ cell_area->x + x_offset + xpad,
+ cell_area->y + y_offset + ypad,
+ width, height);
}
else
{
- gtk_paint_check (gtk_widget_get_style (widget),
- cr,
- state, shadow,
- widget, "cellcheck",
- cell_area->x + x_offset + xpad,
- cell_area->y + y_offset + ypad,
- width, height);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_CHECK);
+ gtk_render_check (context, cr,
+ cell_area->x + x_offset + xpad,
+ cell_area->y + y_offset + ypad,
+ width, height);
}
+ gtk_style_context_restore (context);
cairo_restore (cr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]