diff options
| author | YAMAMOTO Mitsuharu | 2019-03-26 14:50:10 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2019-03-26 14:50:10 +0900 |
| commit | b40db491cbbfd30e495d049c133667ebed828e2a (patch) | |
| tree | 91fbc39901dc87f0c1560e4ce471aeb94b3c6d7a /src | |
| parent | 75b7b2cf7cfd39dd595fa27ddeef859ed85861bb (diff) | |
| download | emacs-b40db491cbbfd30e495d049c133667ebed828e2a.tar.gz emacs-b40db491cbbfd30e495d049c133667ebed828e2a.zip | |
Support tool bar icon image on GTK+ >= 3.10 with cairo
* src/gtkutil.c (xg_get_image_for_pixmap) [USE_CAIRO]: Use cairo image
surface for GtkImage source.
(xg_tool_item_stale_p, update_frame_tool_bar) [USE_CAIRO]: Use cairo
image surface instead of pixmap for data associated with tool bar item.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gtkutil.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 58e95a46796..4bd73b1a6d1 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -368,7 +368,11 @@ xg_get_image_for_pixmap (struct frame *f, | |||
| 368 | GtkWidget *widget, | 368 | GtkWidget *widget, |
| 369 | GtkImage *old_widget) | 369 | GtkImage *old_widget) |
| 370 | { | 370 | { |
| 371 | #if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) | ||
| 372 | cairo_surface_t *surface; | ||
| 373 | #else | ||
| 371 | GdkPixbuf *icon_buf; | 374 | GdkPixbuf *icon_buf; |
| 375 | #endif | ||
| 372 | 376 | ||
| 373 | /* If we have a file, let GTK do all the image handling. | 377 | /* If we have a file, let GTK do all the image handling. |
| 374 | This seems to be the only way to make insensitive and activated icons | 378 | This seems to be the only way to make insensitive and activated icons |
| @@ -396,6 +400,17 @@ xg_get_image_for_pixmap (struct frame *f, | |||
| 396 | on a monochrome display, and sometimes bad on all displays with | 400 | on a monochrome display, and sometimes bad on all displays with |
| 397 | certain themes. */ | 401 | certain themes. */ |
| 398 | 402 | ||
| 403 | #if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) | ||
| 404 | surface = img->cr_data; | ||
| 405 | |||
| 406 | if (surface) | ||
| 407 | { | ||
| 408 | if (! old_widget) | ||
| 409 | old_widget = GTK_IMAGE (gtk_image_new_from_surface (surface)); | ||
| 410 | else | ||
| 411 | gtk_image_set_from_surface (old_widget, surface); | ||
| 412 | } | ||
| 413 | #else | ||
| 399 | /* This is a workaround to make icons look good on pseudo color | 414 | /* This is a workaround to make icons look good on pseudo color |
| 400 | displays. Apparently GTK expects the images to have an alpha | 415 | displays. Apparently GTK expects the images to have an alpha |
| 401 | channel. If they don't, insensitive and activated icons will | 416 | channel. If they don't, insensitive and activated icons will |
| @@ -416,6 +431,7 @@ xg_get_image_for_pixmap (struct frame *f, | |||
| 416 | 431 | ||
| 417 | g_object_unref (G_OBJECT (icon_buf)); | 432 | g_object_unref (G_OBJECT (icon_buf)); |
| 418 | } | 433 | } |
| 434 | #endif | ||
| 419 | 435 | ||
| 420 | return GTK_WIDGET (old_widget); | 436 | return GTK_WIDGET (old_widget); |
| 421 | } | 437 | } |
| @@ -4765,9 +4781,15 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name, | |||
| 4765 | { | 4781 | { |
| 4766 | gpointer gold_img = g_object_get_data (G_OBJECT (wimage), | 4782 | gpointer gold_img = g_object_get_data (G_OBJECT (wimage), |
| 4767 | XG_TOOL_BAR_IMAGE_DATA); | 4783 | XG_TOOL_BAR_IMAGE_DATA); |
| 4784 | #if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) | ||
| 4785 | void *old_img = (void *) gold_img; | ||
| 4786 | if (old_img != img->cr_data) | ||
| 4787 | return 1; | ||
| 4788 | #else | ||
| 4768 | Pixmap old_img = (Pixmap) gold_img; | 4789 | Pixmap old_img = (Pixmap) gold_img; |
| 4769 | if (old_img != img->pixmap) | 4790 | if (old_img != img->pixmap) |
| 4770 | return 1; | 4791 | return 1; |
| 4792 | #endif | ||
| 4771 | } | 4793 | } |
| 4772 | 4794 | ||
| 4773 | /* Check button configuration and label. */ | 4795 | /* Check button configuration and label. */ |
| @@ -5059,7 +5081,13 @@ update_frame_tool_bar (struct frame *f) | |||
| 5059 | img = IMAGE_FROM_ID (f, img_id); | 5081 | img = IMAGE_FROM_ID (f, img_id); |
| 5060 | prepare_image_for_display (f, img); | 5082 | prepare_image_for_display (f, img); |
| 5061 | 5083 | ||
| 5062 | if (img->load_failed_p || img->pixmap == None) | 5084 | if (img->load_failed_p |
| 5085 | #if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) | ||
| 5086 | || img->cr_data == NULL | ||
| 5087 | #else | ||
| 5088 | || img->pixmap == None | ||
| 5089 | #endif | ||
| 5090 | ) | ||
| 5063 | { | 5091 | { |
| 5064 | if (ti) | 5092 | if (ti) |
| 5065 | gtk_container_remove (GTK_CONTAINER (wtoolbar), | 5093 | gtk_container_remove (GTK_CONTAINER (wtoolbar), |
| @@ -5109,7 +5137,12 @@ update_frame_tool_bar (struct frame *f) | |||
| 5109 | { | 5137 | { |
| 5110 | w = xg_get_image_for_pixmap (f, img, x->widget, NULL); | 5138 | w = xg_get_image_for_pixmap (f, img, x->widget, NULL); |
| 5111 | g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, | 5139 | g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, |
| 5112 | (gpointer)img->pixmap); | 5140 | #if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) |
| 5141 | (gpointer)img->cr_data | ||
| 5142 | #else | ||
| 5143 | (gpointer)img->pixmap | ||
| 5144 | #endif | ||
| 5145 | ); | ||
| 5113 | } | 5146 | } |
| 5114 | 5147 | ||
| 5115 | #if GTK_CHECK_VERSION (3, 14, 0) | 5148 | #if GTK_CHECK_VERSION (3, 14, 0) |