]> git.eshelyaron.com Git - emacs.git/commitdiff
* xfns.c (xg_set_icon_from_xpm_data): New function.
authorChong Yidong <cyd@stupidchicken.com>
Wed, 16 Nov 2005 16:38:48 +0000 (16:38 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Wed, 16 Nov 2005 16:38:48 +0000 (16:38 +0000)
* gnu.h (gnu_xpm_bits): Renamed from gnu_bits.
(gnu_xbm_bits): Renamed from gnu_bits (xbm version).

* xterm.c (x_bitmap_icon): Use the xpm if available.

src/ChangeLog
src/gnu.h
src/xfns.c
src/xterm.c

index d366093114b23258adcdce03424c4c5c4e802174..513d9d0ff92883d4efe4a05c067b7a5ddbc845d3 100644 (file)
@@ -1,6 +1,9 @@
 2005-11-16  Chong Yidong  <cyd@stupidchicken.com>
 
-       * gnu.h (gnu_bits): Xpm version of the new Emacs icon.
+       * xfns.c (xg_set_icon_from_xpm_data): New function.
+
+       * gnu.h (gnu_xpm_bits): Renamed from gnu_bits.
+       (gnu_xbm_bits): Renamed from gnu_bits (xbm version).
 
        * xterm.c (x_bitmap_icon): Use the xpm if available.
 
index 2f3bb4c7e516163d5f91eb02e02bac58263f7490..dbf473174939a66cb3f56f8ae16fedb4c208214a 100644 (file)
--- a/src/gnu.h
+++ b/src/gnu.h
@@ -1,5 +1,5 @@
 #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
-static char * gnu_bits[] = {
+static char * gnu_xpm_bits[] = {
 "32 32 173 2",
 "      c None",
 ".     c #67627D",
@@ -206,10 +206,11 @@ static char * gnu_bits[] = {
 "        P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.        ",
 "                                                                ",
 "                                                                "};
-#else
-#define gnu_width 50
-#define gnu_height 50
-static unsigned char gnu_bits[] = {
+#endif /* defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) */
+
+#define gnu_xbm_width 50
+#define gnu_xbm_height 50
+static unsigned char gnu_xbm_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00,
@@ -240,7 +241,6 @@ static unsigned char gnu_bits[] = {
    0xf8, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00};
-#endif
 
 /* arch-tag: b57020c7-c937-4d77-8ca6-3875178d9828
    (do not change this comment) */
index a1aee42b85b1f2cd5f1ca90a9e9082b9d5fcface..c3eb173b4f9738d2871052fe1468aa1b88d2db7a 100644 (file)
@@ -818,6 +818,27 @@ xg_set_icon (f, file)
   UNGCPRO;
   return result;
 }
+
+int
+xg_set_icon_from_xpm_data (f, data)
+    FRAME_PTR f;
+    char **data;
+{
+  int result = 0;
+  GError *err = NULL;
+  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data);
+
+  if (!pixbuf)
+    {
+      g_error_free (err);
+      return 0;
+    }
+
+  gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                      pixbuf);
+  g_object_unref (pixbuf);
+  return 1;
+}
 #endif /* USE_GTK */
 
 
index 8359cec011240f194f3f7b9b0298b83ad36788ad..113a942de5f22c16e22cd292a26b4e29b2a1f45f 100644 (file)
@@ -7362,15 +7362,30 @@ x_bitmap_icon (f, file)
       /* Create the GNU bitmap and mask if necessary.  */
       if (FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0)
        {
+         int rc = -1;
+
 #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
-         FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id
-           = x_create_bitmap_from_xpm_data (f, gnu_bits);
+#ifdef USE_GTK
+         if (xg_set_icon_from_xpm_data (f, gnu_xpm_bits))
+           return 0;
 #else
-         FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id
-           = x_create_bitmap_from_data (f, gnu_bits,
-                                        gnu_width, gnu_height);
-#endif /*  (HAVE_XPM) && defined (HAVE_X_WINDOWS) */
-         x_create_bitmap_mask (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
+         rc = x_create_bitmap_from_xpm_data (f, gnu_xpm_bits);
+         if (rc != -1)
+           FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id = rc;
+#endif /* USE_GTK */
+#endif /* defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) */
+
+         /* If all else fails, use the (black and white) xbm image. */
+         if (rc == -1)
+           {
+             rc = x_create_bitmap_from_data (f, gnu_xbm_bits,
+                                             gnu_xbm_width, gnu_xbm_height);
+             if (rc == -1)
+               return 1;
+
+             FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id = rc;
+             x_create_bitmap_mask (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
+           }
        }
 
       /* The first time we create the GNU bitmap and mask,