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.
15 #include "ControlSearch.h"
17 #include <libglademm.h>
24 typedef GViewCB<ControlSearch, GViewGladeB> base_class;
26 GSearch::GSearch(Dialog & parent)
27 : base_class(parent, _("Find and Replace"), false)
31 void GSearch::doBuild()
33 string const gladeName = findGladeFile("search");
34 xml_ = Gnome::Glade::Xml::create(gladeName);
36 Gtk::Button * cancelbutton;
37 xml_->get_widget("Cancel", cancelbutton);
38 setCancel(cancelbutton);
40 xml_->get_widget("FindNext", findnextbutton);
41 xml_->get_widget("Replace", replacebutton);
42 xml_->get_widget("ReplaceAll", replaceallbutton);
43 xml_->get_widget("FindEntry", findentry);
44 xml_->get_widget("ReplaceEntry", replaceentry);
45 xml_->get_widget("CaseSensitive", casecheck);
46 xml_->get_widget("MatchWord", matchwordcheck);
47 xml_->get_widget("SearchBackwards", backwardscheck);
49 findnextbutton->signal_clicked().connect(
50 SigC::slot(*this, &GSearch::onFindNext));
51 replacebutton->signal_clicked().connect(
52 SigC::slot(*this, &GSearch::onReplace));
53 replaceallbutton->signal_clicked().connect(
54 SigC::slot(*this, &GSearch::onReplaceAll));
55 findentry->signal_changed().connect(
56 SigC::slot(*this,&GSearch::onFindEntryChanged));
58 bcview().addReadOnly(replaceentry);
59 bcview().addReadOnly(replacebutton);
60 bcview().addReadOnly(replaceallbutton);
63 void GSearch::onFindNext()
65 controller().find(findentry->get_text(),
66 casecheck->get_active(),
67 matchwordcheck->get_active(),
68 !backwardscheck->get_active());
71 void GSearch::onReplace()
73 controller().replace(findentry->get_text(),
74 replaceentry->get_text(),
75 casecheck->get_active(),
76 matchwordcheck->get_active(),
77 !backwardscheck->get_active(),
81 void GSearch::onReplaceAll()
83 controller().replace(findentry->get_text(),
84 replaceentry->get_text(),
85 casecheck->get_active(),
86 matchwordcheck->get_active(),
87 !backwardscheck->get_active(),
91 void GSearch::onFindEntryChanged()
93 if (findentry->get_text().empty()) {
94 findnextbutton->set_sensitive(false);
95 replacebutton->set_sensitive(false);
96 replaceallbutton->set_sensitive(false);
98 findnextbutton->set_sensitive(true);
99 replacebutton->set_sensitive(true);
100 replaceallbutton->set_sensitive(true);
104 } // namespace frontend