--- /dev/null
+/**
+ * \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
<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>
<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>