emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master b40db49 2/2: Support tool bar icon image on GTK+ >=


From: YAMAMOTO Mitsuharu
Subject: [Emacs-diffs] master b40db49 2/2: Support tool bar icon image on GTK+ >= 3.10 with cairo
Date: Tue, 26 Mar 2019 01:52:32 -0400 (EDT)

branch: master
commit b40db491cbbfd30e495d049c133667ebed828e2a
Author: YAMAMOTO Mitsuharu <address@hidden>
Commit: YAMAMOTO Mitsuharu <address@hidden>

    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.
---
 src/gtkutil.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/gtkutil.c b/src/gtkutil.c
index 58e95a4..4bd73b1 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]