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