comparison src/xfns.c @ 52095:a2208fe45c36

* 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.
author Jan Djärv <jan.h.d@swipnet.se>
date Thu, 31 Jul 2003 16:10:53 +0000
parents c3f9f23be6a8
children 1a4bd2bec861
comparison
equal deleted inserted replaced
52094:020088a4cf77 52095:a2208fe45c36
1090 f->output_data.x->wait_for_wm = !NILP (new_value); 1090 f->output_data.x->wait_for_wm = !NILP (new_value);
1091 } 1091 }
1092 1092
1093 #ifdef USE_GTK 1093 #ifdef USE_GTK
1094 1094
1095 /* Wrapper for gtk_window_icon_from_file() */ 1095 static Lisp_Object x_find_image_file P_ ((Lisp_Object file));
1096
1097 /* Set icon from FILE for frame F. By using GTK functions the icon
1098 may be any format that GdkPixbuf knows about, i.e. not just bitmaps. */
1096 1099
1097 int 1100 int
1098 xg_set_icon(f, file) 1101 xg_set_icon(f, file)
1099 struct frame *f; 1102 FRAME_PTR f;
1100 Lisp_Object file; 1103 Lisp_Object file;
1101 { 1104 {
1102 struct gcpro gcpro1, gcpro2, gcpro3; 1105 struct gcpro gcpro1;
1103 int fd; 1106 int result = 0;
1104 int result = 1; 1107 Lisp_Object found;
1105 Lisp_Object found, search_path; 1108
1106 char *filename; 1109 GCPRO1 (found);
1107 1110
1108 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path); 1111 found = x_find_image_file (file);
1109 1112
1110 GCPRO3 (found, search_path, file); 1113 if (! NILP (found))
1111 fd = openp (search_path, file, Qnil, &found, Qnil); 1114 {
1112 if (fd > 0) 1115 GdkPixbuf *pixbuf;
1113 { 1116 GError *err = NULL;
1114 filename = (char *) SDATA (found); 1117 char *filename;
1115 BLOCK_INPUT; 1118
1116 result = 1119 filename = SDATA (found);
1117 gtk_window_set_icon_from_file (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 1120 BLOCK_INPUT;
1118 filename, 1121
1119 NULL); 1122 pixbuf = gdk_pixbuf_new_from_file (filename, &err);
1120 UNBLOCK_INPUT; 1123
1121 } 1124 if (pixbuf)
1122 emacs_close (fd); 1125 {
1123 UNGCPRO; 1126 gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1124 return result; 1127 pixbuf);
1128 g_object_unref (pixbuf);
1129
1130 result = 1;
1131 }
1132 else
1133 g_error_free (err);
1134
1135 UNBLOCK_INPUT;
1136 }
1137
1138 UNGCPRO;
1139 return result;
1125 } 1140 }
1126 #endif /* USE_GTK */ 1141 #endif /* USE_GTK */
1127 1142
1128 1143
1129 /* Functions called only from `x_set_frame_param' 1144 /* Functions called only from `x_set_frame_param'