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 "ControlSearch.h"
22 #include <libglademm.h>
29 typedef GViewCB<ControlSearch, GViewGladeB> base_class;
32 GSearch::GSearch(Dialog & parent)
33 : base_class(parent, _("Find and Replace"), false)
37 void GSearch::doBuild()
39 string const gladeName = findGladeFile("search");
40 xml_ = Gnome::Glade::Xml::create(gladeName);
42 Gtk::Button * cancelbutton;
43 xml_->get_widget("Cancel", cancelbutton);
44 setCancel(cancelbutton);
46 xml_->get_widget("FindNext", findnextbutton);
47 xml_->get_widget("Replace", replacebutton);
48 xml_->get_widget("ReplaceAll", replaceallbutton);
49 xml_->get_widget("FindEntry", findentry);
50 xml_->get_widget("ReplaceEntry", replaceentry);
51 xml_->get_widget("CaseSensitive", casecheck);
52 xml_->get_widget("MatchWord", matchwordcheck);
53 xml_->get_widget("SearchBackwards", backwardscheck);
55 findnextbutton->signal_clicked().connect(
56 sigc::mem_fun(*this, &GSearch::onFindNext));
57 replacebutton->signal_clicked().connect(
58 sigc::mem_fun(*this, &GSearch::onReplace));
59 replaceallbutton->signal_clicked().connect(
60 sigc::mem_fun(*this, &GSearch::onReplaceAll));
61 findentry->signal_changed().connect(
62 sigc::mem_fun(*this,&GSearch::onFindEntryChanged));
64 bcview().addReadOnly(replaceentry);
65 bcview().addReadOnly(replacebutton);
66 bcview().addReadOnly(replaceallbutton);
70 void GSearch::update()
72 bc().refreshReadOnly();
77 void GSearch::onFindNext()
79 controller().find(findentry->get_text(),
80 casecheck->get_active(),
81 matchwordcheck->get_active(),
82 !backwardscheck->get_active());
86 void GSearch::onReplace()
88 controller().replace(findentry->get_text(),
89 replaceentry->get_text(),
90 casecheck->get_active(),
91 matchwordcheck->get_active(),
92 !backwardscheck->get_active(),
97 void GSearch::onReplaceAll()
99 controller().replace(findentry->get_text(),
100 replaceentry->get_text(),
101 casecheck->get_active(),
102 matchwordcheck->get_active(),
103 !backwardscheck->get_active(),
108 void GSearch::onFindEntryChanged()
110 if (findentry->get_text().empty()) {
111 findnextbutton->set_sensitive(false);
112 replacebutton->set_sensitive(false);
113 replaceallbutton->set_sensitive(false);
115 findnextbutton->set_sensitive(true);
116 replacebutton->set_sensitive(!readOnly());
117 replaceallbutton->set_sensitive(!readOnly());
121 } // namespace frontend