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.
14 #include "ControlSendto.h"
19 #include <libglademm.h>
27 GSendto::GSendto(Dialog & parent)
28 : GViewCB<ControlSendto, GViewGladeB>(parent, _("Send document to command"), false)
32 void GSendto::doBuild()
34 string const gladeName = findGladeFile("sendto");
35 xml_ = Gnome::Glade::Xml::create(gladeName);
38 xml_->get_widget("Close", button);
40 xml_->get_widget("Execute", button);
43 xml_->get_widget("Format", formatview_);
44 xml_->get_widget("Command", commandentry_);
46 cols_.add(stringcol_);
49 formatstore_ = Gtk::ListStore::create(cols_);
50 formatview_->set_model(formatstore_);
51 formatview_->append_column("Format", stringcol_);
52 formatview_->get_selection()->set_mode(Gtk::SELECTION_BROWSE);
54 commandentry_->signal_changed().connect(
55 sigc::mem_fun(*this, &GSendto::onCommandEntryChanged));
59 void GSendto::onCommandEntryChanged()
61 bc().valid(!commandentry_->get_text().empty());
65 void GSendto::update()
67 vector<Format const *> new_formats;
68 new_formats = controller().allFormats();
70 if (new_formats == all_formats_)
73 all_formats_ = new_formats;
76 keys.resize(all_formats_.size());
78 vector<string>::iterator result = keys.begin();
79 vector<Format const *>::const_iterator it = all_formats_.begin();
80 vector<Format const *>::const_iterator end = all_formats_.end();
81 for (; it != end; ++it, ++result) {
82 *result = (*it)->prettyname();
85 formatstore_->clear();
87 vector<string>::const_iterator keyend = keys.end();
88 vector<string>::const_iterator keyit = keys.begin();
89 for (int rowindex = 0;
90 keyit < keyend; ++keyit, ++rowindex) {
91 Gtk::TreeModel::iterator row = formatstore_->append();
92 (*row)[stringcol_] = *keyit;
93 (*row)[indexcol_] = rowindex;
96 commandentry_->set_text(controller().getCommand());
100 void GSendto::apply()
103 (*formatview_->get_selection()->get_selected())[indexcol_];
105 string const cmd = commandentry_->get_text();
107 controller().setFormat(all_formats_[line]);
108 controller().setCommand(cmd);
111 } // namespace frontend