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 "ControlSearch.h"
17 #include <libglademm.h>
24 typedef GViewCB<ControlSearch, GViewGladeB> base_class;
27 GSearch::GSearch(Dialog & parent)
28 : base_class(parent, _("Find and Replace"), false)
32 void GSearch::doBuild()
34 string const gladeName = findGladeFile("search");
35 xml_ = Gnome::Glade::Xml::create(gladeName);
37 Gtk::Button * cancelbutton;
38 xml_->get_widget("Cancel", cancelbutton);
39 setCancel(cancelbutton);
41 xml_->get_widget("FindNext", findnextbutton);
42 xml_->get_widget("Replace", replacebutton);
43 xml_->get_widget("ReplaceAll", replaceallbutton);
44 xml_->get_widget("FindEntry", findentry);
45 xml_->get_widget("ReplaceEntry", replaceentry);
46 xml_->get_widget("CaseSensitive", casecheck);
47 xml_->get_widget("MatchWord", matchwordcheck);
48 xml_->get_widget("SearchBackwards", backwardscheck);
50 findnextbutton->signal_clicked().connect(
51 sigc::mem_fun(*this, &GSearch::onFindNext));
52 replacebutton->signal_clicked().connect(
53 sigc::mem_fun(*this, &GSearch::onReplace));
54 replaceallbutton->signal_clicked().connect(
55 sigc::mem_fun(*this, &GSearch::onReplaceAll));
56 findentry->signal_changed().connect(
57 sigc::mem_fun(*this,&GSearch::onFindEntryChanged));
59 bcview().addReadOnly(replaceentry);
60 bcview().addReadOnly(replacebutton);
61 bcview().addReadOnly(replaceallbutton);
65 void GSearch::onFindNext()
67 controller().find(findentry->get_text(),
68 casecheck->get_active(),
69 matchwordcheck->get_active(),
70 !backwardscheck->get_active());
74 void GSearch::onReplace()
76 controller().replace(findentry->get_text(),
77 replaceentry->get_text(),
78 casecheck->get_active(),
79 matchwordcheck->get_active(),
80 !backwardscheck->get_active(),
85 void GSearch::onReplaceAll()
87 controller().replace(findentry->get_text(),
88 replaceentry->get_text(),
89 casecheck->get_active(),
90 matchwordcheck->get_active(),
91 !backwardscheck->get_active(),
96 void GSearch::onFindEntryChanged()
98 if (findentry->get_text().empty()) {
99 findnextbutton->set_sensitive(false);
100 replacebutton->set_sensitive(false);
101 replaceallbutton->set_sensitive(false);
103 findnextbutton->set_sensitive(true);
104 replacebutton->set_sensitive(true);
105 replaceallbutton->set_sensitive(true);
109 } // namespace frontend