annotate src/ui-gtk.c @ 2031:d82ed7be1636

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