diff options
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2019-03-26 14:50:10 +0900 |
---|---|---|
committer | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2019-03-26 14:50:10 +0900 |
commit | b40db491cbbfd30e495d049c133667ebed828e2a (patch) | |
tree | 91fbc39901dc87f0c1560e4ce471aeb94b3c6d7a | |
parent | 75b7b2cf7cfd39dd595fa27ddeef859ed85861bb (diff) | |
download | emacs-b40db491cbbfd30e495d049c133667ebed828e2a.tar.gz |
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.
-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, GtkWidget *widget, GtkImage *old_widget) { +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + cairo_surface_t *surface; +#else GdkPixbuf *icon_buf; +#endif /* If we have a file, let GTK do all the image handling. 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, on a monochrome display, and sometimes bad on all displays with certain themes. */ +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + surface = img->cr_data; + + if (surface) + { + if (! old_widget) + old_widget = GTK_IMAGE (gtk_image_new_from_surface (surface)); + else + gtk_image_set_from_surface (old_widget, surface); + } +#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 @@ -416,6 +431,7 @@ xg_get_image_for_pixmap (struct frame *f, g_object_unref (G_OBJECT (icon_buf)); } +#endif return GTK_WIDGET (old_widget); } @@ -4765,9 +4781,15 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name, { gpointer gold_img = g_object_get_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA); +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + void *old_img = (void *) gold_img; + if (old_img != img->cr_data) + return 1; +#else Pixmap old_img = (Pixmap) gold_img; if (old_img != img->pixmap) return 1; +#endif } /* Check button configuration and label. */ @@ -5059,7 +5081,13 @@ update_frame_tool_bar (struct frame *f) img = IMAGE_FROM_ID (f, img_id); prepare_image_for_display (f, img); - if (img->load_failed_p || img->pixmap == None) + if (img->load_failed_p +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + || img->cr_data == NULL +#else + || img->pixmap == None +#endif + ) { if (ti) gtk_container_remove (GTK_CONTAINER (wtoolbar), @@ -5109,7 +5137,12 @@ update_frame_tool_bar (struct frame *f) { w = xg_get_image_for_pixmap (f, img, x->widget, NULL); g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, - (gpointer)img->pixmap); +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + (gpointer)img->cr_data +#else + (gpointer)img->pixmap +#endif + ); } #if GTK_CHECK_VERSION (3, 14, 0) |