[gtranslator] Revert "Moved dialogs files to src folder"
- From: Daniel Mustieles GarcÃa <dmustieles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Revert "Moved dialogs files to src folder"
- Date: Mon, 16 Apr 2012 10:00:53 +0000 (UTC)
commit 0a14f22cde3db07ec64e34b0f562a0957a76bdf9
Author: Daniel Mustieles <daniel mustieles gmail com>
Date: Mon Apr 16 12:00:38 2012 +0200
Revert "Moved dialogs files to src folder"
This reverts commit 7b19c0cccdadca6c34eeb61bd410b00daad55f01.
INSTALL | 9 +-
configure.ac | 1 +
src/Makefile.am | 48 +--
src/dialogs/Makefile.am | 45 ++
src/dialogs/gtr-assistant.c | 474 ++++++++++++++++
src/dialogs/gtr-assistant.h | 72 +++
src/dialogs/gtr-close-confirmation-dialog.c | 629 +++++++++++++++++++++
src/dialogs/gtr-close-confirmation-dialog.h | 86 +++
src/dialogs/gtr-file-dialogs.c | 84 +++
src/dialogs/gtr-file-dialogs.h | 36 ++
src/dialogs/gtr-header-dialog.c | 399 ++++++++++++++
src/dialogs/gtr-header-dialog.h | 76 +++
src/dialogs/gtr-header-dialog.ui | 637 ++++++++++++++++++++++
src/dialogs/gtr-jump-dialog.c | 185 +++++++
src/dialogs/gtr-jump-dialog.h | 76 +++
src/dialogs/gtr-jump-dialog.ui | 103 ++++
src/dialogs/gtr-languages-fetcher.c | 492 +++++++++++++++++
src/dialogs/gtr-languages-fetcher.h | 90 +++
src/dialogs/gtr-languages-fetcher.ui | 252 +++++++++
src/dialogs/gtr-preferences-dialog.c | 782 +++++++++++++++++++++++++++
src/dialogs/gtr-preferences-dialog.h | 67 +++
src/dialogs/gtr-preferences-dialog.ui | 751 +++++++++++++++++++++++++
src/dialogs/gtr-profile-dialog.c | 231 ++++++++
src/dialogs/gtr-profile-dialog.h | 81 +++
src/dialogs/gtr-profile-dialog.ui | 295 ++++++++++
src/dialogs/gtr-search-dialog.c | 752 ++++++++++++++++++++++++++
src/dialogs/gtr-search-dialog.h | 150 +++++
src/dialogs/gtr-search-dialog.ui | 318 +++++++++++
src/gtr-actions-edit.c | 4 +-
src/gtr-actions-file.c | 2 +-
src/gtr-actions-search.c | 2 +-
src/gtr-application.c | 2 +-
32 files changed, 7181 insertions(+), 50 deletions(-)
---
diff --git a/INSTALL b/INSTALL
index a1e89e1..7d1c323 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,8 +1,8 @@
Installation Instructions
*************************
-Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
-Inc.
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@@ -226,11 +226,6 @@ order to use an ANSI C compiler:
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
- HP-UX `make' updates targets which have the same time stamps as
-their prerequisites, which makes it generally unusable when shipped
-generated files such as `configure' are involved. Use GNU `make'
-instead.
-
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
diff --git a/configure.ac b/configure.ac
index fff9379..0d530b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -293,6 +293,7 @@ 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
])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index f145417..6337609 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,17 +2,17 @@
# Welcome to the gtranslator-automake-autoconf Wonderland!
# --------------------------------------------------------
-SUBDIRS = toolbareditor
+SUBDIRS = toolbareditor \
+ dialogs
-noinst_LTLIBRARIES = \
- libgtranslator.la
+noinst_LTLIBRARIES = libgtranslator.la
lib_LTLIBRARIES = libgtranslator-private.la
INCLUDES = \
-I$(top_srcdir) \
+ -I$(top_srcdir)/src/dialogs \
-I$(top_srcdir)/src/toolbareditor \
- -I$(top_builddir)/src \
$(GTRANSLATOR_CFLAGS) \
$(GTKSPELL_CFLAGS) \
$(WARN_CFLAGS) \
@@ -21,21 +21,11 @@ INCLUDES = \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\"
-uidir = $(pkgdatadir)/ui
-ui_DATA = \
- gtr-preferences-dialog.ui \
- gtr-search-dialog.ui \
- gtr-header-dialog.ui \
- gtr-profile-dialog.ui \
- gtr-jump-dialog.ui \
- gtr-languages-fetcher.ui
-
bin_PROGRAMS = \
gtranslator
gtranslator_SOURCES = main.c
-
gtranslator_LDADD = \
libgtranslator.la \
libgtranslator-private.la \
@@ -85,23 +75,14 @@ INST_H_FILES = \
NOINST_H_FILES = \
gtr-actions.h \
- gtr-assistant.h \
gtr-close-button.h \
- gtr-close-confirmation-dialog.h \
gtr-dirs.h \
- gtr-file-dialogs.h \
- gtr-header-dialog.h \
gtr-history-entry.h \
gtr-io-error-info-bar.h \
- gtr-jump-dialog.h \
- gtr-language.h \
- gtr-languages-fetcher.h \
gtr-message-table-model.h \
+ gtr-language.h \
gtr-plugins-engine.h \
- gtr-preferences-dialog.h \
- gtr-profile-dialog.h \
gtr-profile-manager.h \
- gtr-search-dialog.h \
gtr-settings.h \
gtr-status-combo-box.h \
gtr-tab-label.h \
@@ -125,30 +106,21 @@ libgtranslator_c_files = \
gtr-actions-search.c \
gtr-actions-view.c \
gtr-application.c \
- gtr-assistant.c \
gtr-close-button.c \
- gtr-close-confirmation-dialog.c \
gtr-context.c \
gtr-dirs.c \
- gtr-file-dialogs.c \
gtr-header.c \
- gtr-header-dialog.c \
gtr-history-entry.c \
gtr-io-error-info-bar.c \
- gtr-jump-dialog.c \
- gtr-language.c \
- gtr-languages-fetcher.c \
gtr-message-table.c \
gtr-message-table-model.c \
gtr-msg.c \
gtr-notebook.c \
+ gtr-language.c \
gtr-plugins-engine.c \
gtr-po.c \
- gtr-preferences-dialog.c \
gtr-profile.c \
- gtr-profile-dialog.c \
gtr-profile-manager.c \
- gtr-search-dialog.c \
gtr-settings.c \
gtr-statusbar.c \
gtr-status-combo-box.c \
@@ -165,6 +137,7 @@ libgtranslator_la_SOURCES = \
$(INST_H_FILES)
libgtranslator_la_LIBADD = \
+ dialogs/libdialogs.la \
toolbareditor/libtoolbareditor.la \
$(GTRANSLATOR_LIBS)
@@ -181,11 +154,11 @@ gtr-marshal.c: gtr-marshal.list $(GLIB_GENMARSHAL)
$(AM_V_GEN) $(GLIB_GENMARSHAL) $< --body --header --prefix=gtr_marshal > $@
EXTRA_DIST = \
- $(ui_DATA) \
gtr-marshal.list \
gtr-enum-types.h.template \
gtr-enum-types.c.template
+CLEANFILES = $(BUILT_SOURCES)
if HAVE_INTROSPECTION
-include $(INTROSPECTION_MAKEFILE)
@@ -205,10 +178,9 @@ gir_DATA = $(INTROSPECTION_GIRS)
typelibdir = $(libdir)/gtranslator/girepository-1.0
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
-CLEANFILES = \
+CLEANFILES += \
$(gir_DATA) \
- $(typelib_DATA) \
- $(BUILT_SOURCES)
+ $(typelib_DATA)
endif
-include $(top_srcdir)/git.mk
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
new file mode 100644
index 0000000..2bf8c83
--- /dev/null
+++ b/src/dialogs/Makefile.am
@@ -0,0 +1,45 @@
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
+ $(GTRANSLATOR_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED)
+
+noinst_LTLIBRARIES = \
+ libdialogs.la
+
+libdialogs_la_SOURCES = \
+ gtr-close-confirmation-dialog.c \
+ gtr-close-confirmation-dialog.h \
+ gtr-file-dialogs.c \
+ gtr-file-dialogs.h \
+ gtr-languages-fetcher.c \
+ gtr-languages-fetcher.h \
+ gtr-preferences-dialog.c \
+ gtr-preferences-dialog.h \
+ gtr-search-dialog.c \
+ gtr-search-dialog.h \
+ gtr-header-dialog.c \
+ gtr-header-dialog.h \
+ gtr-profile-dialog.c \
+ gtr-profile-dialog.h \
+ gtr-assistant.c \
+ gtr-assistant.h \
+ gtr-jump-dialog.c \
+ gtr-jump-dialog.h
+
+uidir = $(pkgdatadir)/ui
+ui_DATA = \
+ gtr-preferences-dialog.ui \
+ gtr-search-dialog.ui \
+ gtr-header-dialog.ui \
+ gtr-profile-dialog.ui \
+ gtr-jump-dialog.ui \
+ gtr-languages-fetcher.ui
+
+EXTRA_DIST = \
+ $(ui_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/src/dialogs/gtr-assistant.c b/src/dialogs/gtr-assistant.c
new file mode 100644
index 0000000..0ffe296
--- /dev/null
+++ b/src/dialogs/gtr-assistant.c
@@ -0,0 +1,474 @@
+/*
+ * Copyright (C) 2008 Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Igalia
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Pablo Sanxiao <psanxiao gmail com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-application.h"
+#include "gtr-assistant.h"
+#include "gtr-profile.h"
+#include "gtr-profile-manager.h"
+#include "gtr-utils.h"
+#include "gtr-window.h"
+#include "gtr-languages-fetcher.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <string.h>
+#include <gio/gio.h>
+
+#define GTR_ASSISTANT_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_ASSISTANT, \
+ GtrAssistantPrivate))
+
+
+G_DEFINE_TYPE (GtrAssistant, gtr_assistant, GTK_TYPE_ASSISTANT)
+
+struct _GtrAssistantPrivate
+{
+ /* Profiles Page 1 */
+ GtkWidget *profile_name;
+ GtkWidget *name;
+ GtkWidget *email;
+
+ /* Profiles Page 2 */
+ GtkWidget *languages_fetcher;
+
+ /* Confirmation Page */
+ GtkWidget *finish_box;
+ GtkWidget *confirm_label;
+};
+
+static void
+on_assistant_close (GtkAssistant * assistant)
+{
+ gtk_widget_destroy (GTK_WIDGET (assistant));
+}
+
+static void
+on_assistant_apply (GtkAssistant * assistant)
+{
+ GtrAssistant *as = GTR_ASSISTANT (assistant);
+ GtrProfile *profile;
+ GtrProfileManager *prof_manager;
+
+ profile = gtr_profile_new ();
+ prof_manager = gtr_profile_manager_get_default ();
+
+ gtr_profile_set_name (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->profile_name)));
+
+ gtr_profile_set_author_name (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->name)));
+
+ gtr_profile_set_author_email (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->email)));
+
+ gtr_profile_set_language_name (profile,
+ gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)));
+
+ gtr_profile_set_language_code (profile,
+ gtr_languages_fetcher_get_language_code (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)));
+
+ gtr_profile_set_charset (profile,
+ gtr_languages_fetcher_get_charset (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)));
+
+ gtr_profile_set_encoding (profile,
+ gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)));
+
+ gtr_profile_set_group_email (profile,
+ gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)));
+
+ gtr_profile_set_plural_forms (profile,
+ gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)));
+
+ /* Add profile to profile manager and save it */
+ gtr_profile_manager_add_profile (prof_manager, profile);
+
+ g_object_unref (prof_manager);
+
+ g_signal_connect (as, "close",
+ G_CALLBACK (on_assistant_close), NULL);
+}
+
+static void
+on_assistant_prepare (GtkAssistant * assistant, GtkWidget * page)
+{
+ GtrAssistant *as = GTR_ASSISTANT (assistant);
+ gchar *string;
+
+ if (page != as->priv->finish_box)
+ return;
+
+ string = g_strdup_printf (_("Profile name: %s\n"
+ "Translator name: %s\n"
+ "Translator email: %s\n"
+ "Language name: %s\n"
+ "Team email: %s\n"
+ "Language code: %s\n"
+ "Character set: %s\n"
+ "Transfer encoding: %s\n"
+ "Plural form: %s\n"),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->profile_name)),
+ gtk_entry_get_text (GTK_ENTRY (as->priv->name)),
+ gtk_entry_get_text (GTK_ENTRY (as->priv->email)),
+ gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)),
+ gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER (as->priv->languages_fetcher)),
+ 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)));
+
+ gtk_label_set_text (GTK_LABEL (as->priv->confirm_label), string);
+ g_free (string);
+}
+
+static void
+on_assistant_cancel (GtkAssistant * assistant)
+{
+ gtk_widget_destroy (GTK_WIDGET (assistant));
+}
+
+static void
+create_start_page (GtrAssistant * as)
+{
+ GtkWidget *box, *label;
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ 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."));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), box);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Assistant"));
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), box, TRUE);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (as), box,
+ GTK_ASSISTANT_PAGE_INTRO);
+}
+
+static void
+on_profile1_entry_changed (GtkWidget * widget, GtrAssistant * as)
+{
+ const gchar *text;
+ GtkWidget *current_page;
+ gint page_number;
+
+ page_number = gtk_assistant_get_current_page (GTK_ASSISTANT (as));
+ current_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (as), page_number);
+
+ /* Profile name */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->profile_name));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Translator name */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->name));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Translator email */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->email));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+}
+
+static void
+create_profiles_page1 (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);
+
+ /*
+ * Profile name:
+ */
+ 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>Profile name:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->profile_name = gtk_entry_new ();
+ gtk_widget_show (priv->profile_name);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->profile_name, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->profile_name), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ /*
+ * Translator name:
+ */
+ 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>Translator name:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->name = gtk_entry_new ();
+ gtk_widget_show (priv->name);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->name, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->name), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ /*
+ * Translator email:
+ */
+ 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>Translator email:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->email = gtk_entry_new ();
+ gtk_widget_show (priv->email);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->email, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->email), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), box);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Profile"));
+}
+
+static void
+on_profile2_entry_changed (GtkWidget * widget, GtrAssistant * as)
+{
+ GtrAssistantPrivate *priv = as->priv;
+ const gchar *text;
+ GtkWidget *current_page;
+ gint page_number;
+
+ page_number = gtk_assistant_get_current_page (GTK_ASSISTANT (as));
+ current_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (as), page_number);
+
+ /* Language */
+ text = gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Lang code */
+ text = gtr_languages_fetcher_get_language_code (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Charset */
+ text = gtr_languages_fetcher_get_charset (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Trans encoding */
+ text = gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Team email */
+ text = gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
+
+ /* Plural form */
+ text = gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER (priv->languages_fetcher));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
+}
+
+static void
+create_profiles_page2 (GtrAssistant * as)
+{
+ GtrAssistantPrivate *priv = as->priv;
+
+ priv->languages_fetcher = gtr_languages_fetcher_new ();
+ gtk_widget_show (priv->languages_fetcher);
+ gtk_container_set_border_width (GTK_CONTAINER (priv->languages_fetcher), 5);
+ g_signal_connect (priv->languages_fetcher, "changed",
+ G_CALLBACK (on_profile2_entry_changed),
+ as);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), priv->languages_fetcher);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), priv->languages_fetcher, _("Profile"));
+}
+
+static void
+create_finish_page (GtrAssistant * as)
+{
+ as->priv->finish_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_show (as->priv->finish_box);
+
+ as->priv->confirm_label = gtk_label_new (NULL);
+ gtk_widget_show (as->priv->confirm_label);
+ gtk_box_pack_start (GTK_BOX (as->priv->finish_box), as->priv->confirm_label,
+ TRUE, TRUE, 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);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), as->priv->finish_box,
+ TRUE);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), as->priv->finish_box,
+ _("Confirmation"));
+}
+
+static void
+gtr_assistant_init (GtrAssistant * as)
+{
+ as->priv = GTR_ASSISTANT_GET_PRIVATE (as);
+
+ //gtk_window_set_default_size (GTK_WINDOW (as), 300, 200);
+ gtk_window_set_resizable (GTK_WINDOW (as), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (as), TRUE);
+
+ create_start_page (as);
+ create_profiles_page1 (as);
+ create_profiles_page2 (as);
+ create_finish_page (as);
+}
+
+static void
+gtr_assistant_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (gtr_assistant_parent_class)->finalize (object);
+}
+
+static void
+gtr_assistant_class_init (GtrAssistantClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkAssistantClass *assistant_class = GTK_ASSISTANT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtrAssistantPrivate));
+
+ object_class->finalize = gtr_assistant_finalize;
+ assistant_class->prepare = on_assistant_prepare;
+ assistant_class->apply = on_assistant_apply;
+ assistant_class->cancel = on_assistant_cancel;
+ //assistant_class->close = on_assistant_close;
+}
+
+void
+gtr_show_assistant (GtrWindow * window)
+{
+ static GtrAssistant *assist = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (assist == NULL)
+ {
+ assist = g_object_new (GTR_TYPE_ASSISTANT, NULL);
+ g_signal_connect (assist,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &assist);
+
+ gtk_widget_show (GTK_WIDGET (assist));
+ }
+
+ /* Make asssitant modal preventing using application without profile */
+ gtk_window_set_modal (GTK_WINDOW (assist), TRUE);
+
+ if (GTK_WINDOW (window) !=
+ gtk_window_get_transient_for (GTK_WINDOW (assist)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (assist), GTK_WINDOW (window));
+ }
+
+ gtk_window_present (GTK_WINDOW (assist));
+}
diff --git a/src/dialogs/gtr-assistant.h b/src/dialogs/gtr-assistant.h
new file mode 100644
index 0000000..075f2d5
--- /dev/null
+++ b/src/dialogs/gtr-assistant.h
@@ -0,0 +1,72 @@
+/*
+ * 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 __ASSISTANT_H__
+#define __ASSISTANT_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtr-window.h"
+
+G_BEGIN_DECLS
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_ASSISTANT (gtr_assistant_get_type ())
+#define GTR_ASSISTANT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_ASSISTANT, GtrAssistant))
+#define GTR_ASSISTANT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_ASSISTANT, GtrAssistantClass))
+#define GTR_IS_ASSISTANT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_ASSISTANT))
+#define GTR_IS_ASSISTANT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_ASSISTANT))
+#define GTR_ASSISTANT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_ASSISTANT, GtrAssistantClass))
+/* Private structure type */
+typedef struct _GtrAssistantPrivate GtrAssistantPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtrAssistant GtrAssistant;
+
+struct _GtrAssistant
+{
+ GtkAssistant parent_instance;
+
+ /*< private > */
+ GtrAssistantPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtrAssistantClass GtrAssistantClass;
+
+struct _GtrAssistantClass
+{
+ GtkAssistantClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtr_assistant_get_type (void) G_GNUC_CONST;
+
+void gtr_show_assistant (GtrWindow * window);
+
+G_END_DECLS
+#endif /* __ASSISTANT_H__ */
diff --git a/src/dialogs/gtr-close-confirmation-dialog.c b/src/dialogs/gtr-close-confirmation-dialog.c
new file mode 100644
index 0000000..8fa29af
--- /dev/null
+++ b/src/dialogs/gtr-close-confirmation-dialog.c
@@ -0,0 +1,629 @@
+/*
+ * gtr-close-confirmation-dialog.c
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2004-2005 GNOME Foundation
+ * 2008 Ignacio Casal Quinteiro
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n.h>
+
+#include "gtr-close-confirmation-dialog.h"
+#include "gtr-application.h"
+#include "gtr-utils.h"
+#include "gtr-window.h"
+#include "gtr-po.h"
+
+
+/* Properties */
+enum
+{
+ PROP_0,
+ PROP_UNSAVED_DOCUMENTS,
+ PROP_LOGOUT_MODE
+};
+
+/* Mode */
+enum
+{
+ SINGLE_DOC_MODE,
+ MULTIPLE_DOCS_MODE
+};
+
+/* Columns */
+enum
+{
+ SAVE_COLUMN,
+ NAME_COLUMN,
+ DOC_COLUMN, /* a handy pointer to the document */
+ N_COLUMNS
+};
+
+struct _GtrCloseConfirmationDialogPrivate
+{
+ gboolean logout_mode;
+
+ GList *unsaved_documents;
+
+ GList *selected_documents;
+
+ GtkTreeModel *list_store;
+
+ gboolean disable_save_to_disk;
+};
+
+#define GTR_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ GTR_TYPE_CLOSE_CONFIRMATION_DIALOG, \
+ GtrCloseConfirmationDialogPrivate))
+
+#define GET_MODE(priv) (((priv->unsaved_documents != NULL) && \
+ (priv->unsaved_documents->next == NULL)) ? \
+ SINGLE_DOC_MODE : MULTIPLE_DOCS_MODE)
+
+G_DEFINE_TYPE (GtrCloseConfirmationDialog,
+ gtr_close_confirmation_dialog, GTK_TYPE_DIALOG)
+ static void set_unsaved_document (GtrCloseConfirmationDialog *
+ dlg, const GList * list);
+
+ static GList *get_selected_docs (GtkTreeModel * store);
+
+/* Since we connect in the costructor we are sure this handler will be called
+ * before the user ones
+ */
+ static void
+ response_cb (GtrCloseConfirmationDialog * dlg,
+ gint response_id, gpointer data)
+{
+ GtrCloseConfirmationDialogPrivate *priv;
+
+ g_return_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg));
+
+ priv = dlg->priv;
+
+ if (priv->selected_documents != NULL)
+ g_list_free (priv->selected_documents);
+
+ if (response_id == GTK_RESPONSE_YES)
+ {
+ if (GET_MODE (priv) == SINGLE_DOC_MODE)
+ {
+ priv->selected_documents = g_list_copy (priv->unsaved_documents);
+ }
+ else
+ {
+ g_return_if_fail (priv->list_store);
+
+ priv->selected_documents = get_selected_docs (priv->list_store);
+ }
+ }
+ else
+ priv->selected_documents = NULL;
+}
+
+static void
+set_logout_mode (GtrCloseConfirmationDialog * dlg, gboolean logout_mode)
+{
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ _("Close _without Saving"), GTK_RESPONSE_NO);
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg), GTK_STOCK_SAVE, GTK_RESPONSE_YES);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_YES);
+}
+
+static void
+gtr_close_confirmation_dialog_init (GtrCloseConfirmationDialog * dlg)
+{
+ AtkObject *atk_obj;
+
+ dlg->priv = GTR_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), 14);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dlg), TRUE);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), "");
+
+ gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (dlg));
+ atk_object_set_role (atk_obj, ATK_ROLE_ALERT);
+ atk_object_set_name (atk_obj, _("Question"));
+
+ g_signal_connect (dlg, "response", G_CALLBACK (response_cb), NULL);
+}
+
+static void
+gtr_close_confirmation_dialog_finalize (GObject * object)
+{
+ GtrCloseConfirmationDialogPrivate *priv;
+
+ priv = GTR_CLOSE_CONFIRMATION_DIALOG (object)->priv;
+
+ if (priv->unsaved_documents != NULL)
+ g_list_free (priv->unsaved_documents);
+
+ if (priv->selected_documents != NULL)
+ g_list_free (priv->selected_documents);
+
+ /* Call the parent's destructor */
+ G_OBJECT_CLASS (gtr_close_confirmation_dialog_parent_class)->finalize
+ (object);
+}
+
+static void
+gtr_close_confirmation_dialog_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
+ GtrCloseConfirmationDialog *dlg;
+
+ dlg = GTR_CLOSE_CONFIRMATION_DIALOG (object);
+
+ switch (prop_id)
+ {
+ case PROP_UNSAVED_DOCUMENTS:
+ set_unsaved_document (dlg, g_value_get_pointer (value));
+ break;
+
+ case PROP_LOGOUT_MODE:
+ set_logout_mode (dlg, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtr_close_confirmation_dialog_get_property (GObject * object,
+ guint prop_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
+ GtrCloseConfirmationDialogPrivate *priv;
+
+ priv = GTR_CLOSE_CONFIRMATION_DIALOG (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_UNSAVED_DOCUMENTS:
+ g_value_set_pointer (value, priv->unsaved_documents);
+ break;
+
+ case PROP_LOGOUT_MODE:
+ g_value_set_boolean (value, priv->logout_mode);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ gtr_close_confirmation_dialog_class_init
+ (GtrCloseConfirmationDialogClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->set_property = gtr_close_confirmation_dialog_set_property;
+ gobject_class->get_property = gtr_close_confirmation_dialog_get_property;
+ gobject_class->finalize = gtr_close_confirmation_dialog_finalize;
+
+ g_type_class_add_private (klass,
+ sizeof (GtrCloseConfirmationDialogPrivate));
+
+ g_object_class_install_property (gobject_class,
+ PROP_UNSAVED_DOCUMENTS,
+ g_param_spec_pointer ("unsaved_documents",
+ "Unsaved Documents",
+ "List of Unsaved Documents",
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY)));
+
+ g_object_class_install_property (gobject_class,
+ PROP_LOGOUT_MODE,
+ g_param_spec_boolean ("logout_mode",
+ "Logout Mode",
+ "Whether the dialog is in logout mode",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY)));
+}
+
+static GList *
+get_selected_docs (GtkTreeModel * store)
+{
+ GList *list;
+ gboolean valid;
+ GtkTreeIter iter;
+
+ list = NULL;
+ valid = gtk_tree_model_get_iter_first (store, &iter);
+
+ while (valid)
+ {
+ gboolean to_save;
+ GtrPo *doc;
+
+ gtk_tree_model_get (store, &iter,
+ SAVE_COLUMN, &to_save, DOC_COLUMN, &doc, -1);
+ if (to_save)
+ list = g_list_prepend (list, doc);
+
+ valid = gtk_tree_model_iter_next (store, &iter);
+ }
+
+ list = g_list_reverse (list);
+
+ return list;
+}
+
+GList *gtr_close_confirmation_dialog_get_selected_documents
+ (GtrCloseConfirmationDialog * dlg)
+{
+ g_return_val_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
+
+ return g_list_copy (dlg->priv->selected_documents);
+}
+
+GtkWidget *
+gtr_close_confirmation_dialog_new (GtkWindow * parent,
+ GList * unsaved_documents,
+ gboolean logout_mode)
+{
+ GtkWidget *dlg;
+ g_return_val_if_fail (unsaved_documents != NULL, NULL);
+
+ dlg = GTK_WIDGET (g_object_new (GTR_TYPE_CLOSE_CONFIRMATION_DIALOG,
+ "unsaved_documents", unsaved_documents,
+ "logout_mode", logout_mode, NULL));
+ g_return_val_if_fail (dlg != NULL, NULL);
+
+ if (parent != NULL)
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
+ }
+
+ return dlg;
+}
+
+GtkWidget *
+gtr_close_confirmation_dialog_new_single (GtkWindow * parent,
+ GtrPo * doc, gboolean logout_mode)
+{
+ GtkWidget *dlg;
+ GList *unsaved_documents;
+ g_return_val_if_fail (doc != NULL, NULL);
+
+ unsaved_documents = g_list_prepend (NULL, doc);
+
+ dlg = gtr_close_confirmation_dialog_new (parent,
+ unsaved_documents, logout_mode);
+
+ g_list_free (unsaved_documents);
+
+ return dlg;
+}
+
+static void
+build_single_doc_dialog (GtrCloseConfirmationDialog * dlg)
+{
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *primary_label;
+ GtkWidget *image;
+ GtrPo *doc;
+ GFile *location;
+ gchar *doc_name;
+ gchar *str;
+ gchar *markup_str;
+
+ g_return_if_fail (dlg->priv->unsaved_documents->data != NULL);
+ doc = GTR_PO (dlg->priv->unsaved_documents->data);
+
+ /* Image */
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
+
+ /* Primary label */
+ primary_label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
+ gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
+
+ location = gtr_po_get_location (doc);
+ doc_name = g_file_get_path (location);
+ g_object_unref (location);
+
+ str =
+ g_markup_printf_escaped (_
+ ("Save the changes to document \"%s\" before closing?"),
+ doc_name);
+ g_free (doc_name);
+
+ markup_str =
+ g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>",
+ NULL);
+ g_free (str);
+
+ gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
+ g_free (markup_str);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
+ hbox, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (hbox);
+}
+
+static void
+populate_model (GtkTreeModel * store, GList * docs)
+{
+ GtkTreeIter iter;
+
+ while (docs != NULL)
+ {
+ GtrPo *po;
+ GFile *location;
+ gchar *name;
+
+ po = GTR_PO (docs->data);
+
+ location = gtr_po_get_location (po);
+ name = g_file_get_path (location);
+ g_object_unref (location);
+
+ gtk_list_store_append (GTK_LIST_STORE (store), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (store), &iter,
+ SAVE_COLUMN, TRUE,
+ NAME_COLUMN, name, DOC_COLUMN, po, -1);
+
+ g_free (name);
+ docs = g_list_next (docs);
+ }
+}
+
+static void
+save_toggled (GtkCellRendererToggle * renderer,
+ gchar * path_str, GtkTreeModel * store)
+{
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeIter iter;
+ gboolean active;
+
+ gtk_tree_model_get_iter (store, &iter, path);
+ gtk_tree_model_get (store, &iter, SAVE_COLUMN, &active, -1);
+
+ active ^= 1;
+
+ gtk_list_store_set (GTK_LIST_STORE (store), &iter, SAVE_COLUMN, active, -1);
+
+ gtk_tree_path_free (path);
+}
+
+static GtkWidget *
+create_treeview (GtrCloseConfirmationDialogPrivate * priv)
+{
+ GtkListStore *store;
+ GtkWidget *treeview;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ treeview = gtk_tree_view_new ();
+ gtk_widget_set_size_request (treeview, 260, 120);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
+
+ /* Create and populate the model */
+ store = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_POINTER);
+ populate_model (GTK_TREE_MODEL (store), priv->unsaved_documents);
+
+ /* Set model to the treeview */
+ gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ priv->list_store = GTK_TREE_MODEL (store);
+
+ /* Add columns */
+ if (!priv->disable_save_to_disk)
+ {
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (save_toggled), store);
+
+ column = gtk_tree_view_column_new_with_attributes ("Save?",
+ renderer,
+ "active",
+ SAVE_COLUMN, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+ }
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("Name",
+ renderer,
+ "text",
+ NAME_COLUMN, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ return treeview;
+}
+
+static void
+build_multiple_docs_dialog (GtrCloseConfirmationDialog * dlg)
+{
+ GtrCloseConfirmationDialogPrivate *priv;
+ GtkWidget *hbox;
+ GtkWidget *image;
+ GtkWidget *vbox;
+ GtkWidget *primary_label;
+ GtkWidget *vbox2;
+ GtkWidget *select_label;
+ GtkWidget *scrolledwindow;
+ GtkWidget *treeview;
+ GtkWidget *secondary_label;
+ gchar *str;
+ gchar *markup_str;
+
+ priv = dlg->priv;
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), hbox, TRUE, TRUE, 0);
+
+ /* Image */
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ /* Primary label */
+ primary_label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
+ gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
+
+ if (priv->disable_save_to_disk)
+ str =
+ g_strdup_printf (ngettext
+ ("Changes to %d document will be permanently lost.",
+ "Changes to %d documents will be permanently lost.",
+ g_list_length (priv->unsaved_documents)),
+ g_list_length (priv->unsaved_documents));
+ else
+ str =
+ g_strdup_printf (ngettext
+ ("There is %d document with unsaved changes. "
+ "Save changes before closing?",
+ "There are %d documents with unsaved changes. "
+ "Save changes before closing?",
+ g_list_length (priv->unsaved_documents)),
+ g_list_length (priv->unsaved_documents));
+
+ markup_str =
+ g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>",
+ NULL);
+ g_free (str);
+
+ gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
+ g_free (markup_str);
+ gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
+
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
+
+ if (priv->disable_save_to_disk)
+ select_label =
+ gtk_label_new_with_mnemonic (_("Docum_ents with unsaved changes:"));
+ else
+ select_label =
+ gtk_label_new_with_mnemonic (_
+ ("S_elect the documents you want to save:"));
+
+ gtk_box_pack_start (GTK_BOX (vbox2), select_label, FALSE, FALSE, 0);
+ gtk_label_set_line_wrap (GTK_LABEL (select_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (select_label), 0.0, 0.5);
+
+ scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+ gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
+ GTK_SHADOW_IN);
+
+ treeview = create_treeview (priv);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview);
+
+ /* Secondary label */
+ if (priv->disable_save_to_disk)
+ secondary_label =
+ gtk_label_new (_
+ ("Saving has been disabled by the system administrator."));
+ else
+ secondary_label = gtk_label_new (_("If you don't save, "
+ "all your changes will be permanently lost."));
+
+ gtk_box_pack_start (GTK_BOX (vbox2), secondary_label, FALSE, FALSE, 0);
+ gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
+ gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (select_label), treeview);
+
+ gtk_widget_show_all (hbox);
+}
+
+static void
+set_unsaved_document (GtrCloseConfirmationDialog * dlg, const GList * list)
+{
+ GtrCloseConfirmationDialogPrivate *priv;
+
+ g_return_if_fail (list != NULL);
+
+ priv = dlg->priv;
+ g_return_if_fail (priv->unsaved_documents == NULL);
+
+ priv->unsaved_documents = g_list_copy ((GList *) list);
+
+ if (GET_MODE (priv) == SINGLE_DOC_MODE)
+ {
+ build_single_doc_dialog (dlg);
+ }
+ else
+ {
+ build_multiple_docs_dialog (dlg);
+ }
+}
+
+const GList *gtr_close_confirmation_dialog_get_unsaved_documents
+ (GtrCloseConfirmationDialog * dlg)
+{
+ g_return_val_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
+
+ return dlg->priv->unsaved_documents;
+}
diff --git a/src/dialogs/gtr-close-confirmation-dialog.h b/src/dialogs/gtr-close-confirmation-dialog.h
new file mode 100644
index 0000000..ad244cd
--- /dev/null
+++ b/src/dialogs/gtr-close-confirmation-dialog.h
@@ -0,0 +1,86 @@
+/*
+ * gtr-close-confirmation-dialog.h
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2004-2005 GNOME Foundation
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the gedit Team, 2004-2005. See the AUTHORS file for a
+ * list of people on the gtr Team.
+ * See the ChangeLog files for a list of changes.
+ */
+
+#ifndef __GTR_CLOSE_CONFIRMATION_DIALOG_H__
+#define __GTR_CLOSE_CONFIRMATION_DIALOG_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "gtr-po.h"
+
+#define GTR_TYPE_CLOSE_CONFIRMATION_DIALOG (gtr_close_confirmation_dialog_get_type ())
+#define GTR_CLOSE_CONFIRMATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_CLOSE_CONFIRMATION_DIALOG, GtrCloseConfirmationDialog))
+#define GTR_CLOSE_CONFIRMATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_CLOSE_CONFIRMATION_DIALOG, GtrCloseConfirmationDialogClass))
+#define GTR_IS_CLOSE_CONFIRMATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_CLOSE_CONFIRMATION_DIALOG))
+#define GTR_IS_CLOSE_CONFIRMATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_CLOSE_CONFIRMATION_DIALOG))
+#define GTR_CLOSE_CONFIRMATION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GTR_TYPE_CLOSE_CONFIRMATION_DIALOG, GtrCloseConfirmationDialogClass))
+
+typedef struct _GtrCloseConfirmationDialog GtrCloseConfirmationDialog;
+typedef struct _GtrCloseConfirmationDialogClass
+ GtrCloseConfirmationDialogClass;
+typedef struct _GtrCloseConfirmationDialogPrivate
+ GtrCloseConfirmationDialogPrivate;
+
+struct _GtrCloseConfirmationDialog
+{
+ GtkDialog parent;
+
+ /*< private > */
+ GtrCloseConfirmationDialogPrivate *priv;
+};
+
+struct _GtrCloseConfirmationDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+GType
+gtr_close_confirmation_dialog_get_type (void)
+ G_GNUC_CONST;
+
+ GtkWidget *gtr_close_confirmation_dialog_new (GtkWindow * parent,
+ GList *
+ unsaved_documents,
+ gboolean logout_mode);
+ GtkWidget *gtr_close_confirmation_dialog_new_single (GtkWindow *
+ parent,
+ GtrPo
+ * doc,
+ gboolean
+ logout_mode);
+
+ const GList
+ * gtr_close_confirmation_dialog_get_unsaved_documents
+ (GtrCloseConfirmationDialog * dlg);
+
+GList
+ * gtr_close_confirmation_dialog_get_selected_documents
+ (GtrCloseConfirmationDialog * dlg);
+
+#endif /* __GTR_CLOSE_CONFIRMATION_DIALOG_H__ */
diff --git a/src/dialogs/gtr-file-dialogs.c b/src/dialogs/gtr-file-dialogs.c
new file mode 100644
index 0000000..415c7d2
--- /dev/null
+++ b/src/dialogs/gtr-file-dialogs.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2007 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/>.
+ *
+ */
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gtr-file-dialogs.h"
+#include "gtr-tab.h"
+#include "gtr-po.h"
+#include "gtr-window.h"
+
+/*
+ * File chooser dialog
+ */
+GtkWidget *
+gtr_file_chooser_new (GtkWindow * parent,
+ FileselMode mode,
+ const gchar * title, const gchar * dir)
+{
+ GtkWidget *dialog;
+ GtkFileFilter *filter;
+
+ dialog = gtk_file_chooser_dialog_new (title,
+ parent,
+ (mode ==
+ FILESEL_SAVE) ?
+ GTK_FILE_CHOOSER_ACTION_SAVE :
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ (mode ==
+ FILESEL_SAVE) ? GTK_STOCK_SAVE :
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+
+ if (dir)
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), dir);
+
+ if (mode != FILESEL_SAVE)
+ {
+ /* We set a multi selection dialog */
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ /* Now we set the filters */
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Gettext translation"));
+#ifndef G_OS_WIN32
+ gtk_file_filter_add_mime_type (filter, "text/x-gettext-translation");
+#else
+ gtk_file_filter_add_pattern (filter, "*.po");
+#endif
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Gettext translation template"));
+ gtk_file_filter_add_pattern (filter, "*.pot");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ }
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+
+ return dialog;
+}
diff --git a/src/dialogs/gtr-file-dialogs.h b/src/dialogs/gtr-file-dialogs.h
new file mode 100644
index 0000000..e9f5ac3
--- /dev/null
+++ b/src/dialogs/gtr-file-dialogs.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2007 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 __FILE_DIALOGS_H__
+#define __FILE_DIALOGS_H__
+
+#include <gtk/gtk.h>
+
+#include "gtr-window.h"
+
+typedef enum
+{
+ FILESEL_OPEN,
+ FILESEL_SAVE
+} FileselMode;
+
+GtkWidget *gtr_file_chooser_new (GtkWindow * parent,
+ FileselMode mode,
+ const gchar * title, const gchar * dir);
+
+#endif
diff --git a/src/dialogs/gtr-header-dialog.c b/src/dialogs/gtr-header-dialog.c
new file mode 100644
index 0000000..6d2a5d2
--- /dev/null
+++ b/src/dialogs/gtr-header-dialog.c
@@ -0,0 +1,399 @@
+/*
+ * Copyright (C) 2007 Pablo Sanxiao <psanxiao gmail com>
+ * 2010 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 2 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 <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include "gtr-application.h"
+#include "gtr-dirs.h"
+#include "gtr-header-dialog.h"
+#include "gtr-utils.h"
+#include "gtr-settings.h"
+#include "gtr-po.h"
+
+#define GTR_HEADER_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_HEADER_DIALOG, \
+ GtrHeaderDialogPrivate))
+
+G_DEFINE_TYPE (GtrHeaderDialog, gtr_header_dialog, GTK_TYPE_DIALOG)
+
+struct _GtrHeaderDialogPrivate
+{
+ GSettings *settings;
+
+ GtkWidget *main_box;
+ GtkWidget *notebook;
+
+ GtkWidget *prj_page;
+ GtkWidget *lang_page;
+ GtkWidget *lang_vbox;
+
+ GtkWidget *prj_id_version;
+ GtkWidget *rmbt;
+ GtkWidget *prj_comment;
+ GtkWidget *take_my_options;
+
+ GtkWidget *translator;
+ GtkWidget *tr_email;
+ GtkWidget *pot_date;
+ GtkWidget *po_date;
+ GtkWidget *language;
+ GtkWidget *lg_email;
+ GtkWidget *charset;
+ GtkWidget *encoding;
+
+ GtrHeader *header;
+};
+
+static void
+gtr_header_dialog_dispose (GObject * object)
+{
+ GtrHeaderDialog *dlg = GTR_HEADER_DIALOG (object);
+
+ if (dlg->priv->settings != NULL)
+ {
+ g_object_unref (dlg->priv->settings);
+ dlg->priv->settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_header_dialog_parent_class)->dispose (object);
+}
+
+static void
+gtr_header_dialog_class_init (GtrHeaderDialogClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtrHeaderDialogPrivate));
+
+ object_class->dispose = gtr_header_dialog_dispose;
+}
+
+static void
+take_my_options_checkbutton_toggled (GtkToggleButton * button,
+ GtrHeaderDialog * dlg)
+{
+ gboolean active;
+
+ g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->take_my_options));
+
+ active = gtk_toggle_button_get_active (button);
+
+ g_settings_set_boolean (dlg->priv->settings, GTR_SETTINGS_USE_PROFILE_VALUES,
+ active);
+
+ gtk_widget_set_sensitive (dlg->priv->translator, !active);
+ gtk_widget_set_sensitive (dlg->priv->tr_email, !active);
+ gtk_widget_set_sensitive (dlg->priv->language, !active);
+ gtk_widget_set_sensitive (dlg->priv->lg_email, !active);
+ gtk_widget_set_sensitive (dlg->priv->encoding, !active);
+}
+
+static void
+prj_comment_changed (GtkTextBuffer * buffer, GtrHeaderDialog * dlg)
+{
+ GtkTextIter start, end;
+ gchar *text;
+
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
+
+ if (text)
+ {
+ gtr_header_set_comments (dlg->priv->header, text);
+ g_free (text);
+ }
+}
+
+static void
+prj_id_version_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
+{
+ const gchar *text;
+
+ text = gtk_entry_get_text (GTK_ENTRY (widget));
+
+ if (text)
+ gtr_header_set_prj_id_version (dlg->priv->header, text);
+}
+
+static void
+rmbt_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
+{
+ const gchar *text;
+
+ text = gtk_entry_get_text (GTK_ENTRY (widget));
+
+ if (text)
+ gtr_header_set_rmbt (dlg->priv->header, text);
+}
+
+static void
+translator_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
+{
+ const gchar *name, *email;
+
+ name = gtk_entry_get_text (GTK_ENTRY (dlg->priv->translator));
+ email = gtk_entry_get_text (GTK_ENTRY (dlg->priv->tr_email));
+
+ if (name && email)
+ gtr_header_set_translator (dlg->priv->header, name, email);
+}
+
+static void
+language_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
+{
+ const gchar *language, *lg_email;
+
+ language = gtk_entry_get_text (GTK_ENTRY (dlg->priv->language));
+ lg_email = gtk_entry_get_text (GTK_ENTRY (dlg->priv->lg_email));
+
+ if (language && lg_email)
+ gtr_header_set_language (dlg->priv->header, language, lg_email);
+}
+
+static void
+gtr_header_dialog_fill_from_header (GtrHeaderDialog * dlg)
+{
+ GtrHeader *header;
+ GtkTextBuffer *buffer;
+ gchar *text;
+
+ header = dlg->priv->header;
+
+ /* Project Information */
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dlg->priv->prj_comment));
+ gtk_text_buffer_set_text (buffer, gtr_header_get_comments (header), -1);
+
+ text = gtr_header_get_prj_id_version (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->prj_id_version), text);
+ g_free (text);
+
+ text = gtr_header_get_pot_date (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->pot_date), text);
+ g_free (text);
+
+ text = gtr_header_get_po_date (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->po_date), text);
+ g_free (text);
+
+ text = gtr_header_get_rmbt (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->rmbt), text);
+ g_free (text);
+
+ /* Translator and Language Information */
+ text = gtr_header_get_translator (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->translator), text);
+ g_free (text);
+
+ text = gtr_header_get_tr_email (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->tr_email), text);
+ g_free (text);
+
+ text = gtr_header_get_language (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->language), text);
+ g_free (text);
+
+ text = gtr_header_get_lg_email (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->lg_email), text);
+ g_free (text);
+
+ text = gtr_header_get_charset (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->charset), text);
+ g_free (text);
+
+ text = gtr_header_get_encoding (header);
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->encoding), text);
+ g_free (text);
+}
+
+static void
+gtr_header_dialog_init (GtrHeaderDialog * dlg)
+{
+ gboolean ret;
+ GtkWidget *error_widget, *action_area;
+ GtkBox *content_area;
+ gchar *path;
+ gchar *root_objects[] = {
+ "main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_HEADER_DIALOG_GET_PRIVATE (dlg);
+
+ dlg->priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Edit Header"));
+ 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_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (content_area, 2);
+ 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);
+
+ path = gtr_dirs_get_ui_file ("gtr-header-dialog.ui");
+ ret = gtr_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "main_box", &dlg->priv->main_box,
+ "notebook", &dlg->priv->notebook,
+ "lang_vbox", &dlg->priv->lang_vbox,
+ "prj_id_version",
+ &dlg->priv->prj_id_version, "rmbt",
+ &dlg->priv->rmbt, "prj_comment",
+ &dlg->priv->prj_comment,
+ "take_my_options",
+ &dlg->priv->take_my_options,
+ "tr_name", &dlg->priv->translator,
+ "tr_email", &dlg->priv->tr_email,
+ "pot_date", &dlg->priv->pot_date,
+ "po_date", &dlg->priv->po_date,
+ "language_entry",
+ &dlg->priv->language,
+ "lg_email_entry",
+ &dlg->priv->lg_email,
+ "charset_entry",
+ &dlg->priv->charset,
+ "encoding_entry",
+ &dlg->priv->encoding, NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (content_area, dlg->priv->main_box, FALSE, FALSE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->take_my_options),
+ g_settings_get_boolean (dlg->priv->settings,
+ GTR_SETTINGS_USE_PROFILE_VALUES));
+
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (dlg->priv->prj_comment), TRUE);
+
+ gtk_widget_set_sensitive (dlg->priv->pot_date, FALSE);
+ gtk_widget_set_sensitive (dlg->priv->po_date, FALSE);
+ gtk_widget_set_sensitive (dlg->priv->charset, FALSE);
+
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)))
+ {
+ gboolean active;
+
+ active =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->take_my_options));
+
+ gtk_widget_set_sensitive (dlg->priv->translator, !active);
+ gtk_widget_set_sensitive (dlg->priv->tr_email, !active);
+ gtk_widget_set_sensitive (dlg->priv->language, !active);
+ gtk_widget_set_sensitive (dlg->priv->lg_email, !active);
+ gtk_widget_set_sensitive (dlg->priv->encoding, !active);
+ }
+}
+
+static void
+set_default_values (GtrHeaderDialog * dlg, GtrWindow * window)
+{
+ GtkTextBuffer *buffer;
+
+ /* Write header's values on Header dialog */
+ dlg->priv->header = gtr_window_get_header_from_active_tab (window);
+ gtr_header_dialog_fill_from_header (GTR_HEADER_DIALOG (dlg));
+
+ /*Connect signals */
+ g_signal_connect (dlg->priv->take_my_options, "toggled",
+ G_CALLBACK (take_my_options_checkbutton_toggled), dlg);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dlg->priv->prj_comment));
+
+ g_signal_connect (buffer, "changed", G_CALLBACK (prj_comment_changed), dlg);
+
+ /* Connect signals to edit Project information on Header dialog */
+ g_signal_connect (dlg->priv->prj_id_version, "changed",
+ G_CALLBACK (prj_id_version_changed), dlg);
+
+ g_signal_connect (dlg->priv->rmbt, "changed",
+ G_CALLBACK (rmbt_changed), dlg);
+
+ /* Connect signals to edit Translator and Language information on Header dialog */
+ g_signal_connect (dlg->priv->translator, "changed",
+ G_CALLBACK (translator_changed), dlg);
+
+ g_signal_connect (dlg->priv->tr_email, "changed",
+ G_CALLBACK (translator_changed), dlg);
+
+ g_signal_connect (dlg->priv->language, "changed",
+ G_CALLBACK (language_changed), dlg);
+
+ g_signal_connect (dlg->priv->lg_email, "changed",
+ G_CALLBACK (language_changed), dlg);
+}
+
+void
+gtr_show_header_dialog (GtrWindow * window)
+{
+ static GtrHeaderDialog *dlg = NULL;
+ GtrTab *tab;
+
+ tab = gtr_window_get_active_tab (window);
+ g_return_if_fail (tab != NULL);
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ dlg = g_object_new (GTR_TYPE_HEADER_DIALOG, NULL);
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+
+ set_default_values (dlg, window);
+
+ gtk_widget_show (GTK_WIDGET (dlg));
+ }
+
+ if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
+ }
+
+ gtk_window_present (GTK_WINDOW (dlg));
+}
diff --git a/src/dialogs/gtr-header-dialog.h b/src/dialogs/gtr-header-dialog.h
new file mode 100644
index 0000000..28deea0
--- /dev/null
+++ b/src/dialogs/gtr-header-dialog.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2007 Pablo Sanxiao <psanxiao 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 2 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 __HEADER_DIALOG_H__
+#define __HEADER_DIALOG_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtr-window.h"
+
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_HEADER_DIALOG (gtr_header_dialog_get_type ())
+#define GTR_HEADER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_HEADER_DIALOG, GtrHeaderDialog))
+#define GTR_HEADER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_HEADER_DIALOG, GtrHeaderDialogClass))
+#define GTR_IS_HEADER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_HEADER_DIALOG))
+#define GTR_IS_HEADER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_HEADER_DIALOG))
+#define GTR_HEADER_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_HEADER_DIALOG, GtrHeaderDialogClass))
+
+/* Private structure type */
+typedef struct _GtrHeaderDialogPrivate GtrHeaderDialogPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtrHeaderDialog GtrHeaderDialog;
+
+struct _GtrHeaderDialog
+{
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtrHeaderDialogPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtrHeaderDialogClass GtrHeaderDialogClass;
+
+struct _GtrHeaderDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType
+gtr_header_dialog_get_type (void)
+ G_GNUC_CONST;
+
+ GType gtr_header_dialog_register_type (GTypeModule * module);
+
+ void gtr_show_header_dialog (GtrWindow * window);
+
+#endif
diff --git a/src/dialogs/gtr-header-dialog.ui b/src/dialogs/gtr-header-dialog.ui
new file mode 100644
index 0000000..635c264
--- /dev/null
+++ b/src/dialogs/gtr-header-dialog.ui
@@ -0,0 +1,637 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <object class="GtkDialog" id="header_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <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_area2">
+ <property name="visible">True</property>
+ <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">False</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="main_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkNotebook" id="notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">6</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTextView" id="prj_comment">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Comment</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">3</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label16">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label17">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label23">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Project Id _version:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="prj_id_version">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label24">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Pot _file creation date:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">pot_date</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="pot_date">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label25">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Po file _revision date:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">po_date</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="po_date">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label26">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Report message _bugs to:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">rmbt</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="rmbt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Project</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="lang_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="take_my_options">
+ <property name="label" translatable="yes">Use my options to complete the following entries:</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="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">6</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="lang_page">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">6</property>
+ <property name="n_columns">3</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="encoding_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="charset_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="editable">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="lg_email_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="language_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label27">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label28">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label29">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label30">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label31">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label32">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label33">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Translator's _name:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">tr_name</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label34">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Translator's _email:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">tr_email</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label35">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">_Language:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label36">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Language gro_up email:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label37">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Char_set:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label38">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">12</property>
+ <property name="label" translatable="yes">Enc_oding:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="tr_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="tr_email">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Translator and Language</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</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">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/src/dialogs/gtr-jump-dialog.c b/src/dialogs/gtr-jump-dialog.c
new file mode 100644
index 0000000..a5127d8
--- /dev/null
+++ b/src/dialogs/gtr-jump-dialog.c
@@ -0,0 +1,185 @@
+/*
+ * 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/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-dirs.h"
+#include "gtr-jump-dialog.h"
+#include "gtr-tab.h"
+#include "gtr-utils.h"
+#include "gtr-window.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+
+#define GTR_JUMP_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_JUMP_DIALOG, \
+ GtrJumpDialogPrivate))
+
+
+G_DEFINE_TYPE (GtrJumpDialog, gtr_jump_dialog, GTK_TYPE_DIALOG)
+ struct _GtrJumpDialogPrivate
+ {
+ GtkWidget *main_box;
+ GtkWidget *jump;
+
+ GtrWindow *window;
+ };
+
+ static void dialog_response_handler (GtkDialog * dlg, gint res_id)
+{
+ GtrJumpDialog *dialog = GTR_JUMP_DIALOG (dlg);
+ GtrTab *tab;
+ gint number;
+
+ switch (res_id)
+ {
+ case GTK_RESPONSE_OK:
+ number =
+ gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
+ (dialog->priv->jump));
+ tab = gtr_window_get_active_tab (dialog->priv->window);
+ gtr_tab_go_to_number (tab, number - 1);
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ break;
+
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ }
+}
+
+static void
+gtr_jump_dialog_init (GtrJumpDialog * dlg)
+{
+ gboolean ret;
+ GtkWidget *error_widget, *action_area;
+ GtkBox *content_area;
+ gchar *path;
+ gchar *root_objects[] = {
+ "adjustment1",
+ "main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_JUMP_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_OK,
+ GTK_RESPONSE_OK,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Go to Message"));
+ gtk_window_set_default_size (GTK_WINDOW (dlg), 300, 100);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
+ content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (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);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Glade */
+ path = gtr_dirs_get_ui_file ("gtr-jump-dialog.ui");
+ ret = gtr_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "main_box", &dlg->priv->main_box,
+ "jump", &dlg->priv->jump, NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (content_area, dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+}
+
+static void
+gtr_jump_dialog_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (gtr_jump_dialog_parent_class)->finalize (object);
+}
+
+static void
+gtr_jump_dialog_class_init (GtrJumpDialogClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtrJumpDialogPrivate));
+
+ object_class->finalize = gtr_jump_dialog_finalize;
+}
+
+void
+gtr_show_jump_dialog (GtrWindow * window)
+{
+ static GtrJumpDialog *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ GtrTab *tab;
+ GtrPo *po;
+ gint messages;
+
+ dlg = g_object_new (GTR_TYPE_JUMP_DIALOG, NULL);
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+
+ dlg->priv->window = window;
+
+ /* Set the maximum number of the spin button */
+ tab = gtr_window_get_active_tab (window);
+ po = gtr_tab_get_po (tab);
+ messages = gtr_po_get_messages_count (po);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (dlg->priv->jump),
+ 1.0, (gdouble) messages);
+
+ gtk_widget_show (GTK_WIDGET (dlg));
+ }
+
+ if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
+ }
+
+ gtk_window_present (GTK_WINDOW (dlg));
+}
diff --git a/src/dialogs/gtr-jump-dialog.h b/src/dialogs/gtr-jump-dialog.h
new file mode 100644
index 0000000..2444bb1
--- /dev/null
+++ b/src/dialogs/gtr-jump-dialog.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 __JUMP_DIALOG_H__
+#define __JUMP_DIALOG_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtr-window.h"
+
+G_BEGIN_DECLS
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_JUMP_DIALOG (gtr_jump_dialog_get_type ())
+#define GTR_JUMP_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_JUMP_DIALOG, GtrJumpDialog))
+#define GTR_JUMP_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_JUMP_DIALOG, GtrJumpDialogClass))
+#define GTR_IS_JUMP_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_JUMP_DIALOG))
+#define GTR_IS_JUMP_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_JUMP_DIALOG))
+#define GTR_JUMP_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_JUMP_DIALOG, GtrJumpDialogClass))
+/* Private structure type */
+typedef struct _GtrJumpDialogPrivate GtrJumpDialogPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtrJumpDialog GtrJumpDialog;
+
+struct _GtrJumpDialog
+{
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtrJumpDialogPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtrJumpDialogClass GtrJumpDialogClass;
+
+struct _GtrJumpDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType
+gtr_jump_dialog_get_type (void)
+ G_GNUC_CONST;
+
+ GType gtr_jump_dialog_register_type (GTypeModule * module);
+
+ void gtr_show_jump_dialog (GtrWindow * window);
+
+G_END_DECLS
+#endif /* __JUMP_DIALOG_H__ */
diff --git a/src/dialogs/gtr-jump-dialog.ui b/src/dialogs/gtr-jump-dialog.ui
new file mode 100644
index 0000000..9f98dba
--- /dev/null
+++ b/src/dialogs/gtr-jump-dialog.ui
@@ -0,0 +1,103 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ <property name="page_size">10</property>
+ </object>
+ <object class="GtkDialog" id="dialog1">
+ <property name="border_width">5</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkBox" id="main_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Enter message number:</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="jump">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ <property name="adjustment">adjustment1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</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="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button1</action-widget>
+ <action-widget response="0">button2</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/src/dialogs/gtr-languages-fetcher.c b/src/dialogs/gtr-languages-fetcher.c
new file mode 100644
index 0000000..0a9cb8d
--- /dev/null
+++ b/src/dialogs/gtr-languages-fetcher.c
@@ -0,0 +1,492 @@
+/*
+ * gtr-languages-fetcher.c
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * 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-dirs.h"
+#include "gtr-languages-fetcher.h"
+#include "gtr-language.h"
+#include "gtr-utils.h"
+#include <string.h>
+
+#define GTR_LANGUAGES_FETCHER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GTR_TYPE_LANGUAGES_FETCHER, GtrLanguagesFetcherPrivate))
+
+struct _GtrLanguagesFetcherPrivate
+{
+ GtkWidget *language;
+ GtkWidget *language_code;
+ GtkWidget *charset;
+ GtkWidget *encoding;
+ GtkWidget *team_email;
+ GtkWidget *plural_forms;
+
+ GtkListStore *language_store;
+ GtkListStore *code_store;
+};
+
+/* Signals */
+enum
+{
+ CHANGED,
+ LAST_SIGNAL
+};
+
+G_DEFINE_TYPE (GtrLanguagesFetcher, gtr_languages_fetcher, GTK_TYPE_BOX)
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void
+gtr_languages_fetcher_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtr_languages_fetcher_parent_class)->finalize (object);
+}
+
+static void
+gtr_languages_fetcher_class_init (GtrLanguagesFetcherClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gtr_languages_fetcher_finalize;
+
+ signals[CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtrLanguagesFetcherClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_type_class_add_private (object_class, sizeof (GtrLanguagesFetcherPrivate));
+}
+
+static void
+append_from_languages (GtrLanguagesFetcher *fetcher)
+{
+ const GSList *languages, *l;
+ GHashTable *plurals;
+
+ plurals = g_hash_table_new (g_str_hash, g_int_equal);
+
+ languages = gtr_language_get_languages ();
+
+ for (l = languages; l != NULL; l = (const GSList *)g_list_next (l))
+ {
+ GtrLanguage *lang = (GtrLanguage *)l->data;
+ GtkTreeIter iter1, iter2;
+ const gchar *plural_form;
+
+ gtk_list_store_append (fetcher->priv->language_store, &iter1);
+ gtk_list_store_set (fetcher->priv->language_store, &iter1,
+ 0, gtr_language_get_name (lang),
+ 1, lang,
+ -1);
+
+ gtk_list_store_append (fetcher->priv->code_store, &iter2);
+ gtk_list_store_set (fetcher->priv->code_store, &iter2,
+ 0, gtr_language_get_code (lang),
+ 1, lang,
+ -1);
+
+ plural_form = gtr_language_get_plural_form (lang);
+ if (plural_form != NULL && *plural_form != '\0')
+ {
+ gint *value;
+
+ value = g_hash_table_lookup (plurals, plural_form);
+ if (value == NULL)
+ {
+ g_hash_table_insert (plurals, (gchar *)plural_form, GINT_TO_POINTER (1));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (fetcher->priv->plural_forms),
+ plural_form);
+ }
+ }
+ }
+
+ g_hash_table_unref (plurals);
+}
+
+static void
+fill_encoding_and_charset (GtrLanguagesFetcher *fetcher)
+{
+ const gchar *text;
+
+ text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->charset))));
+
+ if (text == NULL || *text == '\0')
+ gtk_combo_box_set_active (GTK_COMBO_BOX (fetcher->priv->charset), 0);
+
+ text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->encoding))));
+
+ if (text == NULL || *text == '\0')
+ gtk_combo_box_set_active (GTK_COMBO_BOX (fetcher->priv->encoding), 0);
+}
+
+static void
+fill_from_language_entry (GtrLanguagesFetcher *fetcher,
+ GtrLanguage *lang)
+{
+ const gchar *entry_text;
+
+ fill_encoding_and_charset (fetcher);
+
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))));
+
+ if (*entry_text == '\0')
+ {
+ const gchar *code;
+
+ code = gtr_language_get_code (lang);
+
+ if (code != NULL && *code != '\0')
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))), code);
+ }
+
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))));
+
+ if (*entry_text == '\0')
+ {
+ const gchar *plural_form;
+
+ plural_form = gtr_language_get_plural_form (lang);
+
+ if (plural_form != NULL && *plural_form != '\0')
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))), plural_form);
+ }
+}
+
+static void
+fill_from_language_code_entry (GtrLanguagesFetcher *fetcher,
+ GtrLanguage *lang)
+{
+ const gchar *entry_text;
+
+ fill_encoding_and_charset (fetcher);
+
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))));
+
+ if (*entry_text == '\0')
+ {
+ const gchar *name;
+
+ name = gtr_language_get_name (lang);
+
+ if (name != NULL && *name != '\0')
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))), name);
+ }
+
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))));
+
+ if (*entry_text == '\0')
+ {
+ const gchar *plural_form;
+
+ plural_form = gtr_language_get_plural_form (lang);
+
+ if (plural_form != NULL && *plural_form != '\0')
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))), plural_form);
+ }
+}
+
+typedef void (* fill_method) (GtrLanguagesFetcher *fetcher, GtrLanguage *lang);
+
+static void
+fill_boxes (GtrLanguagesFetcher *fetcher,
+ GtkEntry *entry,
+ GtkTreeModel *store,
+ fill_method fill)
+{
+ const gchar *text;
+ gchar *entry_row;
+ GtkTreeIter iter;
+ GtrLanguage *lang;
+ gboolean found = FALSE;
+
+ text = gtk_entry_get_text (entry);
+
+ if (text == NULL || *text == '\0' ||
+ !gtk_tree_model_get_iter_first (store, &iter))
+ return;
+
+ do
+ {
+ gtk_tree_model_get (store, &iter,
+ 0, &entry_row,
+ -1);
+
+ if (entry_row != NULL && strcmp (entry_row, text) == 0)
+ {
+ found = TRUE;
+ g_free (entry_row);
+ break;
+ }
+
+ g_free (entry_row);
+ }
+ while (gtk_tree_model_iter_next (store, &iter));
+
+ if (found)
+ {
+ gtk_tree_model_get (store, &iter,
+ 1, &lang,
+ -1);
+
+ fill (fetcher, lang);
+ }
+}
+
+static void
+on_language_activate (GtkEntry *entry,
+ GtrLanguagesFetcher *fetcher)
+{
+ fill_boxes (fetcher, entry, GTK_TREE_MODEL (fetcher->priv->language_store),
+ fill_from_language_entry);
+}
+
+static void
+on_language_focus_out_event (GtkEntry *entry,
+ GdkEvent *event,
+ GtrLanguagesFetcher *fetcher)
+{
+ on_language_activate (entry, fetcher);
+}
+
+static void
+on_language_code_activate (GtkEntry *entry,
+ GtrLanguagesFetcher *fetcher)
+{
+ fill_boxes (fetcher, entry, GTK_TREE_MODEL (fetcher->priv->code_store),
+ fill_from_language_code_entry);
+}
+
+static void
+on_language_code_focus_out_event (GtkEntry *entry,
+ GdkEvent *event,
+ GtrLanguagesFetcher *fetcher)
+{
+ on_language_code_activate (entry, fetcher);
+}
+
+static void
+on_combo_box_changed (GtkWidget *widget,
+ GtrLanguagesFetcher *fetcher)
+{
+ g_signal_emit (fetcher, signals[CHANGED], 0, NULL);
+}
+
+static void
+gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
+{
+ GtkWidget *error_widget;
+ GtkWidget *main_box;
+ gboolean ret;
+ gchar *path;
+ gchar *root_objects[] = {
+ "main_box",
+ "language_store",
+ "code_store",
+ NULL
+ };
+
+ fetcher->priv = GTR_LANGUAGES_FETCHER_GET_PRIVATE (fetcher);
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (fetcher),
+ GTK_ORIENTATION_VERTICAL);
+
+ path = gtr_dirs_get_ui_file ("gtr-languages-fetcher.ui");
+ ret = gtr_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "main_box", &main_box,
+ "language", &fetcher->priv->language,
+ "language_code", &fetcher->priv->language_code,
+ "charset", &fetcher->priv->charset,
+ "encoding", &fetcher->priv->encoding,
+ "team_email", &fetcher->priv->team_email,
+ "plural_forms", &fetcher->priv->plural_forms,
+
+ "language_store", &fetcher->priv->language_store,
+ "code_store", &fetcher->priv->code_store,
+ NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (fetcher), error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (GTK_BOX (fetcher), main_box, FALSE, FALSE, 0);
+
+ /* add items to comboboxes */
+ append_from_languages (fetcher);
+
+ g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language)),
+ "activate",
+ G_CALLBACK (on_language_activate),
+ fetcher);
+ g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language)),
+ "focus-out-event",
+ G_CALLBACK (on_language_focus_out_event),
+ fetcher);
+ g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code)),
+ "activate",
+ G_CALLBACK (on_language_code_activate),
+ fetcher);
+ g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code)),
+ "focus-out-event",
+ G_CALLBACK (on_language_code_focus_out_event),
+ fetcher);
+
+ /* To emit the changed signal */
+ g_signal_connect (fetcher->priv->language, "changed",
+ G_CALLBACK (on_combo_box_changed),
+ fetcher);
+ g_signal_connect (fetcher->priv->language_code, "changed",
+ G_CALLBACK (on_combo_box_changed),
+ fetcher);
+ g_signal_connect (fetcher->priv->charset, "changed",
+ G_CALLBACK (on_combo_box_changed),
+ fetcher);
+ g_signal_connect (fetcher->priv->encoding, "changed",
+ G_CALLBACK (on_combo_box_changed),
+ fetcher);
+ g_signal_connect (fetcher->priv->team_email, "changed",
+ G_CALLBACK (on_combo_box_changed),
+ fetcher);
+ g_signal_connect (fetcher->priv->plural_forms, "changed",
+ G_CALLBACK (on_combo_box_changed),
+ fetcher);
+}
+
+GtkWidget *
+gtr_languages_fetcher_new ()
+{
+ return g_object_new (GTR_TYPE_LANGUAGES_FETCHER, NULL);
+}
+
+const gchar *
+gtr_languages_fetcher_get_language_name (GtrLanguagesFetcher *fetcher)
+{
+ g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))));
+}
+
+void
+gtr_languages_fetcher_set_language_name (GtrLanguagesFetcher *fetcher,
+ const gchar *name)
+{
+ g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
+ g_return_if_fail (name != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))), name);
+}
+
+const gchar *
+gtr_languages_fetcher_get_language_code (GtrLanguagesFetcher *fetcher)
+{
+ g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))));
+}
+
+void
+gtr_languages_fetcher_set_language_code (GtrLanguagesFetcher *fetcher,
+ const gchar *code)
+{
+ g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
+ g_return_if_fail (code != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))), code);
+}
+
+const gchar *
+gtr_languages_fetcher_get_charset (GtrLanguagesFetcher *fetcher)
+{
+ g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->charset))));
+}
+
+void
+gtr_languages_fetcher_set_charset (GtrLanguagesFetcher *fetcher,
+ const gchar *charset)
+{
+ g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
+ g_return_if_fail (charset != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->charset))), charset);
+}
+
+const gchar *
+gtr_languages_fetcher_get_encoding (GtrLanguagesFetcher *fetcher)
+{
+ g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->encoding))));
+}
+
+void
+gtr_languages_fetcher_set_encoding (GtrLanguagesFetcher *fetcher,
+ const gchar *enc)
+{
+ g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
+ g_return_if_fail (enc != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->encoding))), enc);
+}
+
+const gchar *
+gtr_languages_fetcher_get_team_email (GtrLanguagesFetcher *fetcher)
+{
+ g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (fetcher->priv->team_email));
+}
+
+void
+gtr_languages_fetcher_set_team_email (GtrLanguagesFetcher *fetcher,
+ const gchar *email)
+{
+ g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
+ g_return_if_fail (email != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (fetcher->priv->team_email), email);
+}
+
+const gchar *
+gtr_languages_fetcher_get_plural_form (GtrLanguagesFetcher *fetcher)
+{
+ g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))));
+}
+
+void
+gtr_languages_fetcher_set_plural_form (GtrLanguagesFetcher *fetcher,
+ const gchar *plural_form)
+{
+ g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
+ g_return_if_fail (plural_form != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))), plural_form);
+}
diff --git a/src/dialogs/gtr-languages-fetcher.h b/src/dialogs/gtr-languages-fetcher.h
new file mode 100644
index 0000000..88de267
--- /dev/null
+++ b/src/dialogs/gtr-languages-fetcher.h
@@ -0,0 +1,90 @@
+/*
+ * gtr-languages-fetcher.h
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * 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_LANGUAGES_FETCHER_H__
+#define __GTR_LANGUAGES_FETCHER_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_LANGUAGES_FETCHER (gtr_languages_fetcher_get_type ())
+#define GTR_LANGUAGES_FETCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_LANGUAGES_FETCHER, GtrLanguagesFetcher))
+#define GTR_LANGUAGES_FETCHER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_LANGUAGES_FETCHER, GtrLanguagesFetcher const))
+#define GTR_LANGUAGES_FETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_LANGUAGES_FETCHER, GtrLanguagesFetcherClass))
+#define GTR_IS_LANGUAGES_FETCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_LANGUAGES_FETCHER))
+#define GTR_IS_LANGUAGES_FETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_LANGUAGES_FETCHER))
+#define GTR_LANGUAGES_FETCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_LANGUAGES_FETCHER, GtrLanguagesFetcherClass))
+
+typedef struct _GtrLanguagesFetcher GtrLanguagesFetcher;
+typedef struct _GtrLanguagesFetcherClass GtrLanguagesFetcherClass;
+typedef struct _GtrLanguagesFetcherPrivate GtrLanguagesFetcherPrivate;
+
+struct _GtrLanguagesFetcher
+{
+ GtkBox parent;
+
+ GtrLanguagesFetcherPrivate *priv;
+};
+
+struct _GtrLanguagesFetcherClass
+{
+ GtkBoxClass parent_class;
+
+ void (* changed) (GtrLanguagesFetcher *fetcher);
+};
+
+GType gtr_languages_fetcher_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gtr_languages_fetcher_new (void);
+
+const gchar *gtr_languages_fetcher_get_language_name (GtrLanguagesFetcher *fetcher);
+
+void gtr_languages_fetcher_set_language_name (GtrLanguagesFetcher *fetcher,
+ const gchar *name);
+
+const gchar *gtr_languages_fetcher_get_language_code (GtrLanguagesFetcher *fetcher);
+
+void gtr_languages_fetcher_set_language_code (GtrLanguagesFetcher *fetcher,
+ const gchar *code);
+
+const gchar *gtr_languages_fetcher_get_charset (GtrLanguagesFetcher *fetcher);
+
+void gtr_languages_fetcher_set_charset (GtrLanguagesFetcher *fetcher,
+ const gchar *charset);
+
+const gchar *gtr_languages_fetcher_get_encoding (GtrLanguagesFetcher *fetcher);
+
+void gtr_languages_fetcher_set_encoding (GtrLanguagesFetcher *fetcher,
+ const gchar *enc);
+
+const gchar *gtr_languages_fetcher_get_team_email (GtrLanguagesFetcher *fetcher);
+
+void gtr_languages_fetcher_set_team_email (GtrLanguagesFetcher *fetcher,
+ const gchar *email);
+
+const gchar *gtr_languages_fetcher_get_plural_form (GtrLanguagesFetcher *fetcher);
+
+void gtr_languages_fetcher_set_plural_form (GtrLanguagesFetcher *fetcher,
+ const gchar *plural_form);
+
+G_END_DECLS
+
+#endif /* __GTR_LANGUAGES_FETCHER_H__ */
diff --git a/src/dialogs/gtr-languages-fetcher.ui b/src/dialogs/gtr-languages-fetcher.ui
new file mode 100644
index 0000000..476f3be
--- /dev/null
+++ b/src/dialogs/gtr-languages-fetcher.ui
@@ -0,0 +1,252 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkListStore" id="code_store">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name language -->
+ <column type="gpointer"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="language_store">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name language -->
+ <column type="gpointer"/>
+ </columns>
+ </object>
+ <object class="GtkWindow" id="languages-fetcher">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="main_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkTable" id="table4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Team email:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label14">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Transfer en_coding:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Character _set</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Language _code:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Language:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="team_email">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="invisible_char">â</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="charset">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <property name="entry_text_column">0</property>
+ <property name="id_column">1</property>
+ <items>
+ <item>UTF-8</item>
+ </items>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxentry-entry">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="encoding">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <property name="entry_text_column">0</property>
+ <items>
+ <item>8bit</item>
+ </items>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxentry-entry1">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="language">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">language_store</property>
+ <property name="has_entry">True</property>
+ <property name="entry_text_column">0</property>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxentry-entry2">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="language_code">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">code_store</property>
+ <property name="has_entry">True</property>
+ <property name="entry_text_column">0</property>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxentry-entry3">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Plural forms:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="plural_forms">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <property name="entry_text_column">0</property>
+ <property name="id_column">1</property>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxentry-entry4">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/dialogs/gtr-preferences-dialog.c b/src/dialogs/gtr-preferences-dialog.c
new file mode 100644
index 0000000..c44e823
--- /dev/null
+++ b/src/dialogs/gtr-preferences-dialog.c
@@ -0,0 +1,782 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ * 2008 Pablo Sanxiao <psanxiao gmail com>
+ * Igalia
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Pablo Sanxiao <psanxiao gmail com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-application.h"
+#include "gtr-dirs.h"
+#include "gtr-preferences-dialog.h"
+#include "gtr-settings.h"
+#include "gtr-profile.h"
+#include "gtr-profile-manager.h"
+#include "gtr-utils.h"
+#include "gtr-profile-dialog.h"
+#include "gtr-po.h"
+#include "gtr-utils.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <string.h>
+#include <gtksourceview/gtksourcestyleschememanager.h>
+#include <gdl/gdl.h>
+#include <libpeas-gtk/peas-gtk-plugin-manager.h>
+
+#define GTR_PREFERENCES_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_PREFERENCES_DIALOG, \
+ GtrPreferencesDialogPrivate))
+
+
+G_DEFINE_TYPE (GtrPreferencesDialog, gtr_preferences_dialog, GTK_TYPE_DIALOG)
+
+struct _GtrPreferencesDialogPrivate
+{
+ GSettings *ui_settings;
+ GSettings *editor_settings;
+ GSettings *files_settings;
+
+ GtkWidget *notebook;
+
+ /* Files->General */
+ GtkWidget *warn_if_contains_fuzzy_checkbutton;
+
+ /* Files->Autosave */
+ GtkWidget *autosave_checkbutton;
+ GtkWidget *autosave_interval_spinbutton;
+ GtkWidget *autosave_hbox;
+ GtkWidget *create_backup_checkbutton;
+
+ /* Editor->Text display */
+ GtkWidget *highlight_syntax_checkbutton;
+ GtkWidget *visible_whitespace_checkbutton;
+ GtkWidget *use_custom_font_checkbutton;
+ GtkWidget *editor_font_fontbutton;
+ GtkWidget *editor_font_hbox;
+
+ /* Editor->Contents */
+ GtkWidget *unmark_fuzzy_when_changed_checkbutton;
+ GtkWidget *spellcheck_checkbutton;
+
+ /*Profiles */
+ GtkWidget *profile_treeview;
+ GtkWidget *add_button;
+ GtkWidget *edit_button;
+ GtkWidget *delete_button;
+
+ /*Plugins */
+ GtkWidget *plugins_box;
+};
+
+enum
+{
+ PROFILE_NAME_COLUMN,
+ ACTIVE_PROFILE_COLUMN,
+ PROFILE_COLUMN,
+ PROFILE_N_COLUMNS
+};
+
+/***************Files pages****************/
+
+static void
+setup_files_general_page (GtrPreferencesDialog * dlg)
+{
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_WARN_IF_CONTAINS_FUZZY,
+ dlg->priv->warn_if_contains_fuzzy_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+}
+
+static void
+on_auto_save_changed (GSettings *settings,
+ const gchar *key,
+ GtrPreferencesDialog *dlg)
+{
+ gtk_widget_set_sensitive (dlg->priv->autosave_interval_spinbutton,
+ g_settings_get_boolean (settings, key));
+}
+
+static void
+setup_files_autosave_page (GtrPreferencesDialog * dlg)
+{
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE_INTERVAL,
+ dlg->priv->autosave_interval_spinbutton,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE,
+ dlg->priv->autosave_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_signal_connect (dlg->priv->files_settings,
+ "changed::" GTR_SETTINGS_AUTO_SAVE,
+ G_CALLBACK (on_auto_save_changed),
+ dlg);
+ /*Set sensitive */
+ on_auto_save_changed (dlg->priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE,
+ dlg);
+
+ g_settings_bind (dlg->priv->files_settings,
+ GTR_SETTINGS_CREATE_BACKUP,
+ dlg->priv->create_backup_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+}
+
+static void
+setup_files_pages (GtrPreferencesDialog * dlg)
+{
+ /*Children */
+ setup_files_general_page (dlg);
+ setup_files_autosave_page (dlg);
+}
+
+
+/***************Editor pages****************/
+
+static void
+use_custom_font_changed (GSettings *settings,
+ const gchar *key,
+ GtrPreferencesDialog *dlg)
+{
+ gtk_widget_set_sensitive (dlg->priv->editor_font_hbox,
+ g_settings_get_boolean (settings, key));
+}
+
+static void
+setup_editor_text_display_page (GtrPreferencesDialog * dlg)
+{
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_HIGHLIGHT_SYNTAX,
+ dlg->priv->highlight_syntax_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_VISIBLE_WHITESPACE,
+ dlg->priv->visible_whitespace_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_USE_CUSTOM_FONT,
+ dlg->priv->use_custom_font_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_signal_connect (dlg->priv->editor_settings,
+ "changed::" GTR_SETTINGS_USE_CUSTOM_FONT,
+ G_CALLBACK (use_custom_font_changed), dlg);
+ /*Set sensitive */
+ use_custom_font_changed (dlg->priv->editor_settings,
+ GTR_SETTINGS_USE_CUSTOM_FONT,
+ dlg);
+
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_EDITOR_FONT,
+ dlg->priv->editor_font_fontbutton,
+ "font-name",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+}
+
+static void
+setup_editor_contents (GtrPreferencesDialog * dlg)
+{
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED,
+ dlg->priv->unmark_fuzzy_when_changed_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (dlg->priv->editor_settings,
+ GTR_SETTINGS_SPELLCHECK,
+ dlg->priv->spellcheck_checkbutton,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+}
+
+static void
+setup_editor_pages (GtrPreferencesDialog * dlg)
+{
+ /*Children */
+ setup_editor_text_display_page (dlg);
+ setup_editor_contents (dlg);
+}
+
+/***************Profile pages****************/
+static void
+on_profile_dialog_response_cb (GtrProfileDialog *profile_dialog,
+ gint response_id,
+ GtrPreferencesDialog *dlg)
+{
+ GtrProfileManager *prof_manager;
+ GtkTreeModel *model;
+ GtrProfile *profile;
+ GtrProfile *active_profile;
+ GtkTreeIter iter;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ g_return_if_fail (model != NULL);
+
+ prof_manager = gtr_profile_manager_get_default ();
+ profile = gtr_profile_dialog_get_profile (profile_dialog);
+
+ /* add new profile */
+ if (response_id == GTK_RESPONSE_ACCEPT)
+ {
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtr_profile_manager_add_profile (prof_manager, profile);
+
+ active_profile = gtr_profile_manager_get_active_profile (prof_manager);
+
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ PROFILE_NAME_COLUMN, gtr_profile_get_name (profile),
+ ACTIVE_PROFILE_COLUMN, (profile == active_profile),
+ PROFILE_COLUMN, profile,
+ -1);
+ }
+ /* modify profile */
+ else if (response_id == GTK_RESPONSE_YES)
+ {
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ GtrProfile *old;
+
+ gtk_tree_model_get (model, &iter,
+ PROFILE_COLUMN, &old,
+ -1);
+
+ gtr_profile_manager_modify_profile (prof_manager, old, profile);
+ active_profile = gtr_profile_manager_get_active_profile (prof_manager);
+
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ PROFILE_NAME_COLUMN, gtr_profile_get_name (profile),
+ ACTIVE_PROFILE_COLUMN, (profile == active_profile),
+ PROFILE_COLUMN, profile,
+ -1);
+ }
+ }
+
+ g_object_unref (prof_manager);
+ gtk_widget_destroy (GTK_WIDGET (profile_dialog));
+}
+
+static void
+add_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
+{
+ GtrProfileDialog *profile_dialog;
+
+ profile_dialog = gtr_profile_dialog_new (GTK_WIDGET (dlg), NULL);
+
+ g_signal_connect (profile_dialog, "response",
+ G_CALLBACK (on_profile_dialog_response_cb), dlg);
+
+ gtk_widget_show (GTK_WIDGET (profile_dialog));
+ gtk_window_present (GTK_WINDOW (profile_dialog));
+}
+
+static void
+edit_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtrProfile *profile;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ g_return_if_fail (model != NULL);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ GtrProfileDialog *profile_dialog;
+
+ gtk_tree_model_get (model, &iter, PROFILE_COLUMN, &profile, -1);
+
+ profile_dialog = gtr_profile_dialog_new (GTK_WIDGET (dlg), profile);
+
+ g_signal_connect (profile_dialog, "response",
+ G_CALLBACK (on_profile_dialog_response_cb), dlg);
+
+ gtk_widget_show (GTK_WIDGET (profile_dialog));
+ gtk_window_present (GTK_WINDOW (profile_dialog));
+ }
+}
+
+static void
+delete_confirm_dialog_cb (GtkWidget *dialog,
+ gint response_id, GtrPreferencesDialog *dlg)
+{
+ if (response_id == GTK_RESPONSE_YES)
+ {
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ g_return_if_fail (model != NULL);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ GtrProfileManager *prof_manager;
+ GtrProfile *profile;
+
+ gtk_tree_model_get (model, &iter, PROFILE_COLUMN, &profile,
+ -1);
+
+ if (profile != NULL)
+ {
+ prof_manager = gtr_profile_manager_get_default ();
+ gtr_profile_manager_remove_profile (prof_manager, profile);
+ g_object_unref (prof_manager);
+
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ }
+ }
+ }
+
+ gtk_widget_destroy (dialog);
+}
+
+static void
+delete_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ gboolean active;
+ GtkWidget *dialog;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ g_return_if_fail (model != NULL);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ gtk_tree_model_get (model, &iter, ACTIVE_PROFILE_COLUMN, &active, -1);
+
+ if (active)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _("<span weight=\"bold\" size=\"large\">Impossible to remove the active profile</span>"));
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG
+ (dialog),
+ _("Another profile should be selected as active before"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _("<span weight=\"bold\" size=\"large\">Are you sure you want to delete this profile?</span>"));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_DELETE, GTK_RESPONSE_YES);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ g_signal_connect (GTK_DIALOG (dialog), "response",
+ G_CALLBACK (delete_confirm_dialog_cb), dlg);
+ }
+ }
+}
+
+static void
+active_toggled_cb (GtkCellRendererToggle *cell_renderer,
+ gchar *path_str, GtrPreferencesDialog *dlg)
+{
+ GtkTreeIter iter, first;
+ GtkTreePath *path;
+ GtkTreeModel *model;
+ GtrProfile *active_profile;
+
+ path = gtk_tree_path_new_from_string (path_str);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ g_return_if_fail (model != NULL);
+
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ gtk_tree_model_get (model, &iter, PROFILE_COLUMN, &active_profile, -1);
+
+ if (active_profile != NULL)
+ {
+ GtrProfileManager *prof_manager;
+
+ prof_manager = gtr_profile_manager_get_default ();
+
+ if (gtr_profile_manager_get_active_profile (prof_manager) != active_profile)
+ {
+ gtr_profile_manager_set_active_profile (prof_manager, active_profile);
+
+ gtk_tree_model_get_iter_first (model, &first);
+
+ do
+ {
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &first,
+ ACTIVE_PROFILE_COLUMN, FALSE,
+ -1);
+ } while (gtk_tree_model_iter_next (model, &first));
+
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ ACTIVE_PROFILE_COLUMN, TRUE,
+ -1);
+ }
+
+ g_object_unref (prof_manager);
+ }
+
+ gtk_tree_path_free (path);
+}
+
+static void
+fill_profile_treeview (GtrPreferencesDialog *dlg, GtkTreeModel *model)
+{
+ GtrProfileManager *prof_manager;
+ GtkTreeIter iter;
+ GtrProfile *active_profile;
+ GSList *l, *profiles;
+
+ gtk_list_store_clear (GTK_LIST_STORE (model));
+
+ prof_manager = gtr_profile_manager_get_default ();
+ profiles = gtr_profile_manager_get_profiles (prof_manager);
+ active_profile = gtr_profile_manager_get_active_profile (prof_manager);
+
+ for (l = profiles; l != NULL; l = g_slist_next (l))
+ {
+ GtrProfile *profile = GTR_PROFILE (l->data);
+ const gchar *profile_name;
+
+ profile_name = gtr_profile_get_name (profile);
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ PROFILE_NAME_COLUMN, profile_name,
+ ACTIVE_PROFILE_COLUMN, (profile == active_profile),
+ PROFILE_COLUMN, profile,
+ -1);
+ }
+
+ g_object_unref (prof_manager);
+}
+
+static void
+setup_profile_pages (GtrPreferencesDialog *dlg)
+{
+
+ GtkTreeViewColumn *name_column, *toggle_column;
+ GtkCellRenderer *text_renderer, *toggle_renderer;
+ GtkListStore *model;
+
+ model = gtk_list_store_new (PROFILE_N_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ G_TYPE_POINTER);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->profile_treeview),
+ GTK_TREE_MODEL (model));
+
+ g_object_unref (model);
+
+ text_renderer = gtk_cell_renderer_text_new ();
+ toggle_renderer = gtk_cell_renderer_toggle_new ();
+
+ g_signal_connect (toggle_renderer,
+ "toggled", G_CALLBACK (active_toggled_cb), dlg);
+
+ gtk_cell_renderer_toggle_set_activatable (GTK_CELL_RENDERER_TOGGLE (toggle_renderer),
+ TRUE);
+ gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE (toggle_renderer),
+ TRUE);
+
+ name_column = gtk_tree_view_column_new_with_attributes (_("Profile"),
+ text_renderer,
+ "text",
+ PROFILE_NAME_COLUMN,
+ NULL);
+
+ toggle_column = gtk_tree_view_column_new_with_attributes (_("Active"),
+ toggle_renderer,
+ "active",
+ ACTIVE_PROFILE_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_resizable (toggle_column, TRUE);
+ gtk_tree_view_column_set_resizable (name_column, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->profile_treeview),
+ name_column);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->profile_treeview),
+ toggle_column);
+
+ gtk_tree_view_column_set_expand (name_column, TRUE);
+
+ fill_profile_treeview (dlg, GTK_TREE_MODEL (model));
+
+ /* Connect the signals */
+ g_signal_connect (dlg->priv->add_button,
+ "clicked", G_CALLBACK (add_button_clicked), dlg);
+
+ g_signal_connect (dlg->priv->delete_button,
+ "clicked", G_CALLBACK (delete_button_clicked), dlg);
+
+ g_signal_connect (dlg->priv->edit_button,
+ "clicked", G_CALLBACK (edit_button_clicked), dlg);
+}
+
+/***************Plugins pages****************/
+static void
+setup_plugin_pages (GtrPreferencesDialog * dlg)
+{
+ GtkWidget *alignment;
+ GtkWidget *page_content;
+
+ alignment = gtk_alignment_new (0., 0., 1., 1.);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
+
+ page_content = peas_gtk_plugin_manager_new (NULL);
+ g_return_if_fail (page_content != NULL);
+
+ gtk_container_add (GTK_CONTAINER (alignment), page_content);
+
+ gtk_box_pack_start (GTK_BOX (dlg->priv->plugins_box),
+ alignment, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (page_content);
+}
+
+
+static void
+dialog_response_handler (GtkDialog * dlg, gint res_id)
+{
+ switch (res_id)
+ {
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ }
+}
+
+static void
+gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
+{
+ gboolean ret;
+ GtkWidget *error_widget, *action_area;
+ GtkWidget *profiles_toolbar;
+ GtkWidget *profiles_scrolled_window;
+ GtkBox *content_area;
+ GtkStyleContext *context;
+ gchar *root_objects[] = {
+ "notebook",
+ "adjustment1",
+ "adjustment2",
+ "adjustment3",
+ "model1",
+ NULL
+ };
+ gchar *path;
+
+ dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (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->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Preferences"));
+ 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_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (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 (dialog_response_handler), NULL);
+
+ /*Glade */
+
+ path = gtr_dirs_get_ui_file ("gtr-preferences-dialog.ui");
+ ret = gtr_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "notebook", &dlg->priv->notebook,
+ "warn_if_fuzzy_checkbutton",
+ &dlg->
+ priv->warn_if_contains_fuzzy_checkbutton,
+ "autosave_checkbutton",
+ &dlg->priv->autosave_checkbutton,
+ "autosave_interval_spinbutton",
+ &dlg->priv->autosave_interval_spinbutton,
+ "autosave_hbox", &dlg->priv->autosave_hbox,
+ "create_backup_checkbutton",
+ &dlg->priv->create_backup_checkbutton,
+ "highlight_checkbutton",
+ &dlg->priv->highlight_syntax_checkbutton,
+ "visible_whitespace_checkbutton",
+ &dlg->priv->visible_whitespace_checkbutton,
+ "use_custom_font_checkbutton",
+ &dlg->priv->use_custom_font_checkbutton,
+ "editor_font_fontbutton",
+ &dlg->priv->editor_font_fontbutton,
+ "editor_font_hbox",
+ &dlg->priv->editor_font_hbox,
+ "unmark_fuzzy_checkbutton",
+ &dlg->
+ priv->unmark_fuzzy_when_changed_checkbutton,
+ "spellcheck_checkbutton",
+ &dlg->priv->spellcheck_checkbutton,
+ "profile_treeview",
+ &dlg->priv->profile_treeview, "add-button",
+ &dlg->priv->add_button, "edit-button",
+ &dlg->priv->edit_button, "delete-button",
+ &dlg->priv->delete_button,
+ "profiles-toolbar", &profiles_toolbar,
+ "profiles-scrolledwindow", &profiles_scrolled_window,
+ "plugins_box", &dlg->priv->plugins_box,
+ NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (content_area, dlg->priv->notebook, FALSE, FALSE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
+
+ context = gtk_widget_get_style_context (profiles_scrolled_window);
+ gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
+
+ context = gtk_widget_get_style_context (profiles_toolbar);
+ gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+
+ setup_files_pages (dlg);
+ setup_editor_pages (dlg);
+ setup_profile_pages (dlg);
+ setup_plugin_pages (dlg);
+}
+
+static void
+gtr_preferences_dialog_dispose (GObject * object)
+{
+ GtrPreferencesDialog *dlg = GTR_PREFERENCES_DIALOG (object);
+
+ if (dlg->priv->ui_settings != NULL)
+ {
+ g_object_unref (dlg->priv->ui_settings);
+ dlg->priv->ui_settings = NULL;
+ }
+
+ if (dlg->priv->editor_settings != NULL)
+ {
+ g_object_unref (dlg->priv->editor_settings);
+ dlg->priv->editor_settings = NULL;
+ }
+
+ if (dlg->priv->files_settings != NULL)
+ {
+ g_object_unref (dlg->priv->files_settings);
+ dlg->priv->files_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_preferences_dialog_parent_class)->dispose (object);
+}
+
+static void
+gtr_preferences_dialog_class_init (GtrPreferencesDialogClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtrPreferencesDialogPrivate));
+
+ object_class->dispose = gtr_preferences_dialog_dispose;
+}
+
+void
+gtr_show_preferences_dialog (GtrWindow * window)
+{
+ static GtkWidget *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ dlg = GTK_WIDGET (g_object_new (GTR_TYPE_PREFERENCES_DIALOG, NULL));
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+ gtk_widget_show_all (dlg);
+ }
+
+ if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
+ }
+
+ gtk_window_present (GTK_WINDOW (dlg));
+}
diff --git a/src/dialogs/gtr-preferences-dialog.h b/src/dialogs/gtr-preferences-dialog.h
new file mode 100644
index 0000000..edbccec
--- /dev/null
+++ b/src/dialogs/gtr-preferences-dialog.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007 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 __PREFERENCES_DIALOG_H__
+#define __PREFERENCES_DIALOG_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtr-window.h"
+
+G_BEGIN_DECLS
+
+/* Type checking and casting macros */
+#define GTR_TYPE_PREFERENCES_DIALOG (gtr_preferences_dialog_get_type ())
+#define GTR_PREFERENCES_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_PREFERENCES_DIALOG, GtrPreferencesDialog))
+#define GTR_PREFERENCES_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_PREFERENCES_DIALOG, GtrPreferencesDialogClass))
+#define GTR_IS_PREFERENCES_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_PREFERENCES_DIALOG))
+#define GTR_IS_PREFERENCES_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PREFERENCES_DIALOG))
+#define GTR_PREFERENCES_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PREFERENCES_DIALOG, GtrPreferencesDialogClass))
+
+/* Private structure type */
+typedef struct _GtrPreferencesDialogPrivate GtrPreferencesDialogPrivate;
+
+/* Main object structure */
+typedef struct _GtrPreferencesDialog GtrPreferencesDialog;
+
+struct _GtrPreferencesDialog
+{
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtrPreferencesDialogPrivate *priv;
+};
+
+/* Class definition */
+typedef struct _GtrPreferencesDialogClass GtrPreferencesDialogClass;
+
+struct _GtrPreferencesDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+/* Public methods */
+GType gtr_preferences_dialog_get_type (void)G_GNUC_CONST;
+
+void gtr_show_preferences_dialog (GtrWindow *window);
+
+G_END_DECLS
+
+#endif /* __PREFERENCES_DIALOG_H__ */
diff --git a/src/dialogs/gtr-preferences-dialog.ui b/src/dialogs/gtr-preferences-dialog.ui
new file mode 100644
index 0000000..f44a732
--- /dev/null
+++ b/src/dialogs/gtr-preferences-dialog.ui
@@ -0,0 +1,751 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="lower">1</property>
+ <property name="upper">30</property>
+ <property name="value">4</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="value">2</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="upper">100</property>
+ <property name="value">2</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkListStore" id="model1">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0">Text</col>
+ </row>
+ <row>
+ <col id="0">Icons</col>
+ </row>
+ <row>
+ <col id="0">Text + Icons</col>
+ </row>
+ <row>
+ <col id="0">Gnome toolbar setting</col>
+ </row>
+ <row>
+ <col id="0">Tabs</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkDialog" id="preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Gtranslator Preferences</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="help_button">
+ <property name="label">gtk-help</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <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">False</property>
+ <property name="position">1</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="GtkNotebook" id="notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vexpand">True</property>
+ <property name="border_width">6</property>
+ <child>
+ <object class="GtkBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <property name="border_width">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="vbox2">
+ <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="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">General</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="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="warn_if_fuzzy_checkbutton">
+ <property name="label" translatable="yes">_Warn if PO file contains fuzzy translations</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</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="vbox6">
+ <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="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Autosave</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="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="autosave_checkbutton">
+ <property name="label" translatable="yes">_Autosave files every</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</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="autosave_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkSpinButton" id="autosave_interval_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="adjustment">adjustment1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_minutes</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">autosave_interval_spinbutton</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">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="create_backup_checkbutton">
+ <property name="label" translatable="yes">Create a _backup copy of files before saving</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</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>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Files</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox16">
+ <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">6</property>
+ <child>
+ <object class="GtkBox" id="vbox17">
+ <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="label16">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Text Display</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="alignment4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="highlight_checkbutton">
+ <property name="label" translatable="yes">_Highlight message syntax</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="visible_whitespace_checkbutton">
+ <property name="label" translatable="yes">Make _whitespace visible</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="use_custom_font_checkbutton">
+ <property name="label" translatable="yes">Use _custom font</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="editor_font_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="editor_font_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Editor _font:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">editor_font_fontbutton</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFontButton" id="editor_font_fontbutton">
+ <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="font">Sans 12</property>
+ <property name="preview_text"></property>
+ <property name="show_preview_entry">False</property>
+ <property name="use_font">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </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">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox19">
+ <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="label18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Contents</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="alignment5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox20">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="unmark_fuzzy_checkbutton">
+ <property name="label" translatable="yes">_Remove fuzzy status if message is changed</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="spellcheck_checkbutton">
+ <property name="label" translatable="yes">Check _spelling</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </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">True</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">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Editor</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">12</property>
+ <property name="bottom_padding">12</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkScrolledWindow" id="profiles-scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="profile_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection"/>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolbar" id="profiles-toolbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="toolbar_style">icons</property>
+ <property name="icon_size">1</property>
+ <style>
+ <class name="inline-toolbar"/>
+ </style>
+ <child>
+ <object class="GtkToolItem" id="toolbutton1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton" id="add-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">list-add-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="delete-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">list-remove-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="edit-button">
+ <property name="label" translatable="yes">Edit Profile</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">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Profiles</property>
+ </object>
+ <packing>
+ <property name="position">2</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>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <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">3</property>
+ <property name="tab_fill">False</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">help_button</action-widget>
+ <action-widget response="0">close_button</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/src/dialogs/gtr-profile-dialog.c b/src/dialogs/gtr-profile-dialog.c
new file mode 100644
index 0000000..c24195e
--- /dev/null
+++ b/src/dialogs/gtr-profile-dialog.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2007 Pablo Sanxiao <psanxiao gmail com>
+ * 2008 Igalia
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Pablo Sanxiao <psanxiao gmail com>
+ * Ignacio Casal Quinteiro <icq gnome org>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-dirs.h"
+#include "gtr-profile-dialog.h"
+#include "gtr-profile.h"
+#include "gtr-utils.h"
+#include "gtr-languages-fetcher.h"
+
+#include <string.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#define GTR_PROFILE_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_PROFILE_DIALOG, \
+ GtrProfileDialogPrivate))
+
+G_DEFINE_TYPE (GtrProfileDialog, gtr_profile_dialog, GTK_TYPE_DIALOG)
+
+struct _GtrProfileDialogPrivate
+{
+ GtkWidget *main_box;
+
+ GtkWidget *profile_name;
+
+ GtkWidget *author_name;
+ GtkWidget *author_email;
+
+ GtkWidget *languages_fetcher;
+};
+
+static void
+gtr_profile_dialog_class_init (GtrProfileDialogClass *klass)
+{
+ g_type_class_add_private (klass, sizeof (GtrProfileDialogPrivate));
+}
+
+static void
+gtr_profile_dialog_init (GtrProfileDialog *dlg)
+{
+ gboolean ret;
+ GtkWidget *error_widget, *action_area;
+ GtkBox *content_area;
+ GtkWidget *fetcher_box;
+ gchar *path;
+ gchar *root_objects[] = {
+ "main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_PROFILE_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Profile"));
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+ gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
+
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
+ content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (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);
+
+ path = gtr_dirs_get_ui_file ("gtr-profile-dialog.ui");
+ ret = gtr_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "main_box", &dlg->priv->main_box,
+ "profile_name", &dlg->priv->profile_name,
+ "name", &dlg->priv->author_name,
+ "email", &dlg->priv->author_email,
+ "fetcher_box", &fetcher_box,
+ NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (content_area, dlg->priv->main_box, FALSE, FALSE, 0);
+
+ dlg->priv->languages_fetcher = gtr_languages_fetcher_new ();
+ gtk_widget_show (dlg->priv->languages_fetcher);
+ gtk_box_pack_start (GTK_BOX (fetcher_box), dlg->priv->languages_fetcher,
+ TRUE, TRUE, 0);
+}
+
+static void
+fill_entries (GtrProfileDialog *dlg, GtrProfile *profile)
+{
+ if (gtr_profile_get_name (profile) != NULL)
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->profile_name),
+ gtr_profile_get_name (profile));
+
+ if (gtr_profile_get_author_name (profile) != NULL)
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->author_name),
+ gtr_profile_get_author_name (profile));
+
+ if (gtr_profile_get_author_email (profile) != NULL)
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->author_email),
+ gtr_profile_get_author_email (profile));
+
+ if (gtr_profile_get_language_name (profile) != NULL)
+ gtr_languages_fetcher_set_language_name (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_profile_get_language_name (profile));
+
+ if (gtr_profile_get_language_code (profile) != NULL)
+ gtr_languages_fetcher_set_language_code (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_profile_get_language_code (profile));
+
+ if (gtr_profile_get_charset (profile) != NULL)
+ gtr_languages_fetcher_set_charset (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_profile_get_charset (profile));
+
+ if (gtr_profile_get_encoding (profile) != NULL)
+ gtr_languages_fetcher_set_encoding (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_profile_get_encoding (profile));
+
+ if (gtr_profile_get_group_email (profile) != NULL)
+ gtr_languages_fetcher_set_team_email (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_profile_get_group_email (profile));
+
+ if (gtr_profile_get_plural_forms (profile) != NULL)
+ gtr_languages_fetcher_set_plural_form (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_profile_get_plural_forms (profile));
+}
+
+GtrProfileDialog *
+gtr_profile_dialog_new (GtkWidget *parent,
+ GtrProfile *profile)
+{
+ GtrProfileDialog *dlg;
+
+ dlg = g_object_new (GTR_TYPE_PROFILE_DIALOG, NULL);
+
+ if (profile != NULL)
+ {
+ fill_entries (dlg, profile);
+
+ /* We distinguish in the preferences dialog if we are modifying
+ or adding a new profile depending on the response */
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ GTK_STOCK_OK, GTK_RESPONSE_YES);
+ }
+ else
+ {
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+ }
+
+ if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent));
+ }
+
+ return dlg;
+}
+
+GtrProfile *
+gtr_profile_dialog_get_profile (GtrProfileDialog *dlg)
+{
+ GtrProfile *profile;
+
+ g_return_val_if_fail (GTR_IS_PROFILE_DIALOG (dlg), NULL);
+
+ profile = gtr_profile_new ();
+
+ gtr_profile_set_name (profile,
+ gtk_entry_get_text (GTK_ENTRY (dlg->priv->profile_name)));
+
+ gtr_profile_set_author_name (profile,
+ gtk_entry_get_text (GTK_ENTRY (dlg->priv->author_name)));
+
+ gtr_profile_set_author_email (profile,
+ gtk_entry_get_text (GTK_ENTRY (dlg->priv->author_email)));
+
+ gtr_profile_set_language_name (profile,
+ gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher)));
+
+ gtr_profile_set_language_code (profile,
+ gtr_languages_fetcher_get_language_code (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher)));
+
+ gtr_profile_set_charset (profile,
+ gtr_languages_fetcher_get_charset (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher)));
+
+ gtr_profile_set_encoding (profile,
+ gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher)));
+
+ gtr_profile_set_group_email (profile,
+ gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher)));
+
+ gtr_profile_set_plural_forms (profile,
+ gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher)));
+
+ return profile;
+}
diff --git a/src/dialogs/gtr-profile-dialog.h b/src/dialogs/gtr-profile-dialog.h
new file mode 100644
index 0000000..0b25ce6
--- /dev/null
+++ b/src/dialogs/gtr-profile-dialog.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2007 Pablo Sanxiao <psanxiao gmail com>
+ * 2008 Igalia
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Pablo Sanxiao <psanxiao gmail com>
+ */
+
+#ifndef __PROFILE_DIALOG_H__
+#define __PROFILE_DIALOG_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtr-profile.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_PROFILE_DIALOG (gtr_profile_dialog_get_type ())
+#define GTR_PROFILE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_PROFILE_DIALOG, GtrProfileDialog))
+#define GTR_PROFILE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_PROFILE_DIALOG, GtrProfileDialogClass))
+#define GTR_IS_PROFILE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_PROFILE_DIALOG))
+#define GTR_IS_PROFILE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PROFILE_DIALOG))
+#define GTR_PROFILE_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PROFILE_DIALOG, GtrProfileDialogClass))
+
+/* Private structure type */
+typedef struct _GtrProfileDialogPrivate GtrProfileDialogPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtrProfileDialog GtrProfileDialog;
+
+struct _GtrProfileDialog
+{
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtrProfileDialogPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtrProfileDialogClass GtrProfileDialogClass;
+
+struct _GtrProfileDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtr_profile_dialog_get_type (void) G_GNUC_CONST;
+
+GtrProfileDialog *gtr_profile_dialog_new (GtkWidget *parent,
+ GtrProfile *profile);
+
+GtrProfile *gtr_profile_dialog_get_profile (GtrProfileDialog *dlg);
+
+G_END_DECLS
+
+#endif
diff --git a/src/dialogs/gtr-profile-dialog.ui b/src/dialogs/gtr-profile-dialog.ui
new file mode 100644
index 0000000..e588cc9
--- /dev/null
+++ b/src/dialogs/gtr-profile-dialog.ui
@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <object class="GtkDialog" id="dialog1">
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</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="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="layout_style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </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="main_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Profile Information</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="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="profile_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="invisible_char">â</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Name:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">profile_name</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</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="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Translator Information</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="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="email">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="invisible_char">â</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Email:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">email</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">N_ame:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">name</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="invisible_char">â</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</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="GtkBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Language Settings</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="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="fetcher_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/dialogs/gtr-search-dialog.c b/src/dialogs/gtr-search-dialog.c
new file mode 100644
index 0000000..3e0077c
--- /dev/null
+++ b/src/dialogs/gtr-search-dialog.c
@@ -0,0 +1,752 @@
+/*
+ * gedit-search-dialog.c
+ * This file is part of gtranslator based on gedit
+ *
+ * Copyright (C) 2005 Paolo Maggi
+ * 2007 Ignacio Casal
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the gedit Team, 2005. See the AUTHORS file for a
+ * list of people on the gedit Team.
+ * See the ChangeLog files for a list of changes.
+ *
+ * $Id: gedit-search-dialog.c 5931 2007-09-25 20:05:40Z pborelli $
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <glib/gi18n.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "gtr-dirs.h"
+#include "gtr-search-dialog.h"
+#include "gtr-history-entry.h"
+#include "gtr-utils.h"
+#include "gtr-marshal.h"
+
+#define GTR_SEARCH_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ GTR_TYPE_SEARCH_DIALOG, \
+ GtrSearchDialogPrivate))
+
+/* Signals */
+enum
+{
+ SHOW_REPLACE,
+ LAST_SIGNAL
+};
+
+static guint dialog_signals[LAST_SIGNAL] = { 0 };
+
+struct _GtrSearchDialogPrivate
+{
+ gboolean show_replace;
+
+ GtkWidget *grid;
+ GtkWidget *search_label;
+ GtkWidget *search_entry;
+ GtkWidget *search_text_entry;
+ GtkWidget *replace_label;
+ GtkWidget *replace_entry;
+ GtkWidget *replace_text_entry;
+ GtkWidget *original_text_checkbutton;
+ GtkWidget *translated_text_checkbutton;
+ GtkWidget *fuzzy_checkbutton;
+ GtkWidget *match_case_checkbutton;
+ GtkWidget *entire_word_checkbutton;
+ GtkWidget *backwards_checkbutton;
+ GtkWidget *wrap_around_checkbutton;
+ GtkWidget *find_button;
+ GtkWidget *replace_button;
+ GtkWidget *replace_all_button;
+
+ gboolean glade_error;
+};
+
+G_DEFINE_TYPE (GtrSearchDialog, gtr_search_dialog, GTK_TYPE_DIALOG)
+ enum
+ {
+ PROP_0,
+ PROP_SHOW_REPLACE
+ };
+
+ static void
+ gtr_search_dialog_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
+ GtrSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_REPLACE:
+ gtr_search_dialog_set_show_replace (dlg, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtr_search_dialog_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GtrSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_REPLACE:
+ g_value_set_boolean (value, dlg->priv->show_replace);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+show_replace (GtrSearchDialog * dlg)
+{
+ gtr_search_dialog_set_show_replace (dlg, TRUE);
+
+ return TRUE;
+}
+
+static void
+gtr_search_dialog_class_init (GtrSearchDialogClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkBindingSet *binding_set;
+
+ object_class->set_property = gtr_search_dialog_set_property;
+ object_class->get_property = gtr_search_dialog_get_property;
+
+ klass->show_replace = show_replace;
+
+ dialog_signals[SHOW_REPLACE] =
+ g_signal_new ("show_replace",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtrSearchDialogClass,
+ show_replace), NULL, NULL,
+ gtr_marshal_BOOLEAN__NONE, G_TYPE_BOOLEAN, 0);
+
+ g_object_class_install_property (object_class, PROP_SHOW_REPLACE,
+ g_param_spec_boolean ("show-replace",
+ "Show Replace",
+ "Whether the dialog is used for Search&Replace",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class, sizeof (GtrSearchDialogPrivate));
+
+ binding_set = gtk_binding_set_by_class (klass);
+
+ /* Note: we cannot use the keyval/modifier associated with the
+ * GTK_STOCK_FIND_AND_REPLACE stock item since GNOME HIG suggests Ctrl+h
+ * for Replace while gtk+ uses Ctrl+r */
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_h, GDK_CONTROL_MASK,
+ "show_replace", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_H, GDK_CONTROL_MASK,
+ "show_replace", 0);
+}
+
+static void
+insert_text_handler (GtkEditable * editable,
+ const gchar * text,
+ gint length, gint * position, gpointer data)
+{
+ static gboolean insert_text = FALSE;
+ gchar *escaped_text;
+ gint new_len;
+
+ /* To avoid recursive behavior */
+ if (insert_text)
+ return;
+
+ escaped_text = gtr_utils_escape_search_text (text);
+
+ new_len = strlen (escaped_text);
+
+ if (new_len == length)
+ {
+ g_free (escaped_text);
+ return;
+ }
+
+ insert_text = TRUE;
+
+ g_signal_stop_emission_by_name (editable, "insert_text");
+
+ gtk_editable_insert_text (editable, escaped_text, new_len, position);
+
+ insert_text = FALSE;
+
+ g_free (escaped_text);
+}
+
+static void
+search_entry_changed (GtkComboBox * combo, GtrSearchDialog * dialog)
+{
+ GtkWidget *entry;
+ const gchar *search_string;
+
+ entry = gtk_bin_get_child (GTK_BIN (combo));
+ search_string = gtk_entry_get_text (GTK_ENTRY (entry));
+ g_return_if_fail (search_string != NULL);
+
+ if (*search_string != '\0')
+ {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE,
+ TRUE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ TRUE);
+ }
+ else
+ {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE,
+ FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ FALSE);
+ }
+}
+
+/*
+ * Function to manage the sensitive of fuzzy checkbutton.
+ */
+static void
+original_translated_checkbutton_toggled (GtkToggleButton * button,
+ GtrSearchDialog * dialog)
+{
+ gboolean original_text;
+ gboolean translated_text;
+
+ original_text =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->original_text_checkbutton));
+ translated_text =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->
+ priv->translated_text_checkbutton));
+
+ if (!original_text && !translated_text)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->fuzzy_checkbutton), FALSE);
+ gtk_widget_set_sensitive (dialog->priv->fuzzy_checkbutton, FALSE);
+ }
+ else
+ gtk_widget_set_sensitive (dialog->priv->fuzzy_checkbutton, TRUE);
+}
+
+static void
+response_handler (GtrSearchDialog * dialog, gint response_id, gpointer data)
+{
+ const gchar *str;
+
+ switch (response_id)
+ {
+ case GTR_SEARCH_DIALOG_REPLACE_RESPONSE:
+ case GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
+ str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
+ if (*str != '\0')
+ {
+ gchar *text;
+
+ text = gtr_utils_unescape_search_text (str);
+ gtr_history_entry_prepend_text
+ (GTR_HISTORY_ENTRY (dialog->priv->replace_entry), text);
+
+ g_free (text);
+ }
+ /* fall through, so that we also save the find entry */
+ case GTR_SEARCH_DIALOG_FIND_RESPONSE:
+ str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
+ if (*str != '\0')
+ {
+ gchar *text;
+
+ text = gtr_utils_unescape_search_text (str);
+ gtr_history_entry_prepend_text
+ (GTR_HISTORY_ENTRY (dialog->priv->search_entry), text);
+
+ g_free (text);
+ }
+ }
+}
+
+static void
+show_replace_widgets (GtrSearchDialog * dlg, gboolean show_replace)
+{
+ if (show_replace)
+ {
+ gtk_widget_hide (dlg->priv->original_text_checkbutton);
+ gtk_widget_hide (dlg->priv->translated_text_checkbutton);
+
+ /*
+ * Set the default value of checkbutton
+ */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->translated_text_checkbutton),
+ TRUE);
+
+ gtk_widget_show (dlg->priv->replace_label);
+ gtk_widget_show (dlg->priv->replace_entry);
+ gtk_widget_show (dlg->priv->replace_all_button);
+ gtk_widget_show (dlg->priv->replace_button);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Replace"));
+ }
+ else
+ {
+ gtk_widget_show (dlg->priv->original_text_checkbutton);
+ gtk_widget_show (dlg->priv->translated_text_checkbutton);
+
+ /*
+ * Set the default value of checkbuttons
+ */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->original_text_checkbutton),
+ TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->translated_text_checkbutton),
+ TRUE);
+
+ gtk_widget_hide (dlg->priv->replace_label);
+ gtk_widget_hide (dlg->priv->replace_entry);
+ gtk_widget_hide (dlg->priv->replace_all_button);
+ gtk_widget_hide (dlg->priv->replace_button);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Find"));
+ }
+
+ gtk_widget_show (dlg->priv->find_button);
+}
+
+static void
+gtr_search_dialog_init (GtrSearchDialog * dlg)
+{
+ GtkWidget *content;
+ GtkWidget *error_widget, *action_area;
+ GtkBox *content_area;
+ gboolean ret;
+ gchar *path;
+ gchar *root_objects[] = {
+ "search_dialog_content",
+ NULL
+ };
+
+ dlg->priv = GTR_SEARCH_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL);
+
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
+ content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (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), 6);
+
+ path = gtr_dirs_get_ui_file ("gtr-search-dialog.ui");
+ ret = gtr_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "search_dialog_content", &content,
+ "grid", &dlg->priv->grid,
+ "search_label",
+ &dlg->priv->search_label,
+ "replace_with_label",
+ &dlg->priv->replace_label,
+ "original_text_checkbutton",
+ &dlg->priv->original_text_checkbutton,
+ "translated_text_checkbutton",
+ &dlg->priv->translated_text_checkbutton,
+ "fuzzy_checkbutton",
+ &dlg->priv->fuzzy_checkbutton,
+ "match_case_checkbutton",
+ &dlg->priv->match_case_checkbutton,
+ "entire_word_checkbutton",
+ &dlg->priv->entire_word_checkbutton,
+ "search_backwards_checkbutton",
+ &dlg->priv->backwards_checkbutton,
+ "wrap_around_checkbutton",
+ &dlg->priv->wrap_around_checkbutton, NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+
+ gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (error_widget), 5);
+
+ dlg->priv->glade_error = TRUE;
+
+ return;
+ }
+
+ dlg->priv->search_entry = gtr_history_entry_new ("search-for-entry", TRUE);
+ gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
+ gtr_history_entry_set_escape_func
+ (GTR_HISTORY_ENTRY (dlg->priv->search_entry),
+ (GtrHistoryEntryEscapeFunc) gtr_utils_escape_search_text);
+ gtk_widget_set_hexpand (GTK_WIDGET (dlg->priv->search_entry), TRUE);
+
+ dlg->priv->search_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (dlg->priv->search_entry));
+ gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->search_text_entry), TRUE);
+ gtk_widget_show (dlg->priv->search_entry);
+ gtk_grid_attach_next_to (GTK_GRID (dlg->priv->grid),
+ dlg->priv->search_entry,
+ dlg->priv->search_label,
+ GTK_POS_RIGHT, 1, 1);
+
+ dlg->priv->replace_entry = gtr_history_entry_new ("replace-with-entry", TRUE);
+ gtr_history_entry_set_escape_func (GTR_HISTORY_ENTRY
+ (dlg->priv->replace_entry),
+ (GtrHistoryEntryEscapeFunc)
+ gtr_utils_escape_search_text);
+ gtk_widget_set_hexpand (GTK_WIDGET (dlg->priv->replace_entry), TRUE);
+
+ dlg->priv->replace_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (dlg->priv->replace_entry));
+ gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->replace_text_entry), TRUE);
+ gtk_widget_show (dlg->priv->replace_entry);
+ gtk_grid_attach_next_to (GTK_GRID (dlg->priv->grid),
+ dlg->priv->replace_entry,
+ dlg->priv->replace_label,
+ GTK_POS_RIGHT, 1, 1);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->search_label),
+ dlg->priv->search_entry);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->replace_label),
+ dlg->priv->replace_entry);
+
+ dlg->priv->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
+ dlg->priv->replace_all_button =
+ gtk_button_new_with_mnemonic (_("Replace _All"));
+ dlg->priv->replace_button =
+ gtk_button_new_from_stock (GTK_STOCK_FIND_AND_REPLACE);
+ gtk_button_set_label (GTK_BUTTON (dlg->priv->replace_button),
+ _("_Replace"));
+
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ dlg->priv->replace_all_button,
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ dlg->priv->replace_button,
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ dlg->priv->find_button,
+ GTR_SEARCH_DIALOG_FIND_RESPONSE);
+ g_object_set (G_OBJECT (dlg->priv->find_button), "can-default", TRUE, NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE);
+
+ /* insensitive by default */
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE, FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ FALSE);
+
+ gtk_box_pack_start (content_area, content, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (content), 5);
+
+ g_signal_connect (dlg->priv->search_text_entry,
+ "insert_text", G_CALLBACK (insert_text_handler), NULL);
+ g_signal_connect (dlg->priv->replace_text_entry,
+ "insert_text", G_CALLBACK (insert_text_handler), NULL);
+ g_signal_connect (dlg->priv->search_entry,
+ "changed", G_CALLBACK (search_entry_changed), dlg);
+
+ g_signal_connect (dlg->priv->original_text_checkbutton,
+ "toggled",
+ G_CALLBACK (original_translated_checkbutton_toggled),
+ dlg);
+
+ g_signal_connect (dlg->priv->translated_text_checkbutton,
+ "toggled",
+ G_CALLBACK (original_translated_checkbutton_toggled),
+ dlg);
+
+ g_signal_connect (dlg, "response", G_CALLBACK (response_handler), NULL);
+}
+
+GtkWidget *
+gtr_search_dialog_new (GtkWindow * parent, gboolean show_replace)
+{
+ GtrSearchDialog *dlg;
+
+ dlg = g_object_new (GTR_TYPE_SEARCH_DIALOG,
+ "show-replace", show_replace, NULL);
+
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
+
+ return GTK_WIDGET (dlg);
+}
+
+void
+gtr_search_dialog_present_with_time (GtrSearchDialog * dialog,
+ guint32 timestamp)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_window_present_with_time (GTK_WINDOW (dialog), timestamp);
+
+ gtk_widget_grab_focus (dialog->priv->search_text_entry);
+}
+
+gboolean
+gtr_search_dialog_get_show_replace (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return dialog->priv->show_replace;
+}
+
+void
+gtr_search_dialog_set_show_replace (GtrSearchDialog * dialog,
+ gboolean show_replace)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ if (dialog->priv->glade_error)
+ return;
+
+ dialog->priv->show_replace = show_replace != FALSE;
+ show_replace_widgets (dialog, dialog->priv->show_replace);
+
+ g_object_notify (G_OBJECT (dialog), "show-replace");
+}
+
+void
+gtr_search_dialog_set_search_text (GtrSearchDialog * dialog,
+ const gchar * text)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (text != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->priv->search_text_entry), text);
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE,
+ (text != '\0'));
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ (text != '\0'));
+}
+
+/*
+ * The text must be unescaped before searching.
+ */
+const gchar *
+gtr_search_dialog_get_search_text (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
+}
+
+void
+gtr_search_dialog_set_replace_text (GtrSearchDialog * dialog,
+ const gchar * text)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (text != NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->priv->replace_text_entry), text);
+}
+
+const gchar *
+gtr_search_dialog_get_replace_text (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), NULL);
+
+ return gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
+}
+
+void
+gtr_search_dialog_set_original_text (GtrSearchDialog * dialog,
+ gboolean match_case)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->original_text_checkbutton),
+ match_case);
+}
+
+gboolean
+gtr_search_dialog_get_original_text (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->original_text_checkbutton));
+}
+
+void
+gtr_search_dialog_set_translated_text (GtrSearchDialog *
+ dialog, gboolean match_case)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->translated_text_checkbutton),
+ match_case);
+}
+
+gboolean
+gtr_search_dialog_get_translated_text (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->
+ priv->translated_text_checkbutton));
+}
+
+void
+gtr_search_dialog_set_fuzzy (GtrSearchDialog * dialog, gboolean match_case)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->fuzzy_checkbutton),
+ match_case);
+}
+
+gboolean
+gtr_search_dialog_get_fuzzy (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->fuzzy_checkbutton));
+}
+
+void
+gtr_search_dialog_set_match_case (GtrSearchDialog * dialog,
+ gboolean match_case)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->match_case_checkbutton),
+ match_case);
+}
+
+gboolean
+gtr_search_dialog_get_match_case (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->match_case_checkbutton));
+}
+
+void
+gtr_search_dialog_set_entire_word (GtrSearchDialog * dialog,
+ gboolean entire_word)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->entire_word_checkbutton),
+ entire_word);
+}
+
+gboolean
+gtr_search_dialog_get_entire_word (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->entire_word_checkbutton));
+}
+
+void
+gtr_search_dialog_set_backwards (GtrSearchDialog * dialog, gboolean backwards)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->backwards_checkbutton),
+ backwards);
+}
+
+gboolean
+gtr_search_dialog_get_backwards (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->backwards_checkbutton));
+}
+
+void
+gtr_search_dialog_set_wrap_around (GtrSearchDialog * dialog,
+ gboolean wrap_around)
+{
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->wrap_around_checkbutton),
+ wrap_around);
+}
+
+gboolean
+gtr_search_dialog_get_wrap_around (GtrSearchDialog * dialog)
+{
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->wrap_around_checkbutton));
+}
diff --git a/src/dialogs/gtr-search-dialog.h b/src/dialogs/gtr-search-dialog.h
new file mode 100644
index 0000000..e7ec86d
--- /dev/null
+++ b/src/dialogs/gtr-search-dialog.h
@@ -0,0 +1,150 @@
+/*
+ * search-dialog.h
+ * This file is part of gtranslator based on gedit
+ *
+ * Copyright (C) 2005 Paolo Maggi
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __SEARCH_DIALOG_H__
+#define __SEARCH_DIALOG_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_SEARCH_DIALOG (gtr_search_dialog_get_type())
+#define GTR_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTR_TYPE_SEARCH_DIALOG, GtrSearchDialog))
+#define GTR_SEARCH_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTR_TYPE_SEARCH_DIALOG, GtrSearchDialog const))
+#define GTR_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTR_TYPE_SEARCH_DIALOG, GtrSearchDialogClass))
+#define GTR_IS_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTR_TYPE_SEARCH_DIALOG))
+#define GTR_IS_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_SEARCH_DIALOG))
+#define GTR_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTR_TYPE_SEARCH_DIALOG, GtrSearchDialogClass))
+/* Private structure type */
+typedef struct _GtrSearchDialogPrivate GtrSearchDialogPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtrSearchDialog GtrSearchDialog;
+
+struct _GtrSearchDialog
+{
+ GtkDialog dialog;
+
+ /*< private > */
+ GtrSearchDialogPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtrSearchDialogClass GtrSearchDialogClass;
+
+struct _GtrSearchDialogClass
+{
+ GtkDialogClass parent_class;
+
+ /* Key bindings */
+ gboolean (*show_replace) (GtrSearchDialog * dlg);
+};
+
+enum
+{
+ GTR_SEARCH_DIALOG_FIND_RESPONSE = 100,
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE
+};
+
+/*
+ * Public methods
+ */
+GType
+gtr_search_dialog_get_type (void)
+ G_GNUC_CONST;
+
+ GtkWidget *gtr_search_dialog_new (GtkWindow * parent,
+ gboolean show_replace);
+
+ void gtr_search_dialog_present_with_time (GtrSearchDialog
+ * dialog, guint32 timestamp);
+
+gboolean
+gtr_search_dialog_get_show_replace (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_show_replace (GtrSearchDialog
+ * dialog,
+ gboolean show_replace);
+
+ void gtr_search_dialog_set_search_text (GtrSearchDialog *
+ dialog, const gchar * text);
+
+ const gchar
+ * gtr_search_dialog_get_search_text (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_replace_text (GtrSearchDialog
+ * dialog, const gchar * text);
+
+ const gchar
+ * gtr_search_dialog_get_replace_text (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_original_text (GtrSearchDialog
+ * dialog, gboolean match_case);
+
+gboolean
+gtr_search_dialog_get_original_text (GtrSearchDialog * dialog);
+
+ void
+ gtr_search_dialog_set_translated_text (GtrSearchDialog
+ * dialog, gboolean match_case);
+
+gboolean
+gtr_search_dialog_get_translated_text (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_fuzzy (GtrSearchDialog *
+ dialog, gboolean match_case);
+
+ gboolean gtr_search_dialog_get_fuzzy (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_match_case (GtrSearchDialog *
+ dialog, gboolean match_case);
+
+gboolean
+gtr_search_dialog_get_match_case (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_entire_word (GtrSearchDialog *
+ dialog, gboolean entire_word);
+
+gboolean
+gtr_search_dialog_get_entire_word (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_backwards (GtrSearchDialog *
+ dialog, gboolean backwards);
+
+ gboolean gtr_search_dialog_get_backwards (GtrSearchDialog * dialog);
+
+ void gtr_search_dialog_set_wrap_around (GtrSearchDialog *
+ dialog, gboolean wrap_around);
+
+gboolean
+gtr_search_dialog_get_wrap_around (GtrSearchDialog * dialog);
+
+G_END_DECLS
+#endif /* __SEARCH_DIALOG_H__ */
diff --git a/src/dialogs/gtr-search-dialog.ui b/src/dialogs/gtr-search-dialog.ui
new file mode 100644
index 0000000..c9547a5
--- /dev/null
+++ b/src/dialogs/gtr-search-dialog.ui
@@ -0,0 +1,318 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <object class="GtkDialog" id="dialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Replace</property>
+ <property name="resizable">False</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="replace_all_button">
+ <property name="label" translatable="yes">Replace All</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="replace_button">
+ <property name="label" translatable="yes">Replace</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="find_next_button">
+ <property name="label">gtk-find</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</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">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="search_dialog_content">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="search_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Search for: </property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="replace_with_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Replace _with: </property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <object class="GtkCheckButton" id="original_text_checkbutton">
+ <property name="label" translatable="yes">_Original text</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</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="GtkCheckButton" id="translated_text_checkbutton">
+ <property name="label" translatable="yes">_Translated text</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">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">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHSeparator" id="hseparator1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="fuzzy_checkbutton">
+ <property name="label" translatable="yes">Include fu_zzy strings</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="match_case_checkbutton">
+ <property name="label" translatable="yes">_Match case</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="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="entire_word_checkbutton">
+ <property name="label" translatable="yes">Match _entire word only</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="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="search_backwards_checkbutton">
+ <property name="label" translatable="yes">Search _backwards</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wrap_around_checkbutton">
+ <property name="label" translatable="yes">_Wrap around</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="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ </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">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">close_button</action-widget>
+ <action-widget response="0">replace_all_button</action-widget>
+ <action-widget response="0">replace_button</action-widget>
+ <action-widget response="0">find_next_button</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/src/gtr-actions-edit.c b/src/gtr-actions-edit.c
index 3046b6f..e0275a9 100644
--- a/src/gtr-actions-edit.c
+++ b/src/gtr-actions-edit.c
@@ -24,8 +24,8 @@
#include <glib.h>
#include <glib/gi18n.h>
-#include "gtr-header-dialog.h"
-#include "gtr-preferences-dialog.h"
+#include "dialogs/gtr-header-dialog.h"
+#include "dialogs/gtr-preferences-dialog.h"
#include "gtr-actions.h"
#include "gtr-msg.h"
#include "gtr-po.h"
diff --git a/src/gtr-actions-file.c b/src/gtr-actions-file.c
index 1e63c6c..b575894 100644
--- a/src/gtr-actions-file.c
+++ b/src/gtr-actions-file.c
@@ -30,7 +30,7 @@
#include <string.h>
#include <gio/gio.h>
-#include "gtr-close-confirmation-dialog.h"
+#include "dialogs/gtr-close-confirmation-dialog.h"
#include "gtr-actions.h"
#include "gtr-application.h"
#include "gtr-dirs.h"
diff --git a/src/gtr-actions-search.c b/src/gtr-actions-search.c
index a4a84f9..117a0f3 100644
--- a/src/gtr-actions-search.c
+++ b/src/gtr-actions-search.c
@@ -38,7 +38,7 @@
#include "gtr-utils.h"
#include "gtr-view.h"
#include "gtr-window.h"
-#include "gtr-search-dialog.h"
+#include "dialogs/gtr-search-dialog.h"
#define GTR_SEARCH_DIALOG_KEY "gtr-search-dialog-key"
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 4b540ae..ea788ec 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -24,7 +24,7 @@
#include <config.h>
#endif
-#include "gtr-assistant.h"
+#include "dialogs/gtr-assistant.h"
#include "gtr-actions.h"
#include "gtr-application.h"
#include "gtr-debug.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]