462
|
1 /* ui-gtk.c
|
|
2 **
|
|
3 ** Description: Creating 'real' UIs from lisp.
|
|
4 **
|
|
5 ** Created by: William M. Perry <wmperry@gnu.org>
|
|
6 ** Copyright (c) 2000 William M. Perry <wmperry@gnu.org>
|
|
7 **
|
|
8 */
|
|
9
|
|
10 #include <config.h>
|
|
11 #include "lisp.h"
|
1346
|
12
|
462
|
13 #include "buffer.h"
|
2168
|
14 #include "console-gtk-impl.h"
|
462
|
15 #include "device.h"
|
|
16 #include "elhash.h"
|
778
|
17 #include "event-gtk.h"
|
1346
|
18 #include "events.h"
|
|
19 #include "faces.h"
|
|
20 #include "glyphs-gtk.h"
|
|
21 #include "hash.h"
|
|
22 #include "objects-gtk.h"
|
|
23 #include "sysdll.h"
|
|
24 #include "ui-gtk.h"
|
|
25 #include "window.h"
|
462
|
26
|
|
27 /* XEmacs specific GTK types */
|
|
28 #include "gtk-glue.c"
|
|
29
|
2054
|
30 /* Is the fundamental type of 't' the xemacs defined fundamental type 'type'? */
|
|
31 #define IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t,type) (((GtkType) GTK_FUNDAMENTAL_TYPE(t)) == (type))
|
|
32
|
462
|
33 Lisp_Object Qemacs_ffip;
|
|
34 Lisp_Object Qemacs_gtk_objectp;
|
|
35 Lisp_Object Qemacs_gtk_boxedp;
|
|
36 Lisp_Object Qvoid;
|
|
37 Lisp_Object Venumeration_info;
|
|
38
|
|
39 static GHashTable *dll_cache;
|
|
40
|
|
41 Lisp_Object gtk_type_to_lisp (GtkArg *arg);
|
|
42 int lisp_to_gtk_type (Lisp_Object obj, GtkArg *arg);
|
1883
|
43 int lisp_to_gtk_ret_type (Lisp_Object obj, GtkArg *arg);
|
778
|
44 #if 0
|
462
|
45 void describe_gtk_arg (GtkArg *arg);
|
778
|
46 #endif
|
462
|
47 guint symbol_to_enum (Lisp_Object obj, GtkType t);
|
|
48 static guint lisp_to_flag (Lisp_Object obj, GtkType t);
|
|
49 static Lisp_Object flags_to_list (guint value, GtkType t);
|
|
50 static Lisp_Object enum_to_symbol (guint value, GtkType t);
|
|
51
|
|
52 #define NIL_OR_VOID_P(x) (NILP (x) || EQ (x, Qvoid))
|
|
53
|
|
54 static void
|
|
55 initialize_dll_cache (void)
|
|
56 {
|
|
57 if (!dll_cache)
|
|
58 {
|
2054
|
59 static char text[] = "---XEmacs Internal Handle---";
|
|
60
|
462
|
61 dll_cache = g_hash_table_new (g_str_hash, g_str_equal);
|
|
62
|
2054
|
63 g_hash_table_insert (dll_cache, text, dll_open (Qnil));
|
462
|
64 }
|
|
65 }
|
|
66
|
|
67 DEFUN ("dll-load", Fdll_load, 1, 1, 0, /*
|
|
68 Load a shared library DLL into XEmacs. No initialization routines are required.
|
|
69 This is for loading dependency DLLs into XEmacs.
|
|
70 */
|
|
71 (dll))
|
|
72 {
|
|
73 dll_handle h;
|
|
74
|
|
75 CHECK_STRING (dll);
|
|
76
|
|
77 initialize_dll_cache ();
|
|
78
|
|
79 /* If the dll name has a directory component in it, then we should
|
|
80 expand it. */
|
|
81 if (!NILP (Fstring_match (build_string ("/"), dll, Qnil, Qnil)))
|
|
82 dll = Fexpand_file_name (dll, Qnil);
|
|
83
|
|
84 /* Check if we have already opened it first */
|
|
85 h = g_hash_table_lookup (dll_cache, XSTRING_DATA (dll));
|
|
86
|
|
87 if (!h)
|
|
88 {
|
1811
|
89 h = dll_open (dll);
|
462
|
90
|
|
91 if (h)
|
|
92 {
|
2054
|
93 g_hash_table_insert (dll_cache, qxestrdup (XSTRING_DATA (dll)), h);
|
462
|
94 }
|
|
95 else
|
|
96 {
|
2054
|
97 signal_error (Qfile_error, "dll_open error", dll_error());
|
462
|
98 }
|
|
99 }
|
|
100 return (h ? Qt : Qnil);
|
|
101 }
|
|
102
|
|
103
|
|
104 /* Gtk object importing */
|
|
105 EXFUN (Fgtk_import_type, 1);
|
|
106
|
|
107 static struct hash_table *internal_type_hash;
|
|
108
|
|
109 static int
|
|
110 type_hash_equal(const void *arg1, const void *arg2)
|
|
111 {
|
|
112 return ((GtkType) arg1 == (GtkType) arg2);
|
|
113 }
|
|
114
|
|
115 static unsigned long
|
|
116 type_hash_hash(const void *arg)
|
|
117 {
|
|
118 return ((unsigned long) arg);
|
|
119 }
|
|
120
|
|
121 static int
|
|
122 type_already_imported_p (GtkType t)
|
|
123 {
|
|
124 void *retval = NULL;
|
|
125
|
|
126 /* These are cases that we don't need to import */
|
|
127 switch (GTK_FUNDAMENTAL_TYPE (t))
|
|
128 {
|
|
129 case GTK_TYPE_CHAR:
|
|
130 case GTK_TYPE_UCHAR:
|
|
131 case GTK_TYPE_BOOL:
|
|
132 case GTK_TYPE_INT:
|
|
133 case GTK_TYPE_UINT:
|
|
134 case GTK_TYPE_LONG:
|
|
135 case GTK_TYPE_ULONG:
|
|
136 case GTK_TYPE_FLOAT:
|
|
137 case GTK_TYPE_DOUBLE:
|
|
138 case GTK_TYPE_STRING:
|
|
139 case GTK_TYPE_BOXED:
|
|
140 case GTK_TYPE_POINTER:
|
|
141 case GTK_TYPE_SIGNAL:
|
|
142 case GTK_TYPE_ARGS:
|
|
143 case GTK_TYPE_CALLBACK:
|
|
144 case GTK_TYPE_C_CALLBACK:
|
|
145 case GTK_TYPE_FOREIGN:
|
|
146 return (1);
|
|
147 }
|
|
148
|
|
149 if (!internal_type_hash)
|
|
150 {
|
|
151 internal_type_hash = make_general_hash_table (163, type_hash_hash, type_hash_equal);
|
|
152 return (0);
|
|
153 }
|
|
154
|
|
155 if (gethash ((void *)t, internal_type_hash, (const void **)&retval))
|
|
156 {
|
|
157 return (1);
|
|
158 }
|
|
159 return (0);
|
|
160 }
|
|
161
|
|
162 static void
|
|
163 mark_type_as_imported (GtkType t)
|
|
164 {
|
|
165 if (type_already_imported_p (t))
|
|
166 return;
|
|
167
|
|
168 puthash ((void *) t, (void *) 1, internal_type_hash);
|
|
169 }
|
|
170
|
|
171 static void import_gtk_type (GtkType t);
|
|
172
|
|
173 static void
|
|
174 import_gtk_object_internal (GtkType the_type)
|
|
175 {
|
|
176 GtkType original_type = the_type;
|
|
177 int first_time = 1;
|
|
178
|
|
179 do
|
|
180 {
|
|
181 GtkArg *args;
|
|
182 guint32 *flags;
|
|
183 guint n_args;
|
|
184 guint i;
|
|
185 #if 0
|
|
186 GtkObjectClass *klass;
|
|
187 GtkSignalQuery *query;
|
|
188 guint32 *signals;
|
|
189 guint n_signals;
|
|
190 #endif
|
|
191
|
|
192 /* Register the type before we do anything else with it... */
|
|
193 if (!first_time)
|
|
194 {
|
|
195 if (!type_already_imported_p (the_type))
|
|
196 {
|
|
197 import_gtk_type (the_type);
|
|
198 }
|
|
199 }
|
|
200 else
|
|
201 {
|
|
202 /* We need to mark the object type as imported here or we
|
|
203 run the risk of SERIOUS recursion when we do automatic
|
|
204 argument type importing. mark_type_as_imported() is
|
|
205 smart enough to be a noop if we attempt to register
|
|
206 things twice. */
|
|
207 first_time = 0;
|
|
208 mark_type_as_imported (the_type);
|
|
209 }
|
|
210
|
|
211 args = gtk_object_query_args(the_type,&flags,&n_args);
|
|
212
|
|
213 /* First get the arguments the object can accept */
|
|
214 for (i = 0; i < n_args; i++)
|
|
215 {
|
|
216 if ((args[i].type != original_type) && !type_already_imported_p (args[i].type))
|
|
217 {
|
|
218 import_gtk_type (args[i].type);
|
|
219 }
|
|
220 }
|
|
221
|
|
222 g_free(args);
|
|
223 g_free(flags);
|
|
224
|
|
225 #if 0
|
|
226 /* Now lets publish the signals */
|
|
227 klass = (GtkObjectClass *) gtk_type_class (the_type);
|
|
228 signals = klass->signals;
|
|
229 n_signals = klass->nsignals;
|
|
230
|
|
231 for (i = 0; i < n_signals; i++)
|
|
232 {
|
|
233 query = gtk_signal_query (signals[i]);
|
|
234 /* What do we want to do here? */
|
|
235 g_free (query);
|
|
236 }
|
|
237 #endif
|
|
238
|
|
239 the_type = gtk_type_parent(the_type);
|
|
240 } while (the_type != GTK_TYPE_INVALID);
|
|
241 }
|
|
242
|
|
243 static void
|
|
244 import_gtk_enumeration_internal (GtkType the_type)
|
|
245 {
|
|
246 GtkEnumValue *vals = gtk_type_enum_get_values (the_type);
|
|
247 Lisp_Object assoc = Qnil;
|
|
248
|
|
249 if (NILP (Venumeration_info))
|
|
250 {
|
|
251 Venumeration_info = call2 (intern ("make-hashtable"), make_int (100), Qequal);
|
|
252 }
|
|
253
|
|
254 while (vals && vals->value_name)
|
|
255 {
|
|
256 assoc = Fcons (Fcons (intern (vals->value_nick), make_int (vals->value)), assoc);
|
|
257 assoc = Fcons (Fcons (intern (vals->value_name), make_int (vals->value)), assoc);
|
|
258 vals++;
|
|
259 }
|
|
260
|
|
261 assoc = Fnreverse (assoc);
|
|
262
|
|
263 Fputhash (make_int (the_type), assoc, Venumeration_info);
|
|
264 }
|
|
265
|
|
266 static void
|
|
267 import_gtk_type (GtkType t)
|
|
268 {
|
|
269 if (type_already_imported_p (t))
|
|
270 {
|
|
271 return;
|
|
272 }
|
|
273
|
|
274 switch (GTK_FUNDAMENTAL_TYPE (t))
|
|
275 {
|
|
276 case GTK_TYPE_ENUM:
|
|
277 case GTK_TYPE_FLAGS:
|
|
278 import_gtk_enumeration_internal (t);
|
|
279 break;
|
|
280 case GTK_TYPE_OBJECT:
|
|
281 import_gtk_object_internal (t);
|
|
282 break;
|
|
283 default:
|
|
284 break;
|
|
285 }
|
|
286
|
|
287 mark_type_as_imported (t);
|
|
288 }
|
|
289
|
|
290
|
|
291 /* Foreign function calls */
|
|
292 static emacs_ffi_data *
|
|
293 allocate_ffi_data (void)
|
|
294 {
|
|
295 emacs_ffi_data *data = alloc_lcrecord_type (emacs_ffi_data, &lrecord_emacs_ffi);
|
|
296
|
|
297 data->return_type = GTK_TYPE_NONE;
|
|
298 data->n_args = 0;
|
|
299 data->function_name = Qnil;
|
|
300 data->function_ptr = 0;
|
|
301 data->marshal = 0;
|
|
302
|
|
303 return (data);
|
|
304 }
|
|
305
|
1204
|
306 static const struct memory_description ffi_data_description [] = {
|
|
307 { XD_LISP_OBJECT, offsetof (emacs_ffi_data, function_name) },
|
934
|
308 { XD_END }
|
|
309 };
|
|
310
|
462
|
311 static Lisp_Object
|
|
312 mark_ffi_data (Lisp_Object obj)
|
|
313 {
|
|
314 emacs_ffi_data *data = (emacs_ffi_data *) XFFI (obj);
|
|
315
|
|
316 mark_object (data->function_name);
|
|
317 return (Qnil);
|
|
318 }
|
|
319
|
|
320 static void
|
2286
|
321 ffi_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
322 int UNUSED (escapeflag))
|
462
|
323 {
|
|
324 if (print_readably)
|
563
|
325 printing_unreadable_object ("#<ffi %p>", XFFI (obj)->function_ptr);
|
462
|
326
|
800
|
327 write_fmt_string_lisp (printcharfun, "#<ffi %S", 1, XFFI (obj)->function_name);
|
462
|
328 if (XFFI (obj)->n_args)
|
800
|
329 write_fmt_string (printcharfun, " %d arguments", XFFI (obj)->n_args);
|
|
330 write_fmt_string (printcharfun, " %p>", (void *)XFFI (obj)->function_ptr);
|
462
|
331 }
|
|
332
|
934
|
333 DEFINE_LRECORD_IMPLEMENTATION ("ffi", emacs_ffi,
|
960
|
334 0, /*dumpable-flag*/
|
934
|
335 mark_ffi_data, ffi_object_printer,
|
|
336 0, 0, 0,
|
|
337 ffi_data_description, emacs_ffi_data);
|
462
|
338
|
2054
|
339 #if defined (__cplusplus)
|
|
340 #define MANY_ARGS ...
|
|
341 #else
|
|
342 #define MANY_ARGS
|
|
343 #endif
|
|
344
|
|
345 typedef void (*pfv)();
|
|
346 typedef GtkObject * (*__OBJECT_fn) (MANY_ARGS);
|
|
347 typedef gint (*__INT_fn) (MANY_ARGS);
|
|
348 typedef void (*__NONE_fn) (MANY_ARGS);
|
|
349 typedef gchar * (*__STRING_fn) (MANY_ARGS);
|
|
350 typedef gboolean (*__BOOL_fn) (MANY_ARGS);
|
|
351 typedef gfloat (*__FLOAT_fn) (MANY_ARGS);
|
|
352 typedef void * (*__POINTER_fn) (MANY_ARGS);
|
|
353 typedef GList * (*__LIST_fn) (MANY_ARGS);
|
462
|
354
|
|
355 /* An auto-generated file of marshalling functions. */
|
|
356 #include "emacs-marshals.c"
|
2054
|
357 #undef MANY_ARGS
|
462
|
358
|
|
359 #define CONVERT_SINGLE_TYPE(var,nam,tp) case GTK_TYPE_##nam: GTK_VALUE_##nam (var) = * (tp *) v; break;
|
|
360 #define CONVERT_RETVAL(a,freep) \
|
|
361 do { \
|
|
362 void *v = GTK_VALUE_POINTER(a); \
|
|
363 switch (GTK_FUNDAMENTAL_TYPE (a.type)) \
|
1726
|
364 { \
|
462
|
365 CONVERT_SINGLE_TYPE(a,CHAR,gchar); \
|
|
366 CONVERT_SINGLE_TYPE(a,UCHAR,guchar); \
|
|
367 CONVERT_SINGLE_TYPE(a,BOOL,gboolean); \
|
|
368 CONVERT_SINGLE_TYPE(a,INT,gint); \
|
|
369 CONVERT_SINGLE_TYPE(a,UINT,guint); \
|
|
370 CONVERT_SINGLE_TYPE(a,LONG,glong); \
|
|
371 CONVERT_SINGLE_TYPE(a,ULONG,gulong); \
|
|
372 CONVERT_SINGLE_TYPE(a,FLOAT,gfloat); \
|
|
373 CONVERT_SINGLE_TYPE(a,DOUBLE,gdouble); \
|
|
374 CONVERT_SINGLE_TYPE(a,STRING,gchar *); \
|
|
375 CONVERT_SINGLE_TYPE(a,ENUM,gint); \
|
|
376 CONVERT_SINGLE_TYPE(a,FLAGS,guint); \
|
|
377 CONVERT_SINGLE_TYPE(a,BOXED,void *); \
|
|
378 CONVERT_SINGLE_TYPE(a,POINTER,void *); \
|
|
379 CONVERT_SINGLE_TYPE(a,OBJECT,GtkObject *); \
|
1726
|
380 default: \
|
|
381 GTK_VALUE_POINTER (a) = * (void **) v; \
|
462
|
382 break; \
|
1726
|
383 } \
|
|
384 if (freep) xfree(v, void *); \
|
462
|
385 } while (0)
|
|
386
|
778
|
387 static gpointer __allocate_object_storage (GtkType t)
|
462
|
388 {
|
|
389 size_t s = 0;
|
|
390 void *rval = NULL;
|
|
391
|
|
392 switch (GTK_FUNDAMENTAL_TYPE (t))
|
|
393 {
|
|
394 /* flag types */
|
|
395 case GTK_TYPE_CHAR:
|
|
396 s = (sizeof (gchar));
|
|
397 break;
|
|
398 case GTK_TYPE_UCHAR:
|
|
399 s = (sizeof (guchar));
|
|
400 break;
|
|
401 case GTK_TYPE_BOOL:
|
|
402 s = (sizeof (gboolean));
|
|
403 break;
|
|
404 case GTK_TYPE_INT:
|
|
405 s = (sizeof (gint));
|
|
406 break;
|
|
407 case GTK_TYPE_UINT:
|
|
408 s = (sizeof (guint));
|
|
409 break;
|
|
410 case GTK_TYPE_LONG:
|
|
411 s = (sizeof (glong));
|
|
412 break;
|
|
413 case GTK_TYPE_ULONG:
|
|
414 s = (sizeof (gulong));
|
|
415 break;
|
|
416 case GTK_TYPE_FLOAT:
|
|
417 s = (sizeof (gfloat));
|
|
418 break;
|
|
419 case GTK_TYPE_DOUBLE:
|
|
420 s = (sizeof (gdouble));
|
|
421 break;
|
|
422 case GTK_TYPE_STRING:
|
|
423 s = (sizeof (gchar *));
|
|
424 break;
|
|
425 case GTK_TYPE_ENUM:
|
|
426 case GTK_TYPE_FLAGS:
|
|
427 s = (sizeof (guint));
|
|
428 break;
|
|
429 case GTK_TYPE_BOXED:
|
|
430 case GTK_TYPE_POINTER:
|
|
431 s = (sizeof (void *));
|
|
432 break;
|
|
433
|
|
434 /* base type of the object system */
|
|
435 case GTK_TYPE_OBJECT:
|
|
436 s = (sizeof (GtkObject *));
|
|
437 break;
|
|
438
|
|
439 default:
|
2054
|
440 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_LISTOF))
|
462
|
441 {
|
|
442 s = (sizeof (void *));
|
|
443 }
|
|
444 rval = NULL;
|
|
445 break;
|
|
446 }
|
|
447
|
|
448 if (s)
|
|
449 {
|
|
450 rval = xmalloc (s);
|
|
451 memset (rval, '\0', s);
|
|
452 }
|
|
453
|
|
454 return (rval);
|
|
455 }
|
|
456
|
778
|
457 static Lisp_Object type_to_marshaller_type (GtkType t)
|
462
|
458 {
|
|
459 switch (GTK_FUNDAMENTAL_TYPE (t))
|
|
460 {
|
|
461 case GTK_TYPE_NONE:
|
|
462 return (build_string ("NONE"));
|
|
463 /* flag types */
|
|
464 case GTK_TYPE_CHAR:
|
|
465 case GTK_TYPE_UCHAR:
|
|
466 return (build_string ("CHAR"));
|
|
467 case GTK_TYPE_BOOL:
|
|
468 return (build_string ("BOOL"));
|
|
469 case GTK_TYPE_ENUM:
|
|
470 case GTK_TYPE_FLAGS:
|
|
471 case GTK_TYPE_INT:
|
|
472 case GTK_TYPE_UINT:
|
|
473 return (build_string ("INT"));
|
|
474 case GTK_TYPE_LONG:
|
|
475 case GTK_TYPE_ULONG:
|
|
476 return (build_string ("LONG"));
|
|
477 case GTK_TYPE_FLOAT:
|
|
478 case GTK_TYPE_DOUBLE:
|
|
479 return (build_string ("FLOAT"));
|
|
480 case GTK_TYPE_STRING:
|
|
481 return (build_string ("STRING"));
|
|
482 case GTK_TYPE_BOXED:
|
|
483 case GTK_TYPE_POINTER:
|
|
484 return (build_string ("POINTER"));
|
|
485 case GTK_TYPE_OBJECT:
|
|
486 return (build_string ("OBJECT"));
|
|
487 case GTK_TYPE_CALLBACK:
|
|
488 return (build_string ("CALLBACK"));
|
|
489 default:
|
|
490 /* I can't put this in the main switch statement because it is a
|
|
491 new fundamental type that is not fixed at compile time.
|
|
492 *sigh*
|
|
493 */
|
2054
|
494 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_ARRAY))
|
462
|
495 return (build_string ("ARRAY"));
|
|
496
|
2054
|
497 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(t, GTK_TYPE_LISTOF))
|
462
|
498 return (build_string ("LIST"));
|
|
499 return (Qnil);
|
|
500 }
|
|
501 }
|
|
502
|
|
503 struct __dll_mapper_closure {
|
2054
|
504 void * (*func) (dll_handle, const CIbyte *);
|
|
505 Ibyte *obj_name;
|
462
|
506 void **storage;
|
|
507 };
|
|
508
|
2286
|
509 static void __dll_mapper (gpointer UNUSED (key), gpointer value,
|
|
510 gpointer user_data)
|
462
|
511 {
|
|
512 struct __dll_mapper_closure *closure = (struct __dll_mapper_closure *) user_data;
|
|
513
|
|
514 if (*(closure->storage) == NULL)
|
|
515 {
|
|
516 /* Need to see if it is in this one */
|
2054
|
517 *(closure->storage) = closure->func ((dll_handle) value, (CIbyte*) closure->obj_name);
|
462
|
518 }
|
|
519 }
|
|
520
|
|
521 DEFUN ("gtk-import-variable-internal", Fgtk_import_variable_internal, 2, 2, 0, /*
|
|
522 Import a variable into the XEmacs namespace.
|
|
523 */
|
|
524 (type, name))
|
|
525 {
|
|
526 void *var = NULL;
|
|
527 GtkArg arg;
|
|
528
|
|
529 if (SYMBOLP (type)) type = Fsymbol_name (type);
|
|
530
|
|
531 CHECK_STRING (type);
|
|
532 CHECK_STRING (name);
|
|
533
|
|
534 initialize_dll_cache ();
|
|
535 xemacs_init_gtk_classes ();
|
|
536
|
|
537 arg.type = gtk_type_from_name ((char *) XSTRING_DATA (type));
|
|
538
|
|
539 if (arg.type == GTK_TYPE_INVALID)
|
|
540 {
|
563
|
541 sferror ("Unknown type", type);
|
462
|
542 }
|
|
543
|
|
544 /* Need to look thru the already-loaded dlls */
|
|
545 {
|
|
546 struct __dll_mapper_closure closure;
|
|
547
|
|
548 closure.func = dll_variable;
|
|
549 closure.obj_name = XSTRING_DATA (name);
|
|
550 closure.storage = &var;
|
|
551
|
|
552 g_hash_table_foreach (dll_cache, __dll_mapper, &closure);
|
|
553 }
|
|
554
|
|
555 if (!var)
|
|
556 {
|
563
|
557 gui_error ("Could not locate variable", name);
|
462
|
558 }
|
|
559
|
|
560 GTK_VALUE_POINTER(arg) = var;
|
|
561 CONVERT_RETVAL (arg, 0);
|
|
562 return (gtk_type_to_lisp (&arg));
|
|
563 }
|
|
564
|
|
565 DEFUN ("gtk-import-function-internal", Fgtk_import_function_internal, 2, 3, 0, /*
|
|
566 Import a function into the XEmacs namespace.
|
|
567 */
|
|
568 (rettype, name, args))
|
|
569 {
|
|
570 Lisp_Object rval = Qnil;
|
|
571 Lisp_Object marshaller = Qnil;
|
|
572 emacs_ffi_data *data = NULL;
|
|
573 gint n_args = 0;
|
|
574 #if 0
|
|
575 dll_handle h = NULL;
|
|
576 #endif
|
|
577 ffi_marshalling_function marshaller_func = NULL;
|
|
578 ffi_actual_function name_func = NULL;
|
|
579
|
|
580 CHECK_SYMBOL (rettype);
|
|
581 CHECK_STRING (name);
|
|
582 CHECK_LIST (args);
|
|
583
|
|
584 initialize_dll_cache ();
|
|
585 xemacs_init_gtk_classes ();
|
|
586
|
|
587 /* Need to look thru the already-loaded dlls */
|
|
588 {
|
|
589 struct __dll_mapper_closure closure;
|
|
590
|
|
591 closure.func = dll_function;
|
|
592 closure.obj_name = XSTRING_DATA (name);
|
|
593 closure.storage = (void **) &name_func;
|
|
594
|
|
595 g_hash_table_foreach (dll_cache, __dll_mapper, &closure);
|
|
596 }
|
|
597
|
|
598 if (!name_func)
|
|
599 {
|
563
|
600 gui_error ("Could not locate function", name);
|
462
|
601 }
|
|
602
|
|
603 data = allocate_ffi_data ();
|
|
604
|
|
605 if (NILP (rettype))
|
|
606 {
|
|
607 rettype = Qvoid;
|
|
608 }
|
|
609
|
|
610 if (!NILP (args))
|
|
611 {
|
|
612 Lisp_Object value = args;
|
|
613 Lisp_Object type = Qnil;
|
|
614
|
2367
|
615 EXTERNAL_LIST_LOOP_2 (elt, value)
|
462
|
616 {
|
|
617 GtkType the_type;
|
|
618 Lisp_Object marshaller_type = Qnil;
|
|
619
|
2367
|
620 CHECK_SYMBOL (elt);
|
462
|
621
|
2367
|
622 type = Fsymbol_name (elt);
|
462
|
623
|
|
624 the_type = gtk_type_from_name ((char *) XSTRING_DATA (type));
|
|
625
|
|
626 if (the_type == GTK_TYPE_INVALID)
|
|
627 {
|
563
|
628 invalid_argument ("Unknown argument type", type);
|
462
|
629 }
|
|
630
|
|
631 /* All things must be reduced to their basest form... */
|
|
632 import_gtk_type (the_type);
|
|
633 data->args[n_args] = the_type; /* GTK_FUNDAMENTAL_TYPE (the_type); */
|
|
634
|
|
635 /* Now lets build up another chunk of our marshaller function name */
|
|
636 marshaller_type = type_to_marshaller_type (data->args[n_args]);
|
|
637
|
|
638 if (NILP (marshaller_type))
|
|
639 {
|
563
|
640 invalid_argument ("Do not know how to marshal", type);
|
462
|
641 }
|
|
642 marshaller = concat3 (marshaller, build_string ("_"), marshaller_type);
|
|
643 n_args++;
|
|
644 }
|
|
645 }
|
|
646 else
|
|
647 {
|
|
648 marshaller = concat3 (marshaller, build_string ("_"), type_to_marshaller_type (GTK_TYPE_NONE));
|
|
649 }
|
|
650
|
|
651 rettype = Fsymbol_name (rettype);
|
|
652 data->return_type = gtk_type_from_name ((char *) XSTRING_DATA (rettype));
|
|
653
|
|
654 if (data->return_type == GTK_TYPE_INVALID)
|
|
655 {
|
563
|
656 invalid_argument ("Unknown return type", rettype);
|
462
|
657 }
|
|
658
|
|
659 import_gtk_type (data->return_type);
|
|
660
|
|
661 marshaller = concat3 (type_to_marshaller_type (data->return_type), build_string ("_"), marshaller);
|
|
662 marshaller = concat2 (build_string ("emacs_gtk_marshal_"), marshaller);
|
|
663
|
|
664 marshaller_func = (ffi_marshalling_function) find_marshaller ((char *) XSTRING_DATA (marshaller));
|
|
665
|
|
666 if (!marshaller_func)
|
|
667 {
|
563
|
668 gui_error ("Could not locate marshaller function", marshaller);
|
462
|
669 }
|
|
670
|
|
671 data->n_args = n_args;
|
|
672 data->function_name = name;
|
2054
|
673 data->function_ptr = (dll_func) name_func;
|
462
|
674 data->marshal = marshaller_func;
|
|
675
|
797
|
676 rval = wrap_emacs_ffi (data);
|
462
|
677 return (rval);
|
|
678 }
|
|
679
|
|
680 DEFUN ("gtk-call-function", Fgtk_call_function, 1, 2, 0, /*
|
|
681 Call an external function.
|
|
682 */
|
|
683 (func, args))
|
|
684 {
|
|
685 GtkArg the_args[MAX_GTK_ARGS];
|
|
686 gint n_args = 0;
|
|
687 Lisp_Object retval = Qnil;
|
|
688
|
|
689 CHECK_FFI (func);
|
|
690 CHECK_LIST (args);
|
|
691
|
|
692 n_args = XINT (Flength (args));
|
|
693
|
|
694 #ifdef XEMACS_IS_SMARTER_THAN_THE_PROGRAMMER
|
|
695 /* #### I think this is too dangerous to enable by default.
|
|
696 ** #### Genuine program bugs would probably be allowed to
|
|
697 ** #### slip by, and not be very easy to find.
|
|
698 ** #### Bill Perry July 9, 2000
|
|
699 */
|
|
700 if (n_args != XFFI(func)->n_args)
|
|
701 {
|
|
702 Lisp_Object for_append[3];
|
|
703
|
|
704 /* Signal an error if they pass in too many arguments */
|
|
705 if (n_args > XFFI(func)->n_args)
|
|
706 {
|
|
707 return Fsignal (Qwrong_number_of_arguments,
|
|
708 list2 (func, make_int (n_args)));
|
|
709 }
|
|
710
|
|
711 /* If they did not provide enough arguments, be nice and assume
|
|
712 ** they wanted `nil' in there.
|
|
713 */
|
|
714 for_append[0] = args;
|
|
715 for_append[1] = Fmake_list (make_int (XFFI(func)->n_args - n_args), Qnil);
|
|
716
|
|
717 args = Fappend (2, for_append);
|
|
718 }
|
|
719 #else
|
|
720 if (n_args != XFFI(func)->n_args)
|
|
721 {
|
|
722 /* Signal an error if they do not pass in the correct # of arguments */
|
|
723 return Fsignal (Qwrong_number_of_arguments,
|
|
724 list2 (func, make_int (n_args)));
|
|
725 }
|
|
726 #endif
|
|
727
|
|
728 if (!NILP (args))
|
|
729 {
|
|
730 Lisp_Object value = args;
|
|
731
|
|
732 CHECK_LIST (args);
|
|
733 n_args = 0;
|
|
734
|
|
735 /* First we convert all of the arguments from Lisp to GtkArgs */
|
2367
|
736 {
|
|
737 EXTERNAL_LIST_LOOP_2 (elt, value)
|
|
738 {
|
|
739 the_args[n_args].type = XFFI (func)->args[n_args];
|
462
|
740
|
2367
|
741 if (lisp_to_gtk_type (elt, &the_args[n_args]))
|
|
742 {
|
|
743 /* There was some sort of an error */
|
|
744 gui_error ("Error converting arguments", args);
|
|
745 }
|
|
746 n_args++;
|
|
747 }
|
|
748 }
|
462
|
749 }
|
|
750
|
|
751 /* Now we need to tack on space for a return value, if they have
|
|
752 asked for one */
|
|
753 if (XFFI (func)->return_type != GTK_TYPE_NONE)
|
|
754 {
|
|
755 the_args[n_args].type = XFFI (func)->return_type;
|
|
756 GTK_VALUE_POINTER (the_args[n_args]) = __allocate_object_storage (the_args[n_args].type);
|
|
757 n_args++;
|
|
758 }
|
|
759
|
|
760 XFFI (func)->marshal ((ffi_actual_function) (XFFI (func)->function_ptr), the_args);
|
|
761
|
|
762 if (XFFI (func)->return_type != GTK_TYPE_NONE)
|
|
763 {
|
|
764 CONVERT_RETVAL (the_args[n_args - 1], 1);
|
|
765 retval = gtk_type_to_lisp (&the_args[n_args - 1]);
|
|
766 }
|
|
767
|
|
768 /* Need to free any array or list pointers */
|
|
769 {
|
|
770 int i;
|
|
771 for (i = 0; i < n_args; i++)
|
|
772 {
|
2054
|
773 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(the_args[i].type, GTK_TYPE_ARRAY))
|
462
|
774 {
|
|
775 g_free (GTK_VALUE_POINTER (the_args[i]));
|
|
776 }
|
2054
|
777 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(the_args[i].type, GTK_TYPE_LISTOF))
|
462
|
778 {
|
|
779 /* g_list_free (GTK_VALUE_POINTER (the_args[i])); */
|
|
780 }
|
|
781 }
|
|
782 }
|
|
783
|
|
784 return (retval);
|
|
785 }
|
|
786
|
|
787
|
|
788
|
|
789 /* GtkObject wrapping for Lisp */
|
|
790 static void
|
2286
|
791 emacs_gtk_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
792 int UNUSED (escapeflag))
|
462
|
793 {
|
|
794 if (print_readably)
|
563
|
795 printing_unreadable_object ("#<GtkObject %p>", XGTK_OBJECT (obj)->object);
|
462
|
796
|
826
|
797 write_c_string (printcharfun, "#<GtkObject (");
|
462
|
798 if (XGTK_OBJECT (obj)->alive_p)
|
826
|
799 write_c_string (printcharfun, gtk_type_name (GTK_OBJECT_TYPE (XGTK_OBJECT (obj)->object)));
|
462
|
800 else
|
826
|
801 write_c_string (printcharfun, "dead");
|
800
|
802 write_fmt_string (printcharfun, ") %p>", (void *) XGTK_OBJECT (obj)->object);
|
462
|
803 }
|
|
804
|
|
805 static Lisp_Object
|
|
806 object_getprop (Lisp_Object obj, Lisp_Object prop)
|
|
807 {
|
|
808 Lisp_Object rval = Qnil;
|
|
809 Lisp_Object prop_name = Qnil;
|
|
810 GtkArgInfo *info = NULL;
|
|
811 char *err;
|
|
812 GtkArg args[2];
|
|
813
|
|
814 CHECK_SYMBOL (prop); /* Shouldn't need to ever do this, but I'm paranoid */
|
|
815
|
|
816 prop_name = Fsymbol_name (prop);
|
|
817
|
|
818 args[0].name = (char *) XSTRING_DATA (prop_name);
|
|
819
|
|
820 err = gtk_object_arg_get_info (GTK_OBJECT_TYPE (XGTK_OBJECT (obj)->object),
|
|
821 args[0].name,
|
|
822 &info);
|
|
823
|
|
824 if (err)
|
|
825 {
|
|
826 /* Not a magic symbol, fall back to just looking in our real plist */
|
|
827 g_free (err);
|
|
828
|
|
829 return (Fplist_get (XGTK_OBJECT (obj)->plist, prop, Qunbound));
|
|
830 }
|
|
831
|
|
832 if (!(info->arg_flags & GTK_ARG_READABLE))
|
|
833 {
|
563
|
834 invalid_operation ("Attempt to get write-only property", prop);
|
462
|
835 }
|
|
836
|
|
837 gtk_object_getv (XGTK_OBJECT (obj)->object, 1, args);
|
|
838
|
|
839 if (args[0].type == GTK_TYPE_INVALID)
|
|
840 {
|
|
841 /* If we can't get the attribute, then let the code in Fget know
|
|
842 so it can use the default value supplied by the caller */
|
|
843 return (Qunbound);
|
|
844 }
|
|
845
|
|
846 rval = gtk_type_to_lisp (&args[0]);
|
|
847
|
|
848 /* Free up any memory. According to the documentation and Havoc's
|
|
849 book, if the fundamental type of the returned value is
|
|
850 GTK_TYPE_STRING, GTK_TYPE_BOXED, or GTK_TYPE_ARGS, you are
|
|
851 responsible for freeing it. */
|
|
852 switch (GTK_FUNDAMENTAL_TYPE (args[0].type))
|
|
853 {
|
|
854 case GTK_TYPE_STRING:
|
|
855 g_free (GTK_VALUE_STRING (args[0]));
|
|
856 break;
|
|
857 case GTK_TYPE_BOXED:
|
|
858 g_free (GTK_VALUE_BOXED (args[0]));
|
|
859 break;
|
|
860 case GTK_TYPE_ARGS:
|
|
861 g_free (GTK_VALUE_ARGS (args[0]).args);
|
|
862 default:
|
|
863 break;
|
|
864 }
|
|
865
|
|
866 return (rval);
|
|
867 }
|
|
868
|
|
869 static int
|
|
870 object_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value)
|
|
871 {
|
|
872 GtkArgInfo *info = NULL;
|
|
873 Lisp_Object prop_name = Qnil;
|
|
874 GtkArg args[2];
|
|
875 char *err = NULL;
|
|
876
|
|
877 prop_name = Fsymbol_name (prop);
|
|
878
|
|
879 args[0].name = (char *) XSTRING_DATA (prop_name);
|
|
880
|
|
881 err = gtk_object_arg_get_info (GTK_OBJECT_TYPE (XGTK_OBJECT (obj)->object),
|
|
882 args[0].name,
|
|
883 &info);
|
|
884
|
|
885 if (err)
|
|
886 {
|
|
887 /* Not a magic symbol, fall back to just storing in our real plist */
|
|
888 g_free (err);
|
|
889
|
|
890 XGTK_OBJECT (obj)->plist = Fplist_put (XGTK_OBJECT (obj)->plist, prop, value);
|
|
891 return (1);
|
|
892 }
|
|
893
|
|
894 args[0].type = info->type;
|
|
895
|
|
896 if (lisp_to_gtk_type (value, &args[0]))
|
|
897 {
|
563
|
898 gui_error ("Error converting to GtkType", value);
|
462
|
899 }
|
|
900
|
|
901 if (!(info->arg_flags & GTK_ARG_WRITABLE))
|
|
902 {
|
563
|
903 invalid_operation ("Attempt to set read-only argument", prop);
|
462
|
904 }
|
|
905
|
|
906 gtk_object_setv (XGTK_OBJECT (obj)->object, 1, args);
|
|
907
|
|
908 return (1);
|
|
909 }
|
|
910
|
1204
|
911 static const struct memory_description gtk_object_data_description [] = {
|
|
912 { XD_LISP_OBJECT, offsetof (emacs_gtk_object_data, plist) },
|
934
|
913 { XD_END }
|
|
914 };
|
|
915
|
462
|
916 static Lisp_Object
|
|
917 mark_gtk_object_data (Lisp_Object obj)
|
|
918 {
|
|
919 return (XGTK_OBJECT (obj)->plist);
|
|
920 }
|
|
921
|
|
922 static void
|
|
923 emacs_gtk_object_finalizer (void *header, int for_disksave)
|
|
924 {
|
|
925 emacs_gtk_object_data *data = (emacs_gtk_object_data *) header;
|
|
926
|
|
927 if (for_disksave)
|
|
928 {
|
797
|
929 Lisp_Object obj = wrap_emacs_gtk_object (data);
|
793
|
930
|
462
|
931
|
563
|
932 invalid_operation
|
462
|
933 ("Can't dump an emacs containing GtkObject objects", obj);
|
|
934 }
|
|
935
|
|
936 if (data->alive_p)
|
|
937 {
|
|
938 gtk_object_unref (data->object);
|
|
939 }
|
|
940 }
|
|
941
|
934
|
942 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("GtkObject", emacs_gtk_object,
|
960
|
943 0, /*dumpable-flag*/
|
1204
|
944 mark_gtk_object_data,
|
|
945 emacs_gtk_object_printer,
|
|
946 emacs_gtk_object_finalizer,
|
934
|
947 0, /* equality */
|
|
948 0, /* hash */
|
1204
|
949 gtk_object_data_description,
|
|
950 object_getprop,
|
|
951 object_putprop,
|
934
|
952 0, /* rem prop */
|
|
953 0, /* plist */
|
|
954 emacs_gtk_object_data);
|
462
|
955
|
|
956 static emacs_gtk_object_data *
|
|
957 allocate_emacs_gtk_object_data (void)
|
|
958 {
|
|
959 emacs_gtk_object_data *data = alloc_lcrecord_type (emacs_gtk_object_data,
|
|
960 &lrecord_emacs_gtk_object);
|
|
961
|
|
962 data->object = NULL;
|
|
963 data->alive_p = FALSE;
|
|
964 data->plist = Qnil;
|
|
965
|
|
966 return (data);
|
|
967 }
|
|
968
|
|
969 /* We need to keep track of when the object is destroyed so that we
|
|
970 can mark it as dead, otherwise even our print routine (which calls
|
|
971 GTK_OBJECT_TYPE) will crap out and die. This is also used in the
|
|
972 lisp_to_gtk_type() routine to defend against passing dead objects
|
|
973 to GTK routines. */
|
|
974 static void
|
2286
|
975 __notice_object_destruction (GtkObject *UNUSED (obj), gpointer user_data)
|
462
|
976 {
|
|
977 ungcpro_popup_callbacks ((GUI_ID) user_data);
|
|
978 }
|
|
979
|
|
980 Lisp_Object build_gtk_object (GtkObject *obj)
|
|
981 {
|
|
982 Lisp_Object retval = Qnil;
|
|
983 emacs_gtk_object_data *data = NULL;
|
|
984 GUI_ID id = 0;
|
|
985
|
2168
|
986 id = (GUI_ID) gtk_object_get_data (obj, GTK_DATA_GUI_IDENTIFIER);
|
462
|
987
|
|
988 if (id)
|
|
989 {
|
|
990 retval = get_gcpro_popup_callbacks (id);
|
|
991 }
|
|
992
|
|
993 if (NILP (retval))
|
|
994 {
|
|
995 data = allocate_emacs_gtk_object_data ();
|
|
996
|
|
997 data->object = obj;
|
|
998 data->alive_p = TRUE;
|
797
|
999 retval = wrap_emacs_gtk_object (data);
|
462
|
1000
|
|
1001 id = new_gui_id ();
|
2168
|
1002 gtk_object_set_data (obj, GTK_DATA_GUI_IDENTIFIER, (gpointer) id);
|
462
|
1003 gcpro_popup_callbacks (id, retval);
|
|
1004 gtk_object_ref (obj);
|
|
1005 gtk_signal_connect (obj, "destroy", GTK_SIGNAL_FUNC (__notice_object_destruction), (gpointer)id);
|
|
1006 }
|
|
1007
|
|
1008 return (retval);
|
|
1009 }
|
|
1010
|
|
1011 static void
|
|
1012 __internal_callback_destroy (gpointer data)
|
|
1013 {
|
|
1014 Lisp_Object lisp_data;
|
|
1015
|
826
|
1016 lisp_data = VOID_TO_LISP (data);
|
462
|
1017
|
|
1018 ungcpro_popup_callbacks (XINT (XCAR (lisp_data)));
|
|
1019 }
|
|
1020
|
|
1021 static void
|
|
1022 __internal_callback_marshal (GtkObject *obj, gpointer data, guint n_args, GtkArg *args)
|
|
1023 {
|
|
1024 Lisp_Object arg_list = Qnil;
|
|
1025 Lisp_Object callback_fn = Qnil;
|
|
1026 Lisp_Object callback_data = Qnil;
|
|
1027 Lisp_Object newargs[3];
|
|
1028 Lisp_Object rval = Qnil;
|
|
1029 struct gcpro gcpro1;
|
|
1030 int i;
|
|
1031
|
826
|
1032 callback_fn = VOID_TO_LISP (data);
|
462
|
1033
|
|
1034 /* Nuke the GUI_ID off the front */
|
|
1035 callback_fn = XCDR (callback_fn);
|
|
1036
|
|
1037 callback_data = XCAR (callback_fn);
|
|
1038 callback_fn = XCDR (callback_fn);
|
|
1039
|
|
1040 /* The callback data goes at the very end of the argument list */
|
|
1041 arg_list = Fcons (callback_data, Qnil);
|
|
1042
|
|
1043 /* Build up the argument list, lisp style */
|
|
1044 for (i = n_args - 1; i >= 0; i--)
|
|
1045 {
|
|
1046 arg_list = Fcons (gtk_type_to_lisp (&args[i]), arg_list);
|
|
1047 }
|
|
1048
|
|
1049 /* We always pass the widget as the first parameter at the very least */
|
|
1050 arg_list = Fcons (build_gtk_object (obj), arg_list);
|
|
1051
|
|
1052 GCPRO1 ((arg_list));
|
|
1053
|
|
1054 newargs[0] = callback_fn;
|
|
1055 newargs[1] = arg_list;
|
|
1056
|
|
1057 rval = Fapply (2, newargs);
|
|
1058 signal_fake_event ();
|
|
1059
|
|
1060 if (args[n_args].type != GTK_TYPE_NONE)
|
1883
|
1061 lisp_to_gtk_ret_type (rval, &args[n_args]);
|
462
|
1062
|
|
1063 UNGCPRO;
|
|
1064 }
|
|
1065
|
|
1066 DEFUN ("gtk-signal-connect", Fgtk_signal_connect, 3, 6, 0, /*
|
|
1067 */
|
|
1068 (obj, name, func, cb_data, object_signal, after_p))
|
|
1069 {
|
|
1070 int c_after;
|
|
1071 int c_object_signal;
|
|
1072 GUI_ID id = 0;
|
|
1073
|
|
1074 CHECK_GTK_OBJECT (obj);
|
|
1075
|
|
1076 if (SYMBOLP (name))
|
|
1077 name = Fsymbol_name (name);
|
|
1078
|
|
1079 CHECK_STRING (name);
|
|
1080
|
|
1081 if (NILP (object_signal))
|
|
1082 c_object_signal = 0;
|
|
1083 else
|
|
1084 c_object_signal = 1;
|
|
1085
|
|
1086 if (NILP (after_p))
|
|
1087 c_after = 0;
|
|
1088 else
|
|
1089 c_after = 1;
|
|
1090
|
|
1091 id = new_gui_id ();
|
|
1092 func = Fcons (cb_data, func);
|
|
1093 func = Fcons (make_int (id), func);
|
|
1094
|
|
1095 gcpro_popup_callbacks (id, func);
|
|
1096
|
|
1097 gtk_signal_connect_full (XGTK_OBJECT (obj)->object, (char *) XSTRING_DATA (name),
|
|
1098 NULL, __internal_callback_marshal, LISP_TO_VOID (func),
|
|
1099 __internal_callback_destroy, c_object_signal, c_after);
|
|
1100 return (Qt);
|
|
1101 }
|
|
1102
|
|
1103
|
|
1104 /* GTK_TYPE_BOXED wrapper for Emacs lisp */
|
1204
|
1105 static const struct memory_description emacs_gtk_boxed_description [] = {
|
960
|
1106 { XD_END }
|
|
1107 };
|
|
1108
|
462
|
1109 static void
|
2286
|
1110 emacs_gtk_boxed_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
1111 int UNUSED (escapeflag))
|
462
|
1112 {
|
|
1113 if (print_readably)
|
563
|
1114 printing_unreadable_object ("#<GtkBoxed %p>", XGTK_BOXED (obj)->object);
|
462
|
1115
|
826
|
1116 write_c_string (printcharfun, "#<GtkBoxed (");
|
|
1117 write_c_string (printcharfun, gtk_type_name (XGTK_BOXED (obj)->object_type));
|
800
|
1118 write_fmt_string (printcharfun, ") %p>", (void *) XGTK_BOXED (obj)->object);
|
462
|
1119 }
|
|
1120
|
|
1121 static int
|
2286
|
1122 emacs_gtk_boxed_equality (Lisp_Object o1, Lisp_Object o2, int UNUSED (depth))
|
462
|
1123 {
|
|
1124 emacs_gtk_boxed_data *data1 = XGTK_BOXED(o1);
|
|
1125 emacs_gtk_boxed_data *data2 = XGTK_BOXED(o2);
|
|
1126
|
|
1127 return ((data1->object == data2->object) &&
|
|
1128 (data1->object_type == data2->object_type));
|
|
1129 }
|
|
1130
|
|
1131 static unsigned long
|
2286
|
1132 emacs_gtk_boxed_hash (Lisp_Object obj, int UNUSED (depth))
|
462
|
1133 {
|
|
1134 emacs_gtk_boxed_data *data = XGTK_BOXED(obj);
|
|
1135 return (HASH2 ((unsigned long)data->object, data->object_type));
|
|
1136 }
|
|
1137
|
960
|
1138 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("GtkBoxed", emacs_gtk_boxed,
|
|
1139 0, /*dumpable-flag*/
|
|
1140 0, /* marker function */
|
1204
|
1141 emacs_gtk_boxed_printer,
|
960
|
1142 0, /* nuker */
|
1204
|
1143 emacs_gtk_boxed_equality,
|
|
1144 emacs_gtk_boxed_hash,
|
|
1145 emacs_gtk_boxed_description,
|
960
|
1146 0, /* get prop */
|
|
1147 0, /* put prop */
|
|
1148 0, /* rem prop */
|
|
1149 0, /* plist */
|
|
1150 emacs_gtk_boxed_data);
|
462
|
1151 /* Currently defined GTK_TYPE_BOXED structures are:
|
|
1152
|
|
1153 GtkAccelGroup -
|
|
1154 GtkSelectionData -
|
|
1155 GtkStyle -
|
|
1156 GtkCTreeNode -
|
|
1157 GdkColormap -
|
|
1158 GdkVisual -
|
|
1159 GdkFont -
|
|
1160 GdkWindow -
|
|
1161 GdkDragContext -
|
|
1162 GdkEvent -
|
|
1163 GdkColor -
|
|
1164 */
|
|
1165 static emacs_gtk_boxed_data *
|
|
1166 allocate_emacs_gtk_boxed_data (void)
|
|
1167 {
|
|
1168 emacs_gtk_boxed_data *data = alloc_lcrecord_type (emacs_gtk_boxed_data,
|
|
1169 &lrecord_emacs_gtk_boxed);
|
|
1170
|
|
1171 data->object = NULL;
|
|
1172 data->object_type = GTK_TYPE_INVALID;
|
|
1173
|
|
1174 return (data);
|
|
1175 }
|
|
1176
|
|
1177 Lisp_Object build_gtk_boxed (void *obj, GtkType t)
|
|
1178 {
|
|
1179 Lisp_Object retval = Qnil;
|
|
1180 emacs_gtk_boxed_data *data = NULL;
|
|
1181
|
|
1182 if (GTK_FUNDAMENTAL_TYPE (t) != GTK_TYPE_BOXED)
|
|
1183 abort();
|
|
1184
|
|
1185 data = allocate_emacs_gtk_boxed_data ();
|
|
1186 data->object = obj;
|
|
1187 data->object_type = t;
|
|
1188
|
797
|
1189 retval = wrap_emacs_gtk_boxed (data);
|
462
|
1190
|
|
1191 return (retval);
|
|
1192 }
|
|
1193
|
|
1194
|
|
1195 /* The automatically generated structure access routines */
|
|
1196 #include "emacs-widget-accessors.c"
|
|
1197
|
|
1198 /* The hand generated funky functions that we can't just import using the FFI */
|
|
1199 #include "ui-byhand.c"
|
|
1200
|
|
1201 /* The glade support */
|
|
1202 #include "glade.c"
|
|
1203
|
|
1204
|
|
1205 /* Type manipulation */
|
|
1206 DEFUN ("gtk-fundamental-type", Fgtk_fundamental_type, 1, 1, 0, /*
|
|
1207 Load a shared library DLL into XEmacs. No initialization routines are required.
|
|
1208 This is for loading dependency DLLs into XEmacs.
|
|
1209 */
|
|
1210 (type))
|
|
1211 {
|
|
1212 GtkType t;
|
|
1213
|
|
1214 if (SYMBOLP (type))
|
|
1215 type = Fsymbol_name (type);
|
|
1216
|
|
1217 CHECK_STRING (type);
|
|
1218
|
|
1219 t = gtk_type_from_name ((char *) XSTRING_DATA (type));
|
|
1220
|
|
1221 if (t == GTK_TYPE_INVALID)
|
|
1222 {
|
563
|
1223 invalid_argument ("Not a GTK type", type);
|
462
|
1224 }
|
|
1225 return (make_int (GTK_FUNDAMENTAL_TYPE (t)));
|
|
1226 }
|
|
1227
|
|
1228 DEFUN ("gtk-object-type", Fgtk_object_type, 1, 1, 0, /*
|
|
1229 Return the GtkType of OBJECT.
|
|
1230 */
|
|
1231 (object))
|
|
1232 {
|
|
1233 CHECK_GTK_OBJECT (object);
|
|
1234 return (make_int (GTK_OBJECT_TYPE (XGTK_OBJECT (object)->object)));
|
|
1235 }
|
|
1236
|
|
1237 DEFUN ("gtk-describe-type", Fgtk_describe_type, 1, 1, 0, /*
|
|
1238 Returns a cons of two lists describing the Gtk object TYPE.
|
|
1239 The car is a list of all the signals that it will emit.
|
|
1240 The cdr is a list of all the magic properties it has.
|
|
1241 */
|
|
1242 (type))
|
|
1243 {
|
|
1244 Lisp_Object rval, signals, props;
|
|
1245 GtkType t;
|
|
1246
|
|
1247 props = signals = rval = Qnil;
|
|
1248
|
|
1249 if (SYMBOLP (type))
|
|
1250 {
|
|
1251 type = Fsymbol_name (type);
|
|
1252 }
|
|
1253
|
|
1254 if (STRINGP (type))
|
|
1255 {
|
2054
|
1256 t = gtk_type_from_name ((gchar*) XSTRING_DATA (type));
|
462
|
1257 if (t == GTK_TYPE_INVALID)
|
|
1258 {
|
563
|
1259 invalid_argument ("Not a GTK type", type);
|
462
|
1260 }
|
|
1261 }
|
|
1262 else
|
|
1263 {
|
|
1264 CHECK_INT (type);
|
|
1265 t = XINT (type);
|
|
1266 }
|
|
1267
|
|
1268 if (GTK_FUNDAMENTAL_TYPE (t) != GTK_TYPE_OBJECT)
|
|
1269 {
|
563
|
1270 invalid_argument ("Not a GtkObject", type);
|
462
|
1271 }
|
|
1272
|
|
1273 /* Need to do stupid shit like this to get the args
|
|
1274 ** registered... damn GTK and its lazy loading
|
|
1275 */
|
|
1276 {
|
|
1277 GtkArg args[3];
|
|
1278 GtkObject *obj = gtk_object_newv (t, 0, args);
|
|
1279
|
|
1280 gtk_object_destroy(obj);
|
|
1281 }
|
|
1282
|
|
1283 do
|
|
1284 {
|
|
1285 guint i;
|
|
1286
|
|
1287 /* Do the magic arguments first */
|
|
1288 {
|
|
1289 GtkArg *args;
|
|
1290 guint32 *flags;
|
|
1291 guint n_args;
|
|
1292
|
|
1293 args = gtk_object_query_args(t,&flags,&n_args);
|
|
1294
|
|
1295 for (i = 0; i < n_args; i++)
|
|
1296 {
|
|
1297 props = Fcons (Fcons (intern (gtk_type_name(args[i].type)),
|
|
1298 intern (args[i].name)), props);
|
|
1299 }
|
|
1300
|
|
1301 g_free (args);
|
|
1302 g_free (flags);
|
|
1303 }
|
|
1304
|
|
1305 /* Now the signals */
|
|
1306 {
|
|
1307 GtkObjectClass *klass;
|
|
1308 GtkSignalQuery *query;
|
|
1309 guint32 *gtk_signals;
|
|
1310 guint n_signals;
|
|
1311
|
|
1312 klass = (GtkObjectClass *) gtk_type_class (t);
|
|
1313 gtk_signals = klass->signals;
|
|
1314 n_signals = klass->nsignals;
|
|
1315
|
|
1316 for (i = 0; i < n_signals; i++)
|
|
1317 {
|
|
1318 Lisp_Object params = Qnil;
|
|
1319
|
|
1320 query = gtk_signal_query (gtk_signals[i]);
|
|
1321
|
|
1322 if (query)
|
|
1323 {
|
|
1324 if (query->nparams)
|
|
1325 {
|
|
1326 int j;
|
|
1327
|
|
1328 for (j = query->nparams - 1; j >= 0; j--)
|
|
1329 {
|
|
1330 params = Fcons (intern (gtk_type_name (query->params[j])), params);
|
|
1331 }
|
|
1332 }
|
|
1333
|
|
1334 signals = Fcons (Fcons (intern (gtk_type_name (query->return_val)),
|
|
1335 Fcons (intern (query->signal_name),
|
|
1336 params)),
|
|
1337 signals);
|
|
1338
|
|
1339 g_free (query);
|
|
1340 }
|
|
1341 }
|
|
1342 }
|
|
1343 t = gtk_type_parent(t);
|
|
1344 } while (t != GTK_TYPE_INVALID);
|
|
1345
|
|
1346 rval = Fcons (signals, props);
|
|
1347
|
|
1348 return (rval);
|
|
1349 }
|
|
1350
|
|
1351
|
|
1352 void
|
|
1353 syms_of_ui_gtk (void)
|
|
1354 {
|
|
1355 INIT_LRECORD_IMPLEMENTATION (emacs_ffi);
|
|
1356 INIT_LRECORD_IMPLEMENTATION (emacs_gtk_object);
|
|
1357 INIT_LRECORD_IMPLEMENTATION (emacs_gtk_boxed);
|
563
|
1358 DEFSYMBOL_MULTIWORD_PREDICATE (Qemacs_ffip);
|
|
1359 DEFSYMBOL_MULTIWORD_PREDICATE (Qemacs_gtk_objectp);
|
|
1360 DEFSYMBOL_MULTIWORD_PREDICATE (Qemacs_gtk_boxedp);
|
|
1361 DEFSYMBOL (Qvoid);
|
462
|
1362 DEFSUBR (Fdll_load);
|
|
1363 DEFSUBR (Fgtk_import_function_internal);
|
|
1364 DEFSUBR (Fgtk_import_variable_internal);
|
|
1365 DEFSUBR (Fgtk_signal_connect);
|
|
1366 DEFSUBR (Fgtk_call_function);
|
|
1367 DEFSUBR (Fgtk_fundamental_type);
|
|
1368 DEFSUBR (Fgtk_object_type);
|
|
1369 DEFSUBR (Fgtk_describe_type);
|
|
1370 syms_of_widget_accessors ();
|
|
1371 syms_of_ui_byhand ();
|
|
1372 syms_of_glade ();
|
|
1373 }
|
|
1374
|
|
1375 void
|
|
1376 vars_of_ui_gtk (void)
|
|
1377 {
|
|
1378 Fprovide (intern ("gtk-ui"));
|
|
1379 DEFVAR_LISP ("gtk-enumeration-info", &Venumeration_info /*
|
|
1380 A hashtable holding type information about GTK enumerations and flags.
|
|
1381 Do NOT modify unless you really understand ui-gtk.c.
|
|
1382 */);
|
|
1383
|
|
1384 Venumeration_info = Qnil;
|
|
1385 vars_of_glade ();
|
|
1386 }
|
|
1387
|
|
1388
|
|
1389 /* Various utility functions */
|
778
|
1390 #if 0
|
462
|
1391 void describe_gtk_arg (GtkArg *arg)
|
|
1392 {
|
|
1393 GtkArg a = *arg;
|
|
1394
|
|
1395 switch (GTK_FUNDAMENTAL_TYPE (a.type))
|
|
1396 {
|
|
1397 /* flag types */
|
|
1398 case GTK_TYPE_CHAR:
|
|
1399 stderr_out ("char: %c\n", GTK_VALUE_CHAR (a));
|
|
1400 break;
|
|
1401 case GTK_TYPE_UCHAR:
|
|
1402 stderr_out ("uchar: %c\n", GTK_VALUE_CHAR (a));
|
|
1403 break;
|
|
1404 case GTK_TYPE_BOOL:
|
|
1405 stderr_out ("uchar: %s\n", GTK_VALUE_BOOL (a) ? "true" : "false");
|
|
1406 break;
|
|
1407 case GTK_TYPE_INT:
|
|
1408 stderr_out ("int: %d\n", GTK_VALUE_INT (a));
|
|
1409 break;
|
|
1410 case GTK_TYPE_UINT:
|
|
1411 stderr_out ("uint: %du\n", GTK_VALUE_UINT (a));
|
|
1412 break;
|
|
1413 case GTK_TYPE_LONG:
|
|
1414 stderr_out ("long: %ld\n", GTK_VALUE_LONG (a));
|
|
1415 break;
|
|
1416 case GTK_TYPE_ULONG:
|
|
1417 stderr_out ("ulong: %lu\n", GTK_VALUE_ULONG (a));
|
|
1418 break;
|
|
1419 case GTK_TYPE_FLOAT:
|
|
1420 stderr_out ("float: %g\n", GTK_VALUE_FLOAT (a));
|
|
1421 break;
|
|
1422 case GTK_TYPE_DOUBLE:
|
|
1423 stderr_out ("double: %f\n", GTK_VALUE_DOUBLE (a));
|
|
1424 break;
|
|
1425 case GTK_TYPE_STRING:
|
|
1426 stderr_out ("string: %s\n", GTK_VALUE_STRING (a));
|
|
1427 break;
|
|
1428 case GTK_TYPE_ENUM:
|
|
1429 case GTK_TYPE_FLAGS:
|
|
1430 stderr_out ("%s: ", (a.type == GTK_TYPE_ENUM) ? "enum" : "flag");
|
|
1431 {
|
|
1432 GtkEnumValue *vals = gtk_type_enum_get_values (a.type);
|
|
1433
|
|
1434 while (vals && vals->value_name && (vals->value != GTK_VALUE_ENUM(a))) vals++;
|
|
1435
|
|
1436 stderr_out ("%s\n", vals ? vals->value_name : "!!! UNKNOWN ENUM VALUE !!!");
|
|
1437 }
|
|
1438 break;
|
|
1439 case GTK_TYPE_BOXED:
|
|
1440 stderr_out ("boxed: %p\n", GTK_VALUE_BOXED (a));
|
|
1441 break;
|
|
1442 case GTK_TYPE_POINTER:
|
|
1443 stderr_out ("pointer: %p\n", GTK_VALUE_BOXED (a));
|
|
1444 break;
|
|
1445
|
|
1446 /* structured types */
|
|
1447 case GTK_TYPE_SIGNAL:
|
|
1448 case GTK_TYPE_ARGS: /* This we can do as a list of values */
|
|
1449 abort();
|
|
1450 case GTK_TYPE_CALLBACK:
|
|
1451 stderr_out ("callback fn: ...\n");
|
|
1452 break;
|
|
1453 case GTK_TYPE_C_CALLBACK:
|
|
1454 case GTK_TYPE_FOREIGN:
|
|
1455 abort();
|
|
1456
|
|
1457 /* base type of the object system */
|
|
1458 case GTK_TYPE_OBJECT:
|
|
1459 if (GTK_VALUE_OBJECT (a))
|
|
1460 stderr_out ("object: %s\n", gtk_type_name (GTK_OBJECT_TYPE (GTK_VALUE_OBJECT (a))));
|
|
1461 else
|
|
1462 stderr_out ("object: NULL\n");
|
|
1463 break;
|
|
1464
|
|
1465 default:
|
|
1466 abort();
|
|
1467 }
|
|
1468 }
|
778
|
1469 #endif
|
462
|
1470
|
|
1471 Lisp_Object gtk_type_to_lisp (GtkArg *arg)
|
|
1472 {
|
|
1473 switch (GTK_FUNDAMENTAL_TYPE (arg->type))
|
|
1474 {
|
|
1475 case GTK_TYPE_NONE:
|
|
1476 return (Qnil);
|
|
1477 case GTK_TYPE_CHAR:
|
|
1478 return (make_char (GTK_VALUE_CHAR (*arg)));
|
|
1479 case GTK_TYPE_UCHAR:
|
|
1480 return (make_char (GTK_VALUE_UCHAR (*arg)));
|
|
1481 case GTK_TYPE_BOOL:
|
|
1482 return (GTK_VALUE_BOOL (*arg) ? Qt : Qnil);
|
|
1483 case GTK_TYPE_INT:
|
|
1484 return (make_int (GTK_VALUE_INT (*arg)));
|
|
1485 case GTK_TYPE_UINT:
|
|
1486 return (make_int (GTK_VALUE_INT (*arg)));
|
|
1487 case GTK_TYPE_LONG: /* I think these are wrong! */
|
|
1488 return (make_int (GTK_VALUE_INT (*arg)));
|
|
1489 case GTK_TYPE_ULONG: /* I think these are wrong! */
|
|
1490 return (make_int (GTK_VALUE_INT (*arg)));
|
|
1491 case GTK_TYPE_FLOAT:
|
|
1492 return (make_float (GTK_VALUE_FLOAT (*arg)));
|
|
1493 case GTK_TYPE_DOUBLE:
|
|
1494 return (make_float (GTK_VALUE_DOUBLE (*arg)));
|
|
1495 case GTK_TYPE_STRING:
|
|
1496 return (build_string (GTK_VALUE_STRING (*arg)));
|
|
1497 case GTK_TYPE_FLAGS:
|
|
1498 return (flags_to_list (GTK_VALUE_FLAGS (*arg), arg->type));
|
|
1499 case GTK_TYPE_ENUM:
|
|
1500 return (enum_to_symbol (GTK_VALUE_ENUM (*arg), arg->type));
|
|
1501 case GTK_TYPE_BOXED:
|
|
1502 if (arg->type == GTK_TYPE_GDK_EVENT)
|
|
1503 {
|
|
1504 return (gdk_event_to_emacs_event((GdkEvent *) GTK_VALUE_BOXED (*arg)));
|
|
1505 }
|
|
1506
|
|
1507 if (GTK_VALUE_BOXED (*arg))
|
|
1508 return (build_gtk_boxed (GTK_VALUE_BOXED (*arg), arg->type));
|
|
1509 else
|
|
1510 return (Qnil);
|
|
1511 case GTK_TYPE_POINTER:
|
|
1512 if (GTK_VALUE_POINTER (*arg))
|
|
1513 {
|
|
1514 Lisp_Object rval;
|
|
1515
|
826
|
1516 rval = VOID_TO_LISP (GTK_VALUE_POINTER (*arg));
|
462
|
1517 return (rval);
|
|
1518 }
|
|
1519 else
|
|
1520 return (Qnil);
|
|
1521 case GTK_TYPE_OBJECT:
|
|
1522 if (GTK_VALUE_OBJECT (*arg))
|
|
1523 return (build_gtk_object (GTK_VALUE_OBJECT (*arg)));
|
|
1524 else
|
|
1525 return (Qnil);
|
|
1526
|
|
1527 case GTK_TYPE_CALLBACK:
|
|
1528 {
|
|
1529 Lisp_Object rval;
|
|
1530
|
826
|
1531 rval = VOID_TO_LISP (GTK_VALUE_CALLBACK (*arg).data);
|
462
|
1532
|
|
1533 return (rval);
|
|
1534 }
|
|
1535
|
|
1536 default:
|
2054
|
1537 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
|
462
|
1538 {
|
|
1539 if (!GTK_VALUE_POINTER (*arg))
|
|
1540 return (Qnil);
|
|
1541 else
|
|
1542 {
|
|
1543 return (xemacs_gtklist_to_list (arg));
|
|
1544 }
|
|
1545 }
|
|
1546 stderr_out ("Do not know how to convert `%s' to lisp!\n", gtk_type_name (arg->type));
|
|
1547 abort ();
|
|
1548 }
|
|
1549 /* This is chuck reminding GCC to... SHUT UP! */
|
|
1550 return (Qnil);
|
|
1551 }
|
|
1552
|
|
1553 int lisp_to_gtk_type (Lisp_Object obj, GtkArg *arg)
|
|
1554 {
|
|
1555 switch (GTK_FUNDAMENTAL_TYPE (arg->type))
|
|
1556 {
|
|
1557 /* flag types */
|
|
1558 case GTK_TYPE_NONE:
|
|
1559 return (0);
|
|
1560 case GTK_TYPE_CHAR:
|
|
1561 {
|
867
|
1562 Ichar c;
|
462
|
1563
|
|
1564 CHECK_CHAR_COERCE_INT (obj);
|
|
1565 c = XCHAR (obj);
|
|
1566 GTK_VALUE_CHAR (*arg) = c;
|
|
1567 }
|
|
1568 break;
|
|
1569 case GTK_TYPE_UCHAR:
|
|
1570 {
|
867
|
1571 Ichar c;
|
462
|
1572
|
|
1573 CHECK_CHAR_COERCE_INT (obj);
|
|
1574 c = XCHAR (obj);
|
|
1575 GTK_VALUE_CHAR (*arg) = c;
|
|
1576 }
|
|
1577 break;
|
|
1578 case GTK_TYPE_BOOL:
|
|
1579 GTK_VALUE_BOOL (*arg) = NILP (obj) ? FALSE : TRUE;
|
|
1580 break;
|
|
1581 case GTK_TYPE_INT:
|
|
1582 case GTK_TYPE_UINT:
|
|
1583 if (NILP (obj) || EQ (Qt, obj))
|
|
1584 {
|
|
1585 /* For we are a kind mistress and allow sending t/nil for
|
|
1586 1/0 to stupid GTK functions that say they take guint or
|
|
1587 gint in the header files, but actually treat it like a
|
|
1588 bool. *sigh*
|
|
1589 */
|
|
1590 GTK_VALUE_INT(*arg) = NILP (obj) ? 0 : 1;
|
|
1591 }
|
|
1592 else
|
|
1593 {
|
|
1594 CHECK_INT (obj);
|
|
1595 GTK_VALUE_INT(*arg) = XINT (obj);
|
|
1596 }
|
|
1597 break;
|
|
1598 case GTK_TYPE_LONG:
|
|
1599 case GTK_TYPE_ULONG:
|
|
1600 abort();
|
|
1601 case GTK_TYPE_FLOAT:
|
|
1602 CHECK_INT_OR_FLOAT (obj);
|
|
1603 GTK_VALUE_FLOAT(*arg) = extract_float (obj);
|
|
1604 break;
|
|
1605 case GTK_TYPE_DOUBLE:
|
|
1606 CHECK_INT_OR_FLOAT (obj);
|
|
1607 GTK_VALUE_DOUBLE(*arg) = extract_float (obj);
|
|
1608 break;
|
|
1609 case GTK_TYPE_STRING:
|
|
1610 if (NILP (obj))
|
|
1611 GTK_VALUE_STRING (*arg) = NULL;
|
|
1612 else
|
|
1613 {
|
|
1614 CHECK_STRING (obj);
|
|
1615 GTK_VALUE_STRING (*arg) = (char *) XSTRING_DATA (obj);
|
|
1616 }
|
|
1617 break;
|
|
1618 case GTK_TYPE_ENUM:
|
|
1619 case GTK_TYPE_FLAGS:
|
|
1620 /* Convert a lisp symbol to a GTK enum */
|
|
1621 GTK_VALUE_ENUM(*arg) = lisp_to_flag (obj, arg->type);
|
|
1622 break;
|
|
1623 case GTK_TYPE_BOXED:
|
|
1624 if (NILP (obj))
|
|
1625 {
|
|
1626 GTK_VALUE_BOXED(*arg) = NULL;
|
|
1627 }
|
|
1628 else if (GTK_BOXEDP (obj))
|
|
1629 {
|
|
1630 GTK_VALUE_BOXED(*arg) = XGTK_BOXED (obj)->object;
|
|
1631 }
|
|
1632 else if (arg->type == GTK_TYPE_STYLE)
|
|
1633 {
|
|
1634 obj = Ffind_face (obj);
|
|
1635 CHECK_FACE (obj);
|
|
1636 GTK_VALUE_BOXED(*arg) = face_to_style (obj);
|
|
1637 }
|
|
1638 else if (arg->type == GTK_TYPE_GDK_GC)
|
|
1639 {
|
|
1640 obj = Ffind_face (obj);
|
|
1641 CHECK_FACE (obj);
|
|
1642 GTK_VALUE_BOXED(*arg) = face_to_gc (obj);
|
|
1643 }
|
|
1644 else if (arg->type == GTK_TYPE_GDK_WINDOW)
|
|
1645 {
|
|
1646 if (GLYPHP (obj))
|
|
1647 {
|
|
1648 Lisp_Object window = Fselected_window (Qnil);
|
793
|
1649 Lisp_Object instance =
|
|
1650 glyph_image_instance (obj, window, ERROR_ME_DEBUG_WARN, 1);
|
462
|
1651 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (instance);
|
|
1652
|
|
1653 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
1654 {
|
|
1655 case IMAGE_TEXT:
|
|
1656 case IMAGE_POINTER:
|
|
1657 case IMAGE_SUBWINDOW:
|
|
1658 case IMAGE_NOTHING:
|
|
1659 GTK_VALUE_BOXED(*arg) = NULL;
|
|
1660 break;
|
|
1661
|
|
1662 case IMAGE_MONO_PIXMAP:
|
|
1663 case IMAGE_COLOR_PIXMAP:
|
|
1664 GTK_VALUE_BOXED(*arg) = IMAGE_INSTANCE_GTK_PIXMAP (p);
|
|
1665 break;
|
|
1666 }
|
|
1667 }
|
|
1668 else if (GTK_OBJECTP (obj) && GTK_IS_WIDGET (XGTK_OBJECT (obj)->object))
|
|
1669 {
|
|
1670 GTK_VALUE_BOXED(*arg) = GTK_WIDGET (XGTK_OBJECT (obj))->window;
|
|
1671 }
|
|
1672 else
|
|
1673 {
|
563
|
1674 invalid_argument ("Don't know how to convert object to GDK_WINDOW", obj);
|
462
|
1675 }
|
|
1676 break;
|
|
1677 }
|
|
1678 else if (arg->type == GTK_TYPE_GDK_COLOR)
|
|
1679 {
|
|
1680 if (COLOR_SPECIFIERP (obj))
|
|
1681 {
|
|
1682 /* If it is a specifier, we just convert it to an
|
|
1683 instance, and let the ifs below handle it.
|
|
1684 */
|
|
1685 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
|
|
1686 }
|
|
1687
|
|
1688 if (COLOR_INSTANCEP (obj))
|
|
1689 {
|
|
1690 /* Easiest one */
|
|
1691 GTK_VALUE_BOXED(*arg) = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (obj));
|
|
1692 }
|
|
1693 else if (STRINGP (obj))
|
|
1694 {
|
563
|
1695 invalid_argument ("Please use a color specifier or instance, not a string", obj);
|
462
|
1696 }
|
|
1697 else
|
|
1698 {
|
563
|
1699 invalid_argument ("Don't know how to convert to GdkColor", obj);
|
462
|
1700 }
|
|
1701 }
|
|
1702 else if (arg->type == GTK_TYPE_GDK_FONT)
|
|
1703 {
|
|
1704 if (SYMBOLP (obj))
|
|
1705 {
|
|
1706 /* If it is a symbol, we treat that as a face name */
|
|
1707 obj = Ffind_face (obj);
|
|
1708 }
|
|
1709
|
|
1710 if (FACEP (obj))
|
|
1711 {
|
|
1712 /* If it is a face, we just grab the font specifier, and
|
|
1713 cascade down until we finally reach a FONT_INSTANCE
|
|
1714 */
|
|
1715 obj = Fget (obj, Qfont, Qnil);
|
|
1716 }
|
|
1717
|
|
1718 if (FONT_SPECIFIERP (obj))
|
|
1719 {
|
|
1720 /* If it is a specifier, we just convert it to an
|
|
1721 instance, and let the ifs below handle it
|
|
1722 */
|
|
1723 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
|
|
1724 }
|
|
1725
|
|
1726 if (FONT_INSTANCEP (obj))
|
|
1727 {
|
|
1728 /* Easiest one */
|
|
1729 GTK_VALUE_BOXED(*arg) = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (obj));
|
|
1730 }
|
|
1731 else if (STRINGP (obj))
|
|
1732 {
|
563
|
1733 invalid_argument ("Please use a font specifier or instance, not a string", obj);
|
462
|
1734 }
|
|
1735 else
|
|
1736 {
|
563
|
1737 invalid_argument ("Don't know how to convert to GdkColor", obj);
|
462
|
1738 }
|
|
1739 }
|
|
1740 else
|
|
1741 {
|
|
1742 /* Unknown type to convert to boxed */
|
|
1743 stderr_out ("Don't know how to convert to boxed!\n");
|
|
1744 GTK_VALUE_BOXED(*arg) = NULL;
|
|
1745 }
|
|
1746 break;
|
|
1747
|
|
1748 case GTK_TYPE_POINTER:
|
|
1749 if (NILP (obj))
|
|
1750 GTK_VALUE_POINTER(*arg) = NULL;
|
|
1751 else
|
|
1752 GTK_VALUE_POINTER(*arg) = LISP_TO_VOID (obj);
|
|
1753 break;
|
|
1754
|
|
1755 /* structured types */
|
|
1756 case GTK_TYPE_SIGNAL:
|
|
1757 case GTK_TYPE_ARGS: /* This we can do as a list of values */
|
|
1758 case GTK_TYPE_C_CALLBACK:
|
|
1759 case GTK_TYPE_FOREIGN:
|
|
1760 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
|
|
1761 return (-1);
|
|
1762
|
|
1763 #if 0
|
|
1764 /* #### BILL! */
|
|
1765 /* This is not used, and does not work with union type */
|
|
1766 case GTK_TYPE_CALLBACK:
|
|
1767 {
|
|
1768 GUI_ID id;
|
|
1769
|
|
1770 id = new_gui_id ();
|
|
1771 obj = Fcons (Qnil, obj); /* Empty data */
|
|
1772 obj = Fcons (make_int (id), obj);
|
|
1773
|
|
1774 gcpro_popup_callbacks (id, obj);
|
|
1775
|
|
1776 GTK_VALUE_CALLBACK(*arg).marshal = __internal_callback_marshal;
|
|
1777 GTK_VALUE_CALLBACK(*arg).data = (gpointer) obj;
|
|
1778 GTK_VALUE_CALLBACK(*arg).notify = __internal_callback_destroy;
|
|
1779 }
|
|
1780 break;
|
|
1781 #endif
|
|
1782
|
|
1783 /* base type of the object system */
|
|
1784 case GTK_TYPE_OBJECT:
|
|
1785 if (NILP (obj))
|
|
1786 GTK_VALUE_OBJECT (*arg) = NULL;
|
|
1787 else
|
|
1788 {
|
|
1789 CHECK_GTK_OBJECT (obj);
|
|
1790 if (XGTK_OBJECT (obj)->alive_p)
|
|
1791 GTK_VALUE_OBJECT (*arg) = XGTK_OBJECT (obj)->object;
|
|
1792 else
|
563
|
1793 invalid_argument ("Attempting to pass dead object to GTK function", obj);
|
462
|
1794 }
|
|
1795 break;
|
|
1796
|
|
1797 default:
|
2054
|
1798 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_ARRAY))
|
462
|
1799 {
|
|
1800 if (NILP (obj))
|
|
1801 GTK_VALUE_POINTER(*arg) = NULL;
|
|
1802 else
|
|
1803 {
|
|
1804 xemacs_list_to_array (obj, arg);
|
|
1805 }
|
|
1806 }
|
2054
|
1807 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
|
462
|
1808 {
|
|
1809 if (NILP (obj))
|
|
1810 GTK_VALUE_POINTER(*arg) = NULL;
|
|
1811 else
|
|
1812 {
|
|
1813 xemacs_list_to_gtklist (obj, arg);
|
|
1814 }
|
|
1815 }
|
|
1816 else
|
|
1817 {
|
|
1818 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
|
|
1819 abort();
|
|
1820 }
|
|
1821 break;
|
|
1822 }
|
|
1823
|
|
1824 return (0);
|
|
1825 }
|
|
1826
|
1883
|
1827 /* Convert lisp types to GTK return types. This is identical to
|
|
1828 lisp_to_gtk_type() except that the macro used to set the value is
|
|
1829 different.
|
|
1830
|
|
1831 ### There should be some way of combining these two functions.
|
|
1832 */
|
|
1833 int lisp_to_gtk_ret_type (Lisp_Object obj, GtkArg *arg)
|
|
1834 {
|
|
1835 switch (GTK_FUNDAMENTAL_TYPE (arg->type))
|
|
1836 {
|
|
1837 /* flag types */
|
|
1838 case GTK_TYPE_NONE:
|
|
1839 return (0);
|
|
1840 case GTK_TYPE_CHAR:
|
|
1841 {
|
|
1842 Ichar c;
|
|
1843
|
|
1844 CHECK_CHAR_COERCE_INT (obj);
|
|
1845 c = XCHAR (obj);
|
|
1846 *(GTK_RETLOC_CHAR (*arg)) = c;
|
|
1847 }
|
|
1848 break;
|
|
1849 case GTK_TYPE_UCHAR:
|
|
1850 {
|
|
1851 Ichar c;
|
|
1852
|
|
1853 CHECK_CHAR_COERCE_INT (obj);
|
|
1854 c = XCHAR (obj);
|
|
1855 *(GTK_RETLOC_CHAR (*arg)) = c;
|
|
1856 }
|
|
1857 break;
|
|
1858 case GTK_TYPE_BOOL:
|
|
1859 *(GTK_RETLOC_BOOL (*arg)) = NILP (obj) ? FALSE : TRUE;
|
|
1860 break;
|
|
1861 case GTK_TYPE_INT:
|
|
1862 case GTK_TYPE_UINT:
|
|
1863 if (NILP (obj) || EQ (Qt, obj))
|
|
1864 {
|
|
1865 /* For we are a kind mistress and allow sending t/nil for
|
|
1866 1/0 to stupid GTK functions that say they take guint or
|
|
1867 gint in the header files, but actually treat it like a
|
|
1868 bool. *sigh*
|
|
1869 */
|
|
1870 *(GTK_RETLOC_INT(*arg)) = NILP (obj) ? 0 : 1;
|
|
1871 }
|
|
1872 else
|
|
1873 {
|
|
1874 CHECK_INT (obj);
|
|
1875 *(GTK_RETLOC_INT(*arg)) = XINT (obj);
|
|
1876 }
|
|
1877 break;
|
|
1878 case GTK_TYPE_LONG:
|
|
1879 case GTK_TYPE_ULONG:
|
|
1880 abort();
|
|
1881 case GTK_TYPE_FLOAT:
|
|
1882 CHECK_INT_OR_FLOAT (obj);
|
|
1883 *(GTK_RETLOC_FLOAT(*arg)) = extract_float (obj);
|
|
1884 break;
|
|
1885 case GTK_TYPE_DOUBLE:
|
|
1886 CHECK_INT_OR_FLOAT (obj);
|
|
1887 *(GTK_RETLOC_DOUBLE(*arg)) = extract_float (obj);
|
|
1888 break;
|
|
1889 case GTK_TYPE_STRING:
|
|
1890 if (NILP (obj))
|
|
1891 *(GTK_RETLOC_STRING (*arg)) = NULL;
|
|
1892 else
|
|
1893 {
|
|
1894 CHECK_STRING (obj);
|
|
1895 *(GTK_RETLOC_STRING (*arg)) = (char *) XSTRING_DATA (obj);
|
|
1896 }
|
|
1897 break;
|
|
1898 case GTK_TYPE_ENUM:
|
|
1899 case GTK_TYPE_FLAGS:
|
|
1900 /* Convert a lisp symbol to a GTK enum */
|
|
1901 *(GTK_RETLOC_ENUM(*arg)) = lisp_to_flag (obj, arg->type);
|
|
1902 break;
|
|
1903 case GTK_TYPE_BOXED:
|
|
1904 if (NILP (obj))
|
|
1905 {
|
|
1906 *(GTK_RETLOC_BOXED(*arg)) = NULL;
|
|
1907 }
|
|
1908 else if (GTK_BOXEDP (obj))
|
|
1909 {
|
|
1910 *(GTK_RETLOC_BOXED(*arg)) = XGTK_BOXED (obj)->object;
|
|
1911 }
|
|
1912 else if (arg->type == GTK_TYPE_STYLE)
|
|
1913 {
|
|
1914 obj = Ffind_face (obj);
|
|
1915 CHECK_FACE (obj);
|
|
1916 *(GTK_RETLOC_BOXED(*arg)) = face_to_style (obj);
|
|
1917 }
|
|
1918 else if (arg->type == GTK_TYPE_GDK_GC)
|
|
1919 {
|
|
1920 obj = Ffind_face (obj);
|
|
1921 CHECK_FACE (obj);
|
|
1922 *(GTK_RETLOC_BOXED(*arg)) = face_to_gc (obj);
|
|
1923 }
|
|
1924 else if (arg->type == GTK_TYPE_GDK_WINDOW)
|
|
1925 {
|
|
1926 if (GLYPHP (obj))
|
|
1927 {
|
|
1928 Lisp_Object window = Fselected_window (Qnil);
|
|
1929 Lisp_Object instance =
|
|
1930 glyph_image_instance (obj, window, ERROR_ME_DEBUG_WARN, 1);
|
|
1931 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (instance);
|
|
1932
|
|
1933 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
1934 {
|
|
1935 case IMAGE_TEXT:
|
|
1936 case IMAGE_POINTER:
|
|
1937 case IMAGE_SUBWINDOW:
|
|
1938 case IMAGE_NOTHING:
|
|
1939 *(GTK_RETLOC_BOXED(*arg)) = NULL;
|
|
1940 break;
|
|
1941
|
|
1942 case IMAGE_MONO_PIXMAP:
|
|
1943 case IMAGE_COLOR_PIXMAP:
|
|
1944 *(GTK_RETLOC_BOXED(*arg)) = IMAGE_INSTANCE_GTK_PIXMAP (p);
|
|
1945 break;
|
|
1946 }
|
|
1947 }
|
|
1948 else if (GTK_OBJECTP (obj) && GTK_IS_WIDGET (XGTK_OBJECT (obj)->object))
|
|
1949 {
|
|
1950 *(GTK_RETLOC_BOXED(*arg)) = GTK_WIDGET (XGTK_OBJECT (obj))->window;
|
|
1951 }
|
|
1952 else
|
|
1953 {
|
|
1954 invalid_argument ("Don't know how to convert object to GDK_WINDOW", obj);
|
|
1955 }
|
|
1956 break;
|
|
1957 }
|
|
1958 else if (arg->type == GTK_TYPE_GDK_COLOR)
|
|
1959 {
|
|
1960 if (COLOR_SPECIFIERP (obj))
|
|
1961 {
|
|
1962 /* If it is a specifier, we just convert it to an
|
|
1963 instance, and let the ifs below handle it.
|
|
1964 */
|
|
1965 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
|
|
1966 }
|
|
1967
|
|
1968 if (COLOR_INSTANCEP (obj))
|
|
1969 {
|
|
1970 /* Easiest one */
|
|
1971 *(GTK_RETLOC_BOXED(*arg)) = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (obj));
|
|
1972 }
|
|
1973 else if (STRINGP (obj))
|
|
1974 {
|
|
1975 invalid_argument ("Please use a color specifier or instance, not a string", obj);
|
|
1976 }
|
|
1977 else
|
|
1978 {
|
|
1979 invalid_argument ("Don't know how to convert to GdkColor", obj);
|
|
1980 }
|
|
1981 }
|
|
1982 else if (arg->type == GTK_TYPE_GDK_FONT)
|
|
1983 {
|
|
1984 if (SYMBOLP (obj))
|
|
1985 {
|
|
1986 /* If it is a symbol, we treat that as a face name */
|
|
1987 obj = Ffind_face (obj);
|
|
1988 }
|
|
1989
|
|
1990 if (FACEP (obj))
|
|
1991 {
|
|
1992 /* If it is a face, we just grab the font specifier, and
|
|
1993 cascade down until we finally reach a FONT_INSTANCE
|
|
1994 */
|
|
1995 obj = Fget (obj, Qfont, Qnil);
|
|
1996 }
|
|
1997
|
|
1998 if (FONT_SPECIFIERP (obj))
|
|
1999 {
|
|
2000 /* If it is a specifier, we just convert it to an
|
|
2001 instance, and let the ifs below handle it
|
|
2002 */
|
|
2003 obj = Fspecifier_instance (obj, Qnil, Qnil, Qnil);
|
|
2004 }
|
|
2005
|
|
2006 if (FONT_INSTANCEP (obj))
|
|
2007 {
|
|
2008 /* Easiest one */
|
|
2009 *(GTK_RETLOC_BOXED(*arg)) = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (obj));
|
|
2010 }
|
|
2011 else if (STRINGP (obj))
|
|
2012 {
|
|
2013 invalid_argument ("Please use a font specifier or instance, not a string", obj);
|
|
2014 }
|
|
2015 else
|
|
2016 {
|
|
2017 invalid_argument ("Don't know how to convert to GdkColor", obj);
|
|
2018 }
|
|
2019 }
|
|
2020 else
|
|
2021 {
|
|
2022 /* Unknown type to convert to boxed */
|
|
2023 stderr_out ("Don't know how to convert to boxed!\n");
|
|
2024 *(GTK_RETLOC_BOXED(*arg)) = NULL;
|
|
2025 }
|
|
2026 break;
|
|
2027
|
|
2028 case GTK_TYPE_POINTER:
|
|
2029 if (NILP (obj))
|
|
2030 *(GTK_RETLOC_POINTER(*arg)) = NULL;
|
|
2031 else
|
|
2032 *(GTK_RETLOC_POINTER(*arg)) = LISP_TO_VOID (obj);
|
|
2033 break;
|
|
2034
|
|
2035 /* structured types */
|
|
2036 case GTK_TYPE_SIGNAL:
|
|
2037 case GTK_TYPE_ARGS: /* This we can do as a list of values */
|
|
2038 case GTK_TYPE_C_CALLBACK:
|
|
2039 case GTK_TYPE_FOREIGN:
|
|
2040 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
|
|
2041 return (-1);
|
|
2042
|
|
2043 #if 0
|
|
2044 /* #### BILL! */
|
|
2045 /* This is not used, and does not work with union type */
|
|
2046 case GTK_TYPE_CALLBACK:
|
|
2047 {
|
|
2048 GUI_ID id;
|
|
2049
|
|
2050 id = new_gui_id ();
|
|
2051 obj = Fcons (Qnil, obj); /* Empty data */
|
|
2052 obj = Fcons (make_int (id), obj);
|
|
2053
|
|
2054 gcpro_popup_callbacks (id, obj);
|
|
2055
|
|
2056 *(GTK_RETLOC_CALLBACK(*arg)).marshal = __internal_callback_marshal;
|
|
2057 *(GTK_RETLOC_CALLBACK(*arg)).data = (gpointer) obj;
|
|
2058 *(GTK_RETLOC_CALLBACK(*arg)).notify = __internal_callback_destroy;
|
|
2059 }
|
|
2060 break;
|
|
2061 #endif
|
|
2062
|
|
2063 /* base type of the object system */
|
|
2064 case GTK_TYPE_OBJECT:
|
|
2065 if (NILP (obj))
|
|
2066 *(GTK_RETLOC_OBJECT (*arg)) = NULL;
|
|
2067 else
|
|
2068 {
|
|
2069 CHECK_GTK_OBJECT (obj);
|
|
2070 if (XGTK_OBJECT (obj)->alive_p)
|
|
2071 *(GTK_RETLOC_OBJECT (*arg)) = XGTK_OBJECT (obj)->object;
|
|
2072 else
|
|
2073 invalid_argument ("Attempting to pass dead object to GTK function", obj);
|
|
2074 }
|
|
2075 break;
|
|
2076
|
|
2077 default:
|
2054
|
2078 if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_ARRAY))
|
1883
|
2079 {
|
|
2080 if (NILP (obj))
|
|
2081 *(GTK_RETLOC_POINTER(*arg)) = NULL;
|
|
2082 else
|
|
2083 {
|
|
2084 xemacs_list_to_array (obj, arg);
|
|
2085 }
|
|
2086 }
|
2054
|
2087 else if (IS_XEMACS_GTK_FUNDAMENTAL_TYPE(arg->type, GTK_TYPE_LISTOF))
|
1883
|
2088 {
|
|
2089 if (NILP (obj))
|
|
2090 *(GTK_RETLOC_POINTER(*arg)) = NULL;
|
|
2091 else
|
|
2092 {
|
|
2093 xemacs_list_to_gtklist (obj, arg);
|
|
2094 }
|
|
2095 }
|
|
2096 else
|
|
2097 {
|
|
2098 stderr_out ("Do not know how to convert `%s' from lisp!\n", gtk_type_name (arg->type));
|
|
2099 abort();
|
|
2100 }
|
|
2101 break;
|
|
2102 }
|
|
2103
|
|
2104 return (0);
|
|
2105 }
|
|
2106
|
462
|
2107 /* This is used in glyphs-gtk.c as well */
|
|
2108 static Lisp_Object
|
|
2109 get_enumeration (GtkType t)
|
|
2110 {
|
|
2111 Lisp_Object alist;
|
|
2112
|
|
2113 if (NILP (Venumeration_info))
|
|
2114 {
|
|
2115 Venumeration_info = call2 (intern ("make-hashtable"), make_int (100), Qequal);
|
|
2116 }
|
|
2117
|
|
2118 alist = Fgethash (make_int (t), Venumeration_info, Qnil);
|
|
2119
|
|
2120 if (NILP (alist))
|
|
2121 {
|
|
2122 import_gtk_enumeration_internal (t);
|
|
2123 alist = Fgethash (make_int (t), Venumeration_info, Qnil);
|
|
2124 }
|
|
2125 return (alist);
|
|
2126 }
|
|
2127
|
|
2128 guint
|
|
2129 symbol_to_enum (Lisp_Object obj, GtkType t)
|
|
2130 {
|
|
2131 Lisp_Object alist = get_enumeration (t);
|
|
2132 Lisp_Object value = Qnil;
|
|
2133
|
|
2134 if (NILP (alist))
|
|
2135 {
|
563
|
2136 invalid_argument ("Unknown enumeration", build_string (gtk_type_name (t)));
|
462
|
2137 }
|
|
2138
|
|
2139 value = Fassq (obj, alist);
|
|
2140
|
|
2141 if (NILP (value))
|
|
2142 {
|
563
|
2143 invalid_argument ("Unknown value", obj);
|
462
|
2144 }
|
|
2145
|
|
2146 CHECK_INT (XCDR (value));
|
|
2147
|
|
2148 return (XINT (XCDR (value)));
|
|
2149 }
|
|
2150
|
|
2151 static guint
|
|
2152 lisp_to_flag (Lisp_Object obj, GtkType t)
|
|
2153 {
|
|
2154 guint val = 0;
|
|
2155
|
|
2156 if (NILP (obj))
|
|
2157 {
|
|
2158 /* Do nothing */
|
|
2159 }
|
|
2160 else if (SYMBOLP (obj))
|
|
2161 {
|
|
2162 val = symbol_to_enum (obj, t);
|
|
2163 }
|
|
2164 else if (LISTP (obj))
|
|
2165 {
|
|
2166 while (!NILP (obj))
|
|
2167 {
|
|
2168 val |= symbol_to_enum (XCAR (obj), t);
|
|
2169 obj = XCDR (obj);
|
|
2170 }
|
|
2171 }
|
|
2172 else
|
|
2173 {
|
|
2174 /* abort ()? */
|
|
2175 }
|
|
2176 return (val);
|
|
2177 }
|
|
2178
|
|
2179 static Lisp_Object
|
|
2180 flags_to_list (guint value, GtkType t)
|
|
2181 {
|
|
2182 Lisp_Object rval = Qnil;
|
|
2183 Lisp_Object alist = get_enumeration (t);
|
|
2184
|
|
2185 while (!NILP (alist))
|
|
2186 {
|
|
2187 if (value & XINT (XCDR (XCAR (alist))))
|
|
2188 {
|
|
2189 rval = Fcons (XCAR (XCAR (alist)), rval);
|
|
2190 value &= ~(XINT (XCDR (XCAR (alist))));
|
|
2191 }
|
|
2192 alist = XCDR (alist);
|
|
2193 }
|
|
2194 return (rval);
|
|
2195 }
|
|
2196
|
|
2197 static Lisp_Object
|
|
2198 enum_to_symbol (guint value, GtkType t)
|
|
2199 {
|
|
2200 Lisp_Object alist = get_enumeration (t);
|
|
2201 Lisp_Object cell = Qnil;
|
|
2202
|
|
2203 if (NILP (alist))
|
|
2204 {
|
563
|
2205 invalid_argument ("Unknown enumeration", build_string (gtk_type_name (t)));
|
462
|
2206 }
|
|
2207
|
|
2208 cell = Frassq (make_int (value), alist);
|
|
2209
|
|
2210 return (NILP (cell) ? Qnil : XCAR (cell));
|
|
2211 }
|