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>
|
|
|
|
#include <gtkmm.h>
|
|
|
|
|
|
|
|
#include "GSearch.h"
|
|
|
|
#include "ControlSearch.h"
|
|
|
|
#include "ghelpers.h"
|
|
|
|
#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(
|
|
|
|
SigC::slot(*this, &GSearch::onFindNext));
|
|
|
|
replacebutton->signal_clicked().connect(
|
|
|
|
SigC::slot(*this, &GSearch::onReplace));
|
|
|
|
replaceallbutton->signal_clicked().connect(
|
|
|
|
SigC::slot(*this, &GSearch::onReplaceAll));
|
|
|
|
findentry->signal_changed().connect(
|
2004-09-26 13:18:29 +00:00
|
|
|
SigC::slot(*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-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);
|
|
|
|
replacebutton->set_sensitive(true);
|
2004-09-26 13:18:29 +00:00
|
|
|
replaceallbutton->set_sensitive(true);
|
2004-09-24 20:07:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|