X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormTexinfo.C;h=98677ef2ce703776f2c2b5a200f43ff7dea1cb93;hb=d5443737342903de489d527802cd2cdd38987d74;hp=80f586b04c112ecfcdf334afecda13628fa1570e;hpb=25e82b07459282a13ac1fd00a9b58ba595c7b6a0;p=lyx.git diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index 80f586b04c..98677ef2ce 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -1,189 +1,143 @@ /** * \file FormTexinfo.C - * Copyright 2001 the LyX Team - * Read the file COPYING + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * \author Herbert Voss - * \date 2001-10-01 + * \author Herbert Voß + * + * Full author contact details are available in file CREDITS. */ #include -#include -#ifdef __GNUG__ -#pragma implementation -#endif +#include "FormTexinfo.h" +#include "forms/form_texinfo.h" +#include "Tooltips.h" #include "xformsBC.h" -#include "FormTexinfo.h" -#include "form_texinfo.h" -#include "gettext.h" -#include "debug.h" -#include "xforms_helpers.h" -#include "support/LAssert.h" - - -typedef FormCB > base_class; -FormTexinfo::FormTexinfo(ControlTexinfo & c) - : base_class(c, _("LaTeX Information")), - activeStyle(ControlTexinfo::cls) -{} +#include "support/filetools.h" -void FormTexinfo::build() { - dialog_.reset(build_texinfo()); - // courier medium - fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE); - // with Path is default - fl_set_button(dialog_->button_fullPath, 1); - updateStyles(ControlTexinfo::cls); - - setPrehandler(dialog_->button_rescan); - setPrehandler(dialog_->button_view); - setPrehandler(dialog_->button_texhash); - setPrehandler(dialog_->button_fullPath); - setPrehandler(dialog_->browser); - setPrehandler(dialog_->radio_cls); - setPrehandler(dialog_->radio_sty); - setPrehandler(dialog_->radio_bst); - setPrehandler(dialog_->message); - - setTooltipHandler(dialog_->button_rescan); - setTooltipHandler(dialog_->button_view); - setTooltipHandler(dialog_->button_texhash); - setTooltipHandler(dialog_->button_fullPath); - setTooltipHandler(dialog_->browser); - setTooltipHandler(dialog_->radio_cls); - setTooltipHandler(dialog_->radio_sty); - setTooltipHandler(dialog_->radio_bst); - setTooltipHandler(dialog_->message); -} +#include "lyx_forms.h" +using std::string; -ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) { +namespace lyx { - if (ob == dialog_->radio_cls) { - updateStyles(ControlTexinfo::cls); +namespace frontend { - } else if (ob == dialog_->radio_sty) { - updateStyles(ControlTexinfo::sty); - } else if (ob == dialog_->radio_bst) { - updateStyles(ControlTexinfo::bst); +typedef FormController > base_class; - } else if (ob == dialog_->button_rescan) { - // build new *Files.lst - controller().rescanStyles(); - updateStyles(activeStyle); +FormTexinfo::FormTexinfo(Dialog & parent) + : base_class(parent, _("TeX Information")), + activeStyle(ControlTexinfo::cls) +{} - } else if (ob == dialog_->button_fullPath) { - setEnabled(dialog_->button_view, - fl_get_button(dialog_->button_fullPath)); - updateStyles(activeStyle); - } else if (ob == dialog_->button_texhash) { - // makes only sense if the rights are set well for - // users (/var/lib/texmf/ls-R) - controller().runTexhash(); - // update files in fact of texhash - controller().rescanStyles(); - - } else if (ob == dialog_->button_view) { - unsigned int selection = fl_get_browser(dialog_->browser); - // a valid entry? - if (selection > 0) { - controller().viewFile( - fl_get_browser_line(dialog_->browser, - selection)); - } - } +void FormTexinfo::build() { + dialog_.reset(build_texinfo(this)); - return ButtonPolicy::SMI_VALID; -} + // callback for double click in browser to view the selected file + fl_set_browser_dblclick_callback(dialog_->browser, + C_FormDialogView_InputCB, 2); -void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) -{ - fl_clear_browser(dialog_->browser); + string const classes_List = _("LaTeX classes|LaTeX styles|BibTeX styles"); + fl_addto_choice(dialog_->choice_classes, classes_List.c_str()); - bool const withFullPath = fl_get_button(dialog_->button_fullPath); + updateStyles(activeStyle); - string const str = - controller().getContents(whichStyle, withFullPath); - fl_add_browser_line(dialog_->browser, str.c_str()); + // set up the tooltips + string str = _("Shows the installed classses and styles for LaTeX/BibTeX; " + "available only if the corresponding LyX layout file exists."); + tooltips().init(dialog_->choice_classes, str); - activeStyle = whichStyle; -} + str = _("Show full path or only file name."); + tooltips().init(dialog_->check_fullpath, str); + str = _("Runs the script \"TexFiles.sh\" to rebuild the file lists."); + tooltips().init(dialog_->button_rescan, str); -void FormTexinfo::clear_feedback() -{ - fl_set_object_label(dialog_->message, ""); - fl_redraw_object(dialog_->message); -} + str = _("Double click to view contents of file."); + tooltips().init(dialog_->browser, str); +#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0) + // Work-around xforms' bug; enable tooltips for browser widgets. + setPrehandler(dialog_->browser); +#endif + str = _("Runs the script \"texhash\" which builds a new LaTeX tree. " + "Needed if you install a new TeX class or style. You need write " + "permissions for the TeX-dirs, often /var/lib/texmf and others."); + tooltips().init(dialog_->button_texhash, str); +} -string const FormTexinfo::getTooltip(FL_OBJECT * ob) -{ - string str; - if (ob == dialog_->radio_cls) { - str = N_(""); +ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) { - } else if (ob == dialog_->radio_sty) { - str = _(""); + if (ob == dialog_->button_texhash) { + // makes only sense if the rights are set well for + // users (/var/lib/texmf/ls-R) + texhash(); + // texhash requires a rescan and an update of the styles + rescanTexStyles(); + updateStyles(activeStyle); - } else if (ob == dialog_->radio_bst) { - str = _(""); - } else if (ob == dialog_->button_rescan) { - str = _("Rescan File List"); + } else if (ob == dialog_->browser && ob_value == 2) { + // double click in browser: view selected file + 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); - } else if (ob == dialog_->button_fullPath) { - str = _("Show Full Path or not"); + // reset the browser so that the following single-click + // callback doesn't do anything + fl_deselect_browser(dialog_->browser); - } else if (ob == dialog_->button_texhash) { - str = _(""); + } else if (ob == dialog_->button_rescan) { + // build new *Files.lst + rescanTexStyles(); + updateStyles(activeStyle); - } else if (ob == dialog_->button_view) { - str = N_("View Content of the File"); + } else if (ob == dialog_->check_fullpath) { + updateStyles(activeStyle); + } else if (ob == dialog_->choice_classes) { + switch (fl_get_choice(dialog_->choice_classes)) { + case 3: + updateStyles(ControlTexinfo::bst); + break; + case 2: + updateStyles(ControlTexinfo::sty); + break; + case 1: + default: + updateStyles(ControlTexinfo::cls); + } } - return str; + return ButtonPolicy::SMI_VALID; } -void FormTexinfo::feedback(FL_OBJECT * ob) -{ - lyx::Assert(ob); - - string str; - - if (ob == dialog_->radio_cls) { - str = N_("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!"); - - } else if (ob == dialog_->radio_sty) { - str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{} in LaTeX preamble."); - - } else if (ob == dialog_->radio_bst) { - str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style."); - - } else if (ob == dialog_->button_rescan) { - str = _("Runs the script \"TexFiles.sh\" to build new file lists."); - - } else if (ob == dialog_->button_fullPath) { - str = _("View full path or only file name. Full path is needed to view the contents of a file."); - } else if (ob == dialog_->button_texhash) { - str = _("Runs the script \"texhash\" which builds the a new LaTeX tree. Needed if you install a new TeX class or style. To execute it, you need the write permissions for the tex-dirs, often /var/lib/texmf and other."); - - } else if (ob == dialog_->button_view) { - str = N_("Shows the contents of the marked file. Only possible in full path mode."); - - } +void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) +{ + ContentsType & data = texdata_[whichStyle]; + bool const withFullPath = fl_get_button(dialog_->check_fullpath); + getTexFileList(whichStyle, data, withFullPath); - str = formatted(_(str), dialog_->message->w-10, FL_SMALL_SIZE); + 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()); - fl_set_object_label(dialog_->message, str.c_str()); - fl_set_object_lsize(dialog_->message, FL_SMALL_SIZE); - fl_redraw_object(dialog_->message); + activeStyle = whichStyle; } + +} // namespace frontend +} // namespace lyx