2001-10-09 15:20:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file FormTexinfo.C
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-10-09 15:20:10 +00:00
|
|
|
|
*
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-10-09 15:20:10 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "FormTexinfo.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
|
#include "forms/form_texinfo.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
|
|
2002-03-11 09:54:42 +00:00
|
|
|
|
#include "Tooltips.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
|
#include "xformsBC.h"
|
|
|
|
|
|
2003-06-20 14:03:49 +00:00
|
|
|
|
#include "support/filetools.h"
|
2002-10-25 09:16:22 +00:00
|
|
|
|
|
2003-05-14 09:17:22 +00:00
|
|
|
|
#include "lyx_forms.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using support::OnlyFilename;
|
|
|
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2003-09-05 13:15:43 +00:00
|
|
|
|
|
2003-06-19 17:16:12 +00:00
|
|
|
|
typedef FormController<ControlTexinfo, FormView<FD_texinfo> > base_class;
|
|
|
|
|
|
|
|
|
|
FormTexinfo::FormTexinfo(Dialog & parent)
|
2005-05-19 18:53:09 +00:00
|
|
|
|
: base_class(parent, _("TeX Information")),
|
2002-02-05 20:36:12 +00:00
|
|
|
|
activeStyle(ControlTexinfo::cls)
|
2001-10-09 15:20:10 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormTexinfo::build() {
|
2002-06-13 13:43:51 +00:00
|
|
|
|
dialog_.reset(build_texinfo(this));
|
2002-09-12 09:07:58 +00:00
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
// callback for double click in browser to view the selected file
|
2003-06-19 17:16:12 +00:00
|
|
|
|
fl_set_browser_dblclick_callback(dialog_->browser,
|
|
|
|
|
C_FormDialogView_InputCB, 2);
|
2001-10-09 15:20:10 +00:00
|
|
|
|
|
2002-09-12 09:07:58 +00:00
|
|
|
|
string const classes_List = _("LaTeX classes|LaTeX styles|BibTeX styles");
|
|
|
|
|
fl_addto_choice(dialog_->choice_classes, classes_List.c_str());
|
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
updateStyles(activeStyle);
|
|
|
|
|
|
2002-03-11 09:54:42 +00:00
|
|
|
|
// set up the tooltips
|
2002-10-25 09:16:22 +00:00
|
|
|
|
string str = _("Shows the installed classses and styles for LaTeX/BibTeX; "
|
|
|
|
|
"available only if the corresponding LyX layout file exists.");
|
2002-09-12 09:07:58 +00:00
|
|
|
|
tooltips().init(dialog_->choice_classes, str);
|
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
str = _("Show full path or only file name.");
|
2002-09-12 09:07:58 +00:00
|
|
|
|
tooltips().init(dialog_->check_fullpath, str);
|
|
|
|
|
|
2005-05-05 11:07:45 +00:00
|
|
|
|
str = _("Runs the script \"TexFiles.sh\" to rebuild the file lists.");
|
2002-03-18 15:56:00 +00:00
|
|
|
|
tooltips().init(dialog_->button_rescan, str);
|
2002-03-11 09:54:42 +00:00
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
str = _("Double click to view contents of file.");
|
|
|
|
|
tooltips().init(dialog_->browser, str);
|
2003-04-09 10:02:59 +00:00
|
|
|
|
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
|
2002-10-28 12:53:23 +00:00
|
|
|
|
// Work-around xforms' bug; enable tooltips for browser widgets.
|
|
|
|
|
setPrehandler(dialog_->browser);
|
2003-04-09 10:02:59 +00:00
|
|
|
|
#endif
|
2002-03-11 09:54:42 +00:00
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
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.");
|
2002-03-18 15:56:00 +00:00
|
|
|
|
tooltips().init(dialog_->button_texhash, str);
|
2001-10-09 15:20:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) {
|
2001-10-09 15:20:10 +00:00
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
if (ob == dialog_->button_texhash) {
|
|
|
|
|
// makes only sense if the rights are set well for
|
|
|
|
|
// users (/var/lib/texmf/ls-R)
|
2003-06-20 14:03:49 +00:00
|
|
|
|
texhash();
|
2002-10-25 09:16:22 +00:00
|
|
|
|
// texhash requires a rescan and an update of the styles
|
2003-06-20 14:03:49 +00:00
|
|
|
|
rescanTexStyles();
|
2002-10-25 09:16:22 +00:00
|
|
|
|
updateStyles(activeStyle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (ob == dialog_->browser && ob_value == 2) {
|
|
|
|
|
// double click in browser: view selected file
|
2003-06-20 14:03:49 +00:00
|
|
|
|
ContentsType::size_type const sel = fl_get_browser(ob);
|
|
|
|
|
ContentsType const & data = texdata_[activeStyle];
|
2005-07-27 17:46:15 +00:00
|
|
|
|
string file = data[sel-1];
|
|
|
|
|
if (!fl_get_button(dialog_->check_fullpath))
|
|
|
|
|
file = getTexFileFromList(data[sel-1],
|
|
|
|
|
controller().getFileType(activeStyle));
|
2003-06-20 14:03:49 +00:00
|
|
|
|
if (sel >= 1 && sel <= data.size())
|
2005-07-27 17:46:15 +00:00
|
|
|
|
controller().viewFile(file);
|
2002-10-25 09:16:22 +00:00
|
|
|
|
|
2003-06-20 14:03:49 +00:00
|
|
|
|
// reset the browser so that the following single-click
|
|
|
|
|
// callback doesn't do anything
|
2002-10-25 09:16:22 +00:00
|
|
|
|
fl_deselect_browser(dialog_->browser);
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2001-10-09 15:20:10 +00:00
|
|
|
|
} else if (ob == dialog_->button_rescan) {
|
|
|
|
|
// build new *Files.lst
|
2003-06-20 14:03:49 +00:00
|
|
|
|
rescanTexStyles();
|
2001-10-09 15:20:10 +00:00
|
|
|
|
updateStyles(activeStyle);
|
|
|
|
|
|
2002-03-12 14:11:15 +00:00
|
|
|
|
} else if (ob == dialog_->check_fullpath) {
|
2001-10-09 15:20:10 +00:00
|
|
|
|
updateStyles(activeStyle);
|
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
} 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);
|
2001-10-09 15:20:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ButtonPolicy::SMI_VALID;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
|
void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
|
2001-10-09 15:20:10 +00:00
|
|
|
|
{
|
2003-06-20 14:03:49 +00:00
|
|
|
|
ContentsType & data = texdata_[whichStyle];
|
2002-03-12 14:11:15 +00:00
|
|
|
|
bool const withFullPath = fl_get_button(dialog_->check_fullpath);
|
2005-07-27 17:46:15 +00:00
|
|
|
|
getTexFileList(whichStyle, data, withFullPath);
|
2001-10-09 15:20:10 +00:00
|
|
|
|
|
2003-06-20 14:03:49 +00:00
|
|
|
|
fl_clear_browser(dialog_->browser);
|
|
|
|
|
ContentsType::const_iterator it = data.begin();
|
|
|
|
|
ContentsType::const_iterator end = data.end();
|
2005-07-27 17:46:15 +00:00
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
fl_add_browser_line(dialog_->browser, (*it).c_str());
|
2001-10-09 15:20:10 +00:00
|
|
|
|
|
|
|
|
|
activeStyle = whichStyle;
|
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|