[gtk+] gtk-demo: Improve flowbox demo code
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtk-demo: Improve flowbox demo code
- Date: Fri, 3 Oct 2014 04:49:17 +0000 (UTC)
commit 23a4affb6f158275cdd5e8e824240f6a5c4190a9
Author: Benjamin Otte <otte redhat com>
Date: Fri Oct 3 06:45:38 2014 +0200
gtk-demo: Improve flowbox demo code
Overriding the background color for a color swatch is wrong. The color
is not the background, it's the foreground, so it should be painted in
a draw signal handler.
demos/gtk-demo/flowbox.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/demos/gtk-demo/flowbox.c b/demos/gtk-demo/flowbox.c
index c0d9217..38ce3c0 100644
--- a/demos/gtk-demo/flowbox.c
+++ b/demos/gtk-demo/flowbox.c
@@ -12,18 +12,31 @@
static GtkWidget *window = NULL;
+static gboolean
+draw_color (GtkWidget *drawingarea,
+ cairo_t *cr,
+ const char *color_name)
+{
+ GdkRGBA rgba;
+
+ if (gdk_rgba_parse (&rgba, color_name))
+ {
+ gdk_cairo_set_source_rgba (cr, &rgba);
+ cairo_paint (cr);
+ }
+
+ return FALSE;
+}
+
static GtkWidget *
color_swatch_new (const gchar *color)
{
GtkWidget *button, *area;
- GdkRGBA rgba;
-
- gdk_rgba_parse (&rgba, color);
button = gtk_button_new ();
area = gtk_drawing_area_new ();
+ g_signal_connect (area, "draw", G_CALLBACK (draw_color), (gpointer) color);
gtk_widget_set_size_request (area, 24, 24);
- gtk_widget_override_background_color (area, 0, &rgba);
gtk_container_add (GTK_CONTAINER (button), area);
gtk_widget_show_all (button);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]