diff options
author | Benjamin Otte <otte@redhat.com> | 2016-02-15 18:08:14 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-02-15 18:17:11 +0100 |
commit | 46f46ed36e18096b2c816afe46a9c1bc590d5439 (patch) | |
tree | 3191717ce4a049f2f141dd6662cb7699ad258416 /gtk/gtkcellrenderertoggle.c | |
parent | d10bd41e43acaac31b4ccf41331659ca0df3c61b (diff) | |
download | gtk+-46f46ed36e18096b2c816afe46a9c1bc590d5439.tar.gz |
cellrenderertoggle: Split out a function
Diffstat (limited to 'gtk/gtkcellrenderertoggle.c')
-rw-r--r-- | gtk/gtkcellrenderertoggle.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c index 079d64b8b7..1e7539485f 100644 --- a/gtk/gtkcellrenderertoggle.c +++ b/gtk/gtkcellrenderertoggle.c @@ -304,6 +304,24 @@ gtk_cell_renderer_toggle_new (void) return g_object_new (GTK_TYPE_CELL_RENDERER_TOGGLE, NULL); } +static GtkStyleContext * +gtk_cell_renderer_toggle_save_context (GtkCellRenderer *cell, + GtkWidget *widget) +{ + GtkCellRendererTogglePrivate *priv = GTK_CELL_RENDERER_TOGGLE (cell)->priv; + + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + + if (priv->radio) + gtk_style_context_save_named (context, "radio"); + else + gtk_style_context_save_named (context, "check"); + + return context; +} + static void gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell, GtkWidget *widget, @@ -400,28 +418,25 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell, gdk_cairo_rectangle (cr, cell_area); cairo_clip (cr); + context = gtk_cell_renderer_toggle_save_context (cell, widget); + gtk_style_context_set_state (context, state); if (priv->radio) { - gtk_style_context_save_named (context, "radio"); - gtk_style_context_set_state (context, state); gtk_render_option (context, cr, cell_area->x + x_offset + xpad, cell_area->y + y_offset + ypad, width, height); - gtk_style_context_restore (context); } else { - gtk_style_context_save_named (context, "check"); - gtk_style_context_set_state (context, state); gtk_render_check (context, cr, cell_area->x + x_offset + xpad, cell_area->y + y_offset + ypad, width, height); - gtk_style_context_restore (context); } + gtk_style_context_restore (context); cairo_restore (cr); } |