]> git.lyx.org Git - lyx.git/blobdiff - src/insets/Inset.cpp
Change inset label from ": filename" to "Program Listing: filename" for listings...
[lyx.git] / src / insets / Inset.cpp
index cb689077e44c784f6a2e330fbfb6e9fb17daae61..d83fc6629ddc029ae2a6f23ae2a2e683ce9f073b 100644 (file)
@@ -33,6 +33,7 @@
 #include "frontends/Painter.h"
 #include "frontends/Application.h"
 
+#include "support/lassert.h"
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstream.h"
@@ -131,8 +132,9 @@ Buffer & Inset::buffer()
 {
        if (!buffer_) {
                odocstringstream s;
+               lyxerr << "LyX Code: " << lyxCode() << " name: " << name() << std::endl;
                s << "LyX Code: " << lyxCode() << " name: " << name();
-               BOOST_ASSERT(false);
+               LASSERT(false, /**/);
                throw ExceptionMessage(BufferException, 
                        from_ascii("Inset::buffer_ member not initialized!"), s.str());
        }
@@ -208,10 +210,18 @@ void Inset::dispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
-void Inset::doDispatch(Cursor & cur, FuncRequest &)
+void Inset::doDispatch(Cursor & cur, FuncRequest &cmd)
 {
-       cur.noUpdate();
-       cur.undispatched();
+       switch (cmd.action) {
+       case LFUN_INSET_TOGGLE:
+               edit(cur, true);
+               cur.dispatched();
+               break;
+       default:
+               cur.noUpdate();
+               cur.undispatched();
+               break;
+       }
 }
 
 
@@ -231,19 +241,25 @@ bool Inset::getStatus(Cursor &, FuncRequest const & cmd,
                // Allow modification of our data.
                // This needs to be handled in the doDispatch method of our
                // instantiatable children.
-               flag.enabled(true);
+               flag.setEnabled(true);
                return true;
 
        case LFUN_INSET_INSERT:
                // Don't allow insertion of new insets.
                // Every inset that wants to allow new insets from open
                // dialogs needs to override this.
-               flag.enabled(false);
+               flag.setEnabled(false);
+               return true;
+
+       case LFUN_INSET_TOGGLE:
+               // remove this if we dissociate toggle from edit.
+               flag.setEnabled(editable() == IS_EDITABLE);
                return true;
 
        default:
-               return false;
+               break;
        }
+       return false;
 }