[goocanvas] removed deprecated calls to override the widget's background color
- From: Damon Chaplin <damon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goocanvas] removed deprecated calls to override the widget's background color
- Date: Wed, 14 Dec 2016 23:45:57 +0000 (UTC)
commit 3abd835e39eed132e1833f03b91b58f4f427c3a1
Author: Damon Chaplin <Damon A Chaplin gmail com>
Date: Wed Dec 14 23:14:46 2016 +0000
removed deprecated calls to override the widget's background color
ChangeLog | 24 +++++++++++++++++-------
src/goocanvas.c | 54 +++++++++++++++++++++++++++++++++---------------------
2 files changed, 50 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f54f23b..5b50bf6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,20 @@
-2016-12-14 Damon Chaplin <damon localhost lan>
+2016-12-14 Damon Chaplin <damon gnome org>
+
+ * src/goocanvas.c: added background_color and background_color_set
+ to GooCanvasPrivate struct.
+ (goo_canvas_init, goo_canvas_get_property)
+ (goo_canvas_set_property): add code to init/get/set background color
+ property, as gtk_widget_override_background_color() and
+ gtk_widget_modify_bg() are now deprecated.
+ (goo_canvas_draw): use the background color property if it is set.
+
+2016-12-14 Damon Chaplin <damon gnome org>
* src/goocanvas.c (goo_canvas_configure_hadjustment)
(goo_canvas_configure_vadjustment): rewrote these to get rid of
deprecated calls to gtk_adjustment_changed/value_changed().
-2016-12-14 Damon Chaplin <damon localhost lan>
+2016-12-14 Damon Chaplin <damon gnome org>
* src/goocanvas.c (goo_canvas_button_press):
(goo_canvas_button_release): use gdk_display_device_is_grabbed()
@@ -16,17 +26,17 @@
(goo_canvas_keyboard_grab, goo_canvas_keyboard_ungrab): use
gdk_seat_grab()/ungrab() instead of gdk_keyboard_grab/ungrab().
-2016-12-14 Damon Chaplin <damon localhost lan>
+2016-12-14 Damon Chaplin <damon gnome org>
* src/goocanvas.c (goo_canvas_create_cairo_context): removed use of
gdk_cairo_create(). We always just use cairo_create() now.
-2016-12-14 Damon Chaplin <damon localhost lan>
+2016-12-14 Damon Chaplin <damon gnome org>
* src/goocanvas.c (goo_canvas_focus_check_is_best): change comment
that confused gtk-doc.
-2016-12-14 Damon Chaplin <damon localhost lan>
+2016-12-14 Damon Chaplin <damon gnome org>
* src/goocanvas.c (goo_canvas_request_update): use
gdk_threads_add_idle_full() instead of g_idle_add_full().
@@ -37,7 +47,7 @@
gdk_threads_add_timeout() instead of g_timeout_add().
(goo_canvas_item_animate_cb): remove GDK_THREADS_ENTER/LEAVE().
-2016-12-13 Damon Chaplin <damon localhost lan>
+2016-12-13 Damon Chaplin <damon gnome org>
* src/goocanvasutils.c (goo_canvas_create_path): added (element-type)
annotation.
@@ -45,7 +55,7 @@
* src/Makefile.am: moved goocanvasprivate.h to _extra_sources so
it doesn't get scanned for introspection.
-2016-12-13 Damon Chaplin <damon localhost lan>
+2016-12-13 Damon Chaplin <damon gnome org>
* demo/*.c: remove deprecated GTK+ calls.
diff --git a/src/goocanvas.c b/src/goocanvas.c
index 3bccc30..0bafb56 100644
--- a/src/goocanvas.c
+++ b/src/goocanvas.c
@@ -120,6 +120,8 @@ struct _GooCanvasPrivate {
GooCanvasItemModel *static_root_item_model;
gint window_x, window_y;
gint static_window_x, static_window_y;
+ GdkRGBA background_color;
+ guint background_color_set : 1;
};
@@ -549,6 +551,7 @@ goo_canvas_init (GooCanvas *canvas)
priv->window_x = priv->static_window_x = 0;
priv->window_y = priv->static_window_y = 0;
+ priv->background_color_set = FALSE;
}
@@ -809,11 +812,11 @@ goo_canvas_set_property (GObject *object,
GParamSpec *pspec)
{
GooCanvas *canvas = (GooCanvas*) object;
- GdkColor color = { 0, 0, 0, 0, };
+ GooCanvasPrivate *priv = GOO_CANVAS_GET_PRIVATE (canvas);
gboolean need_reconfigure = FALSE;
gboolean need_update_automatic_bounds = FALSE;
guint rgb;
- GdkRGBA rgba = { 0, 0, 0, 0 };
+ GdkRGBA rgba = { 0, 0, 0, 0 }, *new_color;
const char *color_string;
switch (prop_id)
@@ -879,21 +882,29 @@ goo_canvas_set_property (GObject *object,
case PROP_BACKGROUND_COLOR:
color_string = g_value_get_string (value);
if (!color_string)
- gtk_widget_override_background_color ((GtkWidget*) canvas, GTK_STATE_FLAG_NORMAL, NULL);
+ {
+ priv->background_color_set = FALSE;
+ }
else if (gdk_rgba_parse (&rgba, color_string))
- gtk_widget_override_background_color ((GtkWidget*) canvas, GTK_STATE_FLAG_NORMAL, &rgba);
+ {
+ priv->background_color = rgba;
+ priv->background_color_set = TRUE;
+ }
else
g_warning ("Unknown color: %s", color_string);
break;
case PROP_BACKGROUND_COLOR_RGB:
rgb = g_value_get_uint (value);
- color.red = ((rgb >> 16) & 0xFF) * 257;
- color.green = ((rgb >> 8) & 0xFF) * 257;
- color.blue = ((rgb) & 0xFF) * 257;
- gtk_widget_modify_bg ((GtkWidget*) canvas, GTK_STATE_NORMAL, &color);
+ priv->background_color.red = ((rgb >> 16) & 0xFF) / 255.0;
+ priv->background_color.green = ((rgb >> 8) & 0xFF) / 255.0;
+ priv->background_color.blue = ((rgb) & 0xFF) / 255.0;
+ priv->background_color.alpha = 1.0;
+ priv->background_color_set = TRUE;
break;
case PROP_BACKGROUND_COLOR_GDK_RGBA:
- gtk_widget_override_background_color ((GtkWidget*) canvas, GTK_STATE_FLAG_NORMAL, g_value_get_boxed
(value));
+ new_color = g_value_get_boxed (value);
+ priv->background_color = *new_color;
+ priv->background_color_set = TRUE;
break;
case PROP_INTEGER_LAYOUT:
canvas->integer_layout = g_value_get_boolean (value);
@@ -2769,18 +2780,19 @@ goo_canvas_draw (GtkWidget *widget,
/* Clear the background. */
if (canvas->clear_background)
{
- GtkAllocation allocation;
- GtkStyleContext *context = gtk_widget_get_style_context (widget);
- gtk_widget_get_allocation (widget, &allocation);
- gtk_render_background (context, cr,
- 0, 0, allocation.width, allocation.height);
-
-#if 0
- const GtkStyle* style = gtk_widget_get_style (widget);
- const GtkStateType state = gtk_widget_get_state (widget);
- gdk_cairo_set_source_color (cr, &(style->base[state]));
- cairo_paint (cr);
-#endif
+ if (priv->background_color_set)
+ {
+ gdk_cairo_set_source_rgba (cr, &priv->background_color);
+ cairo_paint (cr);
+ }
+ else
+ {
+ GtkAllocation allocation;
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_render_background (context, cr,
+ 0, 0, allocation.width, allocation.height);
+ }
cairo_set_source_rgb (cr, 0, 0, 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]