[gimp] libgimpwidgets: add property GimpCellRendererToggle:override-background
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: add property GimpCellRendererToggle:override-background
- Date: Sat, 29 Oct 2016 14:49:13 +0000 (UTC)
commit 956d45bf6110dc5ff9869a6c31b7116e705a9cd2
Author: Michael Natterer <mitch gimp org>
Date: Sat Oct 29 16:47:36 2016 +0200
libgimpwidgets: add property GimpCellRendererToggle:override-background
which makes the cell paint its background color even when the row is
selected.
libgimpwidgets/gimpcellrenderertoggle.c | 48 +++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/libgimpwidgets/gimpcellrenderertoggle.c b/libgimpwidgets/gimpcellrenderertoggle.c
index 5b519e8..dcc4bc0 100644
--- a/libgimpwidgets/gimpcellrenderertoggle.c
+++ b/libgimpwidgets/gimpcellrenderertoggle.c
@@ -53,7 +53,8 @@ enum
PROP_0,
PROP_ICON_NAME,
PROP_STOCK_ID,
- PROP_STOCK_SIZE
+ PROP_STOCK_SIZE,
+ PROP_OVERRIDE_BACKGROUND
};
@@ -61,7 +62,8 @@ typedef struct _GimpCellRendererTogglePrivate GimpCellRendererTogglePrivate;
struct _GimpCellRendererTogglePrivate
{
- gchar *icon_name;
+ gchar *icon_name;
+ gboolean override_background;
};
#define GET_PRIVATE(obj) \
@@ -159,6 +161,13 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_OVERRIDE_BACKGROUND,
+ g_param_spec_boolean ("override-background",
+ NULL, NULL,
+ FALSE,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
g_type_class_add_private (object_class, sizeof (GimpCellRendererTogglePrivate));
}
@@ -217,6 +226,10 @@ gimp_cell_renderer_toggle_get_property (GObject *object,
g_value_set_int (value, toggle->stock_size);
break;
+ case PROP_OVERRIDE_BACKGROUND:
+ g_value_set_boolean (value, priv->override_background);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -250,6 +263,10 @@ gimp_cell_renderer_toggle_set_property (GObject *object,
toggle->stock_size = g_value_get_int (value);
break;
+ case PROP_OVERRIDE_BACKGROUND:
+ priv->override_background = g_value_get_boolean (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -359,6 +376,33 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
return;
}
+ if (flags & GTK_CELL_RENDERER_SELECTED &&
+ priv->override_background)
+ {
+ gboolean background_set;
+
+ g_object_get (cell,
+ "cell-background-set", &background_set,
+ NULL);
+
+ if (background_set)
+ {
+ cairo_t *cr = gdk_cairo_create (window);
+ GdkColor *color;
+
+ g_object_get (cell,
+ "cell-background-gdk", &color,
+ NULL);
+
+ gdk_cairo_rectangle (cr, background_area);
+ gdk_cairo_set_source_color (cr, color);
+ cairo_fill (cr);
+
+ gdk_color_free (color);
+ cairo_destroy (cr);
+ }
+ }
+
gimp_cell_renderer_toggle_get_size (cell, widget, cell_area,
&toggle_rect.x,
&toggle_rect.y,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]