2004-09-24 20:07:54 +00:00
|
|
|
/**
|
|
|
|
* \file GSearch.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Spray
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2004-11-16 23:18:46 +00:00
|
|
|
// Too hard to make concept checks work with this file
|
|
|
|
#ifdef _GLIBCPP_CONCEPT_CHECKS
|
|
|
|
#undef _GLIBCPP_CONCEPT_CHECKS
|
|
|
|
#endif
|
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
#include "GSearch.h"
|
|
|
|
#include "ControlSearch.h"
|
|
|
|
#include "ghelpers.h"
|
2004-09-26 18:36:07 +00:00
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
#include <libglademm.h>
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
typedef GViewCB<ControlSearch, GViewGladeB> base_class;
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
GSearch::GSearch(Dialog & parent)
|
|
|
|
: base_class(parent, _("Find and Replace"), false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void GSearch::doBuild()
|
|
|
|
{
|
|
|
|
string const gladeName = findGladeFile("search");
|
|
|
|
xml_ = Gnome::Glade::Xml::create(gladeName);
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
Gtk::Button * cancelbutton;
|
|
|
|
xml_->get_widget("Cancel", cancelbutton);
|
|
|
|
setCancel(cancelbutton);
|
|
|
|
|
|
|
|
xml_->get_widget("FindNext", findnextbutton);
|
|
|
|
xml_->get_widget("Replace", replacebutton);
|
2004-09-26 13:18:29 +00:00
|
|
|
xml_->get_widget("ReplaceAll", replaceallbutton);
|
2004-09-24 20:07:54 +00:00
|
|
|
xml_->get_widget("FindEntry", findentry);
|
|
|
|
xml_->get_widget("ReplaceEntry", replaceentry);
|
|
|
|
xml_->get_widget("CaseSensitive", casecheck);
|
|
|
|
xml_->get_widget("MatchWord", matchwordcheck);
|
|
|
|
xml_->get_widget("SearchBackwards", backwardscheck);
|
|
|
|
|
|
|
|
findnextbutton->signal_clicked().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GSearch::onFindNext));
|
2004-09-24 20:07:54 +00:00
|
|
|
replacebutton->signal_clicked().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GSearch::onReplace));
|
2004-09-24 20:07:54 +00:00
|
|
|
replaceallbutton->signal_clicked().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GSearch::onReplaceAll));
|
2004-09-24 20:07:54 +00:00
|
|
|
findentry->signal_changed().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this,&GSearch::onFindEntryChanged));
|
2004-09-24 20:07:54 +00:00
|
|
|
|
|
|
|
bcview().addReadOnly(replaceentry);
|
|
|
|
bcview().addReadOnly(replacebutton);
|
|
|
|
bcview().addReadOnly(replaceallbutton);
|
|
|
|
}
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-10-03 12:31:38 +00:00
|
|
|
void GSearch::update()
|
|
|
|
{
|
|
|
|
bc().refreshReadOnly();
|
|
|
|
onFindEntryChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
void GSearch::onFindNext()
|
|
|
|
{
|
|
|
|
controller().find(findentry->get_text(),
|
|
|
|
casecheck->get_active(),
|
|
|
|
matchwordcheck->get_active(),
|
|
|
|
!backwardscheck->get_active());
|
|
|
|
}
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
void GSearch::onReplace()
|
|
|
|
{
|
|
|
|
controller().replace(findentry->get_text(),
|
|
|
|
replaceentry->get_text(),
|
|
|
|
casecheck->get_active(),
|
|
|
|
matchwordcheck->get_active(),
|
|
|
|
!backwardscheck->get_active(),
|
2004-09-26 13:18:29 +00:00
|
|
|
false);
|
2004-09-24 20:07:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
void GSearch::onReplaceAll()
|
|
|
|
{
|
|
|
|
controller().replace(findentry->get_text(),
|
|
|
|
replaceentry->get_text(),
|
|
|
|
casecheck->get_active(),
|
|
|
|
matchwordcheck->get_active(),
|
|
|
|
!backwardscheck->get_active(),
|
2004-09-26 13:18:29 +00:00
|
|
|
true);
|
2004-09-24 20:07:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-09-24 20:07:54 +00:00
|
|
|
void GSearch::onFindEntryChanged()
|
|
|
|
{
|
|
|
|
if (findentry->get_text().empty()) {
|
|
|
|
findnextbutton->set_sensitive(false);
|
|
|
|
replacebutton->set_sensitive(false);
|
2004-09-26 13:18:29 +00:00
|
|
|
replaceallbutton->set_sensitive(false);
|
2004-09-24 20:07:54 +00:00
|
|
|
} else {
|
|
|
|
findnextbutton->set_sensitive(true);
|
2004-10-03 12:31:38 +00:00
|
|
|
replacebutton->set_sensitive(!readOnly());
|
|
|
|
replaceallbutton->set_sensitive(!readOnly());
|
2004-09-24 20:07:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|