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::update()
67 bc().refreshReadOnly();
72 void GSearch::onFindNext()
74 controller().find(findentry->get_text(),
75 casecheck->get_active(),
76 matchwordcheck->get_active(),
77 !backwardscheck->get_active());
81 void GSearch::onReplace()
83 controller().replace(findentry->get_text(),
84 replaceentry->get_text(),
85 casecheck->get_active(),
86 matchwordcheck->get_active(),
87 !backwardscheck->get_active(),
92 void GSearch::onReplaceAll()
94 controller().replace(findentry->get_text(),
95 replaceentry->get_text(),
96 casecheck->get_active(),
97 matchwordcheck->get_active(),
98 !backwardscheck->get_active(),
103 void GSearch::onFindEntryChanged()
105 if (findentry->get_text().empty()) {
106 findnextbutton->set_sensitive(false);
107 replacebutton->set_sensitive(false);
108 replaceallbutton->set_sensitive(false);
110 findnextbutton->set_sensitive(true);
111 replacebutton->set_sensitive(!readOnly());
112 replaceallbutton->set_sensitive(!readOnly());
116 } // namespace frontend