0
|
1 /* General GUI code -- X-specific. (menubars, scrollbars, toolbars, dialogs)
|
|
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
|
4 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
|
25 #include <config.h>
|
|
26 #include "lisp.h"
|
|
27
|
|
28 #include "console-x.h"
|
|
29 #ifdef LWLIB_USES_MOTIF
|
|
30 #include <Xm/Xm.h> /* for XmVersion */
|
|
31 #endif
|
|
32 #include "gui-x.h"
|
|
33 #include "buffer.h"
|
|
34 #include "device.h"
|
|
35 #include "frame.h"
|
|
36 #include "opaque.h"
|
|
37
|
|
38 #ifdef HAVE_POPUPS
|
|
39 /* count of menus/dboxes currently up */
|
|
40 int popup_up_p;
|
|
41
|
|
42 Lisp_Object Qmenu_no_selection_hook;
|
|
43 #endif
|
|
44
|
|
45 /* we need a unique id for each popup menu, dialog box, and scrollbar */
|
|
46 static unsigned int lwlib_id_tick;
|
|
47
|
|
48 LWLIB_ID new_lwlib_id (void);
|
|
49 LWLIB_ID
|
|
50 new_lwlib_id (void)
|
|
51 {
|
|
52 return ++lwlib_id_tick;
|
|
53 }
|
|
54
|
|
55 widget_value *
|
|
56 xmalloc_widget_value (void)
|
|
57 {
|
|
58 widget_value *tmp = malloc_widget_value ();
|
|
59 if (!tmp) memory_full ();
|
|
60 return tmp;
|
|
61 }
|
|
62
|
|
63
|
|
64 #ifdef HAVE_POPUPS
|
|
65 static Lisp_Object mark_popup_data (Lisp_Object obj,
|
|
66 void (*markobj) (Lisp_Object));
|
|
67 DEFINE_LRECORD_IMPLEMENTATION ("popup-data", popup_data,
|
|
68 mark_popup_data, internal_object_printer,
|
|
69 0, 0, 0, struct popup_data);
|
|
70
|
|
71 struct mark_widget_value_closure
|
|
72 {
|
|
73 void (*markobj) (Lisp_Object);
|
|
74 };
|
|
75
|
|
76 static int
|
|
77 mark_widget_value_mapper (widget_value *val, void *closure)
|
|
78 {
|
|
79 Lisp_Object markee;
|
|
80
|
|
81 struct mark_widget_value_closure *cl =
|
|
82 (struct mark_widget_value_closure *) closure;
|
|
83 if (val->call_data)
|
|
84 {
|
|
85 VOID_TO_LISP (markee, val->call_data);
|
|
86 (cl->markobj) (markee);
|
|
87 }
|
|
88
|
175
|
89 if (val->accel)
|
|
90 {
|
|
91 VOID_TO_LISP (markee, val->accel);
|
|
92 (cl->markobj) (markee);
|
|
93 }
|
0
|
94 return 0;
|
|
95 }
|
|
96
|
|
97 static Lisp_Object
|
|
98 mark_popup_data (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
99 {
|
|
100 struct popup_data *data = (struct popup_data *) XPOPUP_DATA (obj);
|
|
101
|
|
102 /* Now mark the callbacks and such that are hidden in the lwlib
|
|
103 call-data */
|
|
104
|
|
105 if (data->id)
|
|
106 {
|
|
107 struct mark_widget_value_closure closure;
|
|
108
|
|
109 closure.markobj = markobj;
|
|
110 lw_map_widget_values (data->id, mark_widget_value_mapper, &closure);
|
|
111 }
|
173
|
112
|
|
113 return data->last_menubar_buffer;
|
0
|
114 }
|
|
115
|
|
116 /* This is like FRAME_MENUBAR_DATA (f), but contains an alist of
|
|
117 (id . popup-data) for GCPRO'ing the callbacks of the popup menus
|
|
118 and dialog boxes. */
|
|
119 static Lisp_Object Vpopup_callbacks;
|
|
120
|
|
121 void
|
|
122 gcpro_popup_callbacks (LWLIB_ID id)
|
|
123 {
|
|
124 struct popup_data *pdata;
|
|
125 Lisp_Object lid = make_int (id);
|
|
126 Lisp_Object lpdata = Qnil;
|
|
127
|
|
128 assert (NILP (assq_no_quit (lid, Vpopup_callbacks)));
|
185
|
129 pdata = alloc_lcrecord_type (struct popup_data, lrecord_popup_data);
|
0
|
130 pdata->id = id;
|
|
131 pdata->last_menubar_buffer = Qnil;
|
|
132 pdata->menubar_contents_up_to_date = 0;
|
|
133 XSETPOPUP_DATA (lpdata, pdata);
|
|
134 Vpopup_callbacks = Fcons (Fcons (lid, lpdata), Vpopup_callbacks);
|
|
135 }
|
|
136
|
|
137 void
|
|
138 ungcpro_popup_callbacks (LWLIB_ID id)
|
|
139 {
|
|
140 Lisp_Object lid = make_int (id);
|
|
141 Lisp_Object this = assq_no_quit (lid, Vpopup_callbacks);
|
|
142 assert (!NILP (this));
|
|
143 Vpopup_callbacks = delq_no_quit (this, Vpopup_callbacks);
|
|
144 }
|
|
145
|
|
146 int
|
|
147 popup_handled_p (LWLIB_ID id)
|
|
148 {
|
173
|
149 return NILP (assq_no_quit (make_int (id), Vpopup_callbacks));
|
0
|
150 }
|
|
151
|
|
152 /* menu_item_descriptor_to_widget_value() et al. mallocs a
|
|
153 widget_value, but then may signal lisp errors. If an error does
|
|
154 not occur, the opaque ptr we have here has had its pointer set to 0
|
|
155 to tell us not to do anything. Otherwise we free the widget value.
|
|
156 (This has nothing to do with GC, it's just about not dropping
|
|
157 pointers to malloc'd data when errors happen.) */
|
|
158
|
|
159 Lisp_Object
|
|
160 widget_value_unwind (Lisp_Object closure)
|
|
161 {
|
|
162 widget_value *wv = (widget_value *) get_opaque_ptr (closure);
|
|
163 free_opaque_ptr (closure);
|
|
164 if (wv)
|
|
165 free_widget_value (wv);
|
|
166 return Qnil;
|
|
167 }
|
|
168
|
|
169 #if 0
|
|
170 static void
|
|
171 print_widget_value (widget_value *wv, int depth)
|
|
172 {
|
|
173 /* !!#### This function has not been Mule-ized */
|
|
174 char d [200];
|
|
175 int i;
|
|
176 for (i = 0; i < depth; i++) d[i] = ' ';
|
|
177 d[depth]=0;
|
|
178 /* #### - print type field */
|
|
179 printf ("%sname: %s\n", d, (wv->name ? wv->name : "(null)"));
|
|
180 if (wv->value) printf ("%svalue: %s\n", d, wv->value);
|
|
181 if (wv->key) printf ("%skey: %s\n", d, wv->key);
|
|
182 printf ("%senabled: %d\n", d, wv->enabled);
|
|
183 if (wv->contents)
|
|
184 {
|
|
185 printf ("\n%scontents: \n", d);
|
|
186 print_widget_value (wv->contents, depth + 5);
|
|
187 }
|
|
188 if (wv->next)
|
|
189 {
|
|
190 printf ("\n");
|
|
191 print_widget_value (wv->next, depth);
|
|
192 }
|
|
193 }
|
|
194 #endif
|
|
195
|
|
196 /* This recursively calls free_widget_value() on the tree of widgets.
|
|
197 It must free all data that was malloc'ed for these widget_values.
|
|
198
|
|
199 It used to be that emacs only allocated new storage for the `key' slot.
|
|
200 All other slots are pointers into the data of Lisp_Strings, and must be
|
|
201 left alone. */
|
|
202 void
|
|
203 free_popup_widget_value_tree (widget_value *wv)
|
|
204 {
|
|
205 if (! wv) return;
|
|
206 if (wv->key) xfree (wv->key);
|
|
207 if (wv->value) xfree (wv->value);
|
|
208
|
|
209 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
|
|
210
|
|
211 if (wv->contents && (wv->contents != (widget_value*)1))
|
|
212 {
|
|
213 free_popup_widget_value_tree (wv->contents);
|
|
214 wv->contents = (widget_value *) 0xDEADBEEF;
|
|
215 }
|
|
216 if (wv->next)
|
|
217 {
|
|
218 free_popup_widget_value_tree (wv->next);
|
|
219 wv->next = (widget_value *) 0xDEADBEEF;
|
|
220 }
|
|
221 free_widget_value (wv);
|
|
222 }
|
|
223
|
20
|
224 DEFUN ("popup-up-p", Fpopup_up_p, 0, 0, 0, /*
|
0
|
225 Return t if a popup menu or dialog box is up, nil otherwise.
|
|
226 See `popup-menu' and `popup-dialog-box'.
|
20
|
227 */
|
|
228 ())
|
0
|
229 {
|
|
230 return popup_up_p ? Qt : Qnil;
|
|
231 }
|
|
232
|
|
233 /* The following is actually called from somewhere within XtDispatchEvent(),
|
|
234 called from XtAppProcessEvent() in event-Xt.c */
|
|
235
|
|
236 void
|
|
237 popup_selection_callback (Widget widget, LWLIB_ID ignored_id,
|
|
238 XtPointer client_data)
|
|
239 {
|
|
240 Lisp_Object fn, arg;
|
|
241 Lisp_Object data;
|
|
242 Lisp_Object frame = Qnil;
|
|
243 struct device *d = get_device_from_display (XtDisplay (widget));
|
|
244 struct frame *f = x_any_widget_or_parent_to_frame (d, widget);
|
|
245
|
175
|
246 /* set in lwlib to the time stamp associated with the most recent menu
|
|
247 operation */
|
|
248 extern Time x_focus_timestamp_really_sucks_fix_me_better;
|
|
249
|
0
|
250 if (!f)
|
|
251 return;
|
|
252 if (((EMACS_INT) client_data) == 0)
|
|
253 return;
|
|
254 VOID_TO_LISP (data, client_data);
|
|
255 XSETFRAME (frame, f);
|
|
256
|
|
257 #if 0
|
|
258 /* #### What the hell? I can't understand why this call is here,
|
|
259 and doing it is really courting disaster in the new event
|
|
260 model, since popup_selection_callback is called from
|
|
261 within next_event_internal() and Faccept_process_output()
|
|
262 itself calls next_event_internal(). --Ben */
|
|
263
|
|
264 /* Flush the X and process input */
|
|
265 Faccept_process_output (Qnil, Qnil, Qnil);
|
|
266 #endif
|
|
267
|
|
268 if (((EMACS_INT) client_data) == -1)
|
|
269 {
|
|
270 fn = Qrun_hooks;
|
|
271 arg = Qmenu_no_selection_hook;
|
|
272 }
|
|
273 else if (SYMBOLP (data))
|
|
274 {
|
|
275 fn = Qcall_interactively;
|
|
276 arg = data;
|
|
277 }
|
|
278 else if (CONSP (data))
|
|
279 {
|
|
280 fn = Qeval;
|
|
281 arg = data;
|
|
282 }
|
|
283 else
|
|
284 {
|
|
285 fn = Qeval;
|
|
286 arg = list3 (Qsignal,
|
|
287 list2 (Qquote, Qerror),
|
|
288 list2 (Qquote, list2 (build_translated_string
|
|
289 ("illegal popup callback"),
|
|
290 data)));
|
|
291 }
|
|
292
|
|
293 /* This is the timestamp used for asserting focus so we need to get an
|
|
294 up-to-date value event if no events has been dispatched to emacs
|
|
295 */
|
179
|
296 #if defined(HAVE_MENUBARS)
|
175
|
297 DEVICE_X_MOUSE_TIMESTAMP (d) = x_focus_timestamp_really_sucks_fix_me_better;
|
177
|
298 #else
|
|
299 DEVICE_X_MOUSE_TIMESTAMP (d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d);
|
|
300 #endif
|
0
|
301 signal_special_Xt_user_event (frame, fn, arg);
|
|
302 }
|
|
303
|
|
304 #if 1
|
|
305 /* Eval the activep slot of the menu item */
|
|
306 # define wv_set_evalable_slot(slot,form) \
|
|
307 do { Lisp_Object _f_ = (form); \
|
|
308 slot = (NILP (_f_) ? 0 : \
|
|
309 EQ (_f_, Qt) ? 1 : \
|
|
310 !NILP (Feval (_f_))); \
|
|
311 } while (0)
|
|
312 #else
|
|
313 /* Treat the activep slot of the menu item as a boolean */
|
|
314 # define wv_set_evalable_slot(slot,form) \
|
|
315 slot = (!NILP ((form)))
|
|
316 #endif
|
|
317
|
|
318 Boolean
|
|
319 separator_string_p (CONST char *s)
|
|
320 {
|
|
321 CONST char *p;
|
|
322 char first;
|
|
323
|
|
324 if (!s || s[0] == '\0')
|
|
325 return False;
|
|
326 first = s[0];
|
|
327 if (first != '-' && first != '=')
|
|
328 return False;
|
|
329 for (p = s; *p == first; p++);
|
|
330
|
|
331 if (*p == '!' || *p == ':' || *p == '\0')
|
|
332 return True;
|
|
333 return False;
|
|
334 }
|
|
335
|
|
336 char *
|
|
337 menu_separator_style (CONST char *s)
|
|
338 {
|
|
339 CONST char *p;
|
|
340 char first;
|
|
341
|
|
342 if (!s || s[0] == '\0')
|
|
343 return NULL;
|
|
344 first = s[0];
|
|
345 if (first != '-' && first != '=')
|
|
346 return NULL;
|
|
347 for (p = s; *p == first; p++);
|
|
348
|
|
349 /* #### - cannot currently specify a separator tag "--!tag" and a
|
|
350 separator style "--:style" at the same time. */
|
|
351 /* #### - Also, the motif menubar code doesn't deal with the
|
|
352 double etched style yet, so it's not good to get into the habit of
|
|
353 using "===" in menubars to get double-etched lines */
|
|
354 if (*p == '!' || *p == '\0')
|
|
355 return ((first == '-')
|
|
356 ? NULL /* single etched is the default */
|
|
357 : xstrdup ("shadowDoubleEtchedIn"));
|
|
358 else if (*p == ':')
|
|
359 return xstrdup (p+1);
|
173
|
360
|
0
|
361 return NULL;
|
|
362 }
|
|
363
|
175
|
364 /* set menu accelerator key to first underlined character in menu name */
|
|
365
|
|
366 Lisp_Object
|
|
367 menu_name_to_accelerator (char *name)
|
|
368 {
|
|
369 while (*name) {
|
|
370 if (*name=='%') {
|
|
371 ++name;
|
|
372 if (!(*name))
|
|
373 return Qnil;
|
|
374 if (*name=='_'&&*(name+1))
|
|
375 return make_char (tolower(*(name+1)));
|
|
376 }
|
|
377 ++name;
|
|
378 }
|
|
379 return Qnil;
|
|
380 }
|
|
381
|
0
|
382 /* This does the dirty work. gc_currently_forbidden is 1 when this is called.
|
|
383 */
|
|
384
|
|
385 int
|
|
386 button_item_to_widget_value (Lisp_Object desc, widget_value *wv,
|
|
387 int allow_text_field_p, int no_keys_p)
|
|
388 {
|
|
389 /* !!#### This function has not been Mule-ized */
|
|
390 /* This function cannot GC because gc_currently_forbidden is set when
|
|
391 it's called */
|
2
|
392 Lisp_Object name = Qnil;
|
|
393 Lisp_Object callback = Qnil;
|
|
394 Lisp_Object suffix = Qnil;
|
|
395 Lisp_Object active_p = Qt;
|
|
396 Lisp_Object include_p = Qt;
|
0
|
397 Lisp_Object selected_p = Qnil;
|
2
|
398 Lisp_Object keys = Qnil;
|
|
399 Lisp_Object style = Qnil;
|
0
|
400 Lisp_Object config_tag = Qnil;
|
175
|
401 Lisp_Object accel = Qnil;
|
173
|
402 int length = XVECTOR_LENGTH (desc);
|
|
403 Lisp_Object *contents = XVECTOR_DATA (desc);
|
0
|
404 int plist_p;
|
|
405 int selected_spec = 0, included_spec = 0;
|
|
406
|
|
407 if (length < 3)
|
|
408 signal_simple_error ("button descriptors must be at least 3 long", desc);
|
|
409
|
|
410 /* length 3: [ "name" callback active-p ]
|
|
411 length 4: [ "name" callback active-p suffix ]
|
|
412 or [ "name" callback keyword value ]
|
|
413 length 5+: [ "name" callback [ keyword value ]+ ]
|
|
414 */
|
|
415 plist_p = (length >= 5 || KEYWORDP (contents [2]));
|
|
416
|
|
417 if (!plist_p)
|
|
418 /* the old way */
|
|
419 {
|
|
420 name = contents [0];
|
|
421 callback = contents [1];
|
|
422 active_p = contents [2];
|
|
423 if (length == 4)
|
|
424 suffix = contents [3];
|
|
425 }
|
|
426 else
|
|
427 {
|
|
428 /* the new way */
|
|
429 int i;
|
|
430 if (length & 1)
|
|
431 signal_simple_error (
|
|
432 "button descriptor has an odd number of keywords and values",
|
|
433 desc);
|
|
434
|
|
435 name = contents [0];
|
|
436 callback = contents [1];
|
|
437 for (i = 2; i < length;)
|
|
438 {
|
|
439 Lisp_Object key = contents [i++];
|
|
440 Lisp_Object val = contents [i++];
|
|
441 if (!KEYWORDP (key))
|
|
442 signal_simple_error_2 ("not a keyword", key, desc);
|
|
443
|
2
|
444 if (EQ (key, Q_active)) active_p = val;
|
|
445 else if (EQ (key, Q_suffix)) suffix = val;
|
|
446 else if (EQ (key, Q_keys)) keys = val;
|
|
447 else if (EQ (key, Q_style)) style = val;
|
0
|
448 else if (EQ (key, Q_selected)) selected_p = val, selected_spec = 1;
|
2
|
449 else if (EQ (key, Q_included)) include_p = val, included_spec = 1;
|
0
|
450 else if (EQ (key, Q_config)) config_tag = val;
|
175
|
451 else if (EQ (key, Q_accelerator))
|
|
452 {
|
|
453 if ( SYMBOLP (val)
|
|
454 || CHARP (val))
|
|
455 accel = val;
|
|
456 else
|
|
457 signal_simple_error ("bad keyboard accelerator", val);
|
|
458 }
|
0
|
459 else if (EQ (key, Q_filter))
|
|
460 signal_simple_error(":filter keyword not permitted on leaf nodes", desc);
|
173
|
461 else
|
0
|
462 signal_simple_error_2 ("unknown menu item keyword", key, desc);
|
|
463 }
|
|
464 }
|
|
465
|
|
466 #ifdef HAVE_MENUBARS
|
|
467 if ((!NILP (config_tag) && NILP (Fmemq (config_tag, Vmenubar_configuration)))
|
|
468 || (included_spec && NILP (Feval (include_p))))
|
|
469 {
|
|
470 /* the include specification says to ignore this item. */
|
|
471 return 0;
|
|
472 }
|
16
|
473 #endif /* HAVE_MENUBARS */
|
0
|
474
|
|
475 CHECK_STRING (name);
|
14
|
476 wv->name = (char *) XSTRING_DATA (name);
|
0
|
477
|
175
|
478 if (NILP (accel))
|
|
479 accel = menu_name_to_accelerator (wv->name);
|
|
480 wv->accel = LISP_TO_VOID (accel);
|
185
|
481
|
0
|
482 if (!NILP (suffix))
|
|
483 {
|
|
484 CONST char *const_bogosity;
|
|
485 CHECK_STRING (suffix);
|
2
|
486 GET_C_STRING_FILENAME_DATA_ALLOCA (suffix, const_bogosity);
|
0
|
487 wv->value = (char *) const_bogosity;
|
|
488 wv->value = xstrdup (wv->value);
|
|
489 }
|
|
490
|
|
491 wv_set_evalable_slot (wv->enabled, active_p);
|
|
492 wv_set_evalable_slot (wv->selected, selected_p);
|
|
493
|
|
494 wv->call_data = LISP_TO_VOID (callback);
|
|
495
|
|
496 if (no_keys_p
|
|
497 #ifdef HAVE_MENUBARS
|
|
498 || !menubar_show_keybindings
|
|
499 #endif
|
|
500 )
|
|
501 wv->key = 0;
|
|
502 else if (!NILP (keys)) /* Use this string to generate key bindings */
|
|
503 {
|
|
504 CHECK_STRING (keys);
|
|
505 keys = Fsubstitute_command_keys (keys);
|
14
|
506 if (XSTRING_LENGTH (keys) > 0)
|
|
507 wv->key = xstrdup ((char *) XSTRING_DATA (keys));
|
0
|
508 else
|
|
509 wv->key = 0;
|
|
510 }
|
|
511 else if (SYMBOLP (callback)) /* Show the binding of this command. */
|
|
512 {
|
|
513 char buf [1024];
|
|
514 /* #### Warning, dependency here on current_buffer and point */
|
|
515 where_is_to_char (callback, buf);
|
|
516 if (buf [0])
|
|
517 wv->key = xstrdup (buf);
|
|
518 else
|
|
519 wv->key = 0;
|
|
520 }
|
|
521
|
|
522 CHECK_SYMBOL (style);
|
|
523 if (NILP (style))
|
|
524 {
|
|
525 /* If the callback is nil, treat this item like unselectable text.
|
|
526 This way, dashes will show up as a separator. */
|
|
527 if (!wv->enabled)
|
|
528 wv->type = BUTTON_TYPE;
|
|
529 if (separator_string_p (wv->name))
|
|
530 {
|
|
531 wv->type = SEPARATOR_TYPE;
|
|
532 wv->value = menu_separator_style (wv->name);
|
|
533 }
|
|
534 else
|
|
535 {
|
|
536 #if 0
|
|
537 /* #### - this is generally desirable for menubars, but it breaks
|
|
538 a package that uses dialog boxes and next_command_event magic
|
|
539 to use the callback slot in dialog buttons for data instead of
|
|
540 a real callback.
|
|
541
|
|
542 Code is data, right? The beauty of LISP abuse. --Stig */
|
|
543 if (NILP (callback))
|
|
544 wv->type = TEXT_TYPE;
|
|
545 else
|
|
546 #endif
|
|
547 wv->type = BUTTON_TYPE;
|
|
548 }
|
|
549 }
|
|
550 else if (EQ (style, Qbutton))
|
|
551 wv->type = BUTTON_TYPE;
|
|
552 else if (EQ (style, Qtoggle))
|
|
553 wv->type = TOGGLE_TYPE;
|
|
554 else if (EQ (style, Qradio))
|
|
555 wv->type = RADIO_TYPE;
|
|
556 else if (EQ (style, Qtext))
|
|
557 {
|
|
558 wv->type = TEXT_TYPE;
|
|
559 #if 0
|
|
560 wv->value = wv->name;
|
|
561 wv->name = "value";
|
173
|
562 #endif
|
0
|
563 }
|
|
564 else
|
|
565 signal_simple_error_2 ("unknown style", style, desc);
|
|
566
|
|
567 if (!allow_text_field_p && (wv->type == TEXT_TYPE))
|
|
568 signal_simple_error ("text field not allowed in this context", desc);
|
|
569
|
|
570 if (selected_spec && EQ (style, Qtext))
|
|
571 signal_simple_error (
|
|
572 ":selected only makes sense with :style toggle, radio or button",
|
|
573 desc);
|
|
574 return 1;
|
|
575 }
|
|
576
|
|
577 #endif /* HAVE_POPUPS */
|
|
578
|
|
579 /* This is a kludge to make sure emacs can only link against a version of
|
|
580 lwlib that was compiled in the right way. Emacs references symbols which
|
|
581 correspond to the way it thinks lwlib was compiled, and if lwlib wasn't
|
|
582 compiled in that way, then somewhat meaningful link errors will result.
|
|
583 The alternatives to this range from obscure link errors, to obscure
|
|
584 runtime errors that look a lot like bugs.
|
|
585 */
|
|
586
|
|
587 static void
|
|
588 sanity_check_lwlib (void)
|
|
589 {
|
|
590 #define MACROLET(v) { extern int v; v = 1; }
|
|
591
|
|
592 #if (XlibSpecificationRelease == 4)
|
|
593 MACROLET (lwlib_uses_x11r4);
|
|
594 #elif (XlibSpecificationRelease == 5)
|
|
595 MACROLET (lwlib_uses_x11r5);
|
|
596 #elif (XlibSpecificationRelease == 6)
|
|
597 MACROLET (lwlib_uses_x11r6);
|
|
598 #else
|
|
599 MACROLET (lwlib_uses_unknown_x11);
|
|
600 #endif
|
|
601 #ifdef LWLIB_USES_MOTIF
|
|
602 MACROLET (lwlib_uses_motif);
|
|
603 #else
|
|
604 MACROLET (lwlib_does_not_use_motif);
|
|
605 #endif
|
|
606 #if (XmVersion >= 1002)
|
|
607 MACROLET (lwlib_uses_motif_1_2);
|
|
608 #else
|
|
609 MACROLET (lwlib_does_not_use_motif_1_2);
|
|
610 #endif
|
|
611 #ifdef LWLIB_MENUBARS_LUCID
|
|
612 MACROLET (lwlib_menubars_lucid);
|
|
613 #elif defined (HAVE_MENUBARS)
|
|
614 MACROLET (lwlib_menubars_motif);
|
|
615 #endif
|
|
616 #ifdef LWLIB_SCROLLBARS_LUCID
|
|
617 MACROLET (lwlib_scrollbars_lucid);
|
|
618 #elif defined (LWLIB_SCROLLBARS_MOTIF)
|
|
619 MACROLET (lwlib_scrollbars_motif);
|
|
620 #elif defined (HAVE_SCROLLBARS)
|
|
621 MACROLET (lwlib_scrollbars_athena);
|
|
622 #endif
|
|
623 #ifdef LWLIB_DIALOGS_MOTIF
|
|
624 MACROLET (lwlib_dialogs_motif);
|
|
625 #elif defined (HAVE_DIALOGS)
|
|
626 MACROLET (lwlib_dialogs_athena);
|
|
627 #endif
|
|
628 #ifdef ENERGIZE
|
|
629 MACROLET (lwlib_uses_energize);
|
|
630 #else
|
|
631 MACROLET (lwlib_does_not_use_energize);
|
|
632 #endif
|
|
633
|
|
634 #undef MACROLET
|
|
635 }
|
|
636
|
|
637 void
|
|
638 syms_of_gui_x (void)
|
|
639 {
|
|
640 #ifdef HAVE_POPUPS
|
20
|
641 DEFSUBR (Fpopup_up_p);
|
0
|
642 defsymbol (&Qmenu_no_selection_hook, "menu-no-selection-hook");
|
|
643 #endif
|
|
644 }
|
|
645
|
|
646 void
|
|
647 vars_of_gui_x (void)
|
|
648 {
|
|
649 lwlib_id_tick = (1<<16); /* start big, to not conflict with Energize */
|
|
650
|
|
651 #ifdef HAVE_POPUPS
|
|
652 popup_up_p = 0;
|
|
653
|
|
654 Vpopup_callbacks = Qnil;
|
|
655 staticpro (&Vpopup_callbacks);
|
|
656
|
|
657 #if 0
|
|
658 /* This DEFVAR_LISP is just for the benefit of make-docfile. */
|
|
659 /* #### misnamed */
|
|
660 DEFVAR_LISP ("menu-no-selection-hook", &Vmenu_no_selection_hook /*
|
|
661 Function or functions to call when a menu or dialog box is dismissed
|
|
662 without a selection having been made.
|
|
663 */ );
|
|
664 #endif
|
|
665 Fset (Qmenu_no_selection_hook, Qnil);
|
|
666 #endif /* HAVE_POPUPS */
|
|
667
|
|
668 /* this makes only safe calls as in emacs.c */
|
|
669 sanity_check_lwlib ();
|
|
670 }
|