]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormCitation.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / FormCitation.C
index dee34c0f7fe8a53140ee21487958c89efb058b8a..87829f432463bf81d1e434581be05c73feafabaf 100644 (file)
 #include "xforms_helpers.h"
 #include "xformsBC.h"
 
+#include "bufferparams.h"
+
 #include "support/lstrings.h"
 
 #include "lyx_forms.h"
 
-using lyx::support::getStringFromVector;
-using lyx::support::getVectorFromString;
-using lyx::support::trim;
-
 using std::find;
 using std::max;
 
 using std::vector;
+using std::string;
+
+
+namespace lyx {
+
+using support::getStringFromVector;
+using support::getVectorFromString;
+using support::trim;
 
+namespace frontend {
 
 namespace {
 
@@ -68,7 +75,7 @@ void updateStyle(FD_citation * dialog, string command)
        // Find the style of the citekeys
        vector<biblio::CiteStyle> const & styles =
                ControlCitation::getCiteStyles();
-       biblio::CitationStyle cs = biblio::getCitationStyle(command);
+       biblio::CitationStyle const cs(command);
 
        vector<biblio::CiteStyle>::const_iterator cit =
                find(styles.begin(), styles.end(), cs.style);
@@ -108,12 +115,18 @@ void FormCitation::apply()
                bool const force =
                        fl_get_button(dialog_->check_force_uppercase);
 
-               command = biblio::getCiteCommand(styles[choice], full, force);
+               command =
+                       biblio::CitationStyle(styles[choice], full, force)
+                       .asLatexStr();
+
        }
 
        controller().params().setCmdName(command);
        controller().params().setContents(getStringFromVector(citekeys));
 
+       string const before  = getString(dialog_->input_before);
+       controller().params().setSecOptions(before);
+
        string const after  = getString(dialog_->input_after);
        controller().params().setOptions(after);
 }
@@ -421,6 +434,10 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
                fl_set_choice(dialog_->choice_style, choice);
        }
 
+       // Invalid if no citation has been chosen
+       if (fl_get_browser_maxline(dialog_->browser_cite) < 1)
+               activate = ButtonPolicy::SMI_INVALID;
+
        return activate;
 }
 
@@ -445,10 +462,16 @@ void FormCitation::update()
        // Use the citation command to update the GUI
        updateStyle(dialog_.get(), controller().params().getCmdName());
 
-       bool const natbib = controller().usingNatbib();
-       setEnabled(dialog_->check_full_author_list, natbib);
-       setEnabled(dialog_->check_force_uppercase, natbib);
-       setEnabled(dialog_->choice_style, natbib);
+       biblio::CiteEngine const engine = controller().getEngine();
+       bool const natbib_engine =
+               engine == biblio::ENGINE_NATBIB_AUTHORYEAR ||
+               engine == biblio::ENGINE_NATBIB_NUMERICAL;
+       bool const basic_engine = engine == biblio::ENGINE_BASIC;
+
+       setEnabled(dialog_->check_full_author_list, natbib_engine);
+       setEnabled(dialog_->check_force_uppercase, natbib_engine);
+       setEnabled(dialog_->choice_style, !basic_engine);
+       setEnabled(dialog_->input_before, !basic_engine);
 
        // No keys have been selected yet, so...
        fl_clear_browser(dialog_->browser_info);
@@ -456,12 +479,11 @@ void FormCitation::update()
        setCiteButtons(OFF);
 
        // Natbib can have comments before and after the citation.
-       // This is not yet supported. After only.
        fl_set_input(dialog_->input_after,
                     controller().params().getOptions().c_str());
 
-       fl_set_input(dialog_->input_before, _("Not yet supported").c_str());
-       setEnabled(dialog_->input_before, false);
+       fl_set_input(dialog_->input_before,
+                    controller().params().getSecOptions().c_str());
 }
 
 
@@ -508,3 +530,6 @@ void FormCitation::setCiteButtons(State status) const
        setEnabled(dialog_->button_up,   activate_up);
        setEnabled(dialog_->button_down, activate_down);
 }
+
+} // namespace frontend
+} // namespace lyx