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 _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
19 #include "ControlSendto.h"
24 #include <libglademm.h>
32 GSendto::GSendto(Dialog & parent)
33 : GViewCB<ControlSendto, GViewGladeB>(parent, _("Send document to command"), false)
37 void GSendto::doBuild()
39 string const gladeName = findGladeFile("sendto");
40 xml_ = Gnome::Glade::Xml::create(gladeName);
43 xml_->get_widget("Close", button);
45 xml_->get_widget("Execute", button);
48 xml_->get_widget("Format", formatview_);
49 xml_->get_widget("Command", commandentry_);
51 cols_.add(stringcol_);
54 formatstore_ = Gtk::ListStore::create(cols_);
55 formatview_->set_model(formatstore_);
56 formatview_->append_column("Format", stringcol_);
57 formatview_->get_selection()->set_mode(Gtk::SELECTION_BROWSE);
59 commandentry_->signal_changed().connect(
60 sigc::mem_fun(*this, &GSendto::onCommandEntryChanged));
64 void GSendto::onCommandEntryChanged()
66 bc().valid(!commandentry_->get_text().empty());
70 void GSendto::update()
72 vector<Format const *> new_formats;
73 new_formats = controller().allFormats();
75 if (new_formats == all_formats_)
78 all_formats_ = new_formats;
81 keys.resize(all_formats_.size());
83 vector<string>::iterator result = keys.begin();
84 vector<Format const *>::const_iterator it = all_formats_.begin();
85 vector<Format const *>::const_iterator end = all_formats_.end();
86 for (; it != end; ++it, ++result) {
87 *result = (*it)->prettyname();
90 formatstore_->clear();
92 vector<string>::const_iterator keyend = keys.end();
93 vector<string>::const_iterator keyit = keys.begin();
94 for (int rowindex = 0;
95 keyit < keyend; ++keyit, ++rowindex) {
96 Gtk::TreeModel::iterator row = formatstore_->append();
97 (*row)[stringcol_] = *keyit;
98 (*row)[indexcol_] = rowindex;
101 commandentry_->set_text(controller().getCommand());
105 void GSendto::apply()
108 (*formatview_->get_selection()->get_selected())[indexcol_];
110 string const cmd = commandentry_->get_text();
112 controller().setFormat(all_formats_[line]);
113 controller().setCommand(cmd);
116 } // namespace frontend