]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetNote.cpp
Cleanup mouse/selection/context-menu interactions.
[lyx.git] / src / insets / InsetNote.cpp
index 11b37a0f6320f994d5249593bac717c49d15de27..624ff4ca2ac57c574aa54a2742dc5feae2195272 100644 (file)
@@ -106,30 +106,25 @@ void InsetNoteParams::read(Lexer & lex)
 }
 
 
-InsetNote::InsetNote(BufferParams const & bp, string const & label)
-       : InsetCollapsable(bp)
+/////////////////////////////////////////////////////////////////////
+//
+// InsetNode
+//
+/////////////////////////////////////////////////////////////////////
+
+InsetNote::InsetNote(Buffer const & buf, string const & label)
+       : InsetCollapsable(buf)
 {
        params_.type = notetranslator().find(label);
 }
 
 
-InsetNote::InsetNote(InsetNote const & in)
-       : InsetCollapsable(in), params_(in.params_)
-{}
-
-
 InsetNote::~InsetNote()
 {
        InsetNoteMailer(*this).hideDialog();
 }
 
 
-Inset * InsetNote::clone() const
-{
-       return new InsetNote(*this);
-}
-
-
 docstring InsetNote::editMessage() const
 {
        return _("Opened Note Inset");
@@ -202,6 +197,16 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY:
+               // disallow comment and greyed out in commands
+               flag.enabled(!cur.paragraph().layout().isCommand() ||
+                               cmd.getArg(2) == "Note");
+               if (cmd.getArg(0) == "note") {
+                       InsetNoteParams params;
+                       InsetNoteMailer::string2params(to_utf8(cmd.argument()), params);
+                       flag.setOnOff(params_.type == params.type);
+               }
+               return true;
+
        case LFUN_INSET_DIALOG_UPDATE:
                flag.enabled(true);
                return true;
@@ -211,9 +216,10 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
        }
 }
 
+
 void InsetNote::updateLabels(ParIterator const & it)
 {
-       TextClass const & tclass = buffer().params().textClass();
+       DocumentClass const & tclass = buffer().params().documentClass();
        Counters savecnt = tclass.counters();
        InsetCollapsable::updateLabels(it);
        tclass.counters() = savecnt;
@@ -335,6 +341,11 @@ void InsetNote::validate(LaTeXFeatures & features) const
 }
 
 
+docstring InsetNote::contextMenu(BufferView const &, int, int) const
+{
+       return from_ascii("context-note");
+}
+
 
 string const InsetNoteMailer::name_("note");
 
@@ -380,7 +391,7 @@ void InsetNoteMailer::string2params(string const & in,
        string id;
        lex >> id;
        if (!lex || id != "Note")
-               return print_mailer_error("InsetBoxMailer", in, 2, "Note");
+               return print_mailer_error("InsetNoteMailer", in, 2, "Note");
 
        params.read(lex);
 }