]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormShowFile.C
fix crash with "save as"
[lyx.git] / src / frontends / xforms / FormShowFile.C
1 /**
2  * \file FormShowFile.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Herbert Voss
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "xformsBC.h"
18 #include "ControlShowFile.h"
19 #include "FormShowFile.h"
20 #include "forms/form_browser.h"
21 #include "gettext.h"
22 #include FORMS_H_LOCATION
23
24
25 FormShowFile::FormShowFile()
26         : FormCB<ControlShowFile, FormBrowser>(_("Show File"))
27 {}
28
29
30 void FormShowFile::update()
31 {
32         fl_hide_object(dialog_->button_update);
33         fl_clear_browser(dialog_->browser);
34
35         // courier medium
36         fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
37
38         string const title = "LyX: " + controller().getFileName();
39         fl_set_form_title(dialog_->form, title.c_str());
40
41         string const contents = controller().getFileContents();
42         if (contents.empty())
43                 fl_add_browser_line(dialog_->browser,
44                                     "Error -> Cannot load file!");
45         else
46                 fl_add_browser_line(dialog_->browser, contents.c_str());
47 }