]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Toolbar_pimpl.C
fix crash with "save as"
[lyx.git] / src / frontends / xforms / Toolbar_pimpl.C
index 9dcad9f7384af7f7a46ce5693e05408e3c31797e..a0cce76e104f2bbafac61ba48163d6e3a91bb789 100644 (file)
@@ -1,11 +1,13 @@
 /**
- * \file Toolbar_pimpl.C
+ * \file xforms/Toolbar_pimpl.C
  * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
  * Copyright 1996-1998 Lars Gullik Bjønnes
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes, larsbj@lyx.org
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 //  Added pseudo-action handling, asierra 180296
@@ -23,7 +25,6 @@
 #include "FuncStatus.h"
 #include "buffer.h"
 #include "funcrequest.h"
-#include "MathsSymbols.h"
 #include "gettext.h"
 #include "Tooltips.h"
 #include FORMS_H_LOCATION
@@ -166,7 +167,7 @@ void Toolbar::Pimpl::layoutSelected()
        for (LyXTextClass::const_iterator cit = tc.begin();
             cit != end; ++cit) {
                if (_((*cit)->name()) == layoutguiname) {
-                       owner_->getLyXFunc().dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()));
+                       owner_->getLyXFunc().dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()), true);
                        return;
                }
        }
@@ -245,7 +246,7 @@ extern "C" {
 }
 
 
-void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
+void setPixmap(FL_OBJECT * obj, int action)
 {
        string xpm_name;
        FuncRequest ev = lyxaction.retrieveActionArg(action);
@@ -258,6 +259,11 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
 
        string fullname = LibFileSearch("images", xpm_name, "xpm");
 
+       if (ev.action == LFUN_INSERT_MATH && !ev.argument.empty()) {
+               string arg = ev.argument.substr(1);
+               fullname = LibFileSearch("images/math/", arg, "xpm");
+       }
        if (!fullname.empty()) {
                lyxerr[Debug::GUI] << "Full icon name is `"
                                   << fullname << "'" << endl;
@@ -265,19 +271,6 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
                return;
        }
 
-       if (ev.action == LFUN_INSERT_MATH && !ev.argument.empty()) {
-               char const ** pixmap = get_pixmap_from_symbol(ev.argument.c_str(),
-                                                             buttonwidth,
-                                                             height);
-               if (pixmap) {
-                       lyxerr[Debug::GUI] << "Using mathed-provided icon"
-                                          << endl;
-                       fl_set_pixmapbutton_data(obj,
-                                                const_cast<char **>(pixmap));
-                       return;
-               }
-       }
-
        lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
        fullname = LibFileSearch("images", "unknown", "xpm");
        if (!fullname.empty()) {
@@ -337,7 +330,7 @@ void Toolbar::Pimpl::add(int action)
                // The view that this object belongs to.
                obj->u_vdata = owner_;
 
-               setPixmap(obj, action, buttonwidth, height);
+               setPixmap(obj, action);
                // we must remember to update the positions
                xpos += buttonwidth;
                // ypos is constant