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 _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
22 #include "ControlSearch.h"
25 #include <libglademm.h>
32 typedef GViewCB<ControlSearch, GViewGladeB> base_class;
35 GSearch::GSearch(Dialog & parent)
36 : base_class(parent, _("Find and Replace"), false)
40 void GSearch::doBuild()
42 string const gladeName = findGladeFile("search");
43 xml_ = Gnome::Glade::Xml::create(gladeName);
45 Gtk::Button * cancelbutton;
46 xml_->get_widget("Cancel", cancelbutton);
47 setCancel(cancelbutton);
49 xml_->get_widget("FindNext", findnextbutton);
50 xml_->get_widget("Replace", replacebutton);
51 xml_->get_widget("ReplaceAll", replaceallbutton);
52 xml_->get_widget("FindEntry", findentry);
53 xml_->get_widget("ReplaceEntry", replaceentry);
54 xml_->get_widget("CaseSensitive", casecheck);
55 xml_->get_widget("MatchWord", matchwordcheck);
56 xml_->get_widget("SearchBackwards", backwardscheck);
58 findnextbutton->signal_clicked().connect(
59 sigc::mem_fun(*this, &GSearch::onFindNext));
60 replacebutton->signal_clicked().connect(
61 sigc::mem_fun(*this, &GSearch::onReplace));
62 replaceallbutton->signal_clicked().connect(
63 sigc::mem_fun(*this, &GSearch::onReplaceAll));
64 findentry->signal_changed().connect(
65 sigc::mem_fun(*this,&GSearch::onFindEntryChanged));
67 bcview().addReadOnly(replaceentry);
68 bcview().addReadOnly(replacebutton);
69 bcview().addReadOnly(replaceallbutton);
73 void GSearch::update()
75 bc().refreshReadOnly();
76 findentry->grab_focus();
81 void GSearch::onFindNext()
83 controller().find(findentry->get_text(),
84 casecheck->get_active(),
85 matchwordcheck->get_active(),
86 !backwardscheck->get_active());
90 void GSearch::onReplace()
92 controller().replace(findentry->get_text(),
93 replaceentry->get_text(),
94 casecheck->get_active(),
95 matchwordcheck->get_active(),
96 !backwardscheck->get_active(),
101 void GSearch::onReplaceAll()
103 controller().replace(findentry->get_text(),
104 replaceentry->get_text(),
105 casecheck->get_active(),
106 matchwordcheck->get_active(),
107 !backwardscheck->get_active(),
112 void GSearch::onFindEntryChanged()
114 if (findentry->get_text().empty()) {
115 findnextbutton->set_sensitive(false);
116 replacebutton->set_sensitive(false);
117 replaceallbutton->set_sensitive(false);
119 findnextbutton->set_sensitive(true);
120 replacebutton->set_sensitive(!readOnly());
121 replaceallbutton->set_sensitive(!readOnly());
125 } // namespace frontend