Mercurial > hg > xemacs-beta
comparison src/gui.c @ 454:d7a9135ec789 r21-2-42
Import from CVS: tag r21-2-42
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:40:54 +0200 |
parents | abe6d1db359e |
children | 183866b06e0b |
comparison
equal
deleted
inserted
replaced
453:270b05afd845 | 454:d7a9135ec789 |
---|---|
35 | 35 |
36 Lisp_Object Qmenu_no_selection_hook; | 36 Lisp_Object Qmenu_no_selection_hook; |
37 Lisp_Object Vmenu_no_selection_hook; | 37 Lisp_Object Vmenu_no_selection_hook; |
38 | 38 |
39 static Lisp_Object parse_gui_item_tree_list (Lisp_Object list); | 39 static Lisp_Object parse_gui_item_tree_list (Lisp_Object list); |
40 Lisp_Object find_keyword_in_vector (Lisp_Object vector, Lisp_Object keyword); | |
40 | 41 |
41 #ifdef HAVE_POPUPS | 42 #ifdef HAVE_POPUPS |
42 | 43 |
43 /* count of menus/dboxes currently up */ | 44 /* count of menus/dboxes currently up */ |
44 int popup_up_p; | 45 int popup_up_p; |
109 /* | 110 /* |
110 * Add a value VAL associated with keyword KEY into PGUI_ITEM | 111 * Add a value VAL associated with keyword KEY into PGUI_ITEM |
111 * structure. If KEY is not a keyword, or is an unknown keyword, then | 112 * structure. If KEY is not a keyword, or is an unknown keyword, then |
112 * error is signaled. | 113 * error is signaled. |
113 */ | 114 */ |
114 void | 115 int |
115 gui_item_add_keyval_pair (Lisp_Object gui_item, | 116 gui_item_add_keyval_pair (Lisp_Object gui_item, |
116 Lisp_Object key, Lisp_Object val, | 117 Lisp_Object key, Lisp_Object val, |
117 Error_behavior errb) | 118 Error_behavior errb) |
118 { | 119 { |
119 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); | 120 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); |
121 int retval = 0; | |
120 | 122 |
121 if (!KEYWORDP (key)) | 123 if (!KEYWORDP (key)) |
122 syntax_error_2 ("Non-keyword in gui item", key, pgui_item->name); | 124 syntax_error_2 ("Non-keyword in gui item", key, pgui_item->name); |
123 | 125 |
124 if (EQ (key, Q_suffix)) pgui_item->suffix = val; | 126 if (EQ (key, Q_descriptor)) |
125 else if (EQ (key, Q_active)) pgui_item->active = val; | 127 { |
126 else if (EQ (key, Q_included)) pgui_item->included = val; | 128 if (!EQ (pgui_item->name, val)) |
127 else if (EQ (key, Q_config)) pgui_item->config = val; | 129 { |
128 else if (EQ (key, Q_filter)) pgui_item->filter = val; | 130 retval = 1; |
129 else if (EQ (key, Q_style)) pgui_item->style = val; | 131 pgui_item->name = val; |
130 else if (EQ (key, Q_selected)) pgui_item->selected = val; | 132 } |
131 else if (EQ (key, Q_keys)) pgui_item->keys = val; | 133 } |
132 else if (EQ (key, Q_callback)) pgui_item->callback = val; | 134 #define FROB(slot) \ |
133 else if (EQ (key, Q_callback_ex)) pgui_item->callback_ex = val; | 135 else if (EQ (key, Q_##slot)) \ |
134 else if (EQ (key, Q_value)) pgui_item->value = val; | 136 { \ |
137 if (!EQ (pgui_item->slot, val)) \ | |
138 { \ | |
139 retval = 1; \ | |
140 pgui_item->slot = val; \ | |
141 } \ | |
142 } | |
143 FROB (suffix) | |
144 FROB (active) | |
145 FROB (included) | |
146 FROB (config) | |
147 FROB (filter) | |
148 FROB (style) | |
149 FROB (selected) | |
150 FROB (keys) | |
151 FROB (callback) | |
152 FROB (callback_ex) | |
153 FROB (value) | |
154 #undef FROB | |
135 else if (EQ (key, Q_key_sequence)) ; /* ignored for FSF compatibility */ | 155 else if (EQ (key, Q_key_sequence)) ; /* ignored for FSF compatibility */ |
136 else if (EQ (key, Q_label)) ; /* ignored for 21.0 implement in 21.2 */ | 156 else if (EQ (key, Q_label)) ; /* ignored for 21.0 implement in 21.2 */ |
137 else if (EQ (key, Q_accelerator)) | 157 else if (EQ (key, Q_accelerator)) |
138 { | 158 { |
139 if (SYMBOLP (val) || CHARP (val)) | 159 if (!EQ (pgui_item->accelerator, val)) |
140 pgui_item->accelerator = val; | 160 { |
141 else if (ERRB_EQ (errb, ERROR_ME)) | 161 retval = 1; |
142 syntax_error ("Bad keyboard accelerator", val); | 162 if (SYMBOLP (val) || CHARP (val)) |
163 pgui_item->accelerator = val; | |
164 else if (ERRB_EQ (errb, ERROR_ME)) | |
165 syntax_error ("Bad keyboard accelerator", val); | |
166 } | |
143 } | 167 } |
144 else if (ERRB_EQ (errb, ERROR_ME)) | 168 else if (ERRB_EQ (errb, ERROR_ME)) |
145 syntax_error_2 ("Unknown keyword in gui item", key, | 169 syntax_error_2 ("Unknown keyword in gui item", key, |
146 pgui_item->name); | 170 pgui_item->name); |
171 return retval; | |
147 } | 172 } |
148 | 173 |
149 void | 174 void |
150 gui_item_init (Lisp_Object gui_item) | 175 gui_item_init (Lisp_Object gui_item) |
151 { | 176 { |
244 Lisp_Object val = contents [i++]; | 269 Lisp_Object val = contents [i++]; |
245 gui_item_add_keyval_pair (gui_item, key, val, errb); | 270 gui_item_add_keyval_pair (gui_item, key, val, errb); |
246 } | 271 } |
247 } | 272 } |
248 return gui_item; | 273 return gui_item; |
274 } | |
275 | |
276 /* This will only work with descriptors in the new format. */ | |
277 Lisp_Object | |
278 widget_gui_parse_item_keywords (Lisp_Object item) | |
279 { | |
280 int i, length; | |
281 Lisp_Object *contents; | |
282 Lisp_Object gui_item = allocate_gui_item (); | |
283 Lisp_Object desc = find_keyword_in_vector (item, Q_descriptor); | |
284 | |
285 CHECK_VECTOR (item); | |
286 length = XVECTOR_LENGTH (item); | |
287 contents = XVECTOR_DATA (item); | |
288 | |
289 if (!NILP (desc) && !STRINGP (desc) && !VECTORP (desc)) | |
290 syntax_error ("Invalid GUI item descriptor", item); | |
291 | |
292 if (length & 1) | |
293 { | |
294 if (!SYMBOLP (contents [0])) | |
295 syntax_error ("Invalid GUI item descriptor", item); | |
296 contents++; /* Ignore the leading symbol. */ | |
297 length--; | |
298 } | |
299 | |
300 for (i = 0; i < length;) | |
301 { | |
302 Lisp_Object key = contents [i++]; | |
303 Lisp_Object val = contents [i++]; | |
304 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME_NOT); | |
305 } | |
306 | |
307 return gui_item; | |
308 } | |
309 | |
310 /* Update a gui item from a partial descriptor. */ | |
311 int | |
312 update_gui_item_keywords (Lisp_Object gui_item, Lisp_Object item) | |
313 { | |
314 int i, length, retval = 0; | |
315 Lisp_Object *contents; | |
316 | |
317 CHECK_VECTOR (item); | |
318 length = XVECTOR_LENGTH (item); | |
319 contents = XVECTOR_DATA (item); | |
320 | |
321 if (length & 1) | |
322 { | |
323 if (!SYMBOLP (contents [0])) | |
324 syntax_error ("Invalid GUI item descriptor", item); | |
325 contents++; /* Ignore the leading symbol. */ | |
326 length--; | |
327 } | |
328 | |
329 for (i = 0; i < length;) | |
330 { | |
331 Lisp_Object key = contents [i++]; | |
332 Lisp_Object val = contents [i++]; | |
333 if (gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME_NOT)) | |
334 retval = 1; | |
335 } | |
336 return retval; | |
249 } | 337 } |
250 | 338 |
251 Lisp_Object | 339 Lisp_Object |
252 gui_parse_item_keywords (Lisp_Object item) | 340 gui_parse_item_keywords (Lisp_Object item) |
253 { | 341 { |
616 write_c_string ("#<gui-item ", printcharfun); | 704 write_c_string ("#<gui-item ", printcharfun); |
617 sprintf (buf, "0x%x>", g->header.uid); | 705 sprintf (buf, "0x%x>", g->header.uid); |
618 write_c_string (buf, printcharfun); | 706 write_c_string (buf, printcharfun); |
619 } | 707 } |
620 | 708 |
621 static Lisp_Object | 709 Lisp_Object |
622 copy_gui_item (Lisp_Object gui_item) | 710 copy_gui_item (Lisp_Object gui_item) |
623 { | 711 { |
624 Lisp_Object ret = allocate_gui_item (); | 712 Lisp_Object ret = allocate_gui_item (); |
625 Lisp_Gui_Item *lp, *g = XGUI_ITEM (gui_item); | 713 Lisp_Gui_Item *lp, *g = XGUI_ITEM (gui_item); |
626 | 714 |