[gnome-color-manager] trivial: pass a GcmColorRGB value to gcm_sample_window_set_percentage()



commit a2f447f6619836905902d0a1944960b7f2c3d65e
Author: Richard Hughes <richard hughsie com>
Date:   Tue Aug 3 12:42:58 2010 +0100

    trivial: pass a GcmColorRGB value to gcm_sample_window_set_percentage()

 libcolor-glib/gcm-sample-window.c |   16 +++++++---------
 libcolor-glib/gcm-sample-window.h |    5 ++---
 libcolor-glib/gcm-self-test.c     |    8 +++++++-
 3 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/libcolor-glib/gcm-sample-window.c b/libcolor-glib/gcm-sample-window.c
index 20affb3..1a0acde 100644
--- a/libcolor-glib/gcm-sample-window.c
+++ b/libcolor-glib/gcm-sample-window.c
@@ -110,7 +110,7 @@ gcm_sample_window_set_percentage (GcmSampleWindow *sample_window, guint percenta
  * Since: 0.0.1
  **/
 void
-gcm_sample_window_set_color (GcmSampleWindow *sample_window, guint8 red, guint8 green, guint8 blue)
+gcm_sample_window_set_color (GcmSampleWindow *sample_window, const GcmColorRGB *color)
 {
 	GdkPixbuf *pixbuf;
 	gint width;
@@ -139,9 +139,9 @@ gcm_sample_window_set_color (GcmSampleWindow *sample_window, guint8 red, guint8
 	/* set the pixel array */
 	pixels = gdk_pixbuf_get_pixels (pixbuf);
 	for (i=0; i<width*height*3; i+=3) {
-		pixels[i+0] = red;
-		pixels[i+1] = green;
-		pixels[i+2] = blue;
+		pixels[i+0] = (guchar) (color->R * 255.0f);
+		pixels[i+1] = (guchar) (color->G * 255.0f);
+		pixels[i+2] = (guchar) (color->B * 255.0f);
 	}
 
 	/* force redraw */
@@ -177,13 +177,11 @@ gcm_sample_window_init (GcmSampleWindow *sample_window)
 	gtk_container_add (GTK_CONTAINER (sample_window), vbox);
 	gtk_box_pack_start (GTK_BOX (vbox), sample_window->priv->image, TRUE, TRUE, 0);
 	gtk_box_pack_start (GTK_BOX (vbox), sample_window->priv->progress_bar, TRUE, TRUE, 0);
-	gtk_widget_set_size_request (sample_window->priv->image, 200, 200);
+	gtk_widget_set_size_request (sample_window->priv->image, 400, 400);
 	gtk_widget_show_all (vbox);
 
 	/* show on all virtual desktops */
 	gtk_window_stick (window);
-	gtk_window_set_default_size (window, 200, 200);
-
 }
 
 /**
@@ -214,8 +212,8 @@ gcm_sample_window_new (void)
 	sample_window = g_object_new (GCM_TYPE_SAMPLE_WINDOW,
 				      "accept-focus", FALSE,
 				      "decorated", FALSE,
-				      "default-height", 200,
-				      "default-width", 200,
+				      "default-height", 400,
+				      "default-width", 400,
 				      "deletable", FALSE,
 				      "destroy-with-parent", TRUE,
 				      "icon-name", "icc-profile",
diff --git a/libcolor-glib/gcm-sample-window.h b/libcolor-glib/gcm-sample-window.h
index 0b81906..017610c 100644
--- a/libcolor-glib/gcm-sample-window.h
+++ b/libcolor-glib/gcm-sample-window.h
@@ -28,6 +28,7 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
+#include <gcm-color.h>
 
 G_BEGIN_DECLS
 
@@ -55,9 +56,7 @@ struct _GcmSampleWindowClass
 GType		 gcm_sample_window_get_type		(void);
 GtkWindow	*gcm_sample_window_new			(void);
 void		 gcm_sample_window_set_color		(GcmSampleWindow	*sample_window,
-							 guint8			 red,
-							 guint8			 green,
-							 guint8			 blue);
+							 const GcmColorRGB	*color);
 void		 gcm_sample_window_set_percentage	(GcmSampleWindow	*sample_window,
 							 guint			 percentage);
 
diff --git a/libcolor-glib/gcm-self-test.c b/libcolor-glib/gcm-self-test.c
index 96cbee9..0951472 100644
--- a/libcolor-glib/gcm-self-test.c
+++ b/libcolor-glib/gcm-self-test.c
@@ -702,9 +702,15 @@ gcm_test_sample_window_func (void)
 {
 	GtkWindow *window;
 	GMainLoop *loop;
+	GcmColorRGB source;
+
+
 	window = gcm_sample_window_new ();
 	g_assert (window != NULL);
-	gcm_sample_window_set_color (GCM_SAMPLE_WINDOW (window), 0xff, 0xff, 0x00);
+	source.R = 1.0f;
+	source.G = 1.0f;
+	source.B = 0.0f;
+	gcm_sample_window_set_color (GCM_SAMPLE_WINDOW (window), &source);
 	gcm_sample_window_set_percentage (GCM_SAMPLE_WINDOW (window), GCM_SAMPLE_WINDOW_PERCENTAGE_PULSE);
 	gtk_window_present (window);
 	loop = g_main_loop_new (NULL, FALSE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]