]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Menubar_pimpl.C
28b757d1ae8246fadd440f6ecc8901f091f7c351
[lyx.git] / src / frontends / xforms / Menubar_pimpl.C
1 /* This file is part of
2 * ======================================================
3
4 *           LyX, The Document Processor
5 *        
6 *           Copyright (C) 1999 The LyX Team.
7 *
8 *======================================================*/
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <config.h>
15
16 #include <algorithm>
17 #include "support/lstrings.h"
18 #include "support/LAssert.h"
19 #include "debug.h"
20 #include "LyXAction.h"
21 #include "lyxfunc.h"
22 #include "kbmap.h"
23 #include "buffer.h"
24 #include "LyXView.h"
25 #include "MenuBackend.h"
26 #include "Menubar_pimpl.h"
27
28 using std::endl;
29 using std::vector;
30 using std::max;
31 using std::min;
32
33 typedef vector<int>::size_type size_type;
34
35 extern kb_keymap * toplevel_keymap;
36 extern LyXAction lyxaction;
37
38 // Some constants
39 static const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
40 static const int mheight = 30;
41 static const int mbheight= 22;
42 // where to place the menubar?
43 static const int yloc = (mheight - mbheight)/2; //air + bw;
44 static const int mbadd = 20; // menu button add (to width)
45 // Some space between buttons on the menubar 
46 static const int air = 2;
47 static char const * menu_tabstop = "aa";
48 static char const * default_tabstop = "aaaaaaaa";
49 // We do not want to mix position values in a menu (like the index of
50 // a submenu) with the action numbers which convey actual information.
51 // Therefore we offset all the action values by an arbitrary large
52 // constant. 
53 static const int action_offset = 1000;
54
55
56 //Defined later, used in makeMenubar().
57 extern "C"
58 void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button);
59
60 // This is used a few times below.
61 inline
62 int string_width(string const & str) 
63 {
64         return fl_get_string_widthTAB(FL_NORMAL_STYLE, MENU_LABEL_SIZE,
65                                       str.c_str(),
66                                       static_cast<int>(str.length()));
67 }
68
69
70 Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb) 
71         : owner_(view), menubackend_(&mb), current_group_(0)
72 {
73         for (MenuBackend::const_iterator menu = menubackend_->begin();
74             menu != menubackend_->end() ; ++menu) {
75                 if (menu->menubar()) {
76                         FL_OBJECT * group = fl_bgn_group();
77                         makeMenubar(*menu);
78                         fl_end_group();
79                         fl_hide_object(group);
80                         lyxerr[Debug::GUI]
81                                 << "Menubar::Pimpl::Pimpl: "
82                                 << "creating and hiding group " << group
83                                 << " for menubar " << menu->name() << endl;
84                         menubarmap_[menu->name()] = group;
85                 }
86         }
87 }
88
89
90 Menubar::Pimpl::~Pimpl() 
91 {
92         // Should we do something here?
93 }
94
95
96 void Menubar::Pimpl::makeMenubar(Menu const &menu)
97 {
98         FL_FORM * form = owner_->getForm(); 
99         int moffset = 0;
100
101         // Create menu frame if there is non yet.
102         FL_OBJECT * frame = fl_add_frame(FL_UP_FRAME, 0, 0,
103                                          form->w, mheight, "");
104         fl_set_object_resize(frame, FL_RESIZE_ALL);
105         fl_set_object_gravity(frame, NorthWestGravity, 
106                               NorthEastGravity);
107
108         for (Menu::const_iterator i = menu.begin(); 
109              i != menu.end(); ++i) {
110                 FL_OBJECT * obj;
111                 if (i->kind() != MenuItem::Submenu) {
112                         lyxerr << "ERROR: Menubar::Pimpl::createMenubar:"
113                                 " only submenus can appear in a menubar";
114                         break;
115                 }
116                 string label = i->label();
117                 string shortcut = "#" + i->shortcut();
118                 int width = string_width(label);
119                 obj = fl_add_button(FL_MENU_BUTTON,
120                                     air + moffset, yloc,
121                                     width + mbadd,
122                                     mbheight, 
123                                     label.c_str());
124                 fl_set_object_boxtype(obj, FL_FLAT_BOX);
125                 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
126                 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
127                 fl_set_object_lstyle(obj, FL_NORMAL_STYLE);
128                 fl_set_object_resize(obj, FL_RESIZE_ALL);
129                 fl_set_object_gravity(obj, NorthWestGravity, 
130                                       NorthWestGravity);
131                 moffset += obj->w + air;
132                 fl_set_object_shortcut(obj, shortcut.c_str(), 1);
133                 fl_set_object_callback(obj, C_Menubar_Pimpl_MenuCallback, 1);
134
135                 ItemInfo * iteminfo = new ItemInfo(this, 
136                                                    new MenuItem(*i), obj);
137                 buttonlist_.push_back(iteminfo);
138                 obj->u_vdata = iteminfo;
139         }
140
141 }
142
143 void Menubar::Pimpl::set(string const & menu_name) 
144 {
145         lyxerr[Debug::GUI] << "Entering Menubar::Pimpl::set " 
146                            << "for menu `" << menu_name << "'" << endl;
147
148         if (menu_name != current_menu_name_) {
149                 MenubarMap::iterator mbit = menubarmap_.find(menu_name);
150
151                 if (mbit == menubarmap_.end()) {
152                         lyxerr << "ERROR:set: Unknown menu `" << menu_name
153                                << "'" << endl;
154                         return;
155                 }
156
157                 if (current_group_) {
158                         lyxerr[Debug::GUI] << "  hiding group "
159                                            << current_group_ << endl;
160                         fl_hide_object(current_group_);
161                 }
162                 
163                 lyxerr[Debug::GUI] << "  showing group "
164                                    << mbit->second << endl;
165                 fl_show_object(mbit->second);
166                 current_menu_name_ = menu_name;
167                 current_group_ = mbit->second;
168                 lyxerr[Debug::GUI] << "Menubar::Pimpl::set: Menubar set."
169                                    << endl;
170         }
171         else
172                 lyxerr [Debug::GUI] << "Menubar::Pimpl::set: Nothing to do."
173                                     << endl;
174
175
176 void Menubar::Pimpl::openByName(string const & name)
177 {
178         if (menubackend_->getMenu(current_menu_name_).hasSubmenu(name)) {
179                 for (ButtonList::const_iterator cit = buttonlist_.begin();
180                      cit != buttonlist_.end(); ++cit) {
181                         if ((*cit)->item_->submenu() == name) {
182                                 MenuCallback((*cit)->obj_, 1);
183                                 return;
184                         }
185                 }
186         }
187         lyxerr << "Menubar::Pimpl::openByName: menu "
188                << name << " not found" << endl;
189 }
190
191
192 string limit_string_length(string const & str)
193 {
194         string::size_type const max_item_length = 45;
195
196         if (str.size() > max_item_length)
197                 return str.substr(0, max_item_length - 3) + "...";
198         else
199                 return str;
200 }
201
202
203 int get_new_submenu(vector<int> & smn, Window win)
204 {
205         static size_type max_number_of_menus = 32;
206         if (smn.size() >= max_number_of_menus)
207                 max_number_of_menus =
208                     fl_setpup_maxpup(static_cast<int>(2*smn.size()));
209         int menu = fl_newpup(win);
210         smn.push_back(menu);
211         return menu;
212 }
213
214 size_type const max_number_of_items = 25;
215
216 inline
217 string const fixlabel(string const & str)
218 {
219 #if FL_REVISION < 89
220         return subst(str, '%', '?');
221 #else
222         return subst(str, "%", "%%");
223 #endif
224 }
225
226 void add_toc2(int menu, string const & extra_label,
227               vector<int> & smn, Window win,
228               vector<Buffer::TocItem> const & toc_list,
229               size_type from, size_type to, int depth)
230 {
231         if (to - from <= max_number_of_items) {
232                 for (size_type i = from; i < to; ++i) {
233                         int action = lyxaction.
234                                 getPseudoAction(LFUN_GOTO_PARAGRAPH,
235                                                 tostr(toc_list[i].par->id()));
236                         string label(4 * max(0, toc_list[i].depth - depth),' ');
237                         label += fixlabel(toc_list[i].str);
238                         label = limit_string_length(label);
239                         label += "%x" + tostr(action + action_offset);
240                         if (i == to - 1 && depth == 0)
241                                 label += extra_label;
242                         fl_addtopup(menu, label.c_str());
243                 }
244         } else {
245                 size_type pos = from;
246                 size_type count = 0;
247                 while (pos < to) {
248                         ++count;
249                         if (count > max_number_of_items) {
250                                 int menu2 = get_new_submenu(smn, win);
251                                 add_toc2(menu2, extra_label, smn, win,
252                                          toc_list, pos, to, depth);
253                                 string label = _("More");
254                                 label += "...%m";
255                                 if (depth == 0)
256                                         label += extra_label;
257                                 fl_addtopup(menu, label.c_str(), menu2);
258                                 break;
259                         }
260                         size_type new_pos = pos+1;
261                         while (new_pos < to &&
262                                toc_list[new_pos].depth > depth)
263                                 ++new_pos;
264
265                         int action = lyxaction.
266                                 getPseudoAction(LFUN_GOTO_PARAGRAPH,
267                                                 tostr(toc_list[pos].par->id()));
268                         string label(4 * max(0, toc_list[pos].depth - depth), ' ');
269                         label += fixlabel(toc_list[pos].str);
270                         label = limit_string_length(label);
271                         if (new_pos == to && depth == 0)
272                                 label += extra_label;
273
274                         if (new_pos == pos + 1) {
275                                 label += "%x" + tostr(action + action_offset);
276                                 fl_addtopup(menu, label.c_str());
277                         } else {
278                                 int menu2 = get_new_submenu(smn, win);
279                                 add_toc2(menu2, extra_label, smn, win,
280                                          toc_list, pos, new_pos, depth+1);
281                                 label += "%m";
282                                 fl_addtopup(menu, label.c_str(), menu2);
283                         }
284                         pos = new_pos;
285                 }
286         }
287 }
288
289 void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
290                              vector<int> & smn, Window win)
291 {
292         //xgettext:no-c-format
293         static char const * MenuNames[3] = { N_("List of Figures%m"),
294         //xgettext:no-c-format
295                                              N_("List of Tables%m"),
296         //xgettext:no-c-format
297                                              N_("List of Algorithms%m") };
298
299         vector<vector<Buffer::TocItem> > toc_list =
300                 owner_->buffer()->getTocList();
301
302         // Handle LOF/LOT/LOA
303         int max_nonempty = 0;
304         for (int i = 1; i <= 3; ++i)
305                 if (!toc_list[i].empty())
306                         max_nonempty = i;
307
308         for (int j = 1; j <= 3; ++j)
309                 if (!toc_list[j].empty()) {
310                         int menu2 = get_new_submenu(smn, win);
311                         for (size_type i = 0; i < toc_list[j].size(); ++i) {
312                                 if (i > max_number_of_items) {
313                                         fl_addtopup(menu2, ". . .%d");
314                                         break;
315                                 }
316                                 int action = lyxaction.
317                                         getPseudoAction(LFUN_GOTO_PARAGRAPH,
318                                                         tostr(toc_list[j][i].par->id()));
319                                 string label = fixlabel(toc_list[j][i].str);
320                                 label = limit_string_length(label);
321                                 label += "%x" + tostr(action + action_offset);
322                                 fl_addtopup(menu2, label.c_str());
323                         }
324                         if (j == max_nonempty) {
325                                 string label = _(MenuNames[j - 1]);
326                                 label += "%l";
327                                 fl_addtopup(menu, label.c_str(), menu2);
328                         } else
329                                 fl_addtopup(menu, _(MenuNames[j - 1]), menu2);
330                 }
331
332         // Handle normal TOC
333         if (max_nonempty == 0 && toc_list[0].empty()) {
334                 fl_addtopup(menu,_("No Table of Contents%i"));
335                 return;
336         }
337
338         add_toc2(menu, extra_label, smn, win,
339                  toc_list[0], 0, toc_list[0].size(), 0);
340
341 }
342
343 void add_references2(int menu, vector<int> & smn, Window win,
344                      vector<string> const & label_list, string const & type)
345 {
346         size_type const max_number_of_items = 25;
347         size_type const max_number_of_items2 = 20;
348         string::size_type const max_item_length = 40;
349         string::size_type const max_item_length2 = 20;
350
351         if (label_list.size() <= max_number_of_items)
352                 for (size_type i = 0; i < label_list.size(); ++i) {
353                         int action = (type == "goto")
354                                 ? lyxaction.getPseudoAction(LFUN_REF_GOTO, 
355                                                             label_list[i])
356                                 : lyxaction.getPseudoAction(LFUN_REF_INSERT,
357                                                             type + "|++||++|"
358                                                             + label_list[i]);
359                         string label = label_list[i];
360                         if (label.size() > max_item_length)
361                                 label = label.substr(0, max_item_length-1) + "$";
362                         label += "%x" + tostr(action + action_offset);
363                         fl_addtopup(menu, label.c_str());
364                 }
365         else {
366                 size_type count = 0;
367                 for (size_type i = 0; i < label_list.size();
368                      i += max_number_of_items2) {
369                         ++count;
370                         if (count > max_number_of_items) {
371                                 fl_addtopup(menu, ". . .%d");
372                                 break;
373                         }
374                         size_type j = min(label_list.size(),
375                                           i+max_number_of_items2);
376
377                         string label;
378                         label += (label_list[i].size() > max_item_length2)
379                                 ? label_list[i].substr(0, max_item_length2-1) + "$"
380                                 : label_list[i];
381                         label += "..";
382                         label += (label_list[j-1].size() > max_item_length2)
383                                 ? label_list[j-1].substr(0, max_item_length2-1) + "$"
384                                 : label += label_list[j-1];
385
386                         int menu2 = get_new_submenu(smn, win);
387                         for (size_type k = i;  k < j; ++k) {
388                                 int action = (type == "goto")
389                                         ? lyxaction.getPseudoAction(LFUN_REF_GOTO, 
390                                                                     label_list[k])
391                                         : lyxaction.getPseudoAction(LFUN_REF_INSERT,
392                                                                     type + "|++||++|"
393                                                                     + label_list[k]);
394                                 string label2 = label_list[k];
395                                 if (label2.size() > max_item_length)
396                                         label2 = label2.substr(0, max_item_length-1) + "$";
397                                 label2 += "%x" + tostr(action + action_offset);
398                                 fl_addtopup(menu2, label2.c_str());
399                         }
400                         label += "%m";
401                         fl_addtopup(menu, label.c_str(), menu2);
402                 }
403         }
404 }
405
406
407 void Menubar::Pimpl::add_references(int menu, string const & extra_label,
408                                     vector<int> & smn, Window win)
409 {
410         //xgettext:no-c-format
411         static char const * MenuNames[6] = { N_("Insert Reference%m"),
412         //xgettext:no-c-format
413                                              N_("Insert Page Number%m"),
414         //xgettext:no-c-format
415                                              N_("Insert vref%m"),
416         //xgettext:no-c-format
417                                              N_("Insert vpageref%m"),
418         //xgettext:no-c-format
419                                              N_("Insert Pretty Ref%m"),
420         //xgettext:no-c-format
421                                              N_("Goto Reference%m") };
422
423         int const EMPTY = 1;
424         int const SGML = 2;
425         int const READONLY = 4;
426
427         static int MenuFlags[6] = {
428                 EMPTY | READONLY,
429                 EMPTY | READONLY,
430                 EMPTY | READONLY | SGML,
431                 EMPTY | READONLY | SGML,
432                 EMPTY | READONLY | SGML,
433                 EMPTY };
434
435         static string const MenuTypes[6] = {
436                 "ref", "pageref", "vref", "vpageref", "prettyref", "goto" };
437
438         vector<string> label_list = owner_->buffer()->getLabelList();
439
440         int flag = 0;
441         if (label_list.empty())
442                 flag += EMPTY;
443         if (owner_->buffer()->isSGML())
444                 flag += SGML;
445         if (owner_->buffer()->isReadonly())
446                 flag += READONLY;
447
448         int max_nonempty = -1;
449         for (int i = 0; i < 6; ++i)
450                 if ((MenuFlags[i] & flag) == 0)
451                         max_nonempty = i;
452
453         for (int i = 0; i < 6; ++i) {
454                 if ((MenuFlags[i] & flag) == 0) {
455                         string label = _(MenuNames[i]);
456                         if (i == max_nonempty)
457                                 label += extra_label;
458                         int menu2 = get_new_submenu(smn, win);
459                         add_references2(menu2, smn, win, label_list,
460                                         MenuTypes[i]);
461                         fl_addtopup(menu, label.c_str(), menu2);
462                 }
463         }
464 }
465
466
467 int Menubar::Pimpl::create_submenu(Window win, LyXView * view, 
468                                    string const & menu_name, 
469                                    vector<int> & smn) 
470 {
471         if (!menubackend_->hasMenu(menu_name)){ 
472                 lyxerr << "ERROR:create_submenu: Unknown menu `" 
473                        << menu_name << "'" << endl;
474                 return -1;
475         }
476         Menu md = Menu();
477         menubackend_->getMenu(menu_name).expand(md, owner_->buffer());
478
479         int menu = get_new_submenu(smn, win);
480         fl_setpup_softedge(menu, true);
481         fl_setpup_bw(menu, -1);
482         lyxerr[Debug::GUI] << "Adding menu " << menu 
483                            << " in deletion list" << endl;
484
485         // Compute the size of the largest label (because xforms is
486         // not able to support shortcuts correctly...)
487         int max_width = 0;
488         string widest_label;
489         Menu::const_iterator end = md.end();
490         for (Menu::const_iterator i = md.begin(); i != end; ++i) {
491                 MenuItem const & item = (*i);
492                 if (item.kind() == MenuItem::Command) {
493                         string label = item.label() + '\t';
494                         int width = string_width(label);
495                         if (width > max_width) {
496                                 max_width = width;
497                                 widest_label = label;
498                         }
499                 }
500         }
501         lyxerr[Debug::GUI] << "max_width=" << max_width 
502                            << ", widest_label=`" << widest_label 
503                            << "'" << endl;
504
505         // Compute where to put separators
506         vector<string> extra_labels(md.size());
507         vector<string>::iterator it = extra_labels.begin();
508         vector<string>::iterator last = it;
509         for (Menu::const_iterator i = md.begin(); i != end; ++i, ++it)
510                 if (i->kind() == MenuItem::Separator)
511                         *last = "%l";
512                 else if (!i->optional() ||
513                          !(view->getLyXFunc()->getStatus(i->action()) & LyXFunc::Disabled))
514                         last = it;
515
516         it = extra_labels.begin();
517         for (Menu::const_iterator i = md.begin(); i != end; ++i, ++it) {
518                 MenuItem const & item = (*i);
519                 string & extra_label = *it;
520
521                 switch (item.kind()) {
522                 case MenuItem::Command: {
523                         LyXFunc::func_status flag = 
524                                 view->getLyXFunc()->getStatus(item.action()); 
525
526                         // handle optional entries.
527                         if (item.optional() && (flag & LyXFunc::Disabled)) {
528                                 lyxerr[Debug::GUI] 
529                                         << "Skipping optional item " 
530                                         << item.label() << endl; 
531                                 break;
532                         }
533
534                         // Get the keys bound to this action, but keep only the
535                         // first one later
536                         string accel = toplevel_keymap->findbinding(item.action());
537                         // Build the menu label from all the info
538                         string label = item.label();
539
540                         if (!accel.empty()) {
541                                 // Try to be clever and add  just enough
542                                 // tabs to align shortcuts.
543                                 do 
544                                         label += '\t';
545                                 while (string_width(label) < max_width);
546                                 label += accel.substr(1,accel.find(']') - 1);
547                         }
548                         label += "%x" + tostr(item.action() + action_offset)
549                                 + extra_label;
550                         
551                         // Modify the entry using the function status
552                         string pupmode;
553                         if (flag & (LyXFunc::Disabled | LyXFunc::Unknown))
554                                 pupmode += "%i";
555                         if (flag & LyXFunc::ToggleOn)
556                                 pupmode += "%B";
557                         if (flag & LyXFunc::ToggleOff)
558                                 pupmode += "%b";
559                         label += pupmode;
560
561                         // Finally the menu shortcut
562                         string shortcut = item.shortcut();
563
564                         if (!shortcut.empty()) {
565                                 shortcut += lowercase(shortcut[0]);
566                                 label += "%h";
567                                 fl_addtopup(menu, label.c_str(), 
568                                             shortcut.c_str());
569                         } else
570                                 fl_addtopup(menu, label.c_str());
571                         
572                         lyxerr[Debug::GUI] << "Command: \""  
573                                            << lyxaction.getActionName(item.action())
574                                            << "\", binding \"" << accel
575                                            << "\", shortcut \"" << shortcut 
576                                            << "\"" << endl;
577                         break;
578                 }
579
580                 case MenuItem::Submenu: {
581                         int submenu = create_submenu(win, view, 
582                                                      item.submenu(), smn);
583                         if (submenu == -1)
584                                 return -1;
585                         string label = item.label();
586                         label += extra_label + "%m";
587                         string shortcut = item.shortcut();
588                         if (!shortcut.empty()) {
589                                 shortcut += lowercase(shortcut[0]);
590                                 label += "%h";
591                                 fl_addtopup(menu, label.c_str(),
592                                             submenu, shortcut.c_str());
593                         }
594                         else {
595                                 fl_addtopup(menu, label.c_str(), submenu);
596                         }
597                         break;
598                 }
599
600                 case MenuItem::Separator:
601                         // already done, and if it was the first one,
602                         // we just ignore it.
603                         break;
604
605                 case MenuItem::Toc:
606                         add_toc(menu, extra_label, smn, win);
607                         break;
608
609                 case MenuItem::References:
610                         add_references(menu, extra_label, smn, win);
611                         break;
612
613                 case MenuItem::Documents: 
614                 case MenuItem::Lastfiles: 
615                 case MenuItem::ViewFormats:
616                 case MenuItem::UpdateFormats:
617                 case MenuItem::ExportFormats:
618                 case MenuItem::ImportFormats:
619                         lyxerr << "Menubar::Pimpl::create_submenu: "
620                                 "this should not happen" << endl;
621                         break;
622
623                 }
624         }
625         return menu;
626 }
627
628 extern "C"
629 void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button)
630 {
631         Menubar::Pimpl::MenuCallback(ob, button);
632 }
633
634
635 void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
636 {
637         ItemInfo * iteminfo = static_cast<ItemInfo *>(ob->u_vdata);
638 //      lyxerr << "MenuCallback: ItemInfo address=" << iteminfo
639 //             << "Val=(pimpl_=" << iteminfo->pimpl_
640 //             << ", item_=" << iteminfo->item_
641 //             << ", obj_=" << iteminfo->obj_ << ")" <<endl;
642
643         LyXView * view = iteminfo->pimpl_->owner_;
644         MenuItem const * item = iteminfo->item_;
645
646         if (button == 1) {
647                 // set the pseudo menu-button
648                 fl_set_object_boxtype(ob, FL_DOWN_BOX);
649                 fl_set_button(ob, 0);
650                 fl_redraw_object(ob);
651         }
652
653         // Paranoia check
654         Assert(item->kind() == MenuItem::Submenu);
655         
656         // set tabstop length
657         fl_set_tabstop(menu_tabstop);
658         vector<int> submenus;
659         int menu = iteminfo->pimpl_->
660                 create_submenu(FL_ObjWin(ob), view, 
661                                item->submenu(), submenus);
662         if (menu != -1) {
663                 // place popup
664                 fl_setpup_position(view->getForm()->x + ob->x,
665                                    view->getForm()->y + ob->y + ob->h + 10);   
666                 int choice = fl_dopup(menu);
667                 
668                 if (button == 1) {
669                                 // set the pseudo menu-button back
670                         fl_set_object_boxtype(ob, FL_FLAT_BOX);
671                         fl_redraw_object(ob);
672                 }
673
674                 // If the action value is too low, then it is not a
675                 // valid action, but something else.
676                 if (choice >= action_offset + 1) {
677                         view->getLyXFunc()->Dispatch(choice - action_offset);
678                 }
679                 else {
680                         lyxerr[Debug::GUI]
681                                 << "MenuCallback: ignoring bogus action "
682                                 << choice << endl;
683                 }
684         }
685         else 
686                 lyxerr << "Error in MenuCallback" << endl;
687         
688         std::for_each(submenus.begin(), submenus.end(), fl_freepup);
689         // restore tabstop length
690         fl_set_tabstop(default_tabstop);
691
692 }