This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / LaTeXLog.C
blobbd7f7e58d10fe4815f07064b370f13884e59cfc4
1 #include <config.h>
3 #include <cstdlib>
4 #include FORMS_H_LOCATION
5 #include "buffer.h"
6 #include "latexoptions.h"
7 #include "lyx_main.h"
8 #include "LString.h"
9 #include "support/FileInfo.h"
10 #include "support/filetools.h"
11 #include "support/path.h"
12 #include "lyxrc.h"
13 #include "BufferView.h"
14 #include "gettext.h"
16 extern FD_LaTeXLog *fd_latex_log;
17 extern BufferView *current_view;
19 void ShowLatexLog()
21         string filename, fname, bname, path;
22         bool use_build = false;
23         static int ow = -1, oh;
25         filename = current_view->currentBuffer()->getFileName();
26         if (!filename.empty()) {
27                 fname = SpaceLess(ChangeExtension(filename, ".log", true));
28                 bname = SpaceLess(ChangeExtension(filename,
29                                                   lyxrc->literate_extension + ".out", true));
30                 path = OnlyPath(filename);
31                 if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
32                         path = current_view->currentBuffer()->tmppath;
33                 }
34                 FileInfo f_fi(path + fname), b_fi(path + bname);
35                 if (b_fi.exist())
36                         if (!f_fi.exist()
37                             || f_fi.getModificationTime() < b_fi.getModificationTime())
38                                 use_build = true; // If no Latex log or Build log is newer, show Build log
39                 Path p(path); // path to LaTeX file
40                 if (!fl_load_browser(fd_latex_log->browser_latexlog,
41                                      use_build ? bname.c_str() : fname.c_str()))
42                         fl_add_browser_line(fd_latex_log->browser_latexlog,
43                                             _("Unable to show log file!"));
44         } else {
45                 fl_add_browser_line(fd_latex_log->browser_latexlog,
46                                _("NO LATEX LOG FILE!"));
47         }
48         if (fd_latex_log->LaTeXLog->visible) {
49                 fl_raise_form(fd_latex_log->LaTeXLog);
50         } else {
51                 fl_show_form(fd_latex_log->LaTeXLog,
52                              FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER,
53                              use_build ? _("Build Program Log") : _("LaTeX Log"));
54                 if (ow < 0) {
55                         ow = fd_latex_log->LaTeXLog->w;
56                         oh = fd_latex_log->LaTeXLog->h;
57                 }
58                 fl_set_form_minsize(fd_latex_log->LaTeXLog, ow, oh);
59         }
62 void LatexLogClose(FL_OBJECT *, long)
64     fl_hide_form(fd_latex_log->LaTeXLog);
67 void LatexLogUpdate(FL_OBJECT *, long)
69     ShowLatexLog();