Angus Leeming wrote:

> Georg Baum wrote:
>> Angus, do you plan to commit Bernhards work? If not, I will just do
>> it, since the gtk frontend is not in freeze, and this is certainly
>> an improvement.
> 
> Go for it.

Done (minus the controller change, see patch).

> On a more general level, at what point should be scrub the "XForms
> exception" from the licence and from the web pages?

IMHO: When all people who contributed significantly have agreed to the pure
GPL.


Georg
Index: src/frontends/gtk/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/ChangeLog,v
retrieving revision 1.135
diff -u -p -r1.135 ChangeLog
--- src/frontends/gtk/ChangeLog	2 Oct 2005 16:35:56 -0000	1.135
+++ src/frontends/gtk/ChangeLog	14 Oct 2005 15:56:07 -0000
@@ -1,3 +1,10 @@
+2005-10-12  Bernhard Reiter  <[EMAIL PROTECTED]>
+
+	* The Thesaurus dialog
+	* GThesaurus.C, GThesaurus.h, Makefile.am
+	* Dialogs.C: moved BC generation to individual if blocks
+	* glade/thesaurus.glade, glade/Makefile.am
+
 2005-10-02  Martin Vermeer  <[EMAIL PROTECTED]>
 
 	* GToc.C: fix bug 2038
Index: src/frontends/gtk/Dialogs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/Dialogs.C,v
retrieving revision 1.42
diff -u -p -r1.42 Dialogs.C
--- src/frontends/gtk/Dialogs.C	5 Aug 2005 07:20:38 -0000	1.42
+++ src/frontends/gtk/Dialogs.C	14 Oct 2005 15:56:07 -0000
@@ -100,7 +100,7 @@
 
 #ifdef HAVE_LIBAIKSAURUS
 #include "ControlThesaurus.h"
-#include "FormThesaurus.h"
+#include "GThesaurus.h"
 #endif
 
 #include "xformsBC.h"
@@ -520,8 +532,9 @@ Dialogs::DialogPtr Dialogs::build(string
 		dialog->bc().bp(new OkCancelPolicy);
 #ifdef HAVE_LIBAIKSAURUS
 	} else if (name == "thesaurus") {
+		dialog->bc().view(new GBC(dialog->bc()));
 		dialog->setController(new ControlThesaurus(*dialog));
-		dialog->setView(new FormThesaurus(*dialog));
+		dialog->setView(new GThesaurus(*dialog));
 		dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
 #endif
 	} else if (name == "toc") {
Index: src/frontends/gtk/GThesaurus.C
===================================================================
RCS file: src/frontends/gtk/GThesaurus.C
diff -N src/frontends/gtk/GThesaurus.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/frontends/gtk/GThesaurus.C	14 Oct 2005 15:56:07 -0000
@@ -0,0 +1,170 @@
+/**
+ * \file GThesaurus.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Bernhard Reiter
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCXX_CONCEPT_CHECKS
+#undef _GLIBCXX_CONCEPT_CHECKS
+#endif
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
+
+#include "GThesaurus.h"
+#include "ControlThesaurus.h"
+#include "ghelpers.h"
+
+#include "support/lstrings.h"
+
+#include <libglademm.h>
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+class synModelColumns : public Gtk::TreeModel::ColumnRecord
+{
+public:
+
+	synModelColumns() { add(name); }
+
+	Gtk::TreeModelColumn<Glib::ustring> name;
+};
+
+synModelColumns synColumns;
+
+
+GThesaurus::GThesaurus(Dialog & parent)
+	: GViewCB<ControlThesaurus, GViewGladeB>(parent, _("Thesaurus"), false)
+{}
+
+
+void GThesaurus::doBuild()
+{
+	string const gladeName = findGladeFile("thesaurus");
+	xml_ = Gnome::Glade::Xml::create(gladeName);
+
+	xml_->get_widget("Cancel", cancelbutton_);
+	setCancel(cancelbutton_);
+	xml_->get_widget("Apply", applybutton_);
+	setApply(applybutton_);
+	xml_->get_widget("OK", okbutton_);
+	setOK(okbutton_);
+
+	xml_->get_widget("Keyword", keywordentry_);
+	xml_->get_widget("Meanings", meaningsview_);
+
+	meaningsview_->append_column(_("Synonym"), synColumns.name);
+
+
+	// Keyword entry changed
+	keywordentry_->signal_changed().connect(
+		sigc::mem_fun(*this, &GThesaurus::update_lists));
+
+	// Single click in meanings (synonyms) list
+	meaningsview_->signal_cursor_changed().connect(
+		sigc::mem_fun(*this, &GThesaurus::selection_changed));
+
+	// Double click in meanings (synonyms) list
+	meaningsview_->signal_row_activated().connect(
+		sigc::mem_fun(*this, &GThesaurus::meaningsview_activated));
+
+}
+
+void GThesaurus::update()
+{
+	string const contents = support::trim(controller().text());
+	if (contents.empty()) {
+		applylock_ = true;
+		bc().valid(false);
+	} else {
+		applylock_ = false;
+		keywordentry_->set_text(Glib::locale_to_utf8(contents));
+		bc().valid(true);
+	}
+	keywordentry_->grab_focus();
+	update_lists();
+
+}
+
+
+void GThesaurus::selection_changed()
+{
+	Gtk::TreeModel::iterator iter = meaningsview_->get_selection()->get_selected();
+	if(iter) {
+		if (!applylock_) bc().valid(true);
+	}
+
+}
+
+
+void GThesaurus::meaningsview_activated(const Gtk::TreeModel::Path&, Gtk::TreeViewColumn*)
+{
+	Gtk::TreeModel::iterator iter = meaningsview_->get_selection()->get_selected();
+	if(iter) {
+		Gtk::TreeModel::Row row = *iter;
+		keywordentry_->set_text(row[synColumns.name]);
+	}
+	selection_changed();
+	update_lists();
+	if (!applylock_) bc().valid(true);
+}
+
+
+void GThesaurus::apply()
+{
+	Gtk::TreeModel::iterator iter = meaningsview_->get_selection()->get_selected();
+	if(iter) {
+		controller().replace(Glib::locale_from_utf8((*iter)[synColumns.name]));
+	} else if (keywordentry_->get_text_length()) {
+		controller().replace(Glib::locale_from_utf8(keywordentry_->get_text()));
+	}
+	update();
+}
+
+
+void GThesaurus::update_lists()
+{
+	Thesaurus::Meanings meanings = controller().getMeanings(keywordentry_->get_text());
+	synTreeStore_ = Gtk::TreeStore::create(synColumns);
+
+	if (!meanings.empty()) {
+		for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
+			cit != meanings.end(); ++cit) {
+
+			Gtk::TreeModel::Row row = *(synTreeStore_->append());
+			row[synColumns.name] = cit->first;
+
+			for (std::vector<string>::const_iterator cit2 = cit->second.begin(); 
+				cit2 != cit->second.end(); ++cit2) {
+  				Gtk::TreeModel::Row childrow = *(synTreeStore_->append(row.children()));
+				childrow[synColumns.name] = *cit2;
+				}
+		}
+		meaningsview_->set_sensitive(true);
+	} else {
+		Gtk::TreeModel::Row row = *(synTreeStore_->append());
+		row[synColumns.name] = _("No synonyms found");
+		meaningsview_->set_sensitive(false);
+	}
+	meaningsview_->set_model(synTreeStore_);
+
+	if (keywordentry_->get_text_length()) {
+		if (!applylock_) bc().valid(true);
+	} else {
+		bc().valid(false);
+	}
+}
+
+
+} // namespace frontend
+} // namespace lyx
Index: src/frontends/gtk/GThesaurus.h
===================================================================
RCS file: src/frontends/gtk/GThesaurus.h
diff -N src/frontends/gtk/GThesaurus.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/frontends/gtk/GThesaurus.h	14 Oct 2005 15:56:07 -0000
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+/**
+ * \file GThesaurus.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Bernhard Reiter
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GTHESAURUS_H
+#define GTHESAURUS_H
+
+#include "GViewBase.h"
+
+namespace lyx {
+namespace frontend {
+
+class ControlThesaurus;
+
+/** This class provides a GTK+ implementation of the Thesaurus Dialog.
+ */
+class GThesaurus : public GViewCB<ControlThesaurus, GViewGladeB> {
+public:
+	GThesaurus(Dialog & parent);
+private:
+	virtual void apply();
+	virtual void doBuild();
+	virtual void update();
+
+	/// updates the synonym list (e.g. when the keyword is changed)
+	void update_lists();
+	/// enables the apply button if a synonym is selected from the list 
+	void selection_changed();
+	/// changes the keyword entry content to the synonym double-clicked on
+	void meaningsview_activated(const Gtk::TreeModel::Path&, Gtk::TreeViewColumn*);
+
+	/** apply() won't act when this is true. 
+	    true if no text is selected when the thesaurus dialog is opened 
+	 */
+	bool applylock_;
+
+	Gtk::Button * cancelbutton_;
+	Gtk::Button * okbutton_;
+	Gtk::Button * applybutton_;
+	Gtk::Entry * keywordentry_;
+	Gtk::TreeView * meaningsview_;
+	Glib::RefPtr<Gtk::TreeStore> synTreeStore_;
+
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GTHESAURUS_H
Index: src/frontends/gtk/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/Makefile.am,v
retrieving revision 1.42
diff -u -p -r1.42 Makefile.am
--- src/frontends/gtk/Makefile.am	5 Aug 2005 07:20:38 -0000	1.42
+++ src/frontends/gtk/Makefile.am	14 Oct 2005 15:56:07 -0000
@@ -89,6 +89,8 @@ libgtk_la_SOURCES = \
 	GTexinfo.h \
 	GText.C \
 	GText.h \
+	GThesaurus.C \
+	GThesaurus.h \
 	GTimeout.C \
 	GTimeout.h \
 	GToc.C \
@@ -148,7 +150,6 @@ xforms_objects = \
 	../xforms/forms_gettext.lo \
 	../xforms/FormTabular.lo \
 	../xforms/FormText.lo \
-	../xforms/FormThesaurus.lo \
 	../xforms/FormWrap.lo \
 	../xforms/freebrowser.lo \
 	../xforms/input_validators.lo \
Index: src/frontends/gtk/glade/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/glade/Makefile.am,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile.am
--- src/frontends/gtk/glade/Makefile.am	5 Aug 2005 07:20:38 -0000	1.8
+++ src/frontends/gtk/glade/Makefile.am	14 Oct 2005 15:56:07 -0000
@@ -29,6 +29,7 @@ dist_glade_DATA = \
 	tableCreate.glade \
 	texinfo.glade \
 	text.glade \
+	thesaurus.glade \
 	toc.glade \
 	url.glade \
 	vspace.glade
Index: src/frontends/gtk/glade/thesaurus.glade
===================================================================
RCS file: src/frontends/gtk/glade/thesaurus.glade
diff -N src/frontends/gtk/glade/thesaurus.glade
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/frontends/gtk/glade/thesaurus.glade	14 Oct 2005 15:56:07 -0000
@@ -0,0 +1,177 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
+
+<glade-interface>
+
+<widget class="GtkDialog" id="dialog">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">dialog1</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">True</property>
+  <property name="resizable">True</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>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox2">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+	<widget class="GtkHButtonBox" id="dialog-action_area2">
+	  <property name="visible">True</property>
+	  <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class="GtkButton" id="Apply">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-apply</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-10</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="Cancel">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-cancel</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-6</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="OK">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-ok</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-5</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">True</property>
+	  <property name="pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkVBox" id="vbox1">
+	  <property name="border_width">12</property>
+	  <property name="visible">True</property>
+	  <property name="homogeneous">False</property>
+	  <property name="spacing">0</property>
+
+	  <child>
+	    <widget class="GtkHBox" id="hbox2">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">6</property>
+
+	      <child>
+		<widget class="GtkLabel" id="label2">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">_Keyword:</property>
+		  <property name="use_underline">True</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="mnemonic_widget">Keyword</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkEntry" id="Keyword">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">True</property>
+		  <property name="max_length">0</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</property>
+		  <property name="invisible_char">*</property>
+		  <property name="activates_default">False</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">True</property>
+		  <property name="fill">True</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">3</property>
+	      <property name="expand">False</property>
+	      <property name="fill">True</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkScrolledWindow" id="scrolledwindow1">
+	      <property name="visible">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+	      <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+	      <property name="shadow_type">GTK_SHADOW_IN</property>
+	      <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+	      <child>
+		<widget class="GtkTreeView" id="Meanings">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="headers_visible">False</property>
+		  <property name="rules_hint">False</property>
+		  <property name="reorderable">False</property>
+		  <property name="enable_search">True</property>
+		</widget>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">3</property>
+	      <property name="expand">True</property>
+	      <property name="fill">True</property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+</glade-interface>

Reply via email to