]> git.lyx.org Git - features.git/commitdiff
John Spray's gtk search dialog.
authorAngus Leeming <leeming@lyx.org>
Fri, 24 Sep 2004 20:07:54 +0000 (20:07 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 24 Sep 2004 20:07:54 +0000 (20:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9004 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gtk/ChangeLog
src/frontends/gtk/Dialogs.C
src/frontends/gtk/GSearch.C [new file with mode: 0644]
src/frontends/gtk/GSearch.h [new file with mode: 0644]
src/frontends/gtk/Makefile.am
src/frontends/gtk/glade/search.glade

index 5bbff031f60165391ef6cddf54e281babcba5408..1def5b2a911dcfa0415e3a5922514ec6e075c204 100644 (file)
@@ -1,3 +1,12 @@
+2004-09-24  John Spray  <spray_john@users.sourceforge.net>
+
+       * 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  <spray_john@users.sourceforge.net>
 
        * GWorkArea.[Ch]: Add GWorkArea::onScrollWheel to implement
index dc3a89c1e57eb5a161ed76e202f0f963e0cfac30..92ca067f46d84094c543fad52be83410b7a911b6 100644 (file)
@@ -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 (file)
index 0000000..14fa203
--- /dev/null
@@ -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 <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;
+
+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 (file)
index 0000000..0ace513
--- /dev/null
@@ -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<ControlSearch, GViewGladeB>
+{
+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
index efebc5b8e828376fc071d0ba4031c92bbc9923ad..e55cd355662a580b1859a3a1cb01183fdd1371f0 100644 (file)
@@ -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 \
index 8f113fc4cc452dec61d9d50d1bc3b7b0f11d6ec6..eb2f7c7a0ca6f806f9db48c2e037543eab00eda4 100644 (file)
@@ -5,12 +5,18 @@
 
 <widget class="GtkWindow" id="dialog">
   <property name="visible">True</property>
-  <property name="title" translatable="yes">LyX: Find and Replace</property>
+  <property name="title" translatable="yes">Find and Replace</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
   <property name="window_position">GTK_WIN_POS_NONE</property>
   <property name="modal">False</property>
-  <property name="resizable">True</property>
+  <property name="default_width">450</property>
+  <property name="resizable">False</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GtkTable" id="table1">
       <property name="n_columns">3</property>
       <property name="homogeneous">False</property>
       <property name="row_spacing">2</property>
-      <property name="column_spacing">2</property>
+      <property name="column_spacing">4</property>
 
       <child>
        <widget class="GtkLabel" id="label1">
          <property name="visible">True</property>
-         <property name="label" translatable="yes">Find:</property>
+         <property name="label" translatable="yes">Find what:</property>
          <property name="use_underline">False</property>
          <property name="use_markup">False</property>
          <property name="justify">GTK_JUSTIFY_RIGHT</property>
@@ -80,7 +86,7 @@
          <property name="text" translatable="yes"></property>
          <property name="has_frame">True</property>
          <property name="invisible_char" translatable="yes">*</property>
-         <property name="activates_default">False</property>
+         <property name="activates_default">True</property>
        </widget>
        <packing>
          <property name="left_attach">1</property>
       <child>
        <widget class="GtkButton" id="FindNext">
          <property name="visible">True</property>
+         <property name="sensitive">False</property>
          <property name="can_default">True</property>
          <property name="has_default">True</property>
          <property name="can_focus">True</property>
-         <property name="label" translatable="yes">Find next</property>
-         <property name="use_underline">True</property>
+         <property name="label">gtk-find</property>
+         <property name="use_stock">True</property>
          <property name="relief">GTK_RELIEF_NORMAL</property>
+         <property name="focus_on_click">True</property>
        </widget>
        <packing>
          <property name="left_attach">2</property>
       <child>
        <widget class="GtkButton" id="Replace">
          <property name="visible">True</property>
+         <property name="sensitive">False</property>
          <property name="can_focus">True</property>
-         <property name="label" translatable="yes">_Replace</property>
-         <property name="use_underline">True</property>
+         <property name="label">gtk-find-and-replace</property>
+         <property name="use_stock">True</property>
          <property name="relief">GTK_RELIEF_NORMAL</property>
+         <property name="focus_on_click">True</property>
        </widget>
        <packing>
          <property name="left_attach">2</property>
        </packing>
       </child>
 
-      <child>
-       <widget class="GtkButton" id="ReplaceAll">
-         <property name="visible">True</property>
-         <property name="can_focus">True</property>
-         <property name="label" translatable="yes">Repl_ace all</property>
-         <property name="use_underline">True</property>
-         <property name="relief">GTK_RELIEF_NORMAL</property>
-       </widget>
-       <packing>
-         <property name="left_attach">2</property>
-         <property name="right_attach">3</property>
-         <property name="top_attach">2</property>
-         <property name="bottom_attach">3</property>
-         <property name="x_options">fill</property>
-         <property name="y_options"></property>
-       </packing>
-      </child>
-
       <child>
        <widget class="GtkButton" id="Cancel">
          <property name="visible">True</property>
          <property name="can_focus">True</property>
-         <property name="label" translatable="yes">Cancel</property>
-         <property name="use_underline">True</property>
+         <property name="label">gtk-close</property>
+         <property name="use_stock">True</property>
          <property name="relief">GTK_RELIEF_NORMAL</property>
+         <property name="focus_on_click">True</property>
+         <accelerator key="Escape" modifiers="0" signal="clicked"/>
        </widget>
        <packing>
          <property name="left_attach">2</property>
              <property name="label" translatable="yes">_Case sensitive</property>
              <property name="use_underline">True</property>
              <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
              <property name="active">False</property>
              <property name="inconsistent">False</property>
              <property name="draw_indicator">True</property>
              <property name="label" translatable="yes">_Match word</property>
              <property name="use_underline">True</property>
              <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
              <property name="active">False</property>
              <property name="inconsistent">False</property>
              <property name="draw_indicator">True</property>
          <property name="spacing">0</property>
 
          <child>
-           <widget class="GtkCheckButton" id="SearchBackwords">
+           <widget class="GtkCheckButton" id="SearchBackwards">
              <property name="visible">True</property>
              <property name="can_focus">True</property>
              <property name="label" translatable="yes">_Search backwards</property>
              <property name="use_underline">True</property>
              <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
              <property name="active">False</property>
              <property name="inconsistent">False</property>
              <property name="draw_indicator">True</property>
          <property name="y_options">fill</property>
        </packing>
       </child>
+
+      <child>
+       <widget class="GtkButton" id="ReplaceAll">
+         <property name="visible">True</property>
+         <property name="sensitive">False</property>
+         <property name="can_focus">True</property>
+         <property name="label" translatable="yes">Repl_ace all</property>
+         <property name="use_underline">True</property>
+         <property name="relief">GTK_RELIEF_NORMAL</property>
+         <property name="focus_on_click">True</property>
+       </widget>
+       <packing>
+         <property name="left_attach">2</property>
+         <property name="right_attach">3</property>
+         <property name="top_attach">2</property>
+         <property name="bottom_attach">3</property>
+         <property name="x_options">fill</property>
+         <property name="y_options"></property>
+       </packing>
+      </child>
     </widget>
   </child>
 </widget>