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