aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2007-09-16 09:34:52 +0000
committerJan Djärv2007-09-16 09:34:52 +0000
commitd51e0fc41a8f8aa9cac923d52bc0ea3921d010f9 (patch)
tree50e35f0bd71211ea74b91f14d89f74e54d754573 /src
parent846d1b3e948004ade6fc49aad33442b0de450c54 (diff)
downloademacs-d51e0fc41a8f8aa9cac923d52bc0ea3921d010f9.tar.gz
emacs-d51e0fc41a8f8aa9cac923d52bc0ea3921d010f9.zip
(xg_get_image_for_pixmap): Always create a GdkPixbuf
when we have no file name for the icon. (xg_tool_bar_expose_callback): Remove. (xg_create_tool_bar): Don't connect expose signal to xg_tool_bar_expose_callback.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/gtkutil.c65
2 files changed, 26 insertions, 47 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 868e007c863..c69e579d70b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12007-09-16 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2
3 * gtkutil.c (xg_get_image_for_pixmap): Always create a GdkPixbuf
4 when we have no file name for the icon.
5 (xg_tool_bar_expose_callback): Remove.
6 (xg_create_tool_bar): Don't connect expose signal to
7 xg_tool_bar_expose_callback.
8
12007-09-15 Glenn Morris <rgm@gnu.org> 92007-09-15 Glenn Morris <rgm@gnu.org>
2 10
3 * s/hpux.h: No longer define `static' as nothing. 11 * s/hpux.h: No longer define `static' as nothing.
diff --git a/src/gtkutil.c b/src/gtkutil.c
index cf88eeb8bf0..b37620caa9c 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -336,6 +336,8 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
336 GdkPixmap *gpix; 336 GdkPixmap *gpix;
337 GdkPixmap *gmask; 337 GdkPixmap *gmask;
338 GdkDisplay *gdpy; 338 GdkDisplay *gdpy;
339 GdkColormap *cmap;
340 GdkPixbuf *icon_buf;
339 341
340 /* If we have a file, let GTK do all the image handling. 342 /* If we have a file, let GTK do all the image handling.
341 This seems to be the only way to make insensitive and activated icons 343 This seems to be the only way to make insensitive and activated icons
@@ -366,32 +368,24 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
366 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); 368 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap);
367 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0; 369 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0;
368 370
369 if (x_screen_planes (f) > 8 || x_screen_planes (f) == 1) 371 /* This is a workaround to make icons look good on pseudo color
370 { 372 displays. Apparently GTK expects the images to have an alpha
371 if (! old_widget) 373 channel. If they don't, insensitive and activated icons will
372 old_widget = GTK_IMAGE (gtk_image_new_from_pixmap (gpix, gmask)); 374 look bad. This workaround does not work on monochrome displays,
373 else 375 and is strictly not needed on true color/static color displays (i.e.
374 gtk_image_set_from_pixmap (old_widget, gpix, gmask); 376 16 bits and higher). But we do it anyway so we get a pixbuf that is
375 } 377 not associated with the img->pixmap. The img->pixmap may be removed
378 by clearing the image cache and then the tool bar redraw fails, since
379 Gtk+ assumes the pixmap is always there. */
380 cmap = gtk_widget_get_colormap (widget);
381 icon_buf = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap);
382
383 if (! old_widget)
384 old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf));
376 else 385 else
377 { 386 gtk_image_set_from_pixbuf (old_widget, icon_buf);
378
379 /* This is a workaround to make icons look good on pseudo color
380 displays. Apparently GTK expects the images to have an alpha
381 channel. If they don't, insensitive and activated icons will
382 look bad. This workaround does not work on monochrome displays,
383 and is not needed on true color/static color displays (i.e.
384 16 bits and higher). */
385 GdkColormap *cmap = gtk_widget_get_colormap (widget);
386 GdkPixbuf *icon_buf = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap);
387 387
388 if (! old_widget) 388 g_object_unref (G_OBJECT (icon_buf));
389 old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf));
390 else
391 gtk_image_set_from_pixbuf (old_widget, icon_buf);
392
393 g_object_unref (G_OBJECT (icon_buf));
394 }
395 389
396 g_object_unref (G_OBJECT (gpix)); 390 g_object_unref (G_OBJECT (gpix));
397 if (gmask) g_object_unref (G_OBJECT (gmask)); 391 if (gmask) g_object_unref (G_OBJECT (gmask));
@@ -3639,25 +3633,6 @@ xg_tool_bar_item_expose_callback (w, event, client_data)
3639 3633
3640#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) 3634#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX))
3641 3635
3642/* This callback is called when a tool bar shall be redrawn.
3643 We need to update the images in case the image cache
3644 has deleted the pixmaps used in the tool bar.
3645 W is the GtkToolbar to be redrawn.
3646 EVENT is the expose event for W.
3647 CLIENT_DATA is pointing to the frame for this tool bar.
3648
3649 Returns FALSE to tell GTK to keep processing this event. */
3650
3651static gboolean
3652xg_tool_bar_expose_callback (w, event, client_data)
3653 GtkWidget *w;
3654 GdkEventExpose *event;
3655 gpointer client_data;
3656{
3657 FRAME_PTR f = (FRAME_PTR) client_data;
3658 SET_FRAME_GARBAGED (f);
3659 return FALSE;
3660}
3661 3636
3662/* Create a tool bar for frame F. */ 3637/* Create a tool bar for frame F. */
3663 3638
@@ -3699,10 +3674,6 @@ xg_create_tool_bar (f)
3699 G_CALLBACK (xg_tool_bar_detach_callback), f); 3674 G_CALLBACK (xg_tool_bar_detach_callback), f);
3700 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", 3675 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached",
3701 G_CALLBACK (xg_tool_bar_attach_callback), f); 3676 G_CALLBACK (xg_tool_bar_attach_callback), f);
3702 g_signal_connect (G_OBJECT (x->toolbar_widget),
3703 "expose-event",
3704 G_CALLBACK (xg_tool_bar_expose_callback),
3705 f);
3706 3677
3707 gtk_widget_show_all (x->handlebox_widget); 3678 gtk_widget_show_all (x->handlebox_widget);
3708 3679