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 "ControlSendto.h"
27 #include <libglademm.h>
35 GSendto::GSendto(Dialog & parent)
36 : GViewCB<ControlSendto, GViewGladeB>(parent, _("Send document to command"), false)
40 void GSendto::doBuild()
42 string const gladeName = findGladeFile("sendto");
43 xml_ = Gnome::Glade::Xml::create(gladeName);
46 xml_->get_widget("Close", button);
48 xml_->get_widget("Execute", button);
51 xml_->get_widget("Format", formatview_);
52 xml_->get_widget("Command", commandentry_);
54 cols_.add(stringcol_);
57 formatstore_ = Gtk::ListStore::create(cols_);
58 formatview_->set_model(formatstore_);
59 formatview_->append_column("Format", stringcol_);
60 formatview_->get_selection()->set_mode(Gtk::SELECTION_BROWSE);
62 commandentry_->signal_changed().connect(
63 sigc::mem_fun(*this, &GSendto::onCommandEntryChanged));
67 void GSendto::onCommandEntryChanged()
69 bc().valid(!commandentry_->get_text().empty());
73 void GSendto::update()
75 vector<Format const *> new_formats;
76 new_formats = controller().allFormats();
78 if (new_formats == all_formats_)
81 all_formats_ = new_formats;
84 keys.resize(all_formats_.size());
86 vector<string>::iterator result = keys.begin();
87 vector<Format const *>::const_iterator it = all_formats_.begin();
88 vector<Format const *>::const_iterator end = all_formats_.end();
89 for (; it != end; ++it, ++result) {
90 *result = (*it)->prettyname();
93 formatstore_->clear();
95 vector<string>::const_iterator keyend = keys.end();
96 vector<string>::const_iterator keyit = keys.begin();
97 for (int rowindex = 0;
98 keyit < keyend; ++keyit, ++rowindex) {
99 Gtk::TreeModel::iterator row = formatstore_->append();
100 (*row)[stringcol_] = *keyit;
101 (*row)[indexcol_] = rowindex;
104 commandentry_->set_text(controller().getCommand());
108 void GSendto::apply()
111 (*formatview_->get_selection()->get_selected())[indexcol_];
113 string const cmd = commandentry_->get_text();
115 controller().setFormat(all_formats_[line]);
116 controller().setCommand(cmd);
119 } // namespace frontend