]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetexternal.C
My patch from yesterday
[lyx.git] / src / insets / insetexternal.C
index 02e94a059df18041c1372505ac77f5ef816ca837..fd5fe30017f1c40deb2e1380df6d4912eb95d9e1 100644 (file)
@@ -64,17 +64,36 @@ InsetExternal::Params const & InsetExternal::params() const
 
 dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
 {
-       if (cmd.action != LFUN_INSET_MODIFY)
-               return UNDISPATCHED;
+       dispatch_result result = UNDISPATCHED;
 
-       InsetExternal::Params p;
-       InsetExternalMailer::string2params(cmd.argument, p);
-       if (p.filename.empty())
-               return UNDISPATCHED;
+       switch (cmd.action) {
+       case LFUN_INSET_MODIFY: {
+               InsetExternal::Params p;
+               InsetExternalMailer::string2params(cmd.argument, p);
+               if (p.filename.empty())
+                       break;
+
+               setFromParams(p);
+               cmd.view()->updateInset(this);
+               result = DISPATCHED;
+       }
+       break;
+
+       case LFUN_INSET_DIALOG_UPDATE: {
+               InsetExternalMailer mailer(*this);
+               mailer.updateDialog(cmd.view());
+       }
+       break;
 
-       setFromParams(p);
-       cmd.view()->updateInset(this, true);
-       return DISPATCHED;
+       case LFUN_MOUSE_RELEASE:
+               edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+               break;
+
+       default:
+               break;
+       }
+
+       return result;
 }
 
 
@@ -92,10 +111,10 @@ string const InsetExternal::editMessage() const
 }
 
 
-void InsetExternal::edit(BufferView *, int, int, mouse_button::state)
+void InsetExternal::edit(BufferView * bv, int, int, mouse_button::state)
 {
        InsetExternalMailer mailer(*this);
-       mailer.showDialog();
+       mailer.showDialog(bv);
 }
 
 
@@ -344,22 +363,6 @@ void InsetExternal::editExternal() const
 }
 
 
-bool operator==(InsetExternal::Params const & left,
-               InsetExternal::Params const & right)
-{
-       return ((left.filename   == right.filename) &&
-               (left.parameters == right.parameters) &&
-               (left.templ.lyxName == right.templ.lyxName));
-}
-
-
-bool operator!=(InsetExternal::Params const & left,
-               InsetExternal::Params const & right)
-{
-       return  !(left == right);
-}
-
-
 string const InsetExternalMailer::name_("external");
 
 InsetExternalMailer::InsetExternalMailer(InsetExternal & inset)
@@ -398,9 +401,11 @@ void InsetExternalMailer::string2params(string const & in,
                        return;
        }
 
-       InsetExternal inset;    
-       inset.read(0, lex);
-       params = inset.params();
+       if (lex.isOK()) {
+               InsetExternal inset;    
+               inset.read(0, lex);
+               params = inset.params();
+       }
 }