summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2003-07-31 16:10:53 +0000
committerJan Djärv <jan.h.d@swipnet.se>2003-07-31 16:10:53 +0000
commit465aa50afc635773061ce89b3398c5613d8eb8c0 (patch)
tree12620283470991b4f0ac6d858d026348559f3daa
parente430e5baa09f3451c5d03290b5c51e783a30fd26 (diff)
downloademacs-465aa50afc635773061ce89b3398c5613d8eb8c0.tar.gz
* xfns.c (xg_set_icon): Rewrite to compile with GTK 2.0 and 2.2.
* xterm.c (x_bitmap_icon): Return if xg_set_icon succeeds.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xfns.c61
-rw-r--r--src/xterm.c2
3 files changed, 45 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 71f2ff865f8..6c92bf7cd88 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-31 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * xfns.c (xg_set_icon): Rewrite to compile with GTK 2.0 and 2.2.
+
+ * xterm.c (x_bitmap_icon): Return if xg_set_icon succeeds.
+
2003-07-31 Kenichi Handa <handa@m17n.org>
* process.c (read_process_output): Return the actually read bytes
diff --git a/src/xfns.c b/src/xfns.c
index b567b11d283..af7ed7473e8 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1092,36 +1092,51 @@ x_set_wait_for_wm (f, new_value, old_value)
#ifdef USE_GTK
-/* Wrapper for gtk_window_icon_from_file() */
+static Lisp_Object x_find_image_file P_ ((Lisp_Object file));
+
+/* Set icon from FILE for frame F. By using GTK functions the icon
+ may be any format that GdkPixbuf knows about, i.e. not just bitmaps. */
int
xg_set_icon(f, file)
- struct frame *f;
+ FRAME_PTR f;
Lisp_Object file;
{
- struct gcpro gcpro1, gcpro2, gcpro3;
- int fd;
- int result = 1;
- Lisp_Object found, search_path;
- char *filename;
+ struct gcpro gcpro1;
+ int result = 0;
+ Lisp_Object found;
- search_path = Fcons (Vdata_directory, Vx_bitmap_file_path);
+ GCPRO1 (found);
- GCPRO3 (found, search_path, file);
- fd = openp (search_path, file, Qnil, &found, Qnil);
- if (fd > 0)
- {
- filename = (char *) SDATA (found);
- BLOCK_INPUT;
- result =
- gtk_window_set_icon_from_file (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
- filename,
- NULL);
- UNBLOCK_INPUT;
- }
- emacs_close (fd);
- UNGCPRO;
- return result;
+ found = x_find_image_file (file);
+
+ if (! NILP (found))
+ {
+ GdkPixbuf *pixbuf;
+ GError *err = NULL;
+ char *filename;
+
+ filename = SDATA (found);
+ BLOCK_INPUT;
+
+ pixbuf = gdk_pixbuf_new_from_file (filename, &err);
+
+ if (pixbuf)
+ {
+ gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ pixbuf);
+ g_object_unref (pixbuf);
+
+ result = 1;
+ }
+ else
+ g_error_free (err);
+
+ UNBLOCK_INPUT;
+ }
+
+ UNGCPRO;
+ return result;
}
#endif /* USE_GTK */
diff --git a/src/xterm.c b/src/xterm.c
index 7ffff61f361..5463ce8e192 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7474,7 +7474,7 @@ x_bitmap_icon (f, file)
#ifdef USE_GTK
/* Use gtk_window_set_icon_from_file() if available,
It's not restricted to bitmaps */
- if (!xg_set_icon(f, file))
+ if (xg_set_icon(f, file))
return 0;
#endif /* USE_GTK */
bitmap_id = x_create_bitmap_from_file (f, file);