3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
22 #include "ControlInclude.h"
25 #include <libglademm.h>
33 GInclude::GInclude(Dialog & parent)
34 : GViewCB<ControlInclude, GViewGladeB>(parent, _("Child Document"), false)
38 void GInclude::doBuild()
40 string const gladeName = findGladeFile("include");
41 xml_ = Gnome::Glade::Xml::create(gladeName);
44 xml_->get_widget("Cancel", button);
46 xml_->get_widget("Ok", button);
49 xml_->get_widget("Browse", button);
50 button->signal_clicked().connect(
51 sigc::mem_fun(*this, &GInclude::onBrowseClicked));
53 xml_->get_widget("Open", openbutton_);
54 openbutton_->signal_clicked().connect(
55 sigc::mem_fun(*this, &GInclude::onOpenClicked));
57 xml_->get_widget("Include", includeradio_);
58 xml_->get_widget("Input", inputradio_);
59 xml_->get_widget("Verbatim", verbatimradio_);
60 xml_->get_widget("File", fileentry_);
61 xml_->get_widget("MarkSpaces", markspacescheck_);
62 xml_->get_widget("Preview", previewcheck_);
64 inputradio_->signal_toggled().connect(
65 sigc::mem_fun(*this, &GInclude::onTypeToggled));
66 includeradio_->signal_toggled().connect(
67 sigc::mem_fun(*this, &GInclude::onTypeToggled));
68 verbatimradio_->signal_toggled().connect(
69 sigc::mem_fun(*this, &GInclude::onTypeToggled));
73 void GInclude::update()
75 string const filename = controller().params().getContents();
76 fileentry_->set_text(filename);
78 string const cmdname = controller().params().getCmdName();
80 bool const inputCommand = (cmdname == "input" || cmdname.empty());
81 bool const includeCommand = cmdname == "include";
82 bool const verbatimStarCommand = cmdname == "verbatiminput*";
83 bool const verbatimCommand = cmdname == "verbatiminput";
85 bool const preview = static_cast<bool>((controller().params().preview()));
87 previewcheck_->set_sensitive(inputCommand);
88 previewcheck_->set_active(inputCommand ? preview : false);
91 inputradio_->set_active(true);
94 includeradio_->set_active(true);
96 if (verbatimCommand || verbatimStarCommand) {
97 verbatimradio_->set_active(true);
98 markspacescheck_->set_active(verbatimStarCommand);
99 markspacescheck_->set_sensitive(true);
100 openbutton_->set_sensitive(false);
102 markspacescheck_->set_active(false);
103 markspacescheck_->set_sensitive(false);
104 openbutton_->set_sensitive(true);
111 void GInclude::apply()
113 InsetCommandParams params = controller().params();
115 params.preview(previewcheck_->get_active());
116 params.setContents(fileentry_->get_text());
118 if (includeradio_->get_active())
119 params.setCmdName("include");
120 else if (inputradio_->get_active())
121 params.setCmdName("input");
123 if (markspacescheck_->get_active())
124 params.setCmdName("verbatiminput*");
126 params.setCmdName("verbatiminput");
128 controller().setParams(params);
132 void GInclude::onTypeToggled()
134 previewcheck_->set_sensitive(inputradio_->get_active());
135 markspacescheck_->set_sensitive(verbatimradio_->get_active());
136 openbutton_->set_sensitive(!verbatimradio_->get_active());
140 void GInclude::onBrowseClicked()
142 ControlInclude::Type type;
143 if (includeradio_->get_active())
144 type = ControlInclude::INCLUDE;
145 else if (inputradio_->get_active())
146 type = ControlInclude::INPUT;
148 type = ControlInclude::VERBATIM;
150 fileentry_->set_text(controller().browse(fileentry_->get_text(), type));
154 void GInclude::onOpenClicked()
156 string const in_name = fileentry_->get_text();
157 if (!in_name.empty() && controller().fileExists(in_name)) {
159 controller().load(in_name);
164 } // namespace frontend