diff options
| author | Jan Djärv | 2007-09-16 09:38:37 +0000 |
|---|---|---|
| committer | Jan Djärv | 2007-09-16 09:38:37 +0000 |
| commit | 45c94881d59261fc7c6ef8875053490d9219785a (patch) | |
| tree | 6bf2ec8be6d03a8d58cc9c36e67d8a04c5bef9c4 /src | |
| parent | 4d580af2d7dd70d97073bf91da4f3f4d9f10bafc (diff) | |
| download | emacs-45c94881d59261fc7c6ef8875053490d9219785a.tar.gz emacs-45c94881d59261fc7c6ef8875053490d9219785a.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.
(xg_get_file_with_chooser): Move GCPRO1 after declarations.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/gtkutil.c | 67 |
2 files changed, 28 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 12562c88c93..d77539d151c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2007-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 | (xg_get_file_with_chooser): Move GCPRO1 after declarations. | ||
| 9 | |||
| 1 | 2007-09-16 Andreas Schwab <schwab@suse.de> | 10 | 2007-09-16 Andreas Schwab <schwab@suse.de> |
| 2 | 11 | ||
| 3 | * alloc.c (reset_malloc_hooks): Set the hooks to the previous | 12 | * alloc.c (reset_malloc_hooks): Set the hooks to the previous |
diff --git a/src/gtkutil.c b/src/gtkutil.c index b35317dd7fb..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 | 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)); |
| @@ -1412,8 +1406,8 @@ xg_get_file_with_chooser (f, prompt, default_filename, | |||
| 1412 | { | 1406 | { |
| 1413 | Lisp_Object file; | 1407 | Lisp_Object file; |
| 1414 | struct gcpro gcpro1; | 1408 | struct gcpro gcpro1; |
| 1415 | GCPRO1 (file); | ||
| 1416 | char *utf8_filename; | 1409 | char *utf8_filename; |
| 1410 | GCPRO1 (file); | ||
| 1417 | 1411 | ||
| 1418 | file = build_string (default_filename); | 1412 | file = build_string (default_filename); |
| 1419 | 1413 | ||
| @@ -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 | |||
| 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 | ||
| @@ -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 | ||