]> git.lyx.org Git - lyx.git/blob - src/LaTeXLog.C
update all .po files ot latestes pot
[lyx.git] / src / LaTeXLog.C
1 #include <config.h>
2
3 #include <cstdlib>
4 #include FORMS_H_LOCATION
5 #include "buffer.h"
6 #include "log_form.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"
15 #include "converter.h"
16
17 extern FD_LaTeXLog *fd_latex_log;
18 extern BufferView *current_view;
19
20 void ShowLatexLog()
21 {
22         string filename, fname, bname, path;
23         bool use_build = false;
24         static int ow = -1, oh;
25
26         filename = current_view->buffer()->getLatexName();
27         if (!filename.empty()) {
28                 fname = OnlyFilename(ChangeExtension(filename, ".log"));
29                 bname = OnlyFilename(ChangeExtension(filename,
30                                      Formats::Extension("literate") + ".out"));
31                 path = OnlyPath(filename);
32                 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
33                         path = current_view->buffer()->tmppath;
34                 }
35                 FileInfo f_fi(path + fname), b_fi(path + bname);
36                 if (b_fi.exist())
37                         if (!f_fi.exist()
38                             || f_fi.getModificationTime() < b_fi.getModificationTime())
39                                 use_build = true; // If no Latex log or Build log is newer, show Build log
40                 Path p(path); // path to LaTeX file
41                 if (!fl_load_browser(fd_latex_log->browser_latexlog,
42                                      use_build ? bname.c_str() : fname.c_str()))
43                         fl_add_browser_line(fd_latex_log->browser_latexlog,
44                                             _("Unable to show log file!"));
45         } else {
46                 fl_add_browser_line(fd_latex_log->browser_latexlog,
47                                _("NO LATEX LOG FILE!"));
48         }
49         if (fd_latex_log->LaTeXLog->visible) {
50                 fl_raise_form(fd_latex_log->LaTeXLog);
51         } else {
52                 fl_show_form(fd_latex_log->LaTeXLog,
53                              FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
54                              use_build ? _("Build Program Log") : _("LaTeX Log"));
55                 if (ow < 0) {
56                         ow = fd_latex_log->LaTeXLog->w;
57                         oh = fd_latex_log->LaTeXLog->h;
58                 }
59                 fl_set_form_minsize(fd_latex_log->LaTeXLog, ow, oh);
60         }
61 }
62
63 void LatexLogClose(FL_OBJECT *, long)
64 {
65     fl_hide_form(fd_latex_log->LaTeXLog);
66 }
67
68 void LatexLogUpdate(FL_OBJECT *, long)
69 {
70     ShowLatexLog();
71 }