From e5982ba00faa32b609af5b8b6fc9aa21d6e29657 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 24 Sep 2004 20:07:54 +0000 Subject: [PATCH] John Spray's gtk search dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9004 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 9 +++ src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GSearch.C | 105 +++++++++++++++++++++++++++ src/frontends/gtk/GSearch.h | 51 +++++++++++++ src/frontends/gtk/Makefile.am | 98 +++++++++++++------------ src/frontends/gtk/glade/search.glade | 77 ++++++++++++-------- 6 files changed, 265 insertions(+), 80 deletions(-) create mode 100644 src/frontends/gtk/GSearch.C create mode 100644 src/frontends/gtk/GSearch.h diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 5bbff031f6..1def5b2a91 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,12 @@ +2004-09-24 John Spray + + * GSearch.[Ch]: new files + * Dialogs.C: move from formsearch to gsearch + * Makefile.am: move from formsearch to gsearch, alphabetically + sort list of libgtk_la_SOURCES + * glade/search.glade: s/Backwords/Backwards/, accelerator escape + for close button, gtk stock buttons for find and replace. + 2004-09-23 John Spray * GWorkArea.[Ch]: Add GWorkArea::onScrollWheel to implement diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index dc3a89c1e5..92ca067f46 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -78,7 +78,7 @@ #include "FormPreferences.h" #include "FormPrint.h" #include "FormRef.h" -#include "FormSearch.h" +#include "GSearch.h" #include "FormSendto.h" #include "FormTabular.h" #include "FormTexinfo.h" @@ -226,8 +226,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormShowFile(*dialog)); dialog->bc().bp(new OkCancelPolicy); } else if (name == "findreplace") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlSearch(*dialog)); - dialog->setView(new FormSearch(*dialog)); + dialog->setView(new GSearch(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "float") { dialog->setController(new ControlFloat(*dialog)); diff --git a/src/frontends/gtk/GSearch.C b/src/frontends/gtk/GSearch.C new file mode 100644 index 0000000000..14fa2033e3 --- /dev/null +++ b/src/frontends/gtk/GSearch.C @@ -0,0 +1,105 @@ +/** + * \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 +#include + +#include "GSearch.h" +#include "ControlSearch.h" +#include "ghelpers.h" +#include + +using std::string; + +namespace lyx { +namespace frontend { + +typedef GViewCB base_class; + +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); + + Gtk::Button * cancelbutton; + xml_->get_widget("Cancel", cancelbutton); + setCancel(cancelbutton); + + xml_->get_widget("FindNext", findnextbutton); + xml_->get_widget("Replace", replacebutton); + xml_->get_widget("ReplaceAll", replaceallbutton); + 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( + SigC::slot(*this,&GSearch::onFindEntryChanged)); + + bcview().addReadOnly(replaceentry); + bcview().addReadOnly(replacebutton); + bcview().addReadOnly(replaceallbutton); +} + +void GSearch::onFindNext() +{ + controller().find(findentry->get_text(), + casecheck->get_active(), + matchwordcheck->get_active(), + !backwardscheck->get_active()); +} + +void GSearch::onReplace() +{ + controller().replace(findentry->get_text(), + replaceentry->get_text(), + casecheck->get_active(), + matchwordcheck->get_active(), + !backwardscheck->get_active(), + false); +} + +void GSearch::onReplaceAll() +{ + controller().replace(findentry->get_text(), + replaceentry->get_text(), + casecheck->get_active(), + matchwordcheck->get_active(), + !backwardscheck->get_active(), + true); +} + +void GSearch::onFindEntryChanged() +{ + if (findentry->get_text().empty()) { + findnextbutton->set_sensitive(false); + replacebutton->set_sensitive(false); + replaceallbutton->set_sensitive(false); + } else { + findnextbutton->set_sensitive(true); + replacebutton->set_sensitive(true); + replaceallbutton->set_sensitive(true); + } +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GSearch.h b/src/frontends/gtk/GSearch.h new file mode 100644 index 0000000000..0ace5137c4 --- /dev/null +++ b/src/frontends/gtk/GSearch.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +/** + * \file GSearch.h + * 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. + */ + +#ifndef GSEARCH_H +#define GSEARCH_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlSearch; + +/** This class provides a GTK+ implementation of the FormSearch Dialog. + */ +class GSearch : public GViewCB +{ +public: + GSearch(Dialog & parent); +private: + virtual void apply() {} + virtual void doBuild(); + virtual void update() {} + + void onFindNext(); + void onReplace(); + void onReplaceAll(); + void onFindEntryChanged(); + + Gtk::Button * findnextbutton; + Gtk::Button * replacebutton; + Gtk::Button * replaceallbutton; + Gtk::Entry * findentry; + Gtk::Entry * replaceentry; + Gtk::CheckButton * casecheck; + Gtk::CheckButton * matchwordcheck; + Gtk::CheckButton * backwardscheck; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GSEARCH_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index efebc5b8e8..e55cd35566 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -15,62 +15,65 @@ libgtk_la_LIBADD = $(xforms_objects) ../xforms/forms/*.lo @GTK_FRONTEND_LIBS@ @X # Alphabetical order please. It makes it easier to figure out what's missing. libgtk_la_SOURCES = \ - ghelpers.C \ - ghelpers.h \ - lyx_gui.C \ - GtkmmX.h \ - xftFontLoader.C \ - xftFontLoader.h \ - codeConvert.h \ - xftFontMetrics.C \ - GScreen.C \ - GScreen.h \ - LyXScreenFactory.C \ + Alert_pimpl.C \ + Dialogs.C \ + FileDialog.C \ + FileDialogPrivate.C \ + FileDialogPrivate.h \ + GAboutlyx.C \ + GAboutlyx.h \ + GBC.C \ + GBC.h \ + GLyXKeySym.C \ + GLyXKeySym.h \ + GMathDelim.C \ + GMathDelim.h \ + GMathPanel.C \ + GMathPanel.h \ GMenubar.C \ GMenubar.h \ - GTimeout.C \ - GTimeout.h \ - GToolbar.C \ - GToolbar.h \ - WorkAreaFactory.C \ GMiniBuffer.C \ GMiniBuffer.h \ GPainter.C \ GPainter.h \ - GWorkArea.h \ - GWorkArea.C \ - GLyXKeySym.h \ - GLyXKeySym.C \ - LyXKeySymFactory.C \ - Alert_pimpl.C \ - GView.h \ - GView.C \ - IdSc.h \ - IdSc.C \ - io_callback.h \ - io_callback.C \ - Dialogs.C \ - GAboutlyx.h \ - GAboutlyx.C \ - GViewBase.h \ - GViewBase.C \ - GBC.h \ - GBC.C \ - FileDialogPrivate.h \ - FileDialogPrivate.C \ - FileDialog.C \ - GText.h \ + GScreen.C \ + GScreen.h \ + GSearch.C \ + GSearch.h \ + GTableCreate.C \ + GTableCreate.h \ GText.C \ - GUrl.h \ + GText.h \ + GTimeout.C \ + GTimeout.h \ + GToolbar.C \ + GToolbar.h \ GUrl.C \ - GTableCreate.h \ - GTableCreate.C \ - GMathPanel.h \ - GMathPanel.C \ - GXpmBtnTbl.h \ + GUrl.h \ + GView.C \ + GView.h \ + GViewBase.C \ + GViewBase.h \ + GWorkArea.C \ + GWorkArea.h \ GXpmBtnTbl.C \ - GMathDelim.h \ - GMathDelim.C + GXpmBtnTbl.h \ + GtkmmX.h \ + IdSc.C \ + IdSc.h \ + LyXKeySymFactory.C \ + LyXScreenFactory.C \ + WorkAreaFactory.C \ + codeConvert.h \ + ghelpers.C \ + ghelpers.h \ + io_callback.C \ + io_callback.h \ + lyx_gui.C \ + xftFontLoader.C \ + xftFontLoader.h \ + xftFontMetrics.C + # GPrint.h # GPrint.C @@ -111,7 +114,6 @@ xforms_objects = \ ../xforms/FormPreferences.lo \ ../xforms/FormPrint.lo \ ../xforms/FormRef.lo \ - ../xforms/FormSearch.lo \ ../xforms/FormSendto.lo \ ../xforms/forms_gettext.lo \ ../xforms/FormShowFile.lo \ diff --git a/src/frontends/gtk/glade/search.glade b/src/frontends/gtk/glade/search.glade index 8f113fc4cc..eb2f7c7a0c 100644 --- a/src/frontends/gtk/glade/search.glade +++ b/src/frontends/gtk/glade/search.glade @@ -5,12 +5,18 @@ True - LyX: Find and Replace + Find and Replace GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False - True + 450 + False False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST @@ -20,12 +26,12 @@ 3 False 2 - 2 + 4 True - Find: + Find what: False False GTK_JUSTIFY_RIGHT @@ -80,7 +86,7 @@ True * - False + True 1 @@ -115,12 +121,14 @@ True + False True True True - Find next - True + gtk-find + True GTK_RELIEF_NORMAL + True 2 @@ -135,10 +143,12 @@ True + False True - _Replace - True + gtk-find-and-replace + True GTK_RELIEF_NORMAL + True 2 @@ -150,31 +160,15 @@ - - - True - True - Repl_ace all - True - GTK_RELIEF_NORMAL - - - 2 - 3 - 2 - 3 - fill - - - - True True - Cancel - True + gtk-close + True GTK_RELIEF_NORMAL + True + 2 @@ -199,6 +193,7 @@ _Case sensitive True GTK_RELIEF_NORMAL + True False False True @@ -217,6 +212,7 @@ _Match word True GTK_RELIEF_NORMAL + True False False True @@ -245,12 +241,13 @@ 0 - + True True _Search backwards True GTK_RELIEF_NORMAL + True False False True @@ -271,6 +268,26 @@ fill + + + + True + False + True + Repl_ace all + True + GTK_RELIEF_NORMAL + True + + + 2 + 3 + 2 + 3 + fill + + + -- 2.39.2