Mercurial > hg > xemacs-beta
comparison src/gui.c @ 259:11cf20601dec r20-5b28
Import from CVS: tag r20-5b28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:23:02 +0200 |
parents | 677f6a0ee643 |
children | c5d627a313b1 |
comparison
equal
deleted
inserted
replaced
258:58424f6abf56 | 259:11cf20601dec |
---|---|
1 /* Generic GUI code. (menubars, scrollbars, toolbars, dialogs) | 1 /* Generic GUI code. (menubars, scrollbars, toolbars, dialogs) |
2 Copyright (C) 1995 Board of Trustees, University of Illinois. | 2 Copyright (C) 1995 Board of Trustees, University of Illinois. |
3 Copyright (C) 1995, 1996 Ben Wing. | 3 Copyright (C) 1995, 1996 Ben Wing. |
4 Copyright (C) 1995 Sun Microsystems, Inc. | 4 Copyright (C) 1995 Sun Microsystems, Inc. |
5 Copyright (C) 1998 Free Software Foundation, Inc. | |
5 | 6 |
6 This file is part of XEmacs. | 7 This file is part of XEmacs. |
7 | 8 |
8 XEmacs is free software; you can redistribute it and/or modify it | 9 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 under the terms of the GNU General Public License as published by the |
128 | 129 |
129 CHECK_VECTOR (item); | 130 CHECK_VECTOR (item); |
130 length = XVECTOR_LENGTH (item); | 131 length = XVECTOR_LENGTH (item); |
131 contents = XVECTOR_DATA (item); | 132 contents = XVECTOR_DATA (item); |
132 | 133 |
133 if (length < 3) | 134 if (length < 2) |
134 signal_simple_error ("GUI item descriptors must be at least 3 elts long", item); | 135 signal_simple_error ("GUI item descriptors must be at least 2 elts long", item); |
135 | 136 |
136 /* length 3: [ "name" callback active-p ] | 137 /* length 2: [ "name" callback ] |
138 length 3: [ "name" callback active-p ] | |
137 length 4: [ "name" callback active-p suffix ] | 139 length 4: [ "name" callback active-p suffix ] |
138 or [ "name" callback keyword value ] | 140 or [ "name" callback keyword value ] |
139 length 5+: [ "name" callback [ keyword value ]+ ] | 141 length 5+: [ "name" callback [ keyword value ]+ ] |
140 */ | 142 */ |
141 plist_p = (length >= 5 || KEYWORDP (contents [2])); | 143 plist_p = (length >= 5 || (length > 2 && KEYWORDP (contents [2]))); |
142 | 144 |
143 pgui_item->name = contents [0]; | 145 pgui_item->name = contents [0]; |
144 pgui_item->callback = contents [1]; | 146 pgui_item->callback = contents [1]; |
145 | 147 |
146 if (!plist_p) | 148 if (!plist_p && length > 2) |
147 /* the old way */ | 149 /* the old way */ |
148 { | 150 { |
149 pgui_item->active = contents [2]; | 151 pgui_item->active = contents [2]; |
150 if (length == 4) | 152 if (length == 4) |
151 pgui_item->suffix = contents [3]; | 153 pgui_item->suffix = contents [3]; |
232 signal_too_long_error (pgui_item->name); | 234 signal_too_long_error (pgui_item->name); |
233 strcpy (buf, XSTRING_DATA (pgui_item->name)); | 235 strcpy (buf, XSTRING_DATA (pgui_item->name)); |
234 buf += (consumed = XSTRING_LENGTH (pgui_item->name)); | 236 buf += (consumed = XSTRING_LENGTH (pgui_item->name)); |
235 buf_len -= consumed; | 237 buf_len -= consumed; |
236 | 238 |
237 /* Add space and suffix text, if there is a suffix */ | 239 /* Add space and suffix, if there is a suffix. |
240 * If suffix is not string evaluate it */ | |
238 if (!NILP (pgui_item->suffix)) | 241 if (!NILP (pgui_item->suffix)) |
239 { | 242 { |
240 if (XSTRING_LENGTH (pgui_item->suffix) + 1 > buf_len) | 243 Lisp_Object suffix2; |
244 | |
245 /* Shortcut to avoid evaluating suffix each time */ | |
246 if (STRINGP (pgui_item->suffix)) | |
247 suffix2 = pgui_item->suffix; | |
248 else | |
249 { | |
250 suffix2 = Feval (pgui_item->suffix); | |
251 CHECK_STRING (suffix2); | |
252 } | |
253 | |
254 if (XSTRING_LENGTH (suffix2) + 1 > buf_len) | |
241 signal_too_long_error (pgui_item->name); | 255 signal_too_long_error (pgui_item->name); |
242 *(buf++) = ' '; | 256 *(buf++) = ' '; |
243 strcpy (buf, XSTRING_DATA (pgui_item->suffix)); | 257 strcpy (buf, XSTRING_DATA (suffix2)); |
244 consumed += XSTRING_LENGTH (pgui_item->suffix) + 1; | 258 consumed += XSTRING_LENGTH (suffix2) + 1; |
245 } | 259 } |
246 | 260 |
247 return consumed; | 261 return consumed; |
248 } | 262 } |
249 | 263 |