2011-10-07 [colin] 3.7.10cvs21
[claws.git] / src / gtk / colorlabel.c
index 8fa7d1288071af6de3bbe2b3a0d1308df2d52912..c5014bfe65fe29e3aedde1001fc6efaf252e8529 100644 (file)
@@ -189,20 +189,28 @@ gchar *colorlabel_get_color_default_text(gint color_index)
 }
 
 static gboolean colorlabel_drawing_area_expose_event_cb
+#if !GTK_CHECK_VERSION(3, 0, 0)
        (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
+#else
+       (GtkWidget *widget, cairo_t *cr, gpointer data)
+#endif
 {
-       GdkDrawable *drawable = gtk_widget_get_window(widget);
+#if !GTK_CHECK_VERSION(3, 0, 0)
+       cairo_t *cr;
+       GdkWindow *drawable = gtk_widget_get_window(widget);
+#endif
        GtkAllocation allocation;
        gulong c = (gulong) GPOINTER_TO_INT(data);
        GdkColor color;
-       cairo_t *cr;
 
        INTCOLOR_TO_GDKCOLOR(c, color)
 
+#if !GTK_CHECK_VERSION(3, 0, 0)
        gdk_colormap_alloc_color(gtk_widget_get_colormap(widget), &color, FALSE, TRUE);
+       cr = gdk_cairo_create(drawable);
+#endif
        gtk_widget_get_allocation(widget, &allocation);
 
-       cr = gdk_cairo_create(drawable);
        cairo_set_source_rgb(cr, 0., 0., 0.);
        cairo_rectangle(cr, 0, 0,
            allocation.width - 1,
@@ -213,7 +221,9 @@ static gboolean colorlabel_drawing_area_expose_event_cb
            allocation.width - 2,
            allocation.height - 2);
        cairo_fill(cr);
+#if !GTK_CHECK_VERSION(3, 0, 0)
        cairo_destroy(cr);
+#endif
        
        return FALSE;
 }
@@ -231,11 +241,19 @@ static GtkWidget *colorlabel_create_color_widget(GdkColor color)
                         (CL(g) << (gulong)  8) | \
                         (CL(b)))
 
+#if !GTK_CHECK_VERSION(3, 0, 0)
        g_signal_connect(G_OBJECT(widget), "expose_event", 
                         G_CALLBACK
                                (colorlabel_drawing_area_expose_event_cb),
                         GINT_TO_POINTER
                                ((gint)CR(color.red, color.green, color.blue)));
+#else
+       g_signal_connect(G_OBJECT(widget), "draw", 
+                        G_CALLBACK
+                               (colorlabel_drawing_area_expose_event_cb),
+                        GINT_TO_POINTER
+                               ((gint)CR(color.red, color.green, color.blue)));
+#endif
 
        return widget;
 }