X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormTexinfo.C;h=98677ef2ce703776f2c2b5a200f43ff7dea1cb93;hb=d5443737342903de489d527802cd2cdd38987d74;hp=08d664f46668e4955cded1975b33096a1c5df957;hpb=4c16922aad0477028c3725e115f369cbe9f7718f;p=lyx.git diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index 08d664f466..98677ef2ce 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -3,32 +3,34 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Herbert Voss + * \author Herbert Voß * - * Full author contact details are available in file CREDITS - * \date 2001-10-01 + * Full author contact details are available in file CREDITS. */ #include -#include - -#include "xformsBC.h" #include "FormTexinfo.h" #include "forms/form_texinfo.h" + #include "Tooltips.h" -#include "gettext.h" -#include "xforms_helpers.h" -#include "support/LAssert.h" -#include "support/lstrings.h" +#include "xformsBC.h" + +#include "support/filetools.h" #include "lyx_forms.h" -using std::vector; +using std::string; + +namespace lyx { + +namespace frontend { + -typedef FormCB > base_class; -FormTexinfo::FormTexinfo() - : base_class(_("LaTeX Information")), +typedef FormController > base_class; + +FormTexinfo::FormTexinfo(Dialog & parent) + : base_class(parent, _("TeX Information")), activeStyle(ControlTexinfo::cls) {} @@ -37,7 +39,8 @@ void FormTexinfo::build() { dialog_.reset(build_texinfo(this)); // callback for double click in browser to view the selected file - fl_set_browser_dblclick_callback(dialog_->browser, C_FormBaseInputCB, 2); + fl_set_browser_dblclick_callback(dialog_->browser, + C_FormDialogView_InputCB, 2); string const classes_List = _("LaTeX classes|LaTeX styles|BibTeX styles"); fl_addto_choice(dialog_->choice_classes, classes_List.c_str()); @@ -52,7 +55,7 @@ void FormTexinfo::build() { str = _("Show full path or only file name."); tooltips().init(dialog_->check_fullpath, str); - str = _("Runs the script \"TexFiles.sh\" to build new file lists."); + str = _("Runs the script \"TexFiles.sh\" to rebuild the file lists."); tooltips().init(dialog_->button_rescan, str); str = _("Double click to view contents of file."); @@ -74,40 +77,30 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) { if (ob == dialog_->button_texhash) { // makes only sense if the rights are set well for // users (/var/lib/texmf/ls-R) - controller().runTexhash(); + texhash(); // texhash requires a rescan and an update of the styles - controller().rescanStyles(); + rescanTexStyles(); updateStyles(activeStyle); } else if (ob == dialog_->browser && ob_value == 2) { // double click in browser: view selected file - string selection = getString(dialog_->browser); - if (!fl_get_button(dialog_->check_fullpath)) { - // contents in browser has filenames without path - // reconstruct path from controller getContents - string const files = controller().getContents(activeStyle, true); - vector const vec = getVectorFromString(files, "\n"); - - // find line in files vector - vector::const_iterator it = vec.begin(); - for (; it != vec.end(); ++it) { - if ((*it).find(selection) != string::npos) { - selection = *it; - break; - } - } - } - if (!selection.empty()) { - controller().viewFile(selection); - } - - // reset the browser so that the following single-click callback doesn't do anything + ContentsType::size_type const sel = fl_get_browser(ob); + ContentsType const & data = texdata_[activeStyle]; + string file = data[sel-1]; + if (!fl_get_button(dialog_->check_fullpath)) + file = getTexFileFromList(data[sel-1], + controller().getFileType(activeStyle)); + if (sel >= 1 && sel <= data.size()) + controller().viewFile(file); + + // reset the browser so that the following single-click + // callback doesn't do anything fl_deselect_browser(dialog_->browser); } else if (ob == dialog_->button_rescan) { // build new *Files.lst - controller().rescanStyles(); + rescanTexStyles(); updateStyles(activeStyle); } else if (ob == dialog_->check_fullpath) { @@ -133,13 +126,18 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) { void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) { - fl_clear_browser(dialog_->browser); - + ContentsType & data = texdata_[whichStyle]; bool const withFullPath = fl_get_button(dialog_->check_fullpath); + getTexFileList(whichStyle, data, withFullPath); - string const str = - controller().getContents(whichStyle, withFullPath); - fl_add_browser_line(dialog_->browser, str.c_str()); + fl_clear_browser(dialog_->browser); + ContentsType::const_iterator it = data.begin(); + ContentsType::const_iterator end = data.end(); + for (; it != end; ++it) + fl_add_browser_line(dialog_->browser, (*it).c_str()); activeStyle = whichStyle; } + +} // namespace frontend +} // namespace lyx