[gtranslator] The translation memory is now a plugin
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] The translation memory is now a plugin
- Date: Sun, 18 Mar 2012 12:09:04 +0000 (UTC)
commit 174ceb49d3d3b59791151e7841e4c54d960e25e4
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Mar 18 10:10:34 2012 +0100
The translation memory is now a plugin
configure.ac | 14 +-
data/gtranslator-ui.xml | 16 +-
data/org.gnome.gtranslator.gschema.xml.in.in | 41 ---
plugins/Makefile.am | 3 +-
plugins/translation-memory/Makefile.am | 66 ++++
plugins/translation-memory/gda/Makefile.am | 28 ++
{src => plugins}/translation-memory/gda/gtr-gda.c | 4 +-
{src => plugins}/translation-memory/gda/gtr-gda.h | 0
.../gtr-translation-memory-dialog.c | 358 ++++++++++++++++++++
.../gtr-translation-memory-dialog.h | 56 +++
.../gtr-translation-memory-dialog.ui | 322 ++++++++++++++++++
.../gtr-translation-memory-plugin.c | 27 ++
.../gtr-translation-memory-plugin.h | 29 ++
.../gtr-translation-memory-tab-activatable.c | 202 +++++++++++
.../gtr-translation-memory-tab-activatable.h | 57 +++
.../translation-memory/gtr-translation-memory-ui.c | 61 ++--
.../translation-memory/gtr-translation-memory-ui.h | 8 +-
.../gtr-translation-memory-window-activatable.c | 280 +++++++++++++++
.../gtr-translation-memory-window-activatable.h | 57 +++
.../translation-memory/gtr-translation-memory.c | 79 ++---
.../gtr-translation-memory.gresource.xml | 6 +
.../translation-memory/gtr-translation-memory.h | 76 ++++
.../gtr-translation-memory.plugin.desktop.in | 8 +
...or.plugins.translation-memory.gschema.xml.in.in | 43 +++
po/POTFILES.in | 8 +-
po/POTFILES.skip | 1 +
src/Makefile.am | 5 +-
src/dialogs/gtr-assistant.c | 249 +-------------
src/dialogs/gtr-assistant.h | 8 +-
src/dialogs/gtr-preferences-dialog.c | 251 --------------
src/dialogs/gtr-preferences-dialog.ui | 289 +----------------
src/gtr-application.c | 48 +---
src/gtr-application.h | 2 -
src/gtr-settings.h | 5 -
src/gtr-tab.c | 39 ---
src/gtr-tab.h | 2 -
src/gtr-window.c | 19 +-
src/gtr-window.h | 42 +--
src/translation-memory/Makefile.am | 47 ---
src/translation-memory/gda/Makefile.am | 30 --
src/translation-memory/gtr-translation-memory.h | 83 -----
41 files changed, 1734 insertions(+), 1235 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f76e920..5cf80f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,9 +65,14 @@ AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
dnl ================================================================
dnl GSettings stuff
dnl ================================================================
-
GLIB_GSETTINGS
+dnl ================================================================
+dnl GResource stuff
+dnl ================================================================
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
dnl ==========================================================================
dnl
dnl If you add a version number here, you *must* add an AC_SUBST line for
@@ -76,7 +81,7 @@ dnl
dnl ==========================================================================
GTHREAD_REQUIRED=2.13.0
-GTK_REQUIRED=3.0.3
+GTK_REQUIRED=3.3.15
GLIB_REQUIRED=2.28.0
LIBXML_REQUIRED=2.4.12
SOURCEVIEW_REQUIRED=3.0.0
@@ -289,11 +294,12 @@ plugins/open-tran/Makefile
plugins/open-tran/org.gnome.gtranslator.plugins.open-tran.gschema.xml.in
plugins/codeview/Makefile
plugins/codeview/org.gnome.gtranslator.plugins.codeview.gschema.xml.in
+plugins/translation-memory/Makefile
+plugins/translation-memory/gda/Makefile
+plugins/translation-memory/org.gnome.gtranslator.plugins.translation-memory.gschema.xml.in
src/Makefile
src/dialogs/Makefile
src/toolbareditor/Makefile
-src/translation-memory/Makefile
-src/translation-memory/gda/Makefile
])
AC_OUTPUT
diff --git a/data/gtranslator-ui.xml b/data/gtranslator-ui.xml
index addb6fa..fac9fa8 100644
--- a/data/gtranslator-ui.xml
+++ b/data/gtranslator-ui.xml
@@ -26,10 +26,10 @@
<separator/>
<menuitem name="EditFuzzyMenu" action="EditFuzzy"/>
<separator/>
- <menuitem name="EditTranslationMemory" action="EditTranslationMemory"/>
- <separator/>
<placeholder name="EditOps_1" />
<separator/>
+ <placeholder name="EditOps_2" />
+ <separator/>
<menuitem name="EditToolbarMenu" action="EditToolbar"/>
<menuitem name="EditPreferencesMenu" action="EditPreferences"/>
</menu>
@@ -83,7 +83,17 @@
<menuitem name="SearchReplaceMenu" action="SearchReplace"/>
</menu>
- <placeholder name="SubversionPlaceholder" />
+ <menu name="ToolsMenu" action="Tools">
+ <placeholder name="ToolsOps_1" />
+ <separator/>
+ <placeholder name="ToolsOps_2" />
+ <separator/>
+ <placeholder name="ToolsOps_3" />
+ <separator/>
+ <placeholder name="ToolsOps_4" />
+ <separator/>
+ <placeholder name="ToolsOps_5" />
+ </menu>
<placeholder name="ExtraMenu_1" />
diff --git a/data/org.gnome.gtranslator.gschema.xml.in.in b/data/org.gnome.gtranslator.gschema.xml.in.in
index d525c66..1717773 100644
--- a/data/org.gnome.gtranslator.gschema.xml.in.in
+++ b/data/org.gnome.gtranslator.gschema.xml.in.in
@@ -109,47 +109,6 @@
</_description>
</key>
</schema>
- <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.preferences.tm" path="/org/gnome/gtranslator/preferences/tm/">
- <key name="po-directory" type="s">
- <default>''</default>
- <_summary>PO directory</_summary>
- <_description>
- Directory containing PO files to add to the translation memory.
- </_description>
- </key>
- <key name="restrict-to-filename" type="b">
- <default>false</default>
- <_summary>Restrict search by filename</_summary>
- <_description>
- If true, only include files with a specified filename when searching
- the translation memory.
- </_description>
- </key>
- <key name="filename-restriction" type="s">
- <default>''</default>
- <_summary>Filename to restrict search to</_summary>
- <_description>
- Filename to which searching of the translation memory should be
- restricted.
- </_description>
- </key>
- <key name="max-missing-words" type="i">
- <default>2</default>
- <_summary>Maximum number of missing words</_summary>
- <_description>
- Maximum number of words that can be missing from a message displayed as
- a match by the translation memory.
- </_description>
- </key>
- <key name="max-length-diff" type="i">
- <default>2</default>
- <_summary>Maximum difference in message length</_summary>
- <_description>
- Maximum difference in length between messages displayed as matches by
- the translation memory.
- </_description>
- </key>
- </schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.preferences.ui" path="/org/gnome/gtranslator/preferences/ui/">
<key name="panel-switcher-style" enum="org.gnome.gtranslator.SwitcherStyle">
<default>'both'</default>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d01b7cc..a5d69fc 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -3,7 +3,8 @@ SUBDIRS = \
charmap \
codeview \
fullscreen \
- insert-params
+ insert-params \
+ translation-memory
if USE_LIBJSON_GLIB
SUBDIRS += open-tran
diff --git a/plugins/translation-memory/Makefile.am b/plugins/translation-memory/Makefile.am
new file mode 100644
index 0000000..f870ead
--- /dev/null
+++ b/plugins/translation-memory/Makefile.am
@@ -0,0 +1,66 @@
+SUBDIRS = gda
+
+# Translation memory plugin
+plugindir = $(libdir)/gtranslator/plugins
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src \
+ $(GTRANSLATOR_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED)
+
+plugin_LTLIBRARIES = \
+ libtranslation-memory.la
+
+BUILT_SOURCES = \
+ gtr-translation-memory-resources.c
+
+libtranslation_memory_la_SOURCES = \
+ gtr-translation-memory-window-activatable.c \
+ gtr-translation-memory-window-activatable.h \
+ gtr-translation-memory-tab-activatable.c \
+ gtr-translation-memory-tab-activatable.h \
+ gtr-translation-memory-ui.c \
+ gtr-translation-memory-ui.h \
+ gtr-translation-memory-dialog.c \
+ gtr-translation-memory-dialog.h \
+ gtr-translation-memory.c \
+ gtr-translation-memory.h \
+ gtr-translation-memory-plugin.h \
+ gtr-translation-memory-plugin.c \
+ $(BUILT_SOURCES)
+
+libtranslation_memory_la_LDFLAGS = \
+ $(PLUGIN_LIBTOOL_FLAGS) \
+ $(GTRANSLATOR_LIBS) \
+ gda/libgda.la
+
+gtr-translation-memory-resources.c: gtr-translation-memory.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies gtr-translation-memory.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source gtr-translation-memory.gresource.xml
+
+# Plugin Info
+
+plugin_in_files = gtr-translation-memory.plugin.desktop.in
+
+%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
+
+gsettings_SCHEMAS = org.gnome.gtranslator.plugins.translation-memory.gschema.xml
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+ GSETTINGS_RULES@
+
+EXTRA_DIST = \
+ $(plugin_in_files) \
+ gtr-translation-memory.gresource.xml \
+ org.gnome.gtranslator.plugins.translation-memory.gschema.xml.in.in
+
+CLEANFILES = $(plugin_DATA) $(BUILT_SOURCES)
+DISTCLEANFILES = $(plugin_DATA) $(BUILT_SOURCES)
+
+MAINTAINERCLEANFILES = $(gsettings_SCHEMAS:.xml=.valid)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/translation-memory/gda/Makefile.am b/plugins/translation-memory/gda/Makefile.am
new file mode 100644
index 0000000..a5d3e04
--- /dev/null
+++ b/plugins/translation-memory/gda/Makefile.am
@@ -0,0 +1,28 @@
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
+ -I$(top_srcdir)/plugins/translation-memory \
+ -I$(headerdir) \
+ $(GTRANSLATOR_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED)
+
+noinst_LTLIBRARIES = \
+ libgda.la
+
+libgda_la_SOURCES = \
+ gtr-gda.c \
+ gtr-gda.h
+
+libgda_la_CFLAGS = \
+ $(GTRANSLATOR_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED) \
+ $(AM_CFLAGS)
+
+EXTRA_DIST = $(pixmaps__DATA)
+
+
+-include $(top_srcdir)/git.mk
diff --git a/src/translation-memory/gda/gtr-gda.c b/plugins/translation-memory/gda/gtr-gda.c
similarity index 99%
rename from src/translation-memory/gda/gtr-gda.c
rename to plugins/translation-memory/gda/gtr-gda.c
index 9b5ec31..18d5585 100644
--- a/src/translation-memory/gda/gtr-gda.c
+++ b/plugins/translation-memory/gda/gtr-gda.c
@@ -36,7 +36,7 @@
GtrGdaPrivate))
static void
-gtr_translation_memory_iface_init (GtrTranslationMemoryIface * iface);
+gtr_translation_memory_iface_init (GtrTranslationMemoryInterface * iface);
G_DEFINE_TYPE_WITH_CODE (GtrGda,
gtr_gda,
@@ -703,7 +703,7 @@ gtr_gda_set_max_items (GtrTranslationMemory * tm, gint items)
}
static void
-gtr_translation_memory_iface_init (GtrTranslationMemoryIface * iface)
+gtr_translation_memory_iface_init (GtrTranslationMemoryInterface * iface)
{
iface->store = gtr_gda_store;
iface->store_list = gtr_gda_store_list;
diff --git a/src/translation-memory/gda/gtr-gda.h b/plugins/translation-memory/gda/gtr-gda.h
similarity index 100%
rename from src/translation-memory/gda/gtr-gda.h
rename to plugins/translation-memory/gda/gtr-gda.h
diff --git a/plugins/translation-memory/gtr-translation-memory-dialog.c b/plugins/translation-memory/gtr-translation-memory-dialog.c
new file mode 100644
index 0000000..fb33f03
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-dialog.c
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gtr-translation-memory-dialog.h"
+#include "gtr-profile-manager.h"
+#include "gtr-utils.h"
+#include "gtr-po.h"
+
+#include <glib/gi18n.h>
+
+
+#define GTR_TRANSLATION_MEMORY_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GTR_TYPE_TRANSLATION_MEMORY_DIALOG, GtrTranslationMemoryDialogPrivate))
+
+struct _GtrTranslationMemoryDialogPrivate
+{
+ GSettings *tm_settings;
+
+ GtkWidget *directory_entry;
+ GtkWidget *search_button;
+ GtkWidget *add_database_button;
+ GtkWidget *add_database_progressbar;
+ GtkWidget *tm_lang_entry;
+ GtkWidget *use_lang_profile_in_tm;
+
+ GtrTranslationMemory *translation_memory;
+};
+
+G_DEFINE_TYPE (GtrTranslationMemoryDialog, gtr_translation_memory_dialog, GTK_TYPE_DIALOG)
+
+static void
+gtr_translation_memory_dialog_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtr_translation_memory_dialog_parent_class)->finalize (object);
+}
+
+static void
+gtr_translation_memory_dialog_dispose (GObject *object)
+{
+ GtrTranslationMemoryDialogPrivate *priv = GTR_TRANSLATION_MEMORY_DIALOG (object)->priv;
+
+ if (priv->tm_settings != NULL)
+ {
+ g_object_unref (priv->tm_settings);
+ priv->tm_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_translation_memory_dialog_parent_class)->dispose (object);
+}
+
+static void
+gtr_translation_memory_dialog_class_init (GtrTranslationMemoryDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gtr_translation_memory_dialog_finalize;
+ object_class->dispose = gtr_translation_memory_dialog_dispose;
+
+ g_type_class_add_private (object_class, sizeof (GtrTranslationMemoryDialogPrivate));
+}
+
+/***************Translation Memory pages****************/
+static void
+response_filechooser_cb (GtkDialog *dialog,
+ gint response_id, GtrTranslationMemoryDialog *dlg)
+{
+ if (response_id == GTK_RESPONSE_YES)
+ {
+ gchar *filename;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->directory_entry),
+ filename);
+ g_settings_set_string (dlg->priv->tm_settings,
+ "po-directory",
+ filename);
+ g_free (filename);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+on_search_button_clicked (GtkButton *button,
+ GtrTranslationMemoryDialog *dlg)
+{
+ GtkWidget *filechooser;
+
+ filechooser = gtk_file_chooser_dialog_new ("Select PO directory",
+ GTK_WINDOW (dlg),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_YES, NULL);
+
+ g_signal_connect (GTK_DIALOG (filechooser), "response",
+ G_CALLBACK (response_filechooser_cb), dlg);
+
+ gtk_dialog_run (GTK_DIALOG (filechooser));
+}
+
+typedef struct _IdleData
+{
+ GSList *list;
+ GtkProgressBar *progress;
+ GtrTranslationMemory *tm;
+ GtkWindow *parent;
+} IdleData;
+
+static gboolean
+add_to_database (gpointer data_pointer)
+{
+ IdleData *data = (IdleData *) data_pointer;
+ static GSList *l = NULL;
+ gdouble percentage;
+
+ if (l == NULL)
+ l = data->list;
+ else
+ l = g_slist_next (l);
+
+ if (l)
+ {
+ GList *msg_list = NULL;
+ GFile *location;
+ GError *error = NULL;
+ GtrPo *po;
+
+ po = gtr_po_new ();
+ location = (GFile *) l->data;
+
+ gtr_po_parse (po, location, &error);
+ if (error)
+ return TRUE;
+
+ msg_list = gtr_po_get_messages (po);
+
+ gtr_translation_memory_store_list (data->tm, msg_list);
+
+ g_object_unref (po);
+ }
+ else
+ {
+ GtkWidget *dialog;
+
+ gtk_progress_bar_set_fraction (data->progress, 1.0);
+
+ dialog = gtk_message_dialog_new (data->parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("<span weight=\"bold\" size=\"large\">Strings added to database</span>"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return FALSE;
+ }
+
+ percentage =
+ (gdouble) g_slist_position (data->list,
+ l) / (gdouble) g_slist_length (data->list);
+
+ /*
+ * Set the progress only if the values are reasonable.
+ */
+ if (percentage > 0.0 || percentage < 1.0)
+ {
+ /* Set the progressbar status. */
+ gtk_progress_bar_set_fraction (data->progress, percentage);
+ }
+
+ return TRUE;
+}
+
+static void
+destroy_idle_data (gpointer data)
+{
+ IdleData *d = (IdleData *) data;
+
+ gtk_widget_hide (GTK_WIDGET (d->progress));
+
+ g_slist_free_full (d->list, g_object_unref);
+ g_free (d);
+}
+
+static void
+on_add_database_button_clicked (GtkButton *button,
+ GtrTranslationMemoryDialog *dlg)
+{
+ GFile *dir;
+ gchar *dir_name;
+ IdleData *data;
+
+ data = g_new0 (IdleData, 1);
+ data->list = NULL;
+
+ dir_name = g_settings_get_string (dlg->priv->tm_settings,
+ "po-directory");
+
+ dir = g_file_new_for_path (dir_name);
+ g_free (dir_name);
+
+ if (g_settings_get_boolean (dlg->priv->tm_settings,
+ "restrict-to-filename"))
+ {
+ gchar *restriction;
+
+ restriction = g_settings_get_string (dlg->priv->tm_settings,
+ "filename-restriction");
+ gtr_utils_scan_dir (dir, &data->list, restriction);
+ g_free (restriction);
+ }
+ else
+ gtr_utils_scan_dir (dir, &data->list, NULL);
+
+ data->tm = dlg->priv->translation_memory;
+ data->progress = GTK_PROGRESS_BAR (dlg->priv->add_database_progressbar);
+ data->parent = GTK_WINDOW (dlg);
+
+ gtk_widget_show (dlg->priv->add_database_progressbar);
+ g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
+ (GSourceFunc) add_to_database,
+ data, (GDestroyNotify) destroy_idle_data);
+
+ g_object_unref (dir);
+}
+
+static void
+gtr_translation_memory_dialog_init (GtrTranslationMemoryDialog *dlg)
+{
+ GtrTranslationMemoryDialogPrivate *priv;
+ GtkWidget *action_area;
+ GtkWidget *content_area;
+ GtkBuilder *builder;
+ GtkWidget *content;
+ GtrProfileManager *prof_manager;
+ GtrProfile *profile;
+ const gchar *language_code;
+ gchar *filename = NULL;
+ GError *error = NULL;
+ gchar *root_objects[] = {
+ "translation-memory-box",
+ NULL
+ };
+
+ dlg->priv = GTR_TRANSLATION_MEMORY_DIALOG_GET_PRIVATE (dlg);
+ priv = dlg->priv;
+
+ priv->tm_settings = g_settings_new ("org.gnome.gtranslator.plugins.translation-memory");
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Translation Memory Manager"));
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dlg));
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (action_area), 4);
+
+ g_signal_connect (dlg, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/plugins/translation-memory/ui/gtr-translation-memory-dialog.ui", root_objects, &error);
+ content = GTK_WIDGET (gtk_builder_get_object (builder, "translation-memory-box"));
+ g_object_ref (content);
+ priv->directory_entry = GTK_WIDGET (gtk_builder_get_object (builder, "directory-entry"));
+ priv->search_button = GTK_WIDGET (gtk_builder_get_object (builder, "search-button"));
+ priv->add_database_button = GTK_WIDGET (gtk_builder_get_object (builder, "add-database-button"));
+ priv->add_database_progressbar = GTK_WIDGET (gtk_builder_get_object (builder, "add-database-progressbar"));
+ priv->use_lang_profile_in_tm = GTK_WIDGET (gtk_builder_get_object (builder, "use-lang-profile-in-tm"));
+ priv->tm_lang_entry = GTK_WIDGET (gtk_builder_get_object (builder, "tm-lang-entry"));
+ g_object_unref (builder);
+
+ gtk_box_pack_start (GTK_BOX (content_area), content, TRUE, TRUE, 0);
+ g_object_unref (content);
+
+ prof_manager = gtr_profile_manager_get_default ();
+ profile = gtr_profile_manager_get_active_profile (prof_manager);
+
+ if (profile != NULL)
+ {
+ language_code = gtr_profile_get_language_code (profile);
+ filename = g_strconcat (language_code, ".po", NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (priv->tm_lang_entry), filename);
+ }
+ g_object_unref (prof_manager);
+
+ if (filename != NULL)
+ g_settings_set_string (priv->tm_settings,
+ "filename-restriction",
+ filename);
+
+ g_free (filename);
+
+ g_settings_bind (priv->tm_settings,
+ "restrict-to-filename",
+ priv->use_lang_profile_in_tm,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (priv->tm_settings,
+ "po-directory",
+ priv->directory_entry,
+ "text",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (priv->tm_settings,
+ "filename-restriction",
+ priv->tm_lang_entry,
+ "text",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_signal_connect (GTK_BUTTON (priv->search_button), "clicked",
+ G_CALLBACK (on_search_button_clicked), dlg);
+
+ g_signal_connect (GTK_BUTTON (priv->add_database_button), "clicked",
+ G_CALLBACK (on_add_database_button_clicked), dlg);
+}
+
+GtkWidget *
+gtr_translation_memory_dialog_new (GtrTranslationMemory *translation_memory)
+{
+ GtrTranslationMemoryDialog *dlg;
+
+ dlg = GTR_TRANSLATION_MEMORY_DIALOG (g_object_new (GTR_TYPE_TRANSLATION_MEMORY_DIALOG, NULL));
+
+ /* FIXME: use a property */
+ dlg->priv->translation_memory = translation_memory;
+
+ return GTK_WIDGET (dlg);
+}
diff --git a/plugins/translation-memory/gtr-translation-memory-dialog.h b/plugins/translation-memory/gtr-translation-memory-dialog.h
new file mode 100644
index 0000000..989f186
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-dialog.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTR_TRANSLATION_MEMORY_DIALOG_H__
+#define __GTR_TRANSLATION_MEMORY_DIALOG_H__
+
+#include <gtk/gtk.h>
+#include "gtr-translation-memory.h"
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_TRANSLATION_MEMORY_DIALOG (gtr_translation_memory_dialog_get_type ())
+#define GTR_TRANSLATION_MEMORY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_TRANSLATION_MEMORY_DIALOG, GtrTranslationMemoryDialog))
+#define GTR_TRANSLATION_MEMORY_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_TRANSLATION_MEMORY_DIALOG, GtrTranslationMemoryDialog const))
+#define GTR_TRANSLATION_MEMORY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_TRANSLATION_MEMORY_DIALOG, GtrTranslationMemoryDialogClass))
+#define GTR_IS_TRANSLATION_MEMORY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_TRANSLATION_MEMORY_DIALOG))
+#define GTR_IS_TRANSLATION_MEMORY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_TRANSLATION_MEMORY_DIALOG))
+#define GTR_TRANSLATION_MEMORY_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_TRANSLATION_MEMORY_DIALOG, GtrTranslationMemoryDialogClass))
+
+typedef struct _GtrTranslationMemoryDialog GtrTranslationMemoryDialog;
+typedef struct _GtrTranslationMemoryDialogClass GtrTranslationMemoryDialogClass;
+typedef struct _GtrTranslationMemoryDialogPrivate GtrTranslationMemoryDialogPrivate;
+
+struct _GtrTranslationMemoryDialog
+{
+ GtkDialog parent;
+
+ GtrTranslationMemoryDialogPrivate *priv;
+};
+
+struct _GtrTranslationMemoryDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+GType gtr_translation_memory_dialog_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gtr_translation_memory_dialog_new (GtrTranslationMemory *translation_memory);
+
+G_END_DECLS
+
+#endif /* __GTR_TRANSLATION_MEMORY_DIALOG_H__ */
diff --git a/plugins/translation-memory/gtr-translation-memory-dialog.ui b/plugins/translation-memory/gtr-translation-memory-dialog.ui
new file mode 100644
index 0000000..f77e529
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-dialog.ui
@@ -0,0 +1,322 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="translation-memory-dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="translation-memory-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkBox" id="vbox9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label20">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Database:</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="right_padding">12</property>
+ <child>
+ <object class="GtkBox" id="hbox8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkLabel" id="label25">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label26">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Select the directory which contains PO files:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="hbox9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="directory-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="xalign">0.0099999997764825821</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="search-button">
+ <property name="label">gtk-find</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="add-database-button">
+ <property name="label" translatable="yes">Add to Database</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="add-database-progressbar">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label21">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Configuration:</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="right_padding">12</property>
+ <child>
+ <object class="GtkBox" id="hbox7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkLabel" id="label22">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="use-lang-profile-in-tm">
+ <property name="label" translatable="yes">Use only files with this name:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="tm-lang-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/plugins/translation-memory/gtr-translation-memory-plugin.c b/plugins/translation-memory/gtr-translation-memory-plugin.c
new file mode 100644
index 0000000..3c09ecd
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-plugin.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gtr-translation-memory-plugin.h"
+#include "gtr-translation-memory-window-activatable.h"
+#include "gtr-translation-memory-tab-activatable.h"
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+ gtr_window_activatable_register_peas_type (module);
+ gtr_tab_activatable_register_peas_type (module);
+}
diff --git a/plugins/translation-memory/gtr-translation-memory-plugin.h b/plugins/translation-memory/gtr-translation-memory-plugin.h
new file mode 100644
index 0000000..80cc85c
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-plugin.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTR_TRANSLATION_MEMORY_PLUGIN_H__
+#define __GTR_TRANSLATION_MEMORY_PLUGIN_H__
+
+#include <libpeas/peas-object-module.h>
+
+G_BEGIN_DECLS
+
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
+
+G_END_DECLS
+
+#endif /* __GTR_TRANSLATION_MEMORY_PLUGIN_H__ */
diff --git a/plugins/translation-memory/gtr-translation-memory-tab-activatable.c b/plugins/translation-memory/gtr-translation-memory-tab-activatable.c
new file mode 100644
index 0000000..7747d8a
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-tab-activatable.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-translation-memory-tab-activatable.h"
+#include "gtr-window.h"
+#include "gtr-tab-activatable.h"
+#include "gtr-translation-memory.h"
+#include "gtr-translation-memory-ui.h"
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <string.h>
+
+struct _GtrTranslationMemoryTabActivatablePrivate
+{
+ GtrTab *tab;
+ GtrTranslationMemory *translation_memory;
+ GtkWidget *tm_ui;
+};
+
+enum
+{
+ PROP_0,
+ PROP_TAB
+};
+
+static void gtr_tab_activatable_iface_init (GtrTabActivatableInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtrTranslationMemoryTabActivatable,
+ gtr_translation_memory_tab_activatable,
+ PEAS_TYPE_EXTENSION_BASE,
+ 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (GTR_TYPE_TAB_ACTIVATABLE,
+ gtr_tab_activatable_iface_init))
+
+static void
+gtr_translation_memory_tab_activatable_init (GtrTranslationMemoryTabActivatable *tab_activatable)
+{
+ tab_activatable->priv = G_TYPE_INSTANCE_GET_PRIVATE (tab_activatable,
+ GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE,
+ GtrTranslationMemoryTabActivatablePrivate);
+}
+
+static void
+gtr_translation_memory_tab_activatable_dispose (GObject *object)
+{
+ GtrTranslationMemoryTabActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE (object)->priv;
+
+ if (priv->tab != NULL)
+ {
+ g_object_unref (priv->tab);
+ priv->tab = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_translation_memory_tab_activatable_parent_class)->dispose (object);
+}
+
+static void
+gtr_translation_memory_tab_activatable_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtrTranslationMemoryTabActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_TAB:
+ priv->tab = GTR_TAB (g_value_dup_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtr_translation_memory_tab_activatable_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtrTranslationMemoryTabActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_TAB:
+ g_value_set_object (value, priv->tab);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+on_message_edition_finished (GtrTab *tab,
+ GtrMsg *msg,
+ GtrTranslationMemoryTabActivatable *activatable)
+{
+ GtrHeader *header;
+ GtrPo *po;
+
+ po = gtr_tab_get_po (tab);
+ header = gtr_po_get_header (po);
+
+ if (gtr_header_get_profile (header) != NULL)
+ {
+ if (gtr_msg_is_translated (msg) && !gtr_msg_is_fuzzy (msg))
+ gtr_translation_memory_store (activatable->priv->translation_memory, msg);
+ }
+}
+
+static void
+gtr_translation_memory_tab_activatable_activate (GtrTabActivatable *activatable)
+{
+ GtrTranslationMemoryTabActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE (activatable)->priv;
+ GtkWidget *window;
+
+ window = gtk_widget_get_toplevel (GTK_WIDGET (priv->tab));
+
+ priv->translation_memory = GTR_TRANSLATION_MEMORY (g_object_get_data (G_OBJECT (window), "GtrTranslationMemory"));
+
+ /* TM */
+ priv->tm_ui = gtr_translation_memory_ui_new (GTK_WIDGET (priv->tab), priv->translation_memory);
+ gtk_widget_show (priv->tm_ui);
+ gtr_tab_add_widget (priv->tab, priv->tm_ui,
+ "GtrTranslationMemoryUI",
+ _("Translation Memory"),
+ NULL,
+ GTR_TAB_PLACEMENT_RIGHT);
+
+ g_signal_connect (priv->tab, "message-edition-finished",
+ G_CALLBACK (on_message_edition_finished),
+ activatable);
+}
+
+static void
+gtr_translation_memory_tab_activatable_deactivate (GtrTabActivatable *activatable)
+{
+ GtrTranslationMemoryTabActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE (activatable)->priv;
+
+ g_signal_handlers_disconnect_by_func (priv->tab, on_message_edition_finished, activatable);
+
+ gtr_tab_remove_widget (priv->tab, priv->tm_ui);
+}
+
+static void
+gtr_translation_memory_tab_activatable_class_init (GtrTranslationMemoryTabActivatableClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = gtr_translation_memory_tab_activatable_dispose;
+ object_class->set_property = gtr_translation_memory_tab_activatable_set_property;
+ object_class->get_property = gtr_translation_memory_tab_activatable_get_property;
+
+ g_object_class_override_property (object_class, PROP_TAB, "tab");
+
+ g_type_class_add_private (klass, sizeof (GtrTranslationMemoryTabActivatablePrivate));
+}
+
+static void
+gtr_translation_memory_tab_activatable_class_finalize (GtrTranslationMemoryTabActivatableClass *klass)
+{
+}
+
+static void
+gtr_tab_activatable_iface_init (GtrTabActivatableInterface *iface)
+{
+ iface->activate = gtr_translation_memory_tab_activatable_activate;
+ iface->deactivate = gtr_translation_memory_tab_activatable_deactivate;
+}
+
+void
+gtr_tab_activatable_register_peas_type (PeasObjectModule *module)
+{
+ gtr_translation_memory_tab_activatable_register_type (G_TYPE_MODULE (module));
+
+ peas_object_module_register_extension_type (module,
+ GTR_TYPE_TAB_ACTIVATABLE,
+ GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE);
+}
diff --git a/plugins/translation-memory/gtr-translation-memory-tab-activatable.h b/plugins/translation-memory/gtr-translation-memory-tab-activatable.h
new file mode 100644
index 0000000..e86be15
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-tab-activatable.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE_H__
+#define __GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE (gtr_translation_memory_tab_activatable_get_type ())
+#define GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE, GtrTranslationMemoryTabActivatable))
+#define GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE, GtrTranslationMemoryTabActivatableClass))
+#define GTR_IS_TRANSLATION_MEMORY_TAB_ACTIVATABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE))
+#define GTR_IS_TRANSLATION_MEMORY_TAB_ACTIVATABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE))
+#define GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_TRANSLATION_MEMORY_TAB_ACTIVATABLE_TAB_ACTIVATABLE, GtrTranslationMemoryTabActivatableClass))
+
+typedef struct _GtrTranslationMemoryTabActivatable GtrTranslationMemoryTabActivatable;
+typedef struct _GtrTranslationMemoryTabActivatablePrivate GtrTranslationMemoryTabActivatablePrivate;
+typedef struct _GtrTranslationMemoryTabActivatableClass GtrTranslationMemoryTabActivatableClass;
+
+struct _GtrTranslationMemoryTabActivatable
+{
+ PeasExtensionBase parent_instance;
+
+ /*< private >*/
+ GtrTranslationMemoryTabActivatablePrivate *priv;
+};
+
+struct _GtrTranslationMemoryTabActivatableClass
+{
+ PeasExtensionBaseClass parent_class;
+};
+
+GType gtr_translation_memory_tab_activatable_get_type (void) G_GNUC_CONST;
+
+void gtr_tab_activatable_register_peas_type (PeasObjectModule *module);
+
+G_END_DECLS
+#endif /* __GTR_TRANSLATION_MEMORY_TAB_ACTIVATABLE_H__ */
diff --git a/src/translation-memory/gtr-translation-memory-ui.c b/plugins/translation-memory/gtr-translation-memory-ui.c
similarity index 92%
rename from src/translation-memory/gtr-translation-memory-ui.c
rename to plugins/translation-memory/gtr-translation-memory-ui.c
index 626e3e3..eb5ec7a 100644
--- a/src/translation-memory/gtr-translation-memory-ui.c
+++ b/plugins/translation-memory/gtr-translation-memory-ui.c
@@ -45,12 +45,11 @@
GTR_TYPE_TRANSLATION_MEMORY_UI, \
GtrTranslationMemoryUiPrivate))
-G_DEFINE_TYPE (GtrTranslationMemoryUi,
- gtr_translation_memory_ui,
- GTK_TYPE_SCROLLED_WINDOW)
+G_DEFINE_TYPE (GtrTranslationMemoryUi, gtr_translation_memory_ui, GTK_TYPE_SCROLLED_WINDOW)
struct _GtrTranslationMemoryUiPrivate
{
+ GtrTranslationMemory *translation_memory;
GtkWidget *tree_view;
GtrTab *tab;
@@ -61,12 +60,12 @@ struct _GtrTranslationMemoryUiPrivate
};
enum
- {
- SHORTCUT_COLUMN,
- LEVEL_COLUMN,
- STRING_COLUMN,
- N_COLUMNS
- };
+{
+ SHORTCUT_COLUMN,
+ LEVEL_COLUMN,
+ STRING_COLUMN,
+ N_COLUMNS
+};
static void
tree_view_size_cb (GtkWidget * widget,
@@ -81,11 +80,8 @@ choose_translation (GtrTranslationMemoryUi *tm_ui, const gchar *translation)
GtrPo *po;
GList *current_msg = NULL;
GtrMsg *msg;
- GtrWindow *window;
- window = gtr_application_get_active_window (GTR_APP);
-
- view = gtr_window_get_active_view (window);
+ view = gtr_tab_get_active_view (tm_ui->priv->tab);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
po = gtr_tab_get_po (tm_ui->priv->tab);
@@ -103,8 +99,8 @@ choose_translation (GtrTranslationMemoryUi *tm_ui, const gchar *translation)
}
static void
-on_activate_item_cb (GtkMenuItem * menuitem,
- GtrTranslationMemoryUi * tm_ui)
+on_activate_item_cb (GtkMenuItem *menuitem,
+ GtrTranslationMemoryUi *tm_ui)
{
gint index;
@@ -125,9 +121,8 @@ free_match (gpointer data)
}
static void
-showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrTranslationMemoryUi * tm_ui)
+showed_message_cb (GtrTab *tab, GtrMsg *msg, GtrTranslationMemoryUi *tm_ui)
{
- GtrTranslationMemory *tm;
GtkListStore *model;
GtkTreeIter iter;
GtkTreeViewColumn *level_column;
@@ -141,16 +136,15 @@ showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrTranslationMemoryUi * tm_ui)
GtkWidget *tm_item;
GtkWidget *tm_menu;
GtkWidget *items_menu;
- GtrWindow *window;
+ GtkWidget *window;
GtkUIManager *manager;
gchar *item_name;
- model =
- GTK_LIST_STORE (gtk_tree_view_get_model
- (GTK_TREE_VIEW (tm_ui->priv->tree_view)));
+ model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (tm_ui->priv->tree_view)));
- window = gtr_application_get_active_window (GTR_APP);
- tm_menu = gtr_window_get_tm_menu (window);
+ window = gtk_widget_get_toplevel (GTK_WIDGET (tm_ui));
+ manager = gtr_window_get_ui_manager (GTR_WINDOW (window));
+ tm_menu = gtk_ui_manager_get_widget (manager, "/MainMenu/EditMenu/EditOps_1/EditTranslationMemory");
g_signal_connect (tm_ui->priv->tree_view,
"size_allocate",
@@ -163,10 +157,7 @@ showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrTranslationMemoryUi * tm_ui)
msgid = gtr_msg_get_msgid (msg);
- tm =
- GTR_TRANSLATION_MEMORY (gtr_application_get_translation_memory (GTR_APP));
-
- tm_list = gtr_translation_memory_lookup (tm, msgid);
+ tm_list = gtr_translation_memory_lookup (tm_ui->priv->translation_memory, msgid);
if (tm_list == NULL)
{
@@ -230,9 +221,8 @@ showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrTranslationMemoryUi * tm_ui)
g_object_set_data (G_OBJECT (tm_item), "option", GINT_TO_POINTER (j));
gtk_widget_show (tm_item);
- accel_path =
- g_strdup_printf ("<Gtr-sheet>/Edit/_Translation Memory/%s",
- item_name);
+ accel_path = g_strdup_printf ("<Gtr-sheet>/Edit/Translation Memory/%s",
+ item_name);
gtk_menu_item_set_accel_path (GTK_MENU_ITEM (tm_item), accel_path);
gtk_accel_map_add_entry (accel_path, GDK_KEY_0 + (j - 1), GDK_CONTROL_MASK);
@@ -313,7 +303,6 @@ popup_menu_remove_from_memory (GtkMenuItem *menuitem,
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
- GtrTranslationMemory *tm;
gint level;
const gchar *original;
gchar *translation;
@@ -336,11 +325,8 @@ popup_menu_remove_from_memory (GtkMenuItem *menuitem,
STRING_COLUMN, &translation,
-1);
- tm =
- GTR_TRANSLATION_MEMORY (gtr_application_get_translation_memory (GTR_APP));
-
original = gtr_msg_get_msgid (tm_ui->priv->msg);
- gtr_translation_memory_remove (tm, original, translation);
+ gtr_translation_memory_remove (tm_ui->priv->translation_memory, original, translation);
g_free (translation);
@@ -592,12 +578,15 @@ gtr_translation_memory_ui_class_init (GtrTranslationMemoryUiClass * klass)
}
GtkWidget *
-gtr_translation_memory_ui_new (GtkWidget * tab)
+gtr_translation_memory_ui_new (GtkWidget *tab,
+ GtrTranslationMemory *translation_memory)
{
GtrTranslationMemoryUi *tm_ui;
tm_ui = g_object_new (GTR_TYPE_TRANSLATION_MEMORY_UI, NULL);
tm_ui->priv->tab = GTR_TAB (tab);
+ tm_ui->priv->translation_memory = translation_memory;
+
g_signal_connect (tab,
"showed-message", G_CALLBACK (showed_message_cb), tm_ui);
diff --git a/src/translation-memory/gtr-translation-memory-ui.h b/plugins/translation-memory/gtr-translation-memory-ui.h
similarity index 90%
rename from src/translation-memory/gtr-translation-memory-ui.h
rename to plugins/translation-memory/gtr-translation-memory-ui.h
index c936ac5..04c8726 100644
--- a/src/translation-memory/gtr-translation-memory-ui.h
+++ b/plugins/translation-memory/gtr-translation-memory-ui.h
@@ -64,13 +64,11 @@ struct _GtrTranslationMemoryUiClass
/*
* Public methods
*/
-GType
-gtr_translation_memory_ui_get_type (void)
- G_GNUC_CONST;
+GType gtr_translation_memory_ui_get_type (void) G_GNUC_CONST;
- GType gtr_translation_memory_ui_register_type (GTypeModule * module);
+GType gtr_translation_memory_ui_register_type (GTypeModule * module);
- GtkWidget *gtr_translation_memory_ui_new (GtkWidget * tab);
+GtkWidget *gtr_translation_memory_ui_new (GtkWidget *tab, GtrTranslationMemory *translation_memory);
G_END_DECLS
#endif /* __TRANSLATION_MEMORY_UI_H__ */
diff --git a/plugins/translation-memory/gtr-translation-memory-window-activatable.c b/plugins/translation-memory/gtr-translation-memory-window-activatable.c
new file mode 100644
index 0000000..168950a
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-window-activatable.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-translation-memory-window-activatable.h"
+#include "gtr-translation-memory-dialog.h"
+#include "gtr-window.h"
+#include "gtr-window-activatable.h"
+#include "gtr-translation-memory.h"
+#include "gda/gtr-gda.h"
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <string.h>
+
+struct _GtrTranslationMemoryWindowActivatablePrivate
+{
+ GtrWindow *window;
+ GSettings *tm_settings;
+ GtrTranslationMemory *translation_memory;
+
+ GtkActionGroup *action_group;
+ guint ui_id;
+};
+
+enum
+{
+ PROP_0,
+ PROP_WINDOW
+};
+
+static void gtr_window_activatable_iface_init (GtrWindowActivatableInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtrTranslationMemoryWindowActivatable,
+ gtr_translation_memory_window_activatable,
+ PEAS_TYPE_EXTENSION_BASE,
+ 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (GTR_TYPE_WINDOW_ACTIVATABLE,
+ gtr_window_activatable_iface_init))
+
+static void
+on_import_translation_memory_activated (GtkToggleAction *action,
+ GtrTranslationMemoryWindowActivatable *window_activatable)
+{
+ static GtkWidget *dlg = NULL;
+
+ if (dlg == NULL)
+ {
+ dlg = gtr_translation_memory_dialog_new (window_activatable->priv->translation_memory);
+ g_signal_connect (dlg, "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &dlg);
+ gtk_widget_show_all (dlg);
+ }
+
+ if (GTK_WINDOW (window_activatable->priv->window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window_activatable->priv->window));
+ }
+
+ gtk_window_present (GTK_WINDOW (dlg));
+}
+
+static const GtkActionEntry action_entries[] = {
+ {"TranslationMemoryManager", NULL, N_("_Import Translation Memories"), NULL,
+ N_("Import translation memories"),
+ G_CALLBACK (on_import_translation_memory_activated)},
+ {"EditTranslationMemory", NULL, N_("_Translation Memory"), NULL, NULL, NULL}
+};
+
+static const gchar ui_data[] =
+"<ui>"
+ "<menubar name=\"MainMenu\">"
+ "<menu name=\"EditMenu\" action=\"Edit\">"
+ "<placeholder name=\"EditOps_1\">"
+ "<menu action=\"EditTranslationMemory\" />"
+ "</placeholder>"
+ "</menu>"
+ "<menu name=\"ToolsMenu\" action=\"Tools\">"
+ "<placeholder name=\"ToolsOps_1\">"
+ "<menuitem action=\"TranslationMemoryManager\"/>"
+ "</placeholder>"
+ "</menu>"
+ "</menubar>"
+"</ui>";
+
+static void
+gtr_translation_memory_window_activatable_init (GtrTranslationMemoryWindowActivatable *window_activatable)
+{
+ GtrTranslationMemoryWindowActivatablePrivate *priv;
+
+ window_activatable->priv = G_TYPE_INSTANCE_GET_PRIVATE (window_activatable,
+ GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE,
+ GtrTranslationMemoryWindowActivatablePrivate);
+
+ priv = window_activatable->priv;
+
+ priv->tm_settings = g_settings_new ("org.gnome.gtranslator.plugins.translation-memory");
+
+ /* Creating translation memory */
+ priv->translation_memory = GTR_TRANSLATION_MEMORY (gtr_gda_new ());
+
+ gtr_translation_memory_set_max_omits (priv->translation_memory,
+ g_settings_get_int (priv->tm_settings,
+ "max-missing-words"));
+ gtr_translation_memory_set_max_delta (priv->translation_memory,
+ g_settings_get_int (priv->tm_settings,
+ "max-length-diff"));
+ gtr_translation_memory_set_max_items (priv->translation_memory, 10);
+}
+
+static void
+gtr_translation_memory_window_activatable_dispose (GObject *object)
+{
+ GtrTranslationMemoryWindowActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE (object)->priv;
+
+ if (priv->window != NULL)
+ {
+ g_object_unref (priv->window);
+ priv->window = NULL;
+ }
+
+ if (priv->action_group != NULL)
+ {
+ g_object_unref (priv->action_group);
+ priv->action_group = NULL;
+ }
+
+ if (priv->translation_memory != NULL)
+ {
+ g_object_unref (priv->translation_memory);
+ priv->translation_memory = NULL;
+ }
+
+ if (priv->tm_settings != NULL)
+ {
+ g_object_unref (priv->tm_settings);
+ priv->tm_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_translation_memory_window_activatable_parent_class)->dispose (object);
+}
+
+static void
+gtr_translation_memory_window_activatable_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtrTranslationMemoryWindowActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ priv->window = GTR_WINDOW (g_value_dup_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtr_translation_memory_window_activatable_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtrTranslationMemoryWindowActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ g_value_set_object (value, priv->window);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtr_translation_memory_window_activatable_activate (GtrWindowActivatable *activatable)
+{
+ GtrTranslationMemoryWindowActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE (activatable)->priv;
+ GtkUIManager *manager;
+ GError *error = NULL;
+
+ g_object_set_data (G_OBJECT (priv->window), "GtrTranslationMemory", priv->translation_memory);
+
+ manager = gtr_window_get_ui_manager (priv->window);
+
+ priv->action_group = gtk_action_group_new ("GtrTranslationMemoryWindowActivatableActions");
+ gtk_action_group_set_translation_domain (priv->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (priv->action_group, action_entries,
+ G_N_ELEMENTS (action_entries),
+ activatable);
+
+ gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
+
+ priv->ui_id = gtk_ui_manager_add_ui_from_string (manager,
+ ui_data,
+ -1,
+ &error);
+
+ if (error != NULL)
+ {
+ g_message ("%s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+gtr_translation_memory_window_activatable_deactivate (GtrWindowActivatable *activatable)
+{
+ GtrTranslationMemoryWindowActivatablePrivate *priv = GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE (activatable)->priv;
+ GtkUIManager *manager;
+
+ g_object_set_data (G_OBJECT (priv->window), "GtrTranslationMemory", NULL);
+
+ manager = gtr_window_get_ui_manager (priv->window);
+
+ gtk_ui_manager_remove_ui (manager, priv->ui_id);
+ gtk_ui_manager_remove_action_group (manager, priv->action_group);
+}
+
+static void
+gtr_translation_memory_window_activatable_class_init (GtrTranslationMemoryWindowActivatableClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = gtr_translation_memory_window_activatable_dispose;
+ object_class->set_property = gtr_translation_memory_window_activatable_set_property;
+ object_class->get_property = gtr_translation_memory_window_activatable_get_property;
+
+ g_object_class_override_property (object_class, PROP_WINDOW, "window");
+
+ g_type_class_add_private (klass, sizeof (GtrTranslationMemoryWindowActivatablePrivate));
+}
+
+static void
+gtr_translation_memory_window_activatable_class_finalize (GtrTranslationMemoryWindowActivatableClass *klass)
+{
+}
+
+static void
+gtr_window_activatable_iface_init (GtrWindowActivatableInterface *iface)
+{
+ iface->activate = gtr_translation_memory_window_activatable_activate;
+ iface->deactivate = gtr_translation_memory_window_activatable_deactivate;
+}
+
+void
+gtr_window_activatable_register_peas_type (PeasObjectModule *module)
+{
+ gtr_translation_memory_window_activatable_register_type (G_TYPE_MODULE (module));
+
+ peas_object_module_register_extension_type (module,
+ GTR_TYPE_WINDOW_ACTIVATABLE,
+ GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE);
+}
diff --git a/plugins/translation-memory/gtr-translation-memory-window-activatable.h b/plugins/translation-memory/gtr-translation-memory-window-activatable.h
new file mode 100644
index 0000000..de0ae0f
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory-window-activatable.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE_H__
+#define __GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE (gtr_translation_memory_window_activatable_get_type ())
+#define GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE, GtrTranslationMemoryWindowActivatable))
+#define GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE, GtrTranslationMemoryWindowActivatableClass))
+#define GTR_IS_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE))
+#define GTR_IS_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE))
+#define GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE_WINDOW_ACTIVATABLE, GtrTranslationMemoryWindowActivatableClass))
+
+typedef struct _GtrTranslationMemoryWindowActivatable GtrTranslationMemoryWindowActivatable;
+typedef struct _GtrTranslationMemoryWindowActivatablePrivate GtrTranslationMemoryWindowActivatablePrivate;
+typedef struct _GtrTranslationMemoryWindowActivatableClass GtrTranslationMemoryWindowActivatableClass;
+
+struct _GtrTranslationMemoryWindowActivatable
+{
+ PeasExtensionBase parent_instance;
+
+ /*< private >*/
+ GtrTranslationMemoryWindowActivatablePrivate *priv;
+};
+
+struct _GtrTranslationMemoryWindowActivatableClass
+{
+ PeasExtensionBaseClass parent_class;
+};
+
+GType gtr_translation_memory_window_activatable_get_type (void) G_GNUC_CONST;
+
+void gtr_window_activatable_register_peas_type (PeasObjectModule *module);
+
+G_END_DECLS
+#endif /* __GTR_TRANSLATION_MEMORY_WINDOW_ACTIVATABLE_H__ */
diff --git a/src/translation-memory/gtr-translation-memory.c b/plugins/translation-memory/gtr-translation-memory.c
similarity index 68%
rename from src/translation-memory/gtr-translation-memory.c
rename to plugins/translation-memory/gtr-translation-memory.c
index f8b1706..8627559 100644
--- a/src/translation-memory/gtr-translation-memory.c
+++ b/plugins/translation-memory/gtr-translation-memory.c
@@ -1,22 +1,24 @@
/*
* Copyright (C) 2008 Ignacio Casal Quinteiro <nacho resa gmail com>
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gtr-translation-memory.h"
+G_DEFINE_INTERFACE (GtrTranslationMemory, gtr_translation_memory, G_TYPE_OBJECT)
+
/**
* gtr_translation_memory_store:
* @obj: a #GtrTranslationMemory
@@ -121,8 +123,8 @@ gtr_translation_memory_lookup (GtrTranslationMemory * obj,
/* Default implementation */
static GList *
-gtr_translation_memory_lookup_default (GtrTranslationMemory *
- obj, const gchar * phrase)
+gtr_translation_memory_lookup_default (GtrTranslationMemory *obj,
+ const gchar * phrase)
{
g_return_val_if_reached (0);
}
@@ -142,8 +144,8 @@ gtr_translation_memory_set_max_omits (GtrTranslationMemory * obj, gsize omits)
/* Default implementation */
static void
- gtr_translation_memory_set_max_omits_default
- (GtrTranslationMemory * obj, gsize omits)
+gtr_translation_memory_set_max_omits_default (GtrTranslationMemory * obj,
+ gsize omits)
{
g_return_if_reached ();
}
@@ -184,53 +186,26 @@ gtr_translation_memory_set_max_items (GtrTranslationMemory * obj, gint items)
/* Default implementation */
static void
- gtr_translation_memory_set_max_items_default
- (GtrTranslationMemory * obj, gint items)
+gtr_translation_memory_set_max_items_default (GtrTranslationMemory * obj, gint items)
{
g_return_if_reached ();
}
static void
-gtr_translation_memory_base_init (GtrTranslationMemoryIface * klass)
+gtr_translation_memory_default_init (GtrTranslationMemoryInterface *iface)
{
static gboolean initialized = FALSE;
- klass->store = gtr_translation_memory_store_default;
- klass->store_list = gtr_translation_memory_store_list_default;
- klass->remove = gtr_translation_memory_remove_default;
- klass->lookup = gtr_translation_memory_lookup_default;
- klass->set_max_omits = gtr_translation_memory_set_max_omits_default;
- klass->set_max_delta = gtr_translation_memory_set_max_delta_default;
- klass->set_max_items = gtr_translation_memory_set_max_items_default;
+ iface->store = gtr_translation_memory_store_default;
+ iface->store_list = gtr_translation_memory_store_list_default;
+ iface->remove = gtr_translation_memory_remove_default;
+ iface->lookup = gtr_translation_memory_lookup_default;
+ iface->set_max_omits = gtr_translation_memory_set_max_omits_default;
+ iface->set_max_delta = gtr_translation_memory_set_max_delta_default;
+ iface->set_max_items = gtr_translation_memory_set_max_items_default;
if (!initialized)
- {
-
- initialized = TRUE;
- }
+ initialized = TRUE;
}
-GType
-gtr_translation_memory_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GTypeInfo info = {
- sizeof (GtrTranslationMemoryIface),
- (GBaseInitFunc) gtr_translation_memory_base_init,
- NULL,
- NULL,
- NULL,
- NULL,
- 0,
- 0,
- NULL
- };
- type =
- g_type_register_static (G_TYPE_INTERFACE,
- "GtrTranslationMemory", &info, 0);
- g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
- }
- return type;
-}
+
diff --git a/plugins/translation-memory/gtr-translation-memory.gresource.xml b/plugins/translation-memory/gtr-translation-memory.gresource.xml
new file mode 100644
index 0000000..17f797c
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/gtranslator/plugins/translation-memory/ui">
+ <file preprocess="xml-stripblanks">gtr-translation-memory-dialog.ui</file>
+ </gresource>
+</gresources>
diff --git a/plugins/translation-memory/gtr-translation-memory.h b/plugins/translation-memory/gtr-translation-memory.h
new file mode 100644
index 0000000..fd2c585
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2008 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GTR_TRANSLATION_MEMORY_H_
+#define _GTR_TRANSLATION_MEMORY_H_
+
+#include <glib-object.h>
+#include "gtr-msg.h"
+
+G_BEGIN_DECLS
+#define GTR_TYPE_TRANSLATION_MEMORY (gtr_translation_memory_get_type ())
+#define GTR_TRANSLATION_MEMORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_TRANSLATION_MEMORY, GtrTranslationMemory))
+#define GTR_IS_TRANSLATION_MEMORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_TRANSLATION_MEMORY))
+#define GTR_TRANSLATION_MEMORY_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTR_TYPE_TRANSLATION_MEMORY, GtrTranslationMemoryInterface))
+
+typedef struct _GtrTranslationMemory GtrTranslationMemory;
+typedef struct _GtrTranslationMemoryInterface GtrTranslationMemoryInterface;
+
+struct _GtrTranslationMemoryInterface
+{
+ GTypeInterface g_iface;
+
+ gboolean (*store) (GtrTranslationMemory * obj, GtrMsg * msg);
+ gboolean (*store_list) (GtrTranslationMemory * obj, GList * msgs);
+ void (*remove) (GtrTranslationMemory *obj,
+ const gchar *original,
+ const gchar *translation);
+
+ GList *(*lookup) (GtrTranslationMemory * obj, const gchar * phrase);
+ void (*set_max_omits) (GtrTranslationMemory * obj, gsize omits);
+ void (*set_max_delta) (GtrTranslationMemory * obj, gsize delta);
+ void (*set_max_items) (GtrTranslationMemory * obj, gint items);
+};
+
+typedef struct _GtrTranslationMemoryMatch GtrTranslationMemoryMatch;
+struct _GtrTranslationMemoryMatch
+{
+ gchar *match;
+ gint level;
+};
+
+GType gtr_translation_memory_get_type (void);
+
+gboolean gtr_translation_memory_store (GtrTranslationMemory * obj, GtrMsg * msg);
+
+gboolean gtr_translation_memory_store_list (GtrTranslationMemory * obj, GList * msg);
+
+void gtr_translation_memory_remove (GtrTranslationMemory * obj,
+ const gchar * original,
+ const gchar * translation);
+
+GList *gtr_translation_memory_lookup (GtrTranslationMemory * obj,
+ const gchar * phrase);
+
+void gtr_translation_memory_set_max_omits (GtrTranslationMemory * obj, gsize omits);
+
+void gtr_translation_memory_set_max_delta (GtrTranslationMemory * obj, gsize delta);
+
+void gtr_translation_memory_set_max_items (GtrTranslationMemory * obj, gint items);
+
+G_END_DECLS
+#endif
diff --git a/plugins/translation-memory/gtr-translation-memory.plugin.desktop.in b/plugins/translation-memory/gtr-translation-memory.plugin.desktop.in
new file mode 100644
index 0000000..0523eed
--- /dev/null
+++ b/plugins/translation-memory/gtr-translation-memory.plugin.desktop.in
@@ -0,0 +1,8 @@
+[Plugin]
+Module=translation-memory
+IAge=3
+_Name=Translation Memory
+_Description=Get translation suggestions from a data base.
+Authors=Ignacio Casal Quinteiro <icq gnome org>
+Copyright=Copyright @ 2012 Ignacio Casal Quinteiro
+Website=http://projects.gnome.org/gtranslator
diff --git a/plugins/translation-memory/org.gnome.gtranslator.plugins.translation-memory.gschema.xml.in.in b/plugins/translation-memory/org.gnome.gtranslator.plugins.translation-memory.gschema.xml.in.in
new file mode 100644
index 0000000..3c23277
--- /dev/null
+++ b/plugins/translation-memory/org.gnome.gtranslator.plugins.translation-memory.gschema.xml.in.in
@@ -0,0 +1,43 @@
+<schemalist>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gtranslator.plugins.translation-memory" path="/org/gnome/gtranslator/plugins/translation-memory/">
+ <key name="po-directory" type="s">
+ <default>''</default>
+ <_summary>PO directory</_summary>
+ <_description>
+ Directory containing PO files to add to the translation memory.
+ </_description>
+ </key>
+ <key name="restrict-to-filename" type="b">
+ <default>false</default>
+ <_summary>Restrict search by filename</_summary>
+ <_description>
+ If true, only include files with a specified filename when searching
+ the translation memory.
+ </_description>
+ </key>
+ <key name="filename-restriction" type="s">
+ <default>''</default>
+ <_summary>Filename to restrict search to</_summary>
+ <_description>
+ Filename to which searching of the translation memory should be
+ restricted.
+ </_description>
+ </key>
+ <key name="max-missing-words" type="i">
+ <default>2</default>
+ <_summary>Maximum number of missing words</_summary>
+ <_description>
+ Maximum number of words that can be missing from a message displayed as
+ a match by the translation memory.
+ </_description>
+ </key>
+ <key name="max-length-diff" type="i">
+ <default>2</default>
+ <_summary>Maximum difference in message length</_summary>
+ <_description>
+ Maximum difference in length between messages displayed as matches by
+ the translation memory.
+ </_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ef9639a..65a31f4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -28,6 +28,13 @@ plugins/codeview/gtr-codeview.plugin.desktop.in
plugins/codeview/gtr-viewer.c
[type: gettext/glade]plugins/codeview/gtr-viewer.ui
plugins/codeview/org.gnome.gtranslator.plugins.codeview.gschema.xml.in.in
+plugins/translation-memory/gtr-translation-memory-dialog.c
+[type: gettext/glade]plugins/translation-memory/gtr-translation-memory-dialog.ui
+plugins/translation-memory/gtr-translation-memory-tab-activatable.c
+plugins/translation-memory/gtr-translation-memory-ui.c
+plugins/translation-memory/gtr-translation-memory-window-activatable.c
+plugins/translation-memory/gtr-translation-memory.plugin.desktop.in
+plugins/translation-memory/org.gnome.gtranslator.plugins.translation-memory.gschema.xml.in.in
src/gtr-actions-file.c
src/gtr-actions-help.c
src/gtr-actions-search.c
@@ -55,7 +62,6 @@ src/gtr-tab.c
src/gtr-tab-label.c
src/toolbareditor/egg-editable-toolbar.c
src/toolbareditor/egg-toolbar-editor.c
-src/translation-memory/gtr-translation-memory-ui.c
src/gtr-utils.c
src/gtr-view.c
src/gtr-window.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index dbe830c..6d3b284 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -3,3 +3,4 @@ data/org.gnome.gtranslator.gschema.xml.in
plugins/codeview/org.gnome.gtranslator.plugins.codeview.gschema.xml.in
plugins/dictionary/org.gnome.gtranslator.plugins.dictionary.gschema.xml.in
plugins/open-tran/org.gnome.gtranslator.plugins.open-tran.gschema.xml.in
+plugins/translation-memory/org.gnome.gtranslator.plugins.translation-memory.gschema.xml.in
diff --git a/src/Makefile.am b/src/Makefile.am
index 72df2c8..6337609 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,8 +3,7 @@
# --------------------------------------------------------
SUBDIRS = toolbareditor \
- dialogs \
- translation-memory
+ dialogs
noinst_LTLIBRARIES = libgtranslator.la
@@ -14,7 +13,6 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/src/dialogs \
-I$(top_srcdir)/src/toolbareditor \
- -I$(top_srcdir)/src/translation-memory \
$(GTRANSLATOR_CFLAGS) \
$(GTKSPELL_CFLAGS) \
$(WARN_CFLAGS) \
@@ -141,7 +139,6 @@ libgtranslator_la_SOURCES = \
libgtranslator_la_LIBADD = \
dialogs/libdialogs.la \
toolbareditor/libtoolbareditor.la \
- translation-memory/libtranslationmemory.la \
$(GTRANSLATOR_LIBS)
gtr-enum-types.h: gtr-enum-types.h.template $(INST_H_FILES) $(GLIB_MKENUMS)
diff --git a/src/dialogs/gtr-assistant.c b/src/dialogs/gtr-assistant.c
index e39a677..0ffe296 100644
--- a/src/dialogs/gtr-assistant.c
+++ b/src/dialogs/gtr-assistant.c
@@ -24,7 +24,6 @@
#include <config.h>
#endif
-#include "../translation-memory/gtr-translation-memory.h"
#include "gtr-application.h"
#include "gtr-assistant.h"
#include "gtr-profile.h"
@@ -59,110 +58,11 @@ struct _GtrAssistantPrivate
/* Profiles Page 2 */
GtkWidget *languages_fetcher;
- /* Database Page */
- GtkWidget *path;
- GtkWidget *search_button;
- GtkWidget *po_name;
-
/* Confirmation Page */
GtkWidget *finish_box;
GtkWidget *confirm_label;
- GtkWidget *add_db_progressbar;
};
-typedef struct _IdleData
-{
- GSList *list;
- GtkProgressBar *progress;
- GtrTranslationMemory *tm;
- GtkWindow *parent;
-} IdleData;
-
-static gboolean
-add_to_database (gpointer data_pointer)
-{
- IdleData *data = (IdleData *) data_pointer;
- static GSList *l = NULL;
- gdouble percentage;
-
- if (l == NULL)
- l = data->list;
- else
- l = g_slist_next (l);
-
- if (l)
- {
- GList *msg_list = NULL;
- GFile *location;
- GError *error = NULL;
- GtrPo *po;
-
- po = gtr_po_new ();
- location = (GFile *) l->data;
-
- gtr_po_parse (po, location, &error);
- if (error)
- return TRUE;
-
- msg_list = gtr_po_get_messages (po);
-
- gtr_translation_memory_store_list (data->tm, msg_list);
-
- g_object_unref (po);
- }
- else
- {
- GtkWidget *dialog;
-
- gtk_progress_bar_set_fraction (data->progress, 1.0);
-
- dialog = gtk_message_dialog_new (data->parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, NULL);
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
- _
- ("<span weight=\"bold\" size=\"large\">Strings added to database</span>"));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return FALSE;
- }
-
- percentage =
- (gdouble) g_slist_position (data->list,
- l) / (gdouble) g_slist_length (data->list);
-
- /*
- * Set the progress only if the values are reasonable.
- */
- if (percentage > 0.0 || percentage < 1.0)
- {
- /*
- * Set the progressbar status.
- */
- gtk_progress_bar_set_fraction (data->progress, percentage);
- }
-
- return TRUE;
-}
-
-static void
-destroy_idle_data (gpointer data)
-{
- IdleData *d = (IdleData *) data;
-
- gtk_widget_hide (GTK_WIDGET (d->progress));
-
- g_slist_free_full (d->list, g_object_unref);
-
- gtk_widget_destroy (GTK_WIDGET (d->parent));
-
- g_free (d);
-}
-
static void
on_assistant_close (GtkAssistant * assistant)
{
@@ -172,13 +72,8 @@ on_assistant_close (GtkAssistant * assistant)
static void
on_assistant_apply (GtkAssistant * assistant)
{
- GFile *dir;
- const gchar *dir_name;
- IdleData *data;
GtrAssistant *as = GTR_ASSISTANT (assistant);
- const gchar *po_name;
GtrProfile *profile;
- gulong close_signal_id;
GtrProfileManager *prof_manager;
profile = gtr_profile_new ();
@@ -219,37 +114,8 @@ on_assistant_apply (GtkAssistant * assistant)
g_object_unref (prof_manager);
- close_signal_id = g_signal_connect (as,
- "close",
- G_CALLBACK (on_assistant_close), NULL);
-
- dir_name = gtk_entry_get_text (GTK_ENTRY (as->priv->path));
- if (strcmp (dir_name, "") == 0)
- return;
-
- g_signal_handler_block (as, close_signal_id);
-
- data = g_new0 (IdleData, 1);
- data->list = NULL;
-
- dir = g_file_new_for_path (dir_name);
-
- po_name = gtk_entry_get_text (GTK_ENTRY (as->priv->po_name));
-
- gtr_utils_scan_dir (dir, &data->list, po_name);
-
- data->tm =
- GTR_TRANSLATION_MEMORY (gtr_application_get_translation_memory (GTR_APP));
- data->progress = GTK_PROGRESS_BAR (as->priv->add_db_progressbar);
- data->parent = GTK_WINDOW (as);
-
- gtk_widget_show (as->priv->add_db_progressbar);
-
- g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
- (GSourceFunc) add_to_database,
- data, (GDestroyNotify) destroy_idle_data);
-
- g_object_unref (dir);
+ g_signal_connect (as, "close",
+ G_CALLBACK (on_assistant_close), NULL);
}
static void
@@ -257,13 +123,10 @@ on_assistant_prepare (GtkAssistant * assistant, GtkWidget * page)
{
GtrAssistant *as = GTR_ASSISTANT (assistant);
gchar *string;
- const gchar *database_path;
if (page != as->priv->finish_box)
return;
- database_path = gtk_entry_get_text (GTK_ENTRY (as->priv->path));
-
string = g_strdup_printf (_("Profile name: %s\n"
"Translator name: %s\n"
"Translator email: %s\n"
@@ -272,8 +135,7 @@ on_assistant_prepare (GtkAssistant * assistant, GtkWidget * page)
"Language code: %s\n"
"Character set: %s\n"
"Transfer encoding: %s\n"
- "Plural form: %s\n"
- "Database path: %s"),
+ "Plural form: %s\n"),
gtk_entry_get_text (GTK_ENTRY
(as->priv->profile_name)),
gtk_entry_get_text (GTK_ENTRY (as->priv->name)),
@@ -283,9 +145,7 @@ on_assistant_prepare (GtkAssistant * assistant, GtkWidget * page)
gtr_languages_fetcher_get_language_code (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)),
gtr_languages_fetcher_get_charset (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)),
gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)),
- gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)),
- (strcmp (database_path, "") !=
- 0) ? database_path : _("None"));
+ gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)));
gtk_label_set_text (GTK_LABEL (as->priv->confirm_label), string);
g_free (string);
@@ -306,10 +166,7 @@ create_start_page (GtrAssistant * as)
gtk_widget_show (box);
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
- label =
- gtk_label_new (_
- ("This assistant will help you to create the main profile\n"
- "and generate your translation memory database."));
+ label = gtk_label_new (_("This assistant will help you to create the main profile."));
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
@@ -532,96 +389,6 @@ create_profiles_page2 (GtrAssistant * as)
}
static void
-on_dir_find_button_clicked (GtkButton * button, GtrAssistant * as)
-{
- GtkWidget *dialog;
- gint res;
-
- dialog = gtk_file_chooser_dialog_new (_("Checkout directory"),
- GTK_WINDOW (as),
- GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (res)
- {
- case GTK_RESPONSE_OK:
- {
- gchar *filename;
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- gtk_entry_set_text (GTK_ENTRY (as->priv->path), filename);
- g_free (filename);
- break;
- }
- default:
- break;
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-create_database_page (GtrAssistant * as)
-{
- GtkWidget *box, *hbox;
- GtkWidget *label;
- GtrAssistantPrivate *priv = as->priv;
-
- box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_widget_show (box);
- gtk_container_set_border_width (GTK_CONTAINER (box), 5);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _
- ("<b>Select the path to generate the database:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
-
- /* hbox */
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- /* Path entry */
- priv->path = gtk_entry_new ();
- gtk_widget_show (priv->path);
- gtk_box_pack_start (GTK_BOX (hbox), priv->path, TRUE, TRUE, 0);
-
- /* Search button */
- priv->search_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
- gtk_widget_show (priv->search_button);
- gtk_box_pack_start (GTK_BOX (hbox), priv->search_button, FALSE, FALSE, 0);
- g_signal_connect (priv->search_button, "clicked",
- G_CALLBACK (on_dir_find_button_clicked), as);
-
- /* Po name label */
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Look for a specific PO filename:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- /* Po name entry */
- priv->po_name = gtk_entry_new ();
- gtk_widget_show (priv->po_name);
- gtk_box_pack_start (GTK_BOX (hbox), priv->po_name, TRUE, TRUE, 0);
- gtk_widget_set_tooltip_text (priv->po_name, _("E.g.: gl.po"));
-
- gtk_assistant_append_page (GTK_ASSISTANT (as), box);
- gtk_assistant_set_page_title (GTK_ASSISTANT (as), box,
- _("Generate Database"));
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), box, TRUE);
-}
-
-static void
create_finish_page (GtrAssistant * as)
{
as->priv->finish_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
@@ -632,11 +399,6 @@ create_finish_page (GtrAssistant * as)
gtk_box_pack_start (GTK_BOX (as->priv->finish_box), as->priv->confirm_label,
TRUE, TRUE, 0);
- as->priv->add_db_progressbar = gtk_progress_bar_new ();
- gtk_widget_show (as->priv->add_db_progressbar);
- gtk_box_pack_start (GTK_BOX (as->priv->finish_box),
- as->priv->add_db_progressbar, FALSE, FALSE, 0);
-
gtk_assistant_append_page (GTK_ASSISTANT (as), as->priv->finish_box);
gtk_assistant_set_page_type (GTK_ASSISTANT (as), as->priv->finish_box,
GTK_ASSISTANT_PAGE_CONFIRM);
@@ -658,7 +420,6 @@ gtr_assistant_init (GtrAssistant * as)
create_start_page (as);
create_profiles_page1 (as);
create_profiles_page2 (as);
- create_database_page (as);
create_finish_page (as);
}
diff --git a/src/dialogs/gtr-assistant.h b/src/dialogs/gtr-assistant.h
index e71d304..075f2d5 100644
--- a/src/dialogs/gtr-assistant.h
+++ b/src/dialogs/gtr-assistant.h
@@ -64,13 +64,9 @@ struct _GtrAssistantClass
/*
* Public methods
*/
-GType
-gtr_assistant_get_type (void)
- G_GNUC_CONST;
+GType gtr_assistant_get_type (void) G_GNUC_CONST;
- GType gtr_assistant_register_type (GTypeModule * module);
-
- void gtr_show_assistant (GtrWindow * window);
+void gtr_show_assistant (GtrWindow * window);
G_END_DECLS
#endif /* __ASSISTANT_H__ */
diff --git a/src/dialogs/gtr-preferences-dialog.c b/src/dialogs/gtr-preferences-dialog.c
index 1fef54b..ed95edc 100644
--- a/src/dialogs/gtr-preferences-dialog.c
+++ b/src/dialogs/gtr-preferences-dialog.c
@@ -35,7 +35,6 @@
#include "gtr-profile-dialog.h"
#include "gtr-po.h"
#include "gtr-utils.h"
-#include "../translation-memory/gtr-translation-memory.h"
#include <glib.h>
#include <glib/gi18n.h>
@@ -58,7 +57,6 @@ G_DEFINE_TYPE (GtrPreferencesDialog, gtr_preferences_dialog, GTK_TYPE_DIALOG)
struct _GtrPreferencesDialogPrivate
{
GSettings *ui_settings;
- GSettings *tm_settings;
GSettings *editor_settings;
GSettings *files_settings;
@@ -91,14 +89,6 @@ struct _GtrPreferencesDialogPrivate
GtkWidget *edit_button;
GtkWidget *delete_button;
- /*Translation Memory */
- GtkWidget *directory_entry;
- GtkWidget *search_button;
- GtkWidget *add_database_button;
- GtkWidget *add_database_progressbar;
- GtkWidget *tm_lang_entry;
- GtkWidget *use_lang_profile_in_tm;
-
/*Plugins */
GtkWidget *plugins_box;
};
@@ -593,229 +583,6 @@ setup_profile_pages (GtrPreferencesDialog *dlg)
"clicked", G_CALLBACK (edit_button_clicked), dlg);
}
-/***************Translation Memory pages****************/
-static void
-response_filechooser_cb (GtkDialog * dialog,
- gint response_id, GtrPreferencesDialog *dlg)
-{
- if (response_id == GTK_RESPONSE_YES)
- {
- gchar *filename;
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->directory_entry),
- filename);
- g_settings_set_string (dlg->priv->tm_settings,
- GTR_SETTINGS_PO_DIRECTORY,
- filename);
- g_free (filename);
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
-on_search_button_clicked (GtkButton * button, GtrPreferencesDialog *dlg)
-{
- GtkWidget *filechooser;
-
- filechooser = gtk_file_chooser_dialog_new ("Select PO directory",
- GTK_WINDOW (dlg),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_YES, NULL);
-
- g_signal_connect (GTK_DIALOG (filechooser), "response",
- G_CALLBACK (response_filechooser_cb), dlg);
-
- gtk_dialog_run (GTK_DIALOG (filechooser));
-}
-
-typedef struct _IdleData
-{
- GSList *list;
- GtkProgressBar *progress;
- GtrTranslationMemory *tm;
- GtkWindow *parent;
-} IdleData;
-
-static gboolean
-add_to_database (gpointer data_pointer)
-{
- IdleData *data = (IdleData *) data_pointer;
- static GSList *l = NULL;
- gdouble percentage;
-
- if (l == NULL)
- l = data->list;
- else
- l = g_slist_next (l);
-
- if (l)
- {
- GList *msg_list = NULL;
- GFile *location;
- GError *error = NULL;
- GtrPo *po;
-
- po = gtr_po_new ();
- location = (GFile *) l->data;
-
- gtr_po_parse (po, location, &error);
- if (error)
- return TRUE;
-
- msg_list = gtr_po_get_messages (po);
-
- gtr_translation_memory_store_list (data->tm, msg_list);
-
- g_object_unref (po);
- }
- else
- {
- GtkWidget *dialog;
-
- gtk_progress_bar_set_fraction (data->progress, 1.0);
-
- dialog = gtk_message_dialog_new (data->parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, NULL);
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
- _
- ("<span weight=\"bold\" size=\"large\">Strings added to database</span>"));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return FALSE;
- }
-
- percentage =
- (gdouble) g_slist_position (data->list,
- l) / (gdouble) g_slist_length (data->list);
-
- /*
- * Set the progress only if the values are reasonable.
- */
- if (percentage > 0.0 || percentage < 1.0)
- {
- /*
- * Set the progressbar status.
- */
- gtk_progress_bar_set_fraction (data->progress, percentage);
- }
-
- return TRUE;
-}
-
-static void
-destroy_idle_data (gpointer data)
-{
- IdleData *d = (IdleData *) data;
-
- gtk_widget_hide (GTK_WIDGET (d->progress));
-
- g_slist_free_full (d->list, g_object_unref);
-
- g_free (d);
-}
-
-static void
-on_add_database_button_clicked (GtkButton * button, GtrPreferencesDialog * dlg)
-{
- GFile *dir;
- gchar *dir_name;
- IdleData *data;
-
- data = g_new0 (IdleData, 1);
- data->list = NULL;
-
- dir_name = g_settings_get_string (dlg->priv->tm_settings,
- GTR_SETTINGS_PO_DIRECTORY);
-
- dir = g_file_new_for_path (dir_name);
- g_free (dir_name);
-
- if (g_settings_get_boolean (dlg->priv->tm_settings,
- GTR_SETTINGS_RESTRICT_TO_FILENAME))
- {
- gchar *restriction;
-
- restriction = g_settings_get_string (dlg->priv->tm_settings,
- GTR_SETTINGS_FILENAME_RESTRICTION);
- gtr_utils_scan_dir (dir, &data->list, restriction);
- g_free (restriction);
- }
- else
- gtr_utils_scan_dir (dir, &data->list, NULL);
-
- data->tm =
- GTR_TRANSLATION_MEMORY (gtr_application_get_translation_memory (GTR_APP));
- data->progress = GTK_PROGRESS_BAR (dlg->priv->add_database_progressbar);
- data->parent = GTK_WINDOW (dlg);
-
- gtk_widget_show (dlg->priv->add_database_progressbar);
- g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
- (GSourceFunc) add_to_database,
- data, (GDestroyNotify) destroy_idle_data);
-
- g_object_unref (dir);
-}
-
-static void
-setup_tm_pages (GtrPreferencesDialog * dlg)
-{
- GtrProfileManager *prof_manager;
- GtrProfile *profile;
- const gchar *language_code;
- gchar *filename = NULL;
-
- prof_manager = gtr_profile_manager_get_default ();
- profile = gtr_profile_manager_get_active_profile (prof_manager);
-
- if (profile != NULL)
- {
- language_code = gtr_profile_get_language_code (profile);
- filename = g_strconcat (language_code, ".po", NULL);
-
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->tm_lang_entry), filename);
- }
- g_object_unref (prof_manager);
-
- if (filename != NULL)
- g_settings_set_string (dlg->priv->tm_settings,
- GTR_SETTINGS_FILENAME_RESTRICTION,
- filename);
-
- g_free (filename);
-
- g_settings_bind (dlg->priv->tm_settings,
- GTR_SETTINGS_RESTRICT_TO_FILENAME,
- dlg->priv->use_lang_profile_in_tm,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->tm_settings,
- GTR_SETTINGS_PO_DIRECTORY,
- dlg->priv->directory_entry,
- "text",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->tm_settings,
- GTR_SETTINGS_FILENAME_RESTRICTION,
- dlg->priv->tm_lang_entry,
- "text",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-
- g_signal_connect (GTK_BUTTON (dlg->priv->search_button), "clicked",
- G_CALLBACK (on_search_button_clicked), dlg);
-
- g_signal_connect (GTK_BUTTON (dlg->priv->add_database_button), "clicked",
- G_CALLBACK (on_add_database_button_clicked), dlg);
-}
-
/***************Plugins pages****************/
static void
setup_plugin_pages (GtrPreferencesDialog * dlg)
@@ -868,7 +635,6 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
dlg->priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
dlg->priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
- dlg->priv->tm_settings = g_settings_new ("org.gnome.gtranslator.preferences.tm");
dlg->priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
@@ -931,16 +697,6 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
&dlg->priv->add_button, "edit_button",
&dlg->priv->edit_button, "delete_button",
&dlg->priv->delete_button,
- "directory_entry",
- &dlg->priv->directory_entry,
- "search_button", &dlg->priv->search_button,
- "add_database_button",
- &dlg->priv->add_database_button,
- "add_database_progressbar",
- &dlg->priv->add_database_progressbar,
- "use_lang_profile_in_tm",
- &dlg->priv->use_lang_profile_in_tm,
- "tm_lang_entry", &dlg->priv->tm_lang_entry,
"plugins_box", &dlg->priv->plugins_box,
NULL);
g_free (path);
@@ -960,7 +716,6 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
setup_files_pages (dlg);
setup_editor_pages (dlg);
setup_profile_pages (dlg);
- setup_tm_pages (dlg);
setup_plugin_pages (dlg);
}
@@ -975,12 +730,6 @@ gtr_preferences_dialog_dispose (GObject * object)
dlg->priv->ui_settings = NULL;
}
- if (dlg->priv->tm_settings != NULL)
- {
- g_object_unref (dlg->priv->tm_settings);
- dlg->priv->tm_settings = NULL;
- }
-
if (dlg->priv->editor_settings != NULL)
{
g_object_unref (dlg->priv->editor_settings);
diff --git a/src/dialogs/gtr-preferences-dialog.ui b/src/dialogs/gtr-preferences-dialog.ui
index 2f05ee9..31322d3 100644
--- a/src/dialogs/gtr-preferences-dialog.ui
+++ b/src/dialogs/gtr-preferences-dialog.ui
@@ -756,289 +756,6 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="memories_vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">12</property>
- <property name="orientation">vertical</property>
- <property name="spacing">18</property>
- <child>
- <object class="GtkBox" id="vbox9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label20">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Database:</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="right_padding">12</property>
- <child>
- <object class="GtkBox" id="hbox8">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">18</property>
- <child>
- <object class="GtkLabel" id="label25">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="vbox11">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label26">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Select the directory which contains PO files:</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="hbox9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkEntry" id="directory_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="xalign">0.0099999997764825821</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="search_button">
- <property name="label">gtk-find</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="add_database_button">
- <property name="label" translatable="yes">Add to Database</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkProgressBar" id="add_database_progressbar">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="vbox10">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label21">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Configuration:</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="right_padding">12</property>
- <child>
- <object class="GtkBox" id="hbox7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">18</property>
- <child>
- <object class="GtkLabel" id="label22">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="box1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkBox" id="box2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkCheckButton" id="use_lang_profile_in_tm">
- <property name="label" translatable="yes">Use only files with this name:</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="tm_lang_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">â</property>
- <property name="invisible_char_set">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">3</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="memory_page_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Translation Memory</property>
- </object>
- <packing>
- <property name="position">3</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
<object class="GtkBox" id="plugins_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1049,17 +766,17 @@
</child>
</object>
<packing>
- <property name="position">4</property>
+ <property name="position">3</property>
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label12">
+ <object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Plugins</property>
</object>
<packing>
- <property name="position">4</property>
+ <property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 0c3574a..ea788ec 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -33,8 +33,6 @@
#include "gtr-utils.h"
#include "gtr-window.h"
#include "egg-toolbars-model.h"
-#include "./translation-memory/gtr-translation-memory.h"
-#include "./translation-memory/gda/gtr-gda.h"
#include <glib.h>
#include <glib-object.h>
@@ -60,7 +58,6 @@ G_DEFINE_TYPE (GtrApplication, gtr_application, GTK_TYPE_APPLICATION)
struct _GtrApplicationPrivate
{
GSettings *settings;
- GSettings *tm_settings;
GSettings *window_settings;
GtrWindow *active_window;
@@ -72,8 +69,6 @@ struct _GtrApplicationPrivate
gchar *last_dir;
- GtrTranslationMemory *tm;
-
guint first_run : 1;
};
@@ -192,7 +187,6 @@ gtr_application_init (GtrApplication *application)
/* Load settings */
priv->settings = gtr_settings_new ();
- priv->tm_settings = g_settings_new ("org.gnome.gtranslator.preferences.tm");
priv->window_settings = g_settings_new ("org.gnome.gtranslator.state.window");
/* If the config folder exists but there is no profile */
@@ -229,16 +223,6 @@ gtr_application_init (GtrApplication *application)
/* Create Icon factory */
application->priv->icon_factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (application->priv->icon_factory);
-
- /* Creating translation memory */
- application->priv->tm = GTR_TRANSLATION_MEMORY (gtr_gda_new ());
- gtr_translation_memory_set_max_omits (application->priv->tm,
- g_settings_get_int (priv->tm_settings,
- GTR_SETTINGS_MAX_MISSING_WORDS));
- gtr_translation_memory_set_max_delta (application->priv->tm,
- g_settings_get_int (priv->tm_settings,
- GTR_SETTINGS_MAX_LENGTH_DIFF));
- gtr_translation_memory_set_max_items (application->priv->tm, 10);
}
static void
@@ -254,12 +238,6 @@ gtr_application_dispose (GObject * object)
priv->settings = NULL;
}
- if (priv->tm_settings != NULL)
- {
- g_object_unref (priv->tm_settings);
- priv->tm_settings = NULL;
- }
-
if (priv->window_settings != NULL)
{
g_object_unref (priv->window_settings);
@@ -272,12 +250,6 @@ gtr_application_dispose (GObject * object)
priv->icon_factory = NULL;
}
- if (priv->tm)
- {
- g_object_unref (priv->tm);
- priv->tm = NULL;
- }
-
if (priv->toolbars_model)
{
g_object_unref (priv->toolbars_model);
@@ -597,26 +569,10 @@ _gtr_application_set_last_dir (GtrApplication * app, const gchar * last_dir)
app->priv->last_dir = g_strdup (last_dir);
}
-/**
- * gtr_application_get_translation_memory:
- * @app: a #GtrApplication
- *
- * Gets the translation memory.
- *
- * Returns: (transfer none): Get the translation memory.
- */
-GObject *
-gtr_application_get_translation_memory (GtrApplication * app)
-{
- g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
-
- return G_OBJECT (app->priv->tm);
-}
-
GSettings *
_gtr_application_get_settings (GtrApplication *app)
{
- g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+ g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
- return app->priv->settings;
+ return app->priv->settings;
}
diff --git a/src/gtr-application.h b/src/gtr-application.h
index b16997c..d93156c 100644
--- a/src/gtr-application.h
+++ b/src/gtr-application.h
@@ -89,8 +89,6 @@ void gtr_application_register_icon (GtrApplication *app,
const gchar *icon,
const gchar *stock_id);
-GObject *gtr_application_get_translation_memory (GtrApplication *app);
-
/* Non exported funcs */
GObject *_gtr_application_get_toolbars_model (GtrApplication *application);
diff --git a/src/gtr-settings.h b/src/gtr-settings.h
index a4ccce4..b593427 100644
--- a/src/gtr-settings.h
+++ b/src/gtr-settings.h
@@ -74,11 +74,6 @@ gchar *gtr_settings_get_system_font (GtrSettings *gs
#define GTR_SETTINGS_EDITOR_FONT "editor-font"
#define GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED "unmark-fuzzy-when-changed"
#define GTR_SETTINGS_SPELLCHECK "spellcheck"
-#define GTR_SETTINGS_PO_DIRECTORY "po-directory"
-#define GTR_SETTINGS_RESTRICT_TO_FILENAME "restrict-to-filename"
-#define GTR_SETTINGS_FILENAME_RESTRICTION "filename-restriction"
-#define GTR_SETTINGS_MAX_MISSING_WORDS "max-missing-words"
-#define GTR_SETTINGS_MAX_LENGTH_DIFF "max-length-diff"
#define GTR_SETTINGS_PANEL_SWITCHER_STYLE "panel-switcher-style"
#define GTR_SETTINGS_COLOR_SCHEME "color-scheme"
#define GTR_SETTINGS_SORT_ORDER "sort-order"
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index d38659f..1329c10 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -42,8 +42,6 @@
#include "gtr-po.h"
#include "gtr-settings.h"
#include "gtr-view.h"
-#include "gtr-translation-memory.h"
-#include "gtr-translation-memory-ui.h"
#include "gtr-dirs.h"
#include "gtr-plugins-engine.h"
#include "gtr-debug.h"
@@ -85,7 +83,6 @@ struct _GtrTabPrivate
GtkWidget *message_table;
GtkWidget *context;
- GtkWidget *translation_memory;
/*Info bar */
GtkWidget *infobar;
@@ -302,20 +299,8 @@ remove_autosave_timeout (GtrTab * tab)
static void
gtr_tab_edition_finished (GtrTab * tab, GtrMsg * msg)
{
- GtrTranslationMemory *tm;
gchar *message_error;
GtkWidget *infobar;
- GtrHeader *header;
-
- header = gtr_po_get_header (tab->priv->po);
-
- if (gtr_header_get_profile (header) != NULL)
- {
- tm = GTR_TRANSLATION_MEMORY (gtr_application_get_translation_memory (GTR_APP));
-
- if (gtr_msg_is_translated (msg) && !gtr_msg_is_fuzzy (msg))
- gtr_translation_memory_store (tm, msg);
- }
/*
* Checking message
@@ -816,16 +801,6 @@ gtr_tab_draw (GtrTab *tab)
GTR_TAB_PLACEMENT_BOTTOM,
TRUE);
- /* TM */
- priv->translation_memory = gtr_translation_memory_ui_new (GTK_WIDGET (tab));
- gtk_widget_show (priv->translation_memory);
- add_widget_to_dock (tab, priv->translation_memory,
- "GtrTranslationMemoryUI",
- _("Translation Memory"),
- NULL,
- GTR_TAB_PLACEMENT_RIGHT,
- FALSE);
-
/* Context */
priv->context = gtr_context_panel_new (GTK_WIDGET (tab));
gtk_widget_show (priv->context);
@@ -1192,20 +1167,6 @@ gtr_tab_get_context_panel (GtrTab * tab)
}
/**
- * gtr_tab_get_translation_memory_ui:
- * @tab: a #GtrTab
- *
- * Returns: (transfer none): the #GtrTranslationMemoryUi panel.
- */
-GtkWidget *
-gtr_tab_get_translation_memory_ui (GtrTab * tab)
-{
- g_return_val_if_fail (GTR_IS_TAB (tab), NULL);
-
- return tab->priv->translation_memory;
-}
-
-/**
* gtr_tab_get_active_view:
* @tab: a #GtranslationTab
*
diff --git a/src/gtr-tab.h b/src/gtr-tab.h
index a63f081..9db9f41 100644
--- a/src/gtr-tab.h
+++ b/src/gtr-tab.h
@@ -103,8 +103,6 @@ gint gtr_tab_get_active_trans_tab (GtrTab * tab);
GtrContextPanel *gtr_tab_get_context_panel (GtrTab * tab);
-GtkWidget *gtr_tab_get_translation_memory_ui (GtrTab * tab);
-
GtrView *gtr_tab_get_active_view (GtrTab * tab);
GList *gtr_tab_get_all_views (GtrTab * tab,
diff --git a/src/gtr-window.c b/src/gtr-window.c
index e7963a5..1f9a568 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -94,8 +94,6 @@ struct _GtrWindowPrivate
GtkRecentManager *recent_manager;
GtkWidget *recent_menu;
- GtkWidget *tm_menu;
-
gint width;
gint height;
GdkWindowState window_state;
@@ -120,6 +118,7 @@ static const GtkActionEntry always_sensitive_entries[] = {
{"View", NULL, N_("_View")},
{"Search", NULL, N_("_Search")},
{"Go", NULL, N_("_Go")},
+ {"Tools", NULL, N_("_Tools")},
{"Documents", NULL, N_("_Documents")},
{"Help", NULL, N_("_Help")},
@@ -1436,10 +1435,6 @@ gtr_window_draw (GtrWindow * window)
"/MainMenu/FileMenu/FileRecentFilesMenu");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), priv->recent_menu);
- /* Translation Memory */
- priv->tm_menu = gtk_ui_manager_get_widget (priv->ui_manager,
- "/MainMenu/EditMenu/EditTranslationMemory");
-
/* Toolbar */
priv->toolbar = GTK_WIDGET
(g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
@@ -1993,15 +1988,3 @@ _gtr_window_close_tab (GtrWindow * window, GtrTab * tab)
set_sensitive_according_to_window (window);
}
-
-/**
- * gtr_window_get_tm_menu:
- * @window: a #GtrWindow
- *
- * Returns: (transfer none): get the tm_menu GtkWidget instance.
- */
-GtkWidget *
-gtr_window_get_tm_menu (GtrWindow * window)
-{
- return window->priv->tm_menu;
-}
diff --git a/src/gtr-window.h b/src/gtr-window.h
index 07f039b..996c06d 100644
--- a/src/gtr-window.h
+++ b/src/gtr-window.h
@@ -71,48 +71,36 @@ struct _GtrWindowClass
/*
* Public methods
*/
-GType
-gtr_window_get_type (void)
- G_GNUC_CONST;
+GType gtr_window_get_type (void) G_GNUC_CONST;
- GType gtr_window_register_type (GTypeModule * module);
+GType gtr_window_register_type (GTypeModule * module);
- GtrTab *gtr_window_create_tab (GtrWindow * window, GtrPo * po);
+GtrTab *gtr_window_create_tab (GtrWindow * window, GtrPo * po);
- GtrTab *gtr_window_get_active_tab (GtrWindow * window);
+GtrTab *gtr_window_get_active_tab (GtrWindow * window);
- GList *gtr_window_get_all_tabs (GtrWindow * window);
+GList *gtr_window_get_all_tabs (GtrWindow * window);
+
+GtrNotebook *gtr_window_get_notebook (GtrWindow * window);
- GtrNotebook *gtr_window_get_notebook (GtrWindow * window);
GtrHeader * gtr_window_get_header_from_active_tab (GtrWindow * window);
- GtkWidget *
- gtr_window_get_statusbar (GtrWindow * window);
+GtkWidget *gtr_window_get_statusbar (GtrWindow * window);
- GtkUIManager *
- gtr_window_get_ui_manager (GtrWindow * window);
+GtkUIManager *gtr_window_get_ui_manager (GtrWindow * window);
- GtrView *
- gtr_window_get_active_view (GtrWindow * window);
+GtrView *gtr_window_get_active_view (GtrWindow * window);
- GList *
- gtr_window_get_all_views (GtrWindow * window,
+GList *gtr_window_get_all_views (GtrWindow * window,
gboolean original, gboolean translated);
- GtkWidget *
- gtr_window_get_tab_from_location (GtrWindow * window, GFile * location);
-
- void
- gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab);
+GtkWidget *gtr_window_get_tab_from_location (GtrWindow * window, GFile * location);
- void
- _gtr_window_close_tab (GtrWindow * window, GtrTab * tab);
+void gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab);
- GtkWidget *
- gtr_window_get_tm_menu (GtrWindow * window);
+void _gtr_window_close_tab (GtrWindow * window, GtrTab * tab);
- void
- _gtr_recent_add (GtrWindow * window,
+void _gtr_recent_add (GtrWindow * window,
GFile * location, gchar * project_id);
/* FIXME: this is wrong. we should have some signal in the po and set this and
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]