[gimp/gtk3-port: 188/227] Port cell renderers to gtk_cell_renderer_get_state()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 188/227] Port cell renderers to gtk_cell_renderer_get_state()
- Date: Mon, 18 Feb 2013 00:08:12 +0000 (UTC)
commit 3e4a041acb92f3c3b80090ad25e7d3af72cf5300
Author: Michael Natterer <mitch gimp org>
Date: Sun Feb 6 17:44:49 2011 +0100
Port cell renderers to gtk_cell_renderer_get_state()
app/widgets/gimpcellrendererdashes.c | 24 +-----------------------
libgimpwidgets/gimpcellrenderercolor.c | 13 ++-----------
libgimpwidgets/gimpcellrenderertoggle.c | 20 ++++++--------------
3 files changed, 9 insertions(+), 48 deletions(-)
---
diff --git a/app/widgets/gimpcellrendererdashes.c b/app/widgets/gimpcellrendererdashes.c
index c6b4bce..627b439 100644
--- a/app/widgets/gimpcellrendererdashes.c
+++ b/app/widgets/gimpcellrendererdashes.c
@@ -202,29 +202,7 @@ gimp_cell_renderer_dashes_render (GtkCellRenderer *cell,
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
- if (! 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;
- }
- else if ((flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT &&
- gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT)
- {
- state = GTK_STATE_PRELIGHT;
- }
- else
- {
- if (gtk_widget_is_sensitive (widget))
- state = GTK_STATE_NORMAL;
- else
- state = GTK_STATE_INSENSITIVE;
- }
+ state = gtk_cell_renderer_get_state (cell, widget, flags);
y = cell_area->y + (cell_area->height - DASHES_HEIGHT) / 2;
width = cell_area->width - 2 * xpad;
diff --git a/libgimpwidgets/gimpcellrenderercolor.c b/libgimpwidgets/gimpcellrenderercolor.c
index 2ca46ee..7088ad0 100644
--- a/libgimpwidgets/gimpcellrenderercolor.c
+++ b/libgimpwidgets/gimpcellrenderercolor.c
@@ -273,7 +273,7 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
if (rect.width > 2 && rect.height > 2)
{
GtkStyleContext *context = gtk_widget_get_style_context (widget);
- GtkStateFlags state = 0;
+ GtkStateFlags state;
GdkRGBA color;
cairo_rectangle (cr,
@@ -309,16 +309,7 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
rect.x + 0.5, rect.y + 0.5,
rect.width - 1, rect.height - 1);
- if (! gtk_cell_renderer_get_sensitive (cell) ||
- ! gtk_widget_is_sensitive (widget))
- {
- state |= GTK_STATE_FLAG_INSENSITIVE;
- }
-
- if (flags & GTK_CELL_RENDERER_SELECTED)
- {
- state |= GTK_STATE_FLAG_SELECTED;
- }
+ state = gtk_cell_renderer_get_state (cell, widget, flags);
cairo_set_line_width (cr, 1);
gtk_style_context_get_color (context, state, &color);
diff --git a/libgimpwidgets/gimpcellrenderertoggle.c b/libgimpwidgets/gimpcellrenderertoggle.c
index 69b60c4..760aef8 100644
--- a/libgimpwidgets/gimpcellrenderertoggle.c
+++ b/libgimpwidgets/gimpcellrenderertoggle.c
@@ -323,7 +323,7 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
GimpCellRendererTogglePrivate *private = GET_PRIVATE (cell);
GtkStyleContext *context = gtk_widget_get_style_context (widget);
GdkRectangle toggle_rect;
- GtkStateFlags state = 0;
+ GtkStateFlags state;
gboolean active;
gint xpad;
gint ypad;
@@ -357,28 +357,20 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
if (toggle_rect.width <= 0 || toggle_rect.height <= 0)
return;
+ state = gtk_cell_renderer_get_state (cell, widget, flags);
+
active =
gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (cell));
if (active)
state |= GTK_STATE_FLAG_ACTIVE;
- if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
- {
- state |= GTK_STATE_FLAG_SELECTED;
-
- if (gtk_widget_has_focus (widget))
- state |= GTK_STATE_FLAG_FOCUSED;
- }
- else
- {
- if (! gtk_cell_renderer_toggle_get_activatable (GTK_CELL_RENDERER_TOGGLE (cell)))
- state |= GTK_STATE_FLAG_INSENSITIVE;
- }
+ if (! gtk_cell_renderer_toggle_get_activatable (GTK_CELL_RENDERER_TOGGLE (cell)))
+ state |= GTK_STATE_FLAG_INSENSITIVE;
gtk_style_context_set_state (context, state);
- if (flags & GTK_CELL_RENDERER_PRELIT)
+ if (state & GTK_STATE_FLAG_PRELIGHT)
gtk_render_frame (context, cr,
toggle_rect.x, toggle_rect.y,
toggle_rect.width, toggle_rect.height);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]