]> git.lyx.org Git - features.git/commitdiff
Transfer LFUN_CITATION_INSERT to BufferView
authorAbdelrazak Younes <younes@lyx.org>
Sat, 26 Sep 2009 17:30:29 +0000 (17:30 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 26 Sep 2009 17:30:29 +0000 (17:30 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31469 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/LyXFunc.cpp

index cce0932f98b1ca65de36864cd0f899e39cf2d01f..61a40a2eadf53555d2361e7004ed05dd7a8ada9f 100644 (file)
@@ -1146,6 +1146,14 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                flag.setEnabled(!cur.inset().getLayout().isPassThru());
                break;
 
+       case LFUN_CITATION_INSERT: {
+               FuncRequest fr(LFUN_INSET_INSERT, "citation");
+               // FIXME: This could turn in a recursive hell.
+               // Shouldn't we use Buffer::getStatus() instead?
+               flag.setEnabled(lyx::getStatus(fr).enabled());
+               break;
+       }
+
        default:
                flag.setEnabled(false);
                return false;
@@ -1790,6 +1798,31 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                break;
        }
 
+       case LFUN_CITATION_INSERT: {
+               if (argument.empty()) {
+                       lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
+                       break;
+               }
+               // we can have one optional argument, delimited by '|'
+               // citation-insert <key>|<text_before>
+               // this should be enhanced to also support text_after
+               // and citation style
+               string arg = argument;
+               string opt1;
+               if (contains(argument, "|")) {
+                       arg = token(argument, '|', 0);
+                       opt1 = token(argument, '|', 1);
+               }
+               InsetCommandParams icp(CITE_CODE);
+               icp["key"] = from_utf8(arg);
+               if (!opt1.empty())
+                       icp["before"] = from_utf8(opt1);
+               string icstr = InsetCommand::params2string("citation", icp);
+               FuncRequest fr(LFUN_INSET_INSERT, icstr);
+               lyx::dispatch(fr);
+               break;
+       }
+
        default:
                return false;
        }
index 2dda89129e4c6f54630e8e16c3202a50050106f4..3f4bd1481e65abb086f426e4037e003b6775b9c9 100644 (file)
@@ -58,8 +58,6 @@
 #include "Session.h"
 #include "SpellChecker.h"
 
-#include "insets/InsetCommand.h"
-
 #include "frontends/alert.h"
 #include "frontends/Application.h"
 #include "frontends/KeySymbol.h"
@@ -366,12 +364,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        bool enable = true;
        switch (cmd.action) {
 
-       case LFUN_CITATION_INSERT: {
-               FuncRequest fr(LFUN_INSET_INSERT, "citation");
-               enable = getStatus(fr).enabled();
-               break;
-       }
-       
        // This could be used for the no-GUI version. The GUI version is handled in
        // LyXView::getStatus(). See above.
        /*
@@ -579,31 +571,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        theServer().notifyClient(to_utf8(dispatch_buffer));
                        break;
 
-               case LFUN_CITATION_INSERT: {
-                       LASSERT(lv, /**/);
-                       if (!argument.empty()) {
-                               // we can have one optional argument, delimited by '|'
-                               // citation-insert <key>|<text_before>
-                               // this should be enhanced to also support text_after
-                               // and citation style
-                               string arg = argument;
-                               string opt1;
-                               if (contains(argument, "|")) {
-                                       arg = token(argument, '|', 0);
-                                       opt1 = token(argument, '|', 1);
-                               }
-                               InsetCommandParams icp(CITE_CODE);
-                               icp["key"] = from_utf8(arg);
-                               if (!opt1.empty())
-                                       icp["before"] = from_utf8(opt1);
-                               string icstr = InsetCommand::params2string("citation", icp);
-                               FuncRequest fr(LFUN_INSET_INSERT, icstr);
-                               dispatch(fr);
-                       } else
-                               dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
-                       break;
-               }
-
                case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
                        LASSERT(lv, /**/);
                        lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;