Mercurial > emacs
comparison src/gtkutil.c @ 78809:c1d129148b98
(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.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sun, 16 Sep 2007 09:34:41 +0000 |
parents | 96a27ec4e6c5 |
children | 7c710af0ae5e |
comparison
equal
deleted
inserted
replaced
78808:94efc47b8b8b | 78809:c1d129148b98 |
---|---|
334 GtkImage *old_widget; | 334 GtkImage *old_widget; |
335 { | 335 { |
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 |
342 look good in all cases. */ | 344 look good in all cases. */ |
343 Lisp_Object specified_file = file_for_image (img->spec); | 345 Lisp_Object specified_file = file_for_image (img->spec); |
364 | 366 |
365 gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); | 367 gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); |
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 | 387 |
379 /* This is a workaround to make icons look good on pseudo color | 388 g_object_unref (G_OBJECT (icon_buf)); |
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 | |
388 if (! old_widget) | |
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)); |
398 | 392 |
399 return GTK_WIDGET (old_widget); | 393 return GTK_WIDGET (old_widget); |
3637 return FALSE; | 3631 return FALSE; |
3638 } | 3632 } |
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 | |
3651 static gboolean | |
3652 xg_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 |
3664 static void | 3639 static void |
3665 xg_create_tool_bar (f) | 3640 xg_create_tool_bar (f) |
3697 | 3672 |
3698 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", | 3673 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", |
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 |
3709 gtk_widget_size_request (x->toolbar_widget, &req); | 3680 gtk_widget_size_request (x->toolbar_widget, &req); |
3710 FRAME_TOOLBAR_HEIGHT (f) = req.height; | 3681 FRAME_TOOLBAR_HEIGHT (f) = req.height; |