2001-10-09 15:20:10 +00:00
/**
* \ file FormTexinfo . C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
2002-03-11 17:00:41 +00:00
* \ author Herbert Voss , voss @ lyx . org
2001-10-09 15:20:10 +00:00
* \ date 2001 - 10 - 01
*/
# include <config.h>
# include <fstream>
# ifdef __GNUG__
# pragma implementation
# endif
# include "xformsBC.h"
# include "FormTexinfo.h"
2002-06-13 13:43:51 +00:00
# include "forms/form_texinfo.h"
2002-03-11 09:54:42 +00:00
# include "Tooltips.h"
2001-10-09 15:20:10 +00:00
# include "gettext.h"
# include "debug.h"
# include "xforms_helpers.h"
# include "support/LAssert.h"
2002-06-13 13:43:51 +00:00
# include FORMS_H_LOCATION
2002-03-21 21:21:28 +00:00
2001-10-09 15:20:10 +00:00
2002-06-13 13:43:51 +00:00
typedef FormCB < ControlTexinfo , FormDB < FD_texinfo > > base_class ;
2002-08-12 14:28:43 +00:00
FormTexinfo : : FormTexinfo ( )
: base_class ( _ ( " LaTeX 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 ) ) ;
2001-10-09 15:20:10 +00:00
// courier medium
fl_set_browser_fontstyle ( dialog_ - > browser , FL_FIXED_STYLE ) ;
// with Path is default
2002-03-12 14:11:15 +00:00
fl_set_button ( dialog_ - > check_fullpath , 1 ) ;
2001-10-10 16:45:05 +00:00
updateStyles ( ControlTexinfo : : cls ) ;
2001-10-09 15:20:10 +00:00
2002-03-11 09:54:42 +00:00
// set up the tooltips
2002-04-02 17:04:23 +00:00
string str = _ ( " Runs the script \" TexFiles.sh \" to build new 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-04-02 17:04:23 +00:00
str = _ ( " Shows the contents of the marked file. Only possible in full path mode. " ) ;
2002-03-18 15:56:00 +00:00
tooltips ( ) . init ( dialog_ - > button_view , str ) ;
2002-03-11 09:54:42 +00:00
2002-04-02 17:04:23 +00:00
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. " ) ;
2002-03-18 15:56:00 +00:00
tooltips ( ) . init ( dialog_ - > button_texhash , str ) ;
2002-03-11 09:54:42 +00:00
2002-04-02 17:04:23 +00:00
str = _ ( " View full path or only file name. Full path is needed to view the contents of a file. " ) ;
2002-03-18 15:56:00 +00:00
tooltips ( ) . init ( dialog_ - > check_fullpath , str ) ;
2002-03-11 09:54:42 +00:00
2002-04-02 17:04:23 +00:00
str = _ ( " Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists! " ) ;
2002-03-18 15:56:00 +00:00
tooltips ( ) . init ( dialog_ - > radio_cls , str ) ;
2002-03-11 09:54:42 +00:00
2002-04-02 17:04:23 +00:00
str = _ ( " Shows the installed LaTeX style files, which are available in LyX by default, like \" babel \" or through \\ usepackage{<the stylefile>} in LaTeX preamble. " ) ;
2002-03-18 15:56:00 +00:00
tooltips ( ) . init ( dialog_ - > radio_sty , str ) ;
2002-03-11 09:54:42 +00:00
2002-04-02 17:04:23 +00:00
str = _ ( " Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style. " ) ;
2002-03-18 15:56:00 +00:00
tooltips ( ) . init ( dialog_ - > radio_bst , str ) ;
2001-10-09 15:20:10 +00:00
}
ButtonPolicy : : SMInput FormTexinfo : : input ( FL_OBJECT * ob , long ) {
2002-02-05 20:36:12 +00:00
if ( ob = = dialog_ - > radio_cls ) {
2002-02-06 17:15:28 +00:00
updateStyles ( ControlTexinfo : : cls ) ;
2001-10-09 15:20:10 +00:00
} else if ( ob = = dialog_ - > radio_sty ) {
2002-03-21 21:21:28 +00:00
updateStyles ( ControlTexinfo : : sty ) ;
2001-10-09 15:20:10 +00:00
} else if ( ob = = dialog_ - > radio_bst ) {
2002-03-21 21:21:28 +00:00
updateStyles ( ControlTexinfo : : bst ) ;
2001-10-09 15:20:10 +00:00
} else if ( ob = = dialog_ - > button_rescan ) {
// build new *Files.lst
controller ( ) . rescanStyles ( ) ;
updateStyles ( activeStyle ) ;
2002-03-12 14:11:15 +00:00
} else if ( ob = = dialog_ - > check_fullpath ) {
2001-10-09 15:20:10 +00:00
setEnabled ( dialog_ - > button_view ,
2002-03-12 14:11:15 +00:00
fl_get_button ( dialog_ - > check_fullpath ) ) ;
2001-10-09 15:20:10 +00:00
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 ) {
2002-02-16 15:59:55 +00:00
controller ( ) . viewFile (
2001-10-09 15:20:10 +00:00
fl_get_browser_line ( dialog_ - > browser ,
selection ) ) ;
}
}
return ButtonPolicy : : SMI_VALID ;
}
2001-10-10 16:45:05 +00:00
void FormTexinfo : : updateStyles ( ControlTexinfo : : texFileSuffix whichStyle )
2001-10-09 15:20:10 +00:00
{
2002-03-21 21:21:28 +00:00
fl_clear_browser ( dialog_ - > browser ) ;
2001-10-09 15:20:10 +00:00
2002-03-12 14:11:15 +00:00
bool const withFullPath = fl_get_button ( dialog_ - > check_fullpath ) ;
2001-10-09 15:20:10 +00:00
2002-03-21 21:21:28 +00:00
string const str =
2001-10-10 16:45:05 +00:00
controller ( ) . getContents ( whichStyle , withFullPath ) ;
fl_add_browser_line ( dialog_ - > browser , str . c_str ( ) ) ;
2001-10-09 15:20:10 +00:00
activeStyle = whichStyle ;
}