]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetListings.cpp
Change inset label from ": filename" to "Program Listing: filename" for listings...
[lyx.git] / src / insets / InsetListings.cpp
index e74773d30b39f288ff3f09dea2604794addf3107..a2cb9851a40148092aa1b67baa144682e04a0c6a 100644 (file)
 #include <config.h>
 
 #include "InsetListings.h"
-#include "InsetCaption.h"
 
 #include "Buffer.h"
+#include "BufferView.h"
 #include "BufferParams.h"
 #include "Counters.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
+#include "InsetCaption.h"
 #include "InsetList.h"
 #include "Language.h"
 #include "MetricsInfo.h"
@@ -31,6 +32,8 @@
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
+#include "frontends/Application.h"
+
 #include <boost/regex.hpp>
 
 #include <sstream>
@@ -52,7 +55,7 @@ InsetListings::InsetListings(Buffer const & buf, InsetListingsParams const & par
 
 InsetListings::~InsetListings()
 {
-       InsetListingsMailer(*this).hideDialog();
+       hideDialogs("listings", this);
 }
 
 
@@ -97,7 +100,7 @@ void InsetListings::read(Lexer & lex)
 {
        while (lex.isOK()) {
                lex.next();
-               string const token = lex.getString();
+               string token = lex.getString();
                if (token == "lstparams") {
                        lex.next();
                        string const value = lex.getString();
@@ -154,7 +157,7 @@ int InsetListings::latex(odocstream & os, OutputParams const & runparams) const
                }
        }
        if (isInline) {
-                char const * delimiter = lstinline_delimiters;
+               char const * delimiter = lstinline_delimiters;
                for (; delimiter != '\0'; ++delimiter)
                        if (!contains(code, *delimiter))
                                break;
@@ -209,11 +212,11 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd)
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
-               InsetListingsMailer::string2params(to_utf8(cmd.argument()), params());
+               InsetListings::string2params(to_utf8(cmd.argument()), params());
                break;
        }
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetListingsMailer(*this).updateDialog(&cur.bv());
+               cur.bv().updateDialog("listings", params2string(params()));
                break;
        default:
                InsetCollapsable::doDispatch(cur, cmd);
@@ -225,13 +228,13 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd)
 bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd,
        FuncStatus & status) const
 {
-       LYXERR0("CURSOR SIZE: " << cur.depth());
        switch (cmd.action) {
+               case LFUN_INSET_MODIFY:
                case LFUN_INSET_DIALOG_UPDATE:
-                       status.enabled(true);
+                       status.setEnabled(true);
                        return true;
                case LFUN_CAPTION_INSERT:
-                       status.enabled(!params().isInline());
+                       status.setEnabled(!params().isInline());
                        return true;
                default:
                        return InsetCollapsable::getStatus(cur, cmd, status);
@@ -258,7 +261,8 @@ void InsetListings::validate(LaTeXFeatures & features) const
 
 bool InsetListings::showInsetDialog(BufferView * bv) const
 {
-       InsetListingsMailer(const_cast<InsetListings &>(*this)).showDialog(bv);
+       bv->showDialog("listings", params2string(params()),
+               const_cast<InsetListings *>(this));
        return true;
 }
 
@@ -302,27 +306,14 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const
 }
 
 
-string const InsetListingsMailer::name_("listings");
-
-InsetListingsMailer::InsetListingsMailer(InsetListings & inset)
-       : inset_(inset)
-{}
-
-
-string const InsetListingsMailer::inset2string(Buffer const &) const
-{
-       return params2string(inset_.params());
-}
-
-
-void InsetListingsMailer::string2params(string const & in,
+void InsetListings::string2params(string const & in,
                                   InsetListingsParams & params)
 {
        params = InsetListingsParams();
        if (in.empty())
                return;
        istringstream data(in);
-       Lexer lex(0, 0);
+       Lexer lex;
        lex.setStream(data);
        // discard "listings", which is only used to determine inset
        lex.next();
@@ -330,11 +321,10 @@ void InsetListingsMailer::string2params(string const & in,
 }
 
 
-string const
-InsetListingsMailer::params2string(InsetListingsParams const & params)
+string InsetListings::params2string(InsetListingsParams const & params)
 {
        ostringstream data;
-       data << name_ << " ";
+       data << "listings" << ' ';
        params.write(data);
        return data.str();
 }