comparison src/menubar.c @ 418:e804706bfb8c r21-2-17

Import from CVS: tag r21-2-17
author cvs
date Mon, 13 Aug 2007 11:23:13 +0200
parents 697ef44129c6
children 11054d720c21
comparison
equal deleted inserted replaced
417:43a18b32d56e 418:e804706bfb8c
100 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); 100 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
101 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer); 101 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
102 } 102 }
103 103
104 Lisp_Object 104 Lisp_Object
105 menu_parse_submenu_keywords (Lisp_Object desc, struct gui_item* pgui_item) 105 menu_parse_submenu_keywords (Lisp_Object desc, Lisp_Object gui_item)
106 { 106 {
107 struct Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
108
107 /* Menu descriptor should be a list */ 109 /* Menu descriptor should be a list */
108 CHECK_CONS (desc); 110 CHECK_CONS (desc);
109 111
110 /* First element may be menu name, although can be omitted. 112 /* First element may be menu name, although can be omitted.
111 Let's think that if stuff begins with anything than a keyword 113 Let's think that if stuff begins with anything than a keyword
128 CHECK_CONS (desc); 130 CHECK_CONS (desc);
129 val = XCAR (desc); 131 val = XCAR (desc);
130 desc = XCDR (desc); 132 desc = XCDR (desc);
131 if (!NILP (desc)) 133 if (!NILP (desc))
132 CHECK_CONS (desc); 134 CHECK_CONS (desc);
133 gui_item_add_keyval_pair (pgui_item, key, val, ERROR_ME); 135 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME);
134 } 136 }
135 137
136 /* Return the rest - supposed to be a list of items */ 138 /* Return the rest - supposed to be a list of items */
137 return desc; 139 return desc;
138 } 140 }
150 */ 152 */
151 (desc, path)) 153 (desc, path))
152 { 154 {
153 Lisp_Object path_entry, submenu_desc, submenu; 155 Lisp_Object path_entry, submenu_desc, submenu;
154 struct gcpro gcpro1; 156 struct gcpro gcpro1;
155 struct gui_item gui_item; 157 Lisp_Object gui_item = allocate_gui_item ();
156 158 struct Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
157 gui_item_init (&gui_item); 159
158 GCPRO_GUI_ITEM (&gui_item); 160 GCPRO1 (gui_item);
159 161
160 EXTERNAL_LIST_LOOP (path_entry, path) 162 EXTERNAL_LIST_LOOP (path_entry, path)
161 { 163 {
162 /* Verify that DESC describes a menu, not single item */ 164 /* Verify that DESC describes a menu, not single item */
163 if (!CONSP (desc)) 165 if (!CONSP (desc))
164 RETURN_UNGCPRO (Qnil); 166 RETURN_UNGCPRO (Qnil);
165 167
166 /* Parse this menu */ 168 /* Parse this menu */
167 desc = menu_parse_submenu_keywords (desc, &gui_item); 169 desc = menu_parse_submenu_keywords (desc, gui_item);
168 170
169 /* Check that this (sub)menu is active */ 171 /* Check that this (sub)menu is active */
170 if (!gui_item_active_p (&gui_item)) 172 if (!gui_item_active_p (gui_item))
171 RETURN_UNGCPRO (Qnil); 173 RETURN_UNGCPRO (Qnil);
172 174
173 /* Apply :filter */ 175 /* Apply :filter */
174 if (!NILP (gui_item.filter)) 176 if (!NILP (pgui_item->filter))
175 desc = call1 (gui_item.filter, desc); 177 desc = call1 (pgui_item->filter, desc);
176 178
177 /* Find the next menu on the path inside this one */ 179 /* Find the next menu on the path inside this one */
178 EXTERNAL_LIST_LOOP (submenu_desc, desc) 180 EXTERNAL_LIST_LOOP (submenu_desc, desc)
179 { 181 {
180 submenu = XCAR (submenu_desc); 182 submenu = XCAR (submenu_desc);
189 /* Submenu not found */ 191 /* Submenu not found */
190 RETURN_UNGCPRO (Qnil); 192 RETURN_UNGCPRO (Qnil);
191 193
192 descend: 194 descend:
193 /* Prepare for the next iteration */ 195 /* Prepare for the next iteration */
194 gui_item_init (&gui_item); 196 gui_item_init (gui_item);
195 } 197 }
196 198
197 /* We have successfully descended down the end of the path */ 199 /* We have successfully descended down the end of the path */
198 UNGCPRO; 200 UNGCPRO;
199 return desc; 201 return desc;