]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetlabel.C
fix #832
[lyx.git] / src / insets / insetlabel.C
index 015504e96bc41b3d99db5adfb06a91036f729650..128f4ac7f74df3584b0eb93c28efab87c87f1fb7 100644 (file)
@@ -45,51 +45,40 @@ vector<string> const InsetLabel::getLabelList() const
 }
 
 
-void InsetLabel::edit(BufferView *, int, int, mouse_button::state)
-{
-       InsetCommandMailer mailer("label", *this);
-       mailer.showDialog();
-}
-
-
 dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
 {
-       if (cmd.action != LFUN_INSET_MODIFY)
-               return UNDISPATCHED;
-
-       InsetCommandParams p;
-       InsetCommandMailer::string2params(cmd.argument, p);
-       if (p.getCmdName().empty())
-               return UNDISPATCHED;
-
-       bool clean = true;
-       if (view() && p.getContents() != params().getContents()) {
-               clean = view()->ChangeRefsIfUnique(params().getContents(),
-                                                  p.getContents());
+       Inset::RESULT result = UNDISPATCHED;
+
+       switch (cmd.action) {
+
+       case LFUN_INSET_EDIT:
+               InsetCommandMailer("label", *this).showDialog(cmd.view());
+               result = DISPATCHED;
+               break;
+
+       case LFUN_INSET_MODIFY: {
+               InsetCommandParams p;
+               InsetCommandMailer::string2params(cmd.argument, p);
+               if (p.getCmdName().empty())
+                       return UNDISPATCHED;
+
+               bool clean = true;
+               if (view() && p.getContents() != params().getContents()) {
+                       clean = view()->ChangeRefsIfUnique(params().getContents(),
+                                                          p.getContents());
+               }
+
+               setParams(p);
+               cmd.view()->updateInset(this);
+               result = DISPATCHED;
        }
+       break;
 
-       setParams(p);
-       if (view())
-               view()->updateInset(this, !clean);
-
-       return DISPATCHED;
-//     if (result.first) {
-//             string new_contents = trim(result.second);
-//             if (!new_contents.empty() &&
-//                 getContents() != new_contents) {
-//                     bv->buffer()->markDirty();
-//                     bool flag = bv->ChangeRefsIfUnique(getContents(),
-//                                                        new_contents);
-//                     setContents(new_contents);
-//                     bv->updateInset(this, !flag);
-//             }
-//     }
-}
-
+       default:
+               result = InsetCommand::localDispatch(cmd);
+       }
 
-void InsetLabel::edit(BufferView * bv, bool)
-{
-       edit(bv, 0, 0, mouse_button::none);
+       return result;
 }
 
 
@@ -100,6 +89,7 @@ int InsetLabel::latex(Buffer const *, ostream & os,
        return 0;
 }
 
+
 int InsetLabel::ascii(Buffer const *, ostream & os, int) const
 {
        os << '<' << getContents()  << '>';