mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-31 17:30:54 -08:00
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.
This commit is contained in:
parent
75b7b2cf7c
commit
b40db491cb
1 changed files with 35 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue