[cairo-commit] goocanvas/src goocanvas.c,1.15,1.16

Damon Chaplin commit at pdx.freedesktop.org
Tue Mar 27 04:41:05 PDT 2007


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv6973/src

Modified Files:
	goocanvas.c 
Log Message:
2007-03-27  Damon Chaplin  <damon at gnome.org>

	* src/goocanvas.c: added "background-color" and "background-color-rgb"
	properties to set the background color of the canvas, based on a patch
	from Gian Mario Tagliaretti.

	* demo/demo.c (create_canvas_primitives): 
	* demo/mv-demo.c (create_canvas_primitives): use above properties.



Index: goocanvas.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvas.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- goocanvas.c	7 Mar 2007 16:07:11 -0000	1.15
+++ goocanvas.c	27 Mar 2007 11:40:56 -0000	1.16
@@ -117,7 +117,9 @@
   PROP_Y2,
   PROP_UNITS,
   PROP_RESOLUTION_X,
-  PROP_RESOLUTION_Y
+  PROP_RESOLUTION_Y,
+  PROP_BACKGROUND_COLOR,
+  PROP_BACKGROUND_COLOR_RGB
 };
 
 enum {
@@ -311,6 +313,20 @@
 							96.0,
 							G_PARAM_READWRITE));
 
+  /* Convenience properties - writable only. */
+  g_object_class_install_property (gobject_class, PROP_BACKGROUND_COLOR,
+				   g_param_spec_string ("background-color",
+							_("Background Color"),
+							_("The color to use for the canvas background"),
+							NULL,
+							G_PARAM_WRITABLE));
+
+  g_object_class_install_property (gobject_class, PROP_BACKGROUND_COLOR_RGB,
+				   g_param_spec_uint ("background-color-rgb",
+						      _("Background Color RGB"),
+						      _("The color to use for the canvas background, specified as a 24-bit integer value, 0xRRGGBB"),
+						      0, G_MAXUINT, 0,
+						      G_PARAM_WRITABLE));
 
   /**
    * GooCanvas::set-scroll-adjustments
@@ -593,7 +609,9 @@
 			    GParamSpec         *pspec)
 {
   GooCanvas *canvas = (GooCanvas*) object;
+  GdkColor color = { 0, 0, 0, 0, };
   gboolean need_reconfigure = FALSE;
+  guint rgb;
 
   switch (prop_id)
     {
@@ -632,6 +650,21 @@
       canvas->resolution_y = g_value_get_double (value);
       need_reconfigure = TRUE;
       break;
+    case PROP_BACKGROUND_COLOR:
+      if (!g_value_get_string (value))
+	gtk_widget_modify_base ((GtkWidget*) canvas, GTK_STATE_NORMAL, NULL);
+      else if (gdk_color_parse (g_value_get_string (value), &color))
+	gtk_widget_modify_base ((GtkWidget*) canvas, GTK_STATE_NORMAL, &color);
+      else
+	g_warning ("Unknown color: %s", g_value_get_string (value));
+      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_base ((GtkWidget*) canvas, GTK_STATE_NORMAL, &color);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);



More information about the cairo-commit mailing list