]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GSearch.C
disable conecpt checks for gtk dir, fix concept checks for qt
[lyx.git] / src / frontends / gtk / GSearch.C
1 /**
2  * \file GSearch.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Spray
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
16 #endif
17
18 #include "GSearch.h"
19 #include "ControlSearch.h"
20 #include "ghelpers.h"
21
22 #include <libglademm.h>
23
24 using std::string;
25
26 namespace lyx {
27 namespace frontend {
28
29 typedef GViewCB<ControlSearch, GViewGladeB> base_class;
30
31
32 GSearch::GSearch(Dialog & parent)
33         : base_class(parent, _("Find and Replace"), false)
34 {}
35
36
37 void GSearch::doBuild()
38 {
39         string const gladeName = findGladeFile("search");
40         xml_ = Gnome::Glade::Xml::create(gladeName);
41
42         Gtk::Button * cancelbutton;
43         xml_->get_widget("Cancel", cancelbutton);
44         setCancel(cancelbutton);
45
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);
54
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));
63
64         bcview().addReadOnly(replaceentry);
65         bcview().addReadOnly(replacebutton);
66         bcview().addReadOnly(replaceallbutton);
67 }
68
69
70 void GSearch::update()
71 {
72         bc().refreshReadOnly();
73         onFindEntryChanged();
74 }
75
76
77 void GSearch::onFindNext()
78 {
79         controller().find(findentry->get_text(),
80                           casecheck->get_active(),
81                           matchwordcheck->get_active(),
82                           !backwardscheck->get_active());
83 }
84
85
86 void GSearch::onReplace()
87 {
88         controller().replace(findentry->get_text(),
89                              replaceentry->get_text(),
90                              casecheck->get_active(),
91                              matchwordcheck->get_active(),
92                              !backwardscheck->get_active(),
93                              false);
94 }
95
96
97 void GSearch::onReplaceAll()
98 {
99         controller().replace(findentry->get_text(),
100                              replaceentry->get_text(),
101                              casecheck->get_active(),
102                              matchwordcheck->get_active(),
103                              !backwardscheck->get_active(),
104                              true);
105 }
106
107
108 void GSearch::onFindEntryChanged()
109 {
110         if (findentry->get_text().empty()) {
111                 findnextbutton->set_sensitive(false);
112                 replacebutton->set_sensitive(false);
113                 replaceallbutton->set_sensitive(false);
114         } else {
115                 findnextbutton->set_sensitive(true);
116                 replacebutton->set_sensitive(!readOnly());
117                 replaceallbutton->set_sensitive(!readOnly());
118         }
119 }
120
121 } // namespace frontend
122 } // namespace lyx