diff options
author | Karoly Lorentey <lorentey@elte.hu> | 2004-07-03 17:01:39 +0000 |
---|---|---|
committer | Karoly Lorentey <lorentey@elte.hu> | 2004-07-03 17:01:39 +0000 |
commit | 76e9cc50019f98e12f342574ba0de1eca6631767 (patch) | |
tree | 4d42c708429ab4b564466937f9c235dba2f763fb /src/gtkutil.c | |
parent | 69deab57ea8ab5e3bc1cfb80027341aa0451362b (diff) | |
parent | 1e118124a8e4f8e0a0d4ceb7940b11087e3b94e2 (diff) | |
download | emacs-76e9cc50019f98e12f342574ba0de1eca6631767.tar.gz |
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-427
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-428
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-429
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-430
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-431
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-432
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-433
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-434
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-435
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-436
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-204
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r-- | src/gtkutil.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 84aa9f46d4d..3ffba0ba745 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -248,8 +248,46 @@ xg_get_image_for_pixmap (f, img, widget, old_widget) { GdkPixmap *gpix; GdkPixmap *gmask; - GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); + GdkDisplay *gdpy; + + /* If we are on a one bit display, let GTK do all the image handling. + This seems to be the only way to make insensitive and activated icons + look good. */ + if (x_screen_planes (f) == 1) + { + Lisp_Object specified_file = Qnil; + Lisp_Object tail; + extern Lisp_Object QCfile; + + for (tail = XCDR (img->spec); + NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail)); + tail = XCDR (XCDR (tail))) + if (EQ (XCAR (tail), QCfile)) + specified_file = XCAR (XCDR (tail)); + + if (STRINGP (specified_file)) + { + + Lisp_Object file = Qnil; + struct gcpro gcpro1; + GCPRO1 (file); + file = x_find_image_file (specified_file); + /* We already loaded the image once before calling this + function, so this should not fail. */ + xassert (STRINGP (file) != 0); + + if (! old_widget) + old_widget = GTK_IMAGE (gtk_image_new_from_file (SDATA (file))); + else + gtk_image_set_from_file (old_widget, SDATA (file)); + + UNGCPRO; + return GTK_WIDGET (old_widget); + } + } + + gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0; @@ -262,6 +300,12 @@ xg_get_image_for_pixmap (f, img, widget, old_widget) } else { + /* This is a workaround to make icons look good on pseudo color + displays. Apparently GTK expects the images to have an alpha + channel. If they don't, insensitive and activated icons will + look bad. This workaround does not work on monochrome displays, + and is not needed on true color/static color displays (i.e. + 16 bits and higher). */ int x, y, width, height, rowstride, mask_rowstride; GdkPixbuf *icon_buf, *tmp_buf; guchar *pixels; @@ -308,12 +352,9 @@ xg_get_image_for_pixmap (f, img, widget, old_widget) } } - g_object_unref (G_OBJECT (gmask)); g_object_unref (G_OBJECT (mask_buf)); } - g_object_unref (G_OBJECT (gpix)); - if (! old_widget) old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf)); else @@ -322,6 +363,9 @@ xg_get_image_for_pixmap (f, img, widget, old_widget) g_object_unref (G_OBJECT (icon_buf)); } + g_object_unref (G_OBJECT (gpix)); + if (gmask) g_object_unref (G_OBJECT (gmask)); + return GTK_WIDGET (old_widget); } |