summaryrefslogtreecommitdiff
path: root/gtk/gtkpixmap.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-02-09 00:40:48 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-02-09 00:40:48 +0000
commit45510aefc34ce131b5de0db7c4ebf3783d9854b4 (patch)
tree42b08773edbea6846d0d2e7e3123d85ec5fc6c1f /gtk/gtkpixmap.c
parent589b4726093be0f1653648110d5e40150f2e375c (diff)
downloadgdk-pixbuf-45510aefc34ce131b5de0db7c4ebf3783d9854b4.tar.gz
better error message if you try to add a widget to a bin that already has
2001-02-08 Havoc Pennington <hp@redhat.com> * gtk/gtkbin.c (gtk_bin_add): better error message if you try to add a widget to a bin that already has a child. * gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512 * docs/Changes-2.0.txt: note that GdkColorContext is gone. * gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c * gdk/gdk.h: remove gdkcc.h * gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h * gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using GdkPixbuf, since the previous implementation was GdkColorContext dependent. * gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Diffstat (limited to 'gtk/gtkpixmap.c')
-rw-r--r--gtk/gtkpixmap.c115
1 files changed, 30 insertions, 85 deletions
diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c
index a258b21b1..37b7c4d77 100644
--- a/gtk/gtkpixmap.c
+++ b/gtk/gtkpixmap.c
@@ -261,98 +261,43 @@ gtk_pixmap_set_build_insensitive (GtkPixmap *pixmap, guint build)
static void
build_insensitive_pixmap(GtkPixmap *gtkpixmap)
{
- GdkGC *gc;
GdkPixmap *pixmap = gtkpixmap->pixmap;
GdkPixmap *insensitive;
- gint w, h, x, y;
- GdkGCValues vals;
- GdkVisual *visual;
- GdkImage *image;
- GdkColorContext *cc;
- GdkColor color;
- GdkColormap *cmap;
- gint32 red, green, blue;
- GtkStyle *style;
- GtkWidget *window;
- GdkColor c;
- int failed;
-
- window = GTK_WIDGET (gtkpixmap);
-
- g_return_if_fail(window != NULL);
-
- gdk_window_get_size(pixmap, &w, &h);
- image = gdk_image_get(pixmap, 0, 0, w, h);
- insensitive = gdk_pixmap_new(GTK_WIDGET (gtkpixmap)->window, w, h, -1);
- gc = gdk_gc_new (pixmap);
-
- visual = gtk_widget_get_visual(GTK_WIDGET(gtkpixmap));
- cmap = gtk_widget_get_colormap(GTK_WIDGET(gtkpixmap));
- cc = gdk_color_context_new(visual, cmap);
-
- if ((cc->mode != GDK_CC_MODE_TRUE) && (cc->mode != GDK_CC_MODE_MY_GRAY))
- {
- gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
-
- style = gtk_widget_get_style(window);
- color = style->bg[0];
- gdk_gc_set_foreground (gc, &color);
- for (y = 0; y < h; y++)
- {
- for (x = y % 2; x < w; x += 2)
- {
- gdk_draw_point(insensitive, gc, x, y);
- }
- }
- }
- else
- {
- gdk_gc_get_values(gc, &vals);
- style = gtk_widget_get_style(window);
-
- color = style->bg[0];
- red = color.red;
- green = color.green;
- blue = color.blue;
-
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x++)
- {
- c.pixel = gdk_image_get_pixel(image, x, y);
- gdk_color_context_query_color(cc, &c);
- c.red = (((gint32)c.red - red) >> 1) + red;
- c.green = (((gint32)c.green - green) >> 1) + green;
- c.blue = (((gint32)c.blue - blue) >> 1) + blue;
- c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
- &failed);
- gdk_image_put_pixel(image, x, y, c.pixel);
- }
- }
+ gint w, h;
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *stated;
+
+ gdk_window_get_size (pixmap, &w, &h);
+
+ pixbuf = gdk_pixbuf_get_from_drawable (NULL,
+ pixmap,
+ gtk_widget_get_colormap (GTK_WIDGET(gtkpixmap)),
+ 0, 0,
+ 0, 0,
+ w, h);
+
+ stated = gdk_pixbuf_copy (pixbuf);
+
+ gdk_pixbuf_saturate_and_pixelate (pixbuf, stated,
+ 0.8, TRUE);
- for (y = 0; y < h; y++)
- {
- for (x = y % 2; x < w; x += 2)
- {
- c.pixel = gdk_image_get_pixel(image, x, y);
- gdk_color_context_query_color(cc, &c);
- c.red = (((gint32)c.red - red) >> 1) + red;
- c.green = (((gint32)c.green - green) >> 1) + green;
- c.blue = (((gint32)c.blue - blue) >> 1) + blue;
- c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
- &failed);
- gdk_image_put_pixel(image, x, y, c.pixel);
- }
- }
+ g_object_unref (G_OBJECT (pixbuf));
+ pixbuf = NULL;
+
+ insensitive = gdk_pixmap_new (GTK_WIDGET (gtkpixmap)->window, w, h, -1);
- gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
- }
+ gdk_pixbuf_render_to_drawable (stated,
+ insensitive,
+ GTK_WIDGET (gtkpixmap)->style->white_gc,
+ 0, 0,
+ 0, 0,
+ w, h,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
gtkpixmap->pixmap_insensitive = insensitive;
- gdk_image_destroy(image);
- gdk_color_context_free(cc);
- gdk_gc_destroy(gc);
+ g_object_unref (G_OBJECT (stated));
}