[gtranslator/gtk4: 2/52] removed gtr-notebook.h from gtr-window
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/gtk4: 2/52] removed gtr-notebook.h from gtr-window
- Date: Mon, 5 Sep 2022 15:17:48 +0000 (UTC)
commit 05d0d7d6aecec038cf4c53c14877af7077034716
Author: afshan ahmed khan <afshanahmeda2k gmail com>
Date: Fri May 20 12:27:54 2022 +0530
removed gtr-notebook.h from gtr-window
src/codeview/gtr-codeview.c | 30 +-
src/gtr-actions-documents.c | 8 +-
src/gtr-actions-file.c | 49 +-
src/gtr-actions.h | 4 +-
src/gtr-tab-old.c | 2038 +++++++++++++++++++++++++++++++++++++++++++
src/gtr-tab-old.h | 182 ++++
src/gtr-tab-old.ui | 315 +++++++
src/gtr-tab.c | 95 +-
src/gtr-tab.h | 9 +
src/gtr-tab.ui | 499 +++++++++++
src/gtr-window-old.c | 964 ++++++++++++++++++++
src/gtr-window-old.h | 92 ++
src/gtr-window-old.ui | 63 ++
src/gtr-window.c | 115 +--
src/gtr-window.h | 4 +-
15 files changed, 4365 insertions(+), 102 deletions(-)
---
diff --git a/src/codeview/gtr-codeview.c b/src/codeview/gtr-codeview.c
index a639a3e8..e1c221aa 100644
--- a/src/codeview/gtr-codeview.c
+++ b/src/codeview/gtr-codeview.c
@@ -465,22 +465,20 @@ on_context_panel_reloaded (GtrContextPanel *panel,
}
static void
-page_added_cb (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
+page_added_cb (GtkWidget *tab,
GtrCodeView *codeview)
{
GtrContextPanel *panel;
GtkTextView *view;
- panel = gtr_tab_get_context_panel (GTR_TAB (child));
+ panel = gtr_tab_get_context_panel (GTR_TAB (tab));
view = gtr_context_panel_get_context_text_view (panel);
g_return_if_fail (GTK_IS_TEXT_VIEW (view));
- g_signal_connect_after (child, "showed-message",
+ g_signal_connect_after (tab, "showed-message",
G_CALLBACK (showed_message_cb), codeview);
- g_signal_connect (child, "message-edition-finished",
+ g_signal_connect (tab, "message-edition-finished",
G_CALLBACK (message_edition_finished_cb), codeview);
g_signal_connect (view, "event-after", G_CALLBACK (event_after), codeview);
@@ -577,12 +575,12 @@ gtr_code_view_new (GtrWindow *window)
GtrCodeView *self = g_object_new (GTR_TYPE_CODE_VIEW,
"window", window, NULL);
GtrCodeViewPrivate *priv = gtr_code_view_get_instance_private (self);
- GtkWidget *notebook;
+ GtkWidget *tab;
GdkDisplay *display;
GList *tabs, *l;
- notebook = GTK_WIDGET (gtr_window_get_notebook (priv->window));
- display = gtk_widget_get_display (notebook);
+ tab = GTK_WIDGET (gtr_window_get_active_tab (priv->window));
+ display = gtk_widget_get_display (tab);
/*
* Cursors
@@ -590,13 +588,13 @@ gtr_code_view_new (GtrWindow *window)
hand_cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
regular_cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
- g_signal_connect (notebook, "page-added", G_CALLBACK (page_added_cb), self);
+ //g_signal_connect (notebook, "page-added", G_CALLBACK (page_added_cb), self);
/*
* If we already have tabs opened we have to add them
*/
- tabs = gtr_window_get_all_tabs (priv->window);
- for (l = tabs; l != NULL; l = g_list_next (l))
+ //tabs = gtr_window_get_all_tabs (priv->window);
+ /*for (l = tabs; l != NULL; l = g_list_next (l))
{
GtrPo *po;
GList *msg;
@@ -607,7 +605,13 @@ gtr_code_view_new (GtrWindow *window)
msg = gtr_po_get_current_message (po);
showed_message_cb (GTR_TAB (l->data), msg->data, self);
- }
+ }*/
+ GtrPo *po;
+ GList *msg;
+ po = gtr_tab_get_po (GTR_TAB (tab));
+ msg = gtr_po_get_current_message (po);
+ page_added_cb (GTR_TAB(tab), self);
+ showed_message_cb (GTR_TAB (tab), msg->data, self);
return self;
}
diff --git a/src/gtr-actions-documents.c b/src/gtr-actions-documents.c
index e8b397f3..3a0859b6 100644
--- a/src/gtr-actions-documents.c
+++ b/src/gtr-actions-documents.c
@@ -21,18 +21,18 @@
#include "gtr-actions.h"
-void
+/*void
gtr_actions_documents_next_document (GtrWindow * window)
{
GtrNotebook *notebook;
notebook = gtr_window_get_notebook (window);
gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
-}
+}*/
-void
+/*void
gtr_actions_documents_previous_document (GtrWindow * window)
{
GtrNotebook *notebook;
notebook = gtr_window_get_notebook (window);
gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
-}
+}*/
diff --git a/src/gtr-actions-file.c b/src/gtr-actions-file.c
index 1e9a8fe5..405d4925 100644
--- a/src/gtr-actions-file.c
+++ b/src/gtr-actions-file.c
@@ -66,7 +66,6 @@ gtr_open (GFile * location, GtrWindow * window, GError ** error)
GList *current;
GtrView *active_view;
GtrHeader *header;
- GtrNotebook *active_notebook;
gchar *dl_team;
gchar *dl_module;
gchar *dl_branch;
@@ -112,14 +111,14 @@ gtr_open (GFile * location, GtrWindow * window, GError ** error)
* Create a page to add to our list of open files
*/
tab = gtr_window_create_tab (window, po);
- gtr_window_set_active_tab (window, GTK_WIDGET (tab));
+ //gtr_window_set_active_tab (window, GTK_WIDGET (tab));
/*
* Activate the upload file icon if the po file is in the appropriate
* state as on the vertimus workflow
*/
- active_notebook = gtr_window_get_notebook (window);
- gtr_notebook_enable_upload (active_notebook, gtr_po_can_dl_upload (po));
+ //active_notebook = gtr_window_get_notebook (window);
+ gtr_tab_enable_upload (tab, gtr_po_can_dl_upload (po));
/*
* Show the current message.
@@ -247,13 +246,13 @@ void
gtr_open_file_dialog (GtrWindow * window)
{
GtkNativeDialog *dialog;
- g_autoptr (GList) list = NULL;
- list = get_modified_documents (window);
- if (list != NULL)
+ //g_autoptr (GList) list = NULL;
+ //list = get_modified_documents (window);
+ /*if (list != NULL)
{
if (!gtr_want_to_save_current_dialog (window))
return;
- }
+ }*/
dialog = gtr_file_chooser_new (GTK_WINDOW (window),
FILESEL_OPEN,
@@ -334,8 +333,9 @@ _upload_file_callback (GObject *object,
UserData *ud = user_data;
g_autoptr(GInputStream) stream = NULL;
GtkWidget *dialog;
+ GtrTab *active_tab;
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
- GtrNotebook *active_notebook;
+ //GtrNotebook *active_notebook;
GtkWidget *upload_dialog = ud->dialog;
GtkWidget *window = gtr_upload_dialog_get_parent (GTR_UPLOAD_DIALOG (upload_dialog));
@@ -346,7 +346,7 @@ _upload_file_callback (GObject *object,
stream = soup_session_send_finish (session, result, &error);
- active_notebook = gtr_window_get_notebook (GTR_WINDOW (window));
+ active_tab = gtr_window_get_active_tab (GTR_WINDOW (window));
if (error || !SOUP_STATUS_IS_SUCCESSFUL (status_code))
{
@@ -357,7 +357,8 @@ _upload_file_callback (GObject *object,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
_("This file has already been uploaded"));
- gtr_notebook_enable_upload (active_notebook, FALSE);
+ //gtr_notebook_enable_upload (active_notebook, FALSE);
+ gtr_tab_enable_upload (active_tab, FALSE);
goto end;
}
@@ -394,7 +395,7 @@ _upload_file_callback (GObject *object,
GTK_BUTTONS_OK,
_("The file has been uploaded!"));
- gtr_notebook_enable_upload (active_notebook, FALSE);
+ gtr_tab_enable_upload (active_tab, FALSE);
end:
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
@@ -619,15 +620,15 @@ load_file_list (GtrWindow * window, const GSList * locations)
if (!is_duplicated_location (locations_to_load, locations->data))
{
/*We need to now if is already loaded in any tab */
- tab = gtr_window_get_tab_from_location (window,
- (GFile *) locations->data);
+ /*tab = gtr_window_get_tab_from_location (window,
+ (GFile *) locations->data);*/
- if (tab != NULL)
+ /*if (tab != NULL)
{
if (locations == l)
gtr_window_set_active_tab (window, tab);
}
- else
+ else*/
locations_to_load = g_slist_prepend (locations_to_load,
locations->data);
@@ -707,13 +708,13 @@ save_and_close_document (GtrPo * po, GtrWindow * window)
static void
close_all_tabs (GtrWindow * window)
{
- GtrNotebook *nb;
+ /*GtrNotebook *nb;
nb = gtr_window_get_notebook (window);
gtr_notebook_remove_all_pages (nb);
//FIXME: This has to change once we add the close all documents menuitem
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_widget_destroy (GTK_WIDGET (window));*/
}
static void
@@ -867,13 +868,12 @@ gtr_file_close (GtrWindow * window)
static GList *
get_modified_documents (GtrWindow * window)
{
- GtrNotebook *nb;
+ //GtrNotebook *nb;
GtrTab *tab;
GtrPo *po;
- gint pages;
GList *list = NULL;
- nb = gtr_window_get_notebook (window);
+ /*nb = gtr_window_get_notebook (window);
pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
while (pages > 0)
@@ -886,7 +886,12 @@ get_modified_documents (GtrWindow * window)
list = g_list_prepend (list, po);
pages--;
- }
+ }*/
+
+ tab = gtr_window_get_active_tab(window);
+ po = gtr_tab_get_po (tab);
+ if (gtr_po_get_state (po) == GTR_PO_STATE_MODIFIED)
+ list = g_list_prepend (list, po);
return list;
}
diff --git a/src/gtr-actions.h b/src/gtr-actions.h
index 209d4b83..b6283d3e 100644
--- a/src/gtr-actions.h
+++ b/src/gtr-actions.h
@@ -162,9 +162,9 @@ void search_bar_response_cb (GtrSearchBar * dialog,
GtrWindow * window);
/*Documents*/
-void gtr_actions_documents_next_document (GtrWindow * window);
+//void gtr_actions_documents_next_document (GtrWindow * window);
-void gtr_actions_documents_previous_document (GtrWindow * window);
+//void gtr_actions_documents_previous_document (GtrWindow * window);
/*Help*/
void gtr_window_show_home_page (gpointer useless);
diff --git a/src/gtr-tab-old.c b/src/gtr-tab-old.c
new file mode 100644
index 00000000..6bd201a7
--- /dev/null
+++ b/src/gtr-tab-old.c
@@ -0,0 +1,2038 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Fatih Demir <kabalak kabalak net>
+ * Ross Golder <ross golder org>
+ * Gediminas Paulauskas <menesis kabalak net>
+ * homas Ziehmer <thomas kabalak net>
+ * 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:
+ * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Pablo Sanxiao <psanxiao gmail com>
+ * Fatih Demir <kabalak kabalak net>
+ * Ross Golder <ross golder org>
+ * Gediminas Paulauskas <menesis kabalak net>
+ * Thomas Ziehmer <thomas kabalak net>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-application.h"
+#include "gtr-context.h"
+#include "gtr-io-error-info-bar.h"
+#include "gtr-message-table.h"
+#include "gtr-msg.h"
+#include "gtr-tab-activatable.h"
+#include "gtr-tab.h"
+#include "gtr-po.h"
+#include "gtr-settings.h"
+#include "gtr-view.h"
+#include "gtr-dirs.h"
+#include "gtr-debug.h"
+#include "gtr-window.h"
+#include "gtr-progress.h"
+#include "gtr-actions.h"
+#include "gtr-utils.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gtksourceview/gtksource.h>
+
+#define MAX_PLURALS 6
+
+#define GTR_TAB_KEY "GtrTabFromDocument"
+
+typedef struct
+{
+ GSettings *ui_settings;
+ GSettings *files_settings;
+ GSettings *editor_settings;
+ GSettings *state_settings;
+
+ GtkWidget *progress_eventbox;
+ GtkWidget *progress_box;
+ GtkWidget *progress_revealer;
+ GtkWidget *progress_percentage;
+ GtkWidget *progress_trans;
+ GtkWidget *progress_fuzzy;
+ GtkWidget *progress_untrans;
+
+ GtrProgress *progress;
+ gboolean find_replace_flag;
+
+ GtrPo *po;
+
+ GtkWidget *dock;
+
+ /*Vertical and Horizontal Panes */
+ GtkPaned *hbox;
+ GtkPaned *vertical_box;
+ gint context_position;
+ gint content_position;
+
+ GtkWidget *message_table;
+ GtkWidget *context;
+
+ /*Info bar */
+ GtkWidget *infobar;
+
+ /*Original text */
+ GtkWidget *text_msgid;
+ GtkWidget *text_plural_scroll;
+ GtkWidget *text_msgid_plural;
+ GtkWidget *msgid_tags;
+ GtkWidget *msgid_ctxt;
+
+ /*Translated text */
+ GtkWidget *msgstr_label;
+ GtkWidget *trans_notebook;
+ GtkWidget *trans_msgstr[MAX_PLURALS];
+
+ /*Status widgets */
+ GtkWidget *translated;
+ GtkWidget *fuzzy;
+ GtkWidget *untranslated;
+
+ /* Autosave */
+ GTimer *timer;
+ gint autosave_interval;
+ guint autosave_timeout;
+ guint autosave : 1;
+ /*Blocking movement */
+ guint blocking : 1;
+
+ guint tab_realized : 1;
+ guint dispose_has_run : 1;
+
+ /*Search Bar*/
+ GtkOverlay *overlay;
+ GtkRevealer *search_revealer;
+ GtrSearchBar *search_bar;
+ GtkSearchEntry *search;
+
+} GtrTabPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrTab, gtr_tab, GTK_TYPE_BOX)
+
+enum
+{
+ SHOWED_MESSAGE,
+ MESSAGE_CHANGED,
+ MESSAGE_EDITION_FINISHED,
+ SELECTION_CHANGED,
+ SEARCHBAR_TOGGLED,
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_AUTOSAVE,
+ PROP_AUTOSAVE_INTERVAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+static gboolean gtr_tab_autosave (GtrTab * tab);
+
+//---------------------------Search Bar Revealer------------------//
+
+void
+gtr_page_stop_search (GtrTab *tab,
+ GtrSearchBar *search_bar)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ g_assert (GTR_IS_TAB (tab));
+ g_assert (GTR_IS_SEARCH_BAR (priv->search_bar));
+
+ gtk_revealer_set_reveal_child (priv->search_revealer, FALSE);
+
+}
+
+void
+gtr_tab_focus_search_bar (GtrTab *tab)
+{
+ GtrTabPrivate *priv;
+ GtkEntry *entry;
+
+ g_assert (GTR_IS_TAB (tab));
+ priv = gtr_tab_get_instance_private (tab);
+
+ entry = (GtkEntry *) gtr_search_bar_get_search (priv->search_bar);
+
+ gtk_entry_grab_focus_without_selecting (entry);
+}
+
+void
+gtr_tab_show_hide_search_bar (GtrTab *tab, gboolean show)
+{
+ GtrTabPrivate *priv;
+
+ g_assert (GTR_IS_TAB (tab));
+ priv = gtr_tab_get_instance_private (tab);
+
+ gtk_revealer_set_reveal_child (priv->search_revealer, show);
+}
+
+void
+gtr_tab_find_set_replace (GtrTab *tab,
+ gboolean replace)
+{
+ GtrTabPrivate *priv;
+
+ g_assert (GTR_IS_TAB (tab));
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_search_bar_set_replace_mode (priv->search_bar, replace);
+}
+
+void
+gtr_tab_find_next (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_search_bar_find_next (priv->search_bar);
+}
+
+void
+gtr_tab_find_prev (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_search_bar_find_prev (priv->search_bar);
+}
+
+void
+gtr_page_notify_child_revealed (GtrTab *tab,
+ GParamSpec *pspec,
+ GtkRevealer *revealer)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ g_assert (GTR_IS_TAB (tab));
+ g_assert (GTK_IS_REVEALER (revealer));
+
+ if (gtk_revealer_get_child_revealed (revealer))
+ {
+ GtkWidget *toplevel = gtk_widget_get_ancestor (GTK_WIDGET (revealer), GTK_TYPE_WINDOW);
+ GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
+
+ /* Only focus the search bar if it doesn't already have focus,
+ * as it can reselect the search text.
+ */
+ if (focus == NULL || !gtk_widget_is_ancestor (focus, GTK_WIDGET (revealer)))
+ gtk_widget_grab_focus (GTK_WIDGET (priv->search_bar));
+ }
+}
+
+//----------------------------------------------------------------//
+
+static gboolean
+show_hide_revealer (GtkWidget *widget, GdkEvent *ev, GtrTab *tab)
+{
+ GtrTabPrivate *priv;
+ GtkRevealer *rev;
+
+ priv = gtr_tab_get_instance_private (tab);
+ rev = GTK_REVEALER (priv->progress_revealer);
+ gtk_revealer_set_reveal_child (rev, !gtk_revealer_get_reveal_child (rev));
+
+ return TRUE;
+}
+
+static gboolean
+msg_grab_focus (GtrTab *tab)
+{
+ GtrTabPrivate *priv;
+ priv = gtr_tab_get_instance_private (tab);
+ gtk_widget_grab_focus (priv->trans_msgstr[0]);
+ return FALSE;
+}
+
+static void
+install_autosave_timeout (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+ gint timeout;
+
+ priv = gtr_tab_get_instance_private (tab);
+ g_return_if_fail (priv->autosave_timeout <= 0);
+ g_return_if_fail (priv->autosave);
+ g_return_if_fail (priv->autosave_interval > 0);
+
+ /* Add a new timeout */
+ timeout = g_timeout_add (priv->autosave_interval * 1000 * 60,
+ (GSourceFunc) gtr_tab_autosave, tab);
+
+ priv->autosave_timeout = timeout;
+}
+
+static gboolean
+install_autosave_timeout_if_needed (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ g_return_val_if_fail (priv->autosave_timeout <= 0, FALSE);
+
+ if (priv->autosave)
+ {
+ install_autosave_timeout (tab);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+gtr_tab_autosave (GtrTab * tab)
+{
+ GError *error = NULL;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ if (!(gtr_po_get_state (priv->po) == GTR_PO_STATE_MODIFIED))
+ return TRUE;
+
+ gtr_po_save_file (priv->po, &error);
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ return TRUE;
+}
+
+static void
+remove_autosave_timeout (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ g_return_if_fail (priv->autosave_timeout > 0);
+
+ g_source_remove (priv->autosave_timeout);
+ priv->autosave_timeout = 0;
+}
+
+static void
+gtr_tab_edition_finished (GtrTab * tab, GtrMsg * msg)
+{
+ gchar *message_error;
+ GtkWidget *infobar;
+
+ /*
+ * Checking message
+ */
+ message_error = gtr_msg_check (msg);
+
+ if (message_error != NULL)
+ {
+ gtr_tab_block_movement (tab);
+
+ infobar = create_error_info_bar (_("There is an error in the message:"),
+ message_error);
+ gtr_tab_set_info_bar (tab, infobar);
+ g_free (message_error);
+ }
+ else
+ {
+ gtr_tab_unblock_movement (tab);
+ gtr_tab_set_info_bar (tab, NULL);
+ }
+}
+
+/*
+ * Write the change back to the gettext PO instance in memory and
+ * mark the page dirty
+ */
+static void
+gtr_message_translation_update (GtkTextBuffer * textbuffer, GtrTab * tab)
+{
+ GtrHeader *header;
+ GtkTextIter start, end;
+ GtkTextBuffer *buf;
+ GList *msg_aux;
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+ const gchar *check;
+ gchar *translation;
+ gboolean unmark_fuzzy;
+ gint i;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ /* Work out which message this is associated with */
+ header = gtr_po_get_header (priv->po);
+
+ msg_aux = gtr_po_get_current_message (priv->po);
+ msg = msg_aux->data;
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[0]));
+ unmark_fuzzy = g_settings_get_boolean (priv->editor_settings,
+ GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED);
+
+ unmark_fuzzy = unmark_fuzzy && !priv->find_replace_flag;
+ if (gtr_msg_is_fuzzy (msg) && unmark_fuzzy)
+ gtr_msg_set_fuzzy (msg, FALSE);
+
+ if (textbuffer == buf)
+ {
+ /* Get message as UTF-8 buffer */
+ gtk_text_buffer_get_bounds (textbuffer, &start, &end);
+ translation = gtk_text_buffer_get_text (textbuffer, &start, &end, TRUE);
+
+ /* TODO: convert to file's own encoding if not UTF-8 */
+
+ /* Write back to PO file in memory */
+ if (!(check = gtr_msg_get_msgid_plural (msg)))
+ {
+ gtr_msg_set_msgstr (msg, translation);
+ }
+ else
+ {
+ gtr_msg_set_msgstr_plural (msg, 0, translation);
+ //free(check);
+ }
+ g_free (translation);
+ return;
+ }
+ i = 1;
+ while (i < gtr_header_get_nplurals (header))
+ {
+ /* Know when to break out of the loop */
+ if (!priv->trans_msgstr[i])
+ {
+ break;
+ }
+
+ /* Have we reached the one we want yet? */
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[i]));
+ if (textbuffer != buf)
+ {
+ i++;
+ continue;
+ }
+
+ /* Get message as UTF-8 buffer */
+ gtk_text_buffer_get_bounds (textbuffer, &start, &end);
+ translation = gtk_text_buffer_get_text (textbuffer, &start, &end, TRUE);
+
+ /* TODO: convert to file's own encoding if not UTF-8 */
+
+ /* Write back to PO file in memory */
+ gtr_msg_set_msgstr_plural (msg, i, translation);
+ return;
+ }
+
+ /* Shouldn't get here */
+ g_return_if_reached ();
+}
+
+static GtkWidget *
+gtr_tab_append_msgstr_page (const gchar * tab_label,
+ GtkWidget * box, gboolean spellcheck,
+ GtrTab *tab)
+{
+ GtkWidget *scroll;
+ GtkWidget *label;
+ GtkWidget *widget;
+ GtrTabPrivate *priv;
+
+ label = gtk_label_new (tab_label);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scroll);
+
+ widget = gtr_view_new ();
+ gtk_widget_show (widget);
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ gtk_container_add (GTK_CONTAINER (scroll), widget);
+
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+ GTK_SHADOW_IN);
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (box), scroll, label);
+
+ return widget;
+}
+
+static void
+gtr_message_plural_forms (GtrTab * tab, GtrMsg * msg)
+{
+ GtrHeader *header;
+ GtkTextBuffer *buf;
+ GtrTabPrivate *priv;
+ const gchar *msgstr_plural;
+ gint i;
+
+ g_return_if_fail (tab != NULL);
+ g_return_if_fail (msg != NULL);
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ header = gtr_po_get_header (priv->po);
+
+ for (i = 0; i < gtr_header_get_nplurals (header); i++)
+ {
+ msgstr_plural = gtr_msg_get_msgstr_plural (msg, i);
+ if (msgstr_plural)
+ {
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW
+ (priv->trans_msgstr[i]));
+ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER
+ (buf));
+ gtk_text_buffer_set_text (buf, (gchar *) msgstr_plural, -1);
+ gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (buf));
+ }
+ }
+}
+
+/*
+ * gtr_tab_show_message:
+ * @tab: a #GtranslationTab
+ * @msg: a #GtrMsg
+ *
+ * Shows the @msg in the @tab TextViews
+ *
+ */
+static void
+gtr_tab_show_message (GtrTab * tab, GtrMsg * msg)
+{
+ GtrTabPrivate *priv;
+ GtrPo *po;
+ GtkTextBuffer *buf;
+ const gchar *msgid, *msgid_plural;
+ const gchar *msgstr;
+ const gchar *msgctxt;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ priv = gtr_tab_get_instance_private (tab);
+ gtk_label_set_text (GTK_LABEL (priv->msgid_tags), "");
+
+ msgctxt = gtr_msg_get_msgctxt (msg);
+ if (msgctxt)
+ {
+ gtk_label_set_text (GTK_LABEL (priv->msgid_ctxt), msgctxt);
+ gtk_widget_show (priv->msgid_ctxt);
+ }
+ else
+ {
+ gtk_widget_hide (priv->msgid_ctxt);
+ }
+
+ po = priv->po;
+ gtr_po_update_current_message (po, msg);
+ msgid = gtr_msg_get_msgid (msg);
+ if (msgid)
+ {
+ gchar *msg_error = gtr_msg_check (msg);
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->text_msgid));
+ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER (buf));
+ gtk_text_buffer_set_text (buf, (gchar *) msgid, -1);
+ gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (buf));
+
+ if (gtr_msg_is_fuzzy (msg))
+ gtk_label_set_text (GTK_LABEL (priv->msgid_tags), _("fuzzy"));
+ if (msg_error) {
+ gtk_label_set_text (GTK_LABEL (priv->msgid_tags), msg_error);
+ g_free (msg_error);
+ }
+ }
+ msgid_plural = gtr_msg_get_msgid_plural (msg);
+ if (!msgid_plural)
+ {
+ msgstr = gtr_msg_get_msgstr (msg);
+ /*
+ * Disable notebook tabs and hide widgets
+ */
+ gtk_widget_hide (priv->text_plural_scroll);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->trans_notebook), FALSE);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->trans_notebook), 0);
+ if (msgstr)
+ {
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[0]));
+ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER
+ (buf));
+ gtk_text_buffer_set_text (buf, (gchar *) msgstr, -1);
+ gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (buf));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (priv->msgstr_label),
+ priv->trans_msgstr[0]);
+ }
+ }
+ else
+ {
+ gtk_widget_show (priv->text_plural_scroll);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->trans_notebook),
+ TRUE);
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW
+ (priv->text_msgid_plural));
+ gtk_text_buffer_set_text (buf, (gchar *) msgid_plural, -1);
+ gtr_message_plural_forms (tab, msg);
+ }
+}
+
+static void
+emit_message_changed_signal (GtkTextBuffer * buf, GtrTab * tab)
+{
+ GList *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ msg = gtr_po_get_current_message (priv->po);
+
+ g_signal_emit (G_OBJECT (tab), signals[MESSAGE_CHANGED], 0, msg->data);
+}
+
+static void
+emit_selection_changed (GtkTextBuffer * buf, GParamSpec * spec, GtrTab * tab)
+{
+ g_signal_emit (G_OBJECT (tab), signals[SELECTION_CHANGED], 0);
+}
+
+static void
+emit_searchbar_toggled (GtkRevealer *revealer,
+ GParamSpec *pspec,
+ GtrTab *tab)
+{
+ gboolean revealed = gtk_revealer_get_child_revealed (revealer);
+ g_signal_emit (G_OBJECT (tab), signals[SEARCHBAR_TOGGLED], 0, revealed);
+}
+
+static void
+update_status (GtrTab * tab, GtrMsg * msg, gpointer useless)
+{
+ GtrMsgStatus status;
+ GtrPoState po_state;
+ GtrTabPrivate *priv;
+ gboolean fuzzy, translated;
+ gchar *msg_error = NULL;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ status = gtr_msg_get_status (msg);
+ po_state = gtr_po_get_state (priv->po);
+
+ fuzzy = gtr_msg_is_fuzzy (msg);
+ translated = gtr_msg_is_translated (msg);
+
+ if ((status == GTR_MSG_STATUS_FUZZY) && !fuzzy && !priv->find_replace_flag)
+ {
+ _gtr_po_increase_decrease_fuzzy (priv->po, FALSE);
+ if (translated)
+ {
+ status = GTR_MSG_STATUS_TRANSLATED;
+ _gtr_po_increase_decrease_translated (priv->po, TRUE);
+ }
+ else
+ {
+ status = GTR_MSG_STATUS_UNTRANSLATED;
+ }
+ }
+ else if ((status == GTR_MSG_STATUS_TRANSLATED) && !translated)
+ {
+ status = GTR_MSG_STATUS_UNTRANSLATED;
+ _gtr_po_increase_decrease_translated (priv->po, FALSE);
+ }
+ else if ((status == GTR_MSG_STATUS_TRANSLATED) && fuzzy)
+ {
+ status = GTR_MSG_STATUS_FUZZY;
+ _gtr_po_increase_decrease_translated (priv->po, FALSE);
+ _gtr_po_increase_decrease_fuzzy (priv->po, TRUE);
+ }
+ else if ((status == GTR_MSG_STATUS_UNTRANSLATED) && translated)
+ {
+ if (fuzzy)
+ {
+ status = GTR_MSG_STATUS_FUZZY;
+ _gtr_po_increase_decrease_fuzzy (priv->po, TRUE);
+ }
+ else
+ {
+ status = GTR_MSG_STATUS_TRANSLATED;
+ _gtr_po_increase_decrease_translated (priv->po, TRUE);
+ }
+ }
+
+ if (status != gtr_msg_get_status (msg))
+ {
+ gtr_msg_set_status (msg, status);
+ g_signal_emit (G_OBJECT (tab), signals[MESSAGE_CHANGED], 0, msg);
+ }
+
+ msg_error = gtr_msg_check (msg);
+ if (msg_error) {
+ gtk_label_set_text (GTK_LABEL (priv->msgid_tags), msg_error);
+ g_free (msg_error);
+ }
+ else if (gtr_msg_is_fuzzy (msg))
+ gtk_label_set_text (GTK_LABEL (priv->msgid_tags), _("fuzzy"));
+ else
+ gtk_label_set_text (GTK_LABEL (priv->msgid_tags), "");
+
+ /* We need to update the tab state too if is neccessary */
+ if (po_state != GTR_PO_STATE_MODIFIED)
+ gtr_po_set_state (priv->po, GTR_PO_STATE_MODIFIED);
+}
+
+static void
+gtr_tab_add_msgstr_tabs (GtrTab * tab)
+{
+ GtrHeader *header;
+ GtrTabPrivate *priv;
+ gchar *label;
+ GtkTextBuffer *buf;
+ gint i = 0;
+ gchar *lang_code = NULL;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ /*
+ * We get the header of the po file
+ */
+ header = gtr_po_get_header (priv->po);
+ lang_code = gtr_header_get_language_code (header);
+
+ do
+ {
+
+ label = g_strdup_printf (_("Plural %d"), i);
+ priv->trans_msgstr[i] = gtr_tab_append_msgstr_page (label,
+ priv->trans_notebook,
+ TRUE,
+ tab);
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[i]));
+ g_signal_connect (buf, "end-user-action",
+ G_CALLBACK (gtr_message_translation_update), tab);
+
+ g_signal_connect_after (buf, "end_user_action",
+ G_CALLBACK (emit_message_changed_signal), tab);
+ g_signal_connect (buf, "notify::has-selection",
+ G_CALLBACK (emit_selection_changed), tab);
+ i++;
+ g_free (label);
+ }
+ while (i < gtr_header_get_nplurals (header));
+ g_free (lang_code);
+}
+
+static void
+on_location_notify (GtrPo *po,
+ GParamSpec *pspec,
+ GtrTab *tab)
+{
+ g_object_notify (G_OBJECT (tab), "name");
+}
+
+static void
+on_state_notify (GtrPo *po,
+ GParamSpec *pspec,
+ GtrTab *tab)
+{
+ g_object_notify (G_OBJECT (tab), "name");
+}
+
+static void
+gtr_tab_init (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ gtk_widget_init_template (GTK_WIDGET (tab));
+
+ priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
+ priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+ priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+ priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+
+ g_signal_connect (tab, "message-changed", G_CALLBACK (update_status), NULL);
+
+ /*Load gsettings for panes */
+ priv->context_position = g_settings_get_int (priv->state_settings,
+ GTR_SETTINGS_CONTEXT_PANEL_SIZE);
+
+ priv->content_position = g_settings_get_int (priv->state_settings,
+ GTR_SETTINGS_CONTENT_PANEL_SIZE);
+
+ gtk_paned_set_position (priv->hbox, priv->context_position);
+ gtk_paned_set_position (priv->vertical_box, priv->content_position);
+
+ /* Manage auto save data */
+ priv->autosave = g_settings_get_boolean (priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE);
+ priv->autosave = (priv->autosave != FALSE);
+
+ priv->autosave_interval = g_settings_get_int (priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE_INTERVAL);
+ if (priv->autosave_interval <= 0)
+ priv->autosave_interval = 1;
+
+ priv->find_replace_flag = FALSE;
+ priv->progress = gtr_progress_new ();
+ gtk_widget_show (GTK_WIDGET (priv->progress));
+ gtk_box_append (GTK_BOX (priv->progress_box), GTK_WIDGET (priv->progress));
+
+ g_signal_connect (priv->progress_eventbox, "button-press-event",
+ G_CALLBACK (show_hide_revealer), tab);
+
+ g_signal_connect (priv->search_revealer, "notify::child-revealed",
+ G_CALLBACK (emit_searchbar_toggled), tab);
+}
+
+static void
+gtr_tab_finalize (GObject * object)
+{
+ GtrTab *tab = GTR_TAB (object);
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (priv->timer != NULL)
+ g_timer_destroy (priv->timer);
+
+ if (priv->autosave_timeout > 0)
+ remove_autosave_timeout (tab);
+
+ G_OBJECT_CLASS (gtr_tab_parent_class)->finalize (object);
+}
+
+static void
+save_pane_state(GtrTab *tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ priv->context_position = gtk_paned_get_position (priv->hbox);
+ priv->content_position = gtk_paned_get_position (priv->vertical_box);
+
+ g_settings_set_int (priv->state_settings, GTR_SETTINGS_CONTEXT_PANEL_SIZE,
+ priv->context_position);
+
+ g_settings_set_int (priv->state_settings, GTR_SETTINGS_CONTENT_PANEL_SIZE,
+ priv->content_position);
+}
+
+static void
+gtr_tab_dispose (GObject * object)
+{
+ GtrTab *tab = GTR_TAB(object);
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (GTR_TAB (object));
+
+ if (!priv->dispose_has_run)
+ {
+ save_pane_state (tab);
+ priv->dispose_has_run = TRUE;
+ }
+
+ g_clear_object (&priv->po);
+ g_clear_object (&priv->ui_settings);
+ g_clear_object (&priv->files_settings);
+ g_clear_object (&priv->editor_settings);
+ g_clear_object (&priv->state_settings);
+
+ G_OBJECT_CLASS (gtr_tab_parent_class)->dispose (object);
+}
+
+static void
+gtr_tab_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ GtrTab *tab = GTR_TAB (object);
+
+ switch (prop_id)
+ {
+ case PROP_AUTOSAVE:
+ g_value_set_boolean (value, gtr_tab_get_autosave_enabled (tab));
+ break;
+ case PROP_AUTOSAVE_INTERVAL:
+ g_value_set_int (value, gtr_tab_get_autosave_interval (tab));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtr_tab_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
+{
+ GtrTab *tab = GTR_TAB (object);
+
+ switch (prop_id)
+ {
+ case PROP_AUTOSAVE:
+ gtr_tab_set_autosave_enabled (tab, g_value_get_boolean (value));
+ break;
+ case PROP_AUTOSAVE_INTERVAL:
+ gtr_tab_set_autosave_interval (tab, g_value_get_int (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtr_tab_realize (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (gtr_tab_parent_class)->realize (widget);
+}
+
+static void
+gtr_tab_class_init (GtrTabClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gtr_tab_finalize;
+ object_class->dispose = gtr_tab_dispose;
+ object_class->set_property = gtr_tab_set_property;
+ object_class->get_property = gtr_tab_get_property;
+
+ widget_class->realize = gtr_tab_realize;
+
+ klass->message_edition_finished = gtr_tab_edition_finished;
+
+ /* Signals */
+ signals[SHOWED_MESSAGE] =
+ g_signal_new ("showed-message",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtrTabClass, showed_message),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GTR_TYPE_MSG);
+
+ signals[MESSAGE_CHANGED] =
+ g_signal_new ("message-changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtrTabClass, message_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GTR_TYPE_MSG);
+
+ signals[MESSAGE_EDITION_FINISHED] =
+ g_signal_new ("message-edition-finished",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtrTabClass, message_edition_finished),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GTR_TYPE_MSG);
+ signals[SELECTION_CHANGED] =
+ g_signal_new ("selection-changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtrTabClass, selection_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[SEARCHBAR_TOGGLED] =
+ g_signal_new ("searchbar-toggled",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtrTabClass, searchbar_toggled),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+ /* Properties */
+ g_object_class_install_property (object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ "Name",
+ "The tab's name",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_AUTOSAVE,
+ g_param_spec_boolean ("autosave",
+ "Autosave",
+ "Autosave feature",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_AUTOSAVE_INTERVAL,
+ g_param_spec_int ("autosave-interval",
+ "AutosaveInterval",
+ "Time between two autosaves",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/translator/gtr-tab.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, message_table);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, text_msgid);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, msgid_tags);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, msgid_ctxt);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, text_plural_scroll);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, text_msgid_plural);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, msgstr_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, trans_notebook);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, context);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, hbox);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, vertical_box);
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_eventbox);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_box);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_revealer);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_trans);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_fuzzy);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_untrans);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, progress_percentage);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, overlay);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, search_bar);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, search_revealer);
+ gtk_widget_class_bind_template_callback (widget_class, gtr_page_notify_child_revealed);
+ gtk_widget_class_bind_template_callback (widget_class, gtr_page_stop_search);
+
+ g_type_ensure (gtr_view_get_type ());
+ g_type_ensure (gtr_context_panel_get_type ());
+ g_type_ensure (gtr_message_table_get_type ());
+ g_type_ensure (gtr_search_bar_get_type ());
+}
+
+/***************************** Public funcs ***********************************/
+
+/**
+ * gtr_tab_new:
+ * @po: a #GtrPo
+ * @window: a #GtkWindow
+ *
+ * Creates a new #GtrTab.
+ *
+ * Return value: a new #GtrTab object
+ **/
+GtrTab *
+gtr_tab_new (GtrPo * po,
+ GtkWindow *window)
+{
+ GtrTab *tab;
+ GtrTabPrivate *priv;
+
+ g_return_val_if_fail (po != NULL, NULL);
+
+ tab = g_object_new (GTR_TYPE_TAB, NULL);
+
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_context_init_tm (GTR_CONTEXT_PANEL (priv->context),
+ gtr_window_get_tm (GTR_WINDOW (window)));
+
+ /* FIXME: make the po a property */
+ priv->po = po;
+ g_object_set_data (G_OBJECT (po), GTR_TAB_KEY, tab);
+
+ g_signal_connect (po, "notify::location",
+ G_CALLBACK (on_location_notify), tab);
+
+ g_signal_connect (po, "notify::state",
+ G_CALLBACK (on_state_notify), tab);
+
+ install_autosave_timeout_if_needed (tab);
+
+ /* Now we have to initialize the number of msgstr tabs */
+ gtr_tab_add_msgstr_tabs (tab);
+
+ gtr_message_table_populate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_MESSAGE_CONTAINER (priv->po));
+
+ gtk_widget_show (GTK_WIDGET (tab));
+ return tab;
+}
+
+/**
+ * gtr_tab_get_po:
+ * @tab: a #GtrTab
+ *
+ * Return value: (transfer none): the #GtrPo stored in the #GtrTab
+**/
+GtrPo *
+gtr_tab_get_po (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ return priv->po;
+}
+
+/**
+ * gtr_tab_get_active_trans_tab:
+ * @tab: a #GtranslationTab
+ *
+ * Return value: the number of the active translation notebook.
+ **/
+gint
+gtr_tab_get_active_trans_tab (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ return
+ gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->trans_notebook));
+}
+
+/**
+ * gtr_tab_get_context_panel:
+ * @tab: a #GtrTab
+ *
+ * Return value: (transfer none): the #GtranslaorContextPanel
+ */
+GtrContextPanel *
+gtr_tab_get_context_panel (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ return GTR_CONTEXT_PANEL (priv->context);
+}
+
+/**
+ * gtr_tab_get_active_view:
+ * @tab: a #GtranslationTab
+ *
+ * Return value: (transfer none): the active page of the translation notebook.
+**/
+GtrView *
+gtr_tab_get_active_view (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+ gint num;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ num =
+ gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->trans_notebook));
+ return GTR_VIEW (priv->trans_msgstr[num]);
+}
+
+/**
+ * gtr_tab_get_all_views:
+ * @tab: the #GtranslationTab
+ * @original: TRUE if you want original TextViews.
+ * @translated: TRUE if you want tranlated TextViews.
+ *
+ * Returns all the views currently present in #GtranslationTab
+ *
+ * Returns: (transfer container) (element-type Gtranslator.View):
+ * a newly allocated list of #GtranslationTab objects
+ */
+GList *
+gtr_tab_get_all_views (GtrTab * tab, gboolean original, gboolean translated)
+{
+ GList *ret = NULL;
+ GtrTabPrivate *priv;
+ gint i = 0;
+
+ g_return_val_if_fail (GTR_IS_TAB (tab), NULL);
+
+ priv = gtr_tab_get_instance_private (tab);
+ if (original)
+ {
+ ret = g_list_append (ret, priv->text_msgid);
+ ret = g_list_append (ret, priv->text_msgid_plural);
+ }
+
+ if (translated)
+ {
+ while (i < MAX_PLURALS)
+ {
+ if (priv->trans_msgstr[i])
+ ret = g_list_append (ret, priv->trans_msgstr[i]);
+ else
+ break;
+ i++;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * gtr_tab_message_go_to:
+ * @tab: a #GtrTab
+ * @to_go: the #GtrMsg you want to jump
+ * @searching: TRUE if we are searching in the message list
+ *
+ * Jumps to the specific @to_go pointer message and show the message
+ * in the #GtrView.
+**/
+void
+gtr_tab_message_go_to (GtrTab * tab,
+ GtrMsg * to_go,
+ gboolean searching,
+ GtrTabMove move)
+{
+ static gboolean first_msg = TRUE;
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (tab != NULL);
+ g_return_if_fail (GTR_IS_MSG (to_go));
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (!priv->blocking || first_msg)
+ {
+ gboolean plurals;
+ gint current_page, n_pages;
+ /*
+ * If the current message is plural and we press next/prev
+ * we have to change to the next/prev plural tab in case is not
+ * the last
+ * To implement that:
+ * if the tabs are showed then we check if we want prev or
+ * next and then if we need to change the tab we change it
+ * in other case we show the message
+ *
+ * I don't like too much this implementation so if anybody can
+ * rewrite this is a better way would be great.
+ */
+ plurals =
+ gtk_notebook_get_show_tabs (GTK_NOTEBOOK (priv->trans_notebook));
+ current_page =
+ gtk_notebook_get_current_page (GTK_NOTEBOOK
+ (priv->trans_notebook));
+ n_pages =
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->trans_notebook));
+ if ((plurals == TRUE) && (move != GTR_TAB_MOVE_NONE))
+ {
+ if ((n_pages - 1) == current_page && move == GTR_TAB_MOVE_NEXT)
+ {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (priv->trans_notebook), 0);
+ gtr_tab_show_message (tab, to_go);
+ }
+ else if (current_page == 0 && move == GTR_TAB_MOVE_PREV)
+ {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (priv->trans_notebook),
+ n_pages - 1);
+ gtr_tab_show_message (tab, to_go);
+ }
+ else
+ {
+ if (move == GTR_TAB_MOVE_NEXT)
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (priv->trans_notebook),
+ current_page + 1);
+ else
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (priv->trans_notebook),
+ current_page - 1);
+ return;
+ }
+ }
+ else
+ gtr_tab_show_message (tab, to_go);
+ first_msg = FALSE;
+ }
+ else
+ return;
+
+ /*
+ * Emitting showed-message signal
+ */
+ if (!searching)
+ {
+ g_signal_emit (G_OBJECT (tab), signals[SHOWED_MESSAGE], 0,
+ GTR_MSG (to_go));
+
+ // Grabbing the focus in the GtrView to edit the message
+ // This is done in the idle add to avoid the focus grab from the
+ // message-table
+ g_idle_add((GSourceFunc)msg_grab_focus, tab);
+ }
+}
+
+/**
+ * _gtr_tab_get_name:
+ * @tab: a #GtrTab
+ *
+ * Return value: a new allocated string with the name of the @tab.
+ */
+gchar *
+_gtr_tab_get_name (GtrTab *tab)
+{
+ GtrHeader *header;
+ GtrPoState state;
+ GtrTabPrivate *priv;
+ const gchar *str;
+ gchar *tab_name;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ header = gtr_po_get_header (priv->po);
+ state = gtr_po_get_state (priv->po);
+
+ str = gtr_header_get_prj_id_version (header);
+
+ if (state == GTR_PO_STATE_MODIFIED)
+ {
+ tab_name = g_strdup_printf ("*%s", str);
+ return tab_name;
+ }
+
+ return g_strdup (str);
+}
+
+gchar *
+_gtr_tab_get_tooltips (GtrTab *tab)
+{
+ GFile *location;
+ GtrTabPrivate *priv;
+ gchar *tooltips;
+ gchar *path;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ location = gtr_po_get_location (priv->po);
+ path = g_file_get_path (location);
+ g_object_unref (location);
+
+ /* Translators: Path to the document opened */
+ tooltips = g_strdup_printf ("<b>%s</b> %s", _("Path:"), path);
+ g_free (path);
+
+ return tooltips;
+}
+
+/**
+ * _gtr_tab_can_close:
+ * @tab: a #GtrTab
+ *
+ * Whether a #GtrTab can be closed.
+ *
+ * Returns: TRUE if the #GtrPo of the @tab is already saved
+ */
+gboolean
+_gtr_tab_can_close (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+ return gtr_po_get_state (priv->po) == GTR_PO_STATE_SAVED;
+}
+
+/**
+ * gtr_tab_get_from_document:
+ * @po: a #GtrPo
+ *
+ * Returns the #GtrTab for a specific #GtrPo.
+ *
+ * Returns: (transfer none): the #GtrTab for a specific #GtrPo
+ */
+GtrTab *
+gtr_tab_get_from_document (GtrPo * po)
+{
+ gpointer res;
+
+ g_return_val_if_fail (GTR_IS_PO (po), NULL);
+
+ res = g_object_get_data (G_OBJECT (po), GTR_TAB_KEY);
+
+ return (res != NULL) ? GTR_TAB (res) : NULL;
+}
+
+/**
+ * gtr_tab_get_autosave_enabled:
+ * @tab: a #GtrTab
+ *
+ * Gets the current state for the autosave feature
+ *
+ * Return value: TRUE if the autosave is enabled, else FALSE
+ **/
+gboolean
+gtr_tab_get_autosave_enabled (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ g_return_val_if_fail (GTR_IS_TAB (tab), FALSE);
+
+ priv = gtr_tab_get_instance_private (tab);
+ return priv->autosave;
+}
+
+/**
+ * gtr_tab_set_autosave_enabled:
+ * @tab: a #GtrTab
+ * @enable: enable (TRUE) or disable (FALSE) auto save
+ *
+ * Enables or disables the autosave feature. It does not install an
+ * autosave timeout if the document is new or is read-only
+ **/
+void
+gtr_tab_set_autosave_enabled (GtrTab * tab, gboolean enable)
+{
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (priv->autosave == enable)
+ return;
+
+ priv->autosave = enable;
+
+ if (enable && (priv->autosave_timeout <= 0))
+ {
+ install_autosave_timeout (tab);
+
+ return;
+ }
+
+ if (!enable && (priv->autosave_timeout > 0))
+ {
+ remove_autosave_timeout (tab);
+
+ return;
+ }
+
+ g_return_if_fail (!enable && (priv->autosave_timeout <= 0));
+}
+
+/**
+ * gtr_tab_get_autosave_interval:
+ * @tab: a #GtrTab
+ *
+ * Gets the current interval for the autosaves
+ *
+ * Return value: the value of the autosave
+ **/
+gint
+gtr_tab_get_autosave_interval (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ g_return_val_if_fail (GTR_IS_TAB (tab), 0);
+
+ priv = gtr_tab_get_instance_private (tab);
+ return priv->autosave_interval;
+}
+
+/**
+ * gtr_tab_set_autosave_interval:
+ * @tab: a #GtrTab
+ * @interval: the new interval
+ *
+ * Sets the interval for the autosave feature. It does nothing if the
+ * interval is the same as the one already present. It removes the old
+ * interval timeout and adds a new one with the autosave passed as
+ * argument.
+ **/
+void
+gtr_tab_set_autosave_interval (GtrTab * tab, gint interval)
+{
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+ g_return_if_fail (interval > 0);
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (priv->autosave_interval == interval)
+ return;
+
+ priv->autosave_interval = interval;
+
+ if (!priv->autosave)
+ return;
+
+ if (priv->autosave_timeout > 0)
+ {
+ remove_autosave_timeout (tab);
+
+ install_autosave_timeout (tab);
+ }
+}
+
+/**
+ * gtr_tab_clear_msgstr_views:
+ * @tab: a #GtrTab
+ *
+ * Clears all text from msgstr text views.
+ */
+void
+gtr_tab_clear_msgstr_views (GtrTab * tab)
+{
+ gint i = 0;
+ GtrHeader *header;
+ GtkTextBuffer *buf;
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ header = gtr_po_get_header (priv->po);
+
+ do
+ {
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[i]));
+ gtk_text_buffer_begin_user_action (buf);
+ gtk_text_buffer_set_text (buf, "", -1);
+ gtk_text_buffer_end_user_action (buf);
+ i++;
+ }
+ while (i < gtr_header_get_nplurals (header));
+}
+
+/**
+ * gtr_tab_copy_to_translation:
+ * @tab: a #GtrTab
+ *
+ * Copies the text from the original text box to the translation text box.
+ */
+void
+gtr_tab_copy_to_translation (GtrTab * tab)
+{
+ GtkTextBuffer *msgstr, *msgid;
+ gint page_index;
+ gchar *text;
+ GtkTextIter start, end;
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ page_index = gtr_tab_get_active_trans_tab (tab);
+
+ msgstr =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW
+ (priv->trans_msgstr[page_index]));
+ msgid = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->text_msgid));
+
+ gtk_text_buffer_begin_user_action (msgstr);
+ gtk_text_buffer_get_bounds (msgid, &start, &end);
+ text = gtk_text_buffer_get_text (msgid, &start, &end, FALSE);
+ gtk_text_buffer_set_text (msgstr, text, -1);
+ g_free (text);
+ gtk_text_buffer_end_user_action (msgstr);
+}
+
+/**
+ * gtr_tab_block_movement:
+ * @tab: a #GtrTab
+ *
+ * Blocks the movement to the next/prev message.
+ */
+void
+gtr_tab_block_movement (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ priv = gtr_tab_get_instance_private (tab);
+ priv->blocking = TRUE;
+}
+
+/**
+ * gtr_tab_unblock_movement:
+ * @tab: a #GtrTab
+ *
+ * Unblocks the movement to the next/prev message.
+ */
+void
+gtr_tab_unblock_movement (GtrTab * tab)
+{
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ priv = gtr_tab_get_instance_private (tab);
+ priv->blocking = FALSE;
+}
+
+static gboolean
+_gtr_tab_finish_edition (GtrTab * tab)
+{
+ GList *current_msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ current_msg = gtr_po_get_current_message (priv->po);
+
+ /* movement is blocked/unblocked within the handler */
+ g_signal_emit (G_OBJECT (tab), signals[MESSAGE_EDITION_FINISHED],
+ 0, GTR_MSG (current_msg->data));
+
+ return !priv->blocking;
+}
+
+/**
+ * gtr_tab_go_to_next:
+ * @tab: a #GtrTab
+ *
+ * Moves to the next message or plural tab in case the message has plurals.
+ */
+void
+gtr_tab_go_to_next (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (_gtr_tab_finish_edition (tab))
+ {
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_NEXT, NULL);
+ if (msg)
+ gtr_tab_message_go_to (tab, msg,
+ FALSE, GTR_TAB_MOVE_NEXT);
+ }
+}
+
+/**
+ * gtr_tab_go_to_prev:
+ * @tab: a #GtrTab
+ *
+ * Moves to the previous message or plural tab in case the message has plurals.
+ */
+void
+gtr_tab_go_to_prev (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (_gtr_tab_finish_edition (tab))
+ {
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_PREV, NULL);
+ if (msg)
+ gtr_tab_message_go_to (tab, msg,
+ FALSE, GTR_TAB_MOVE_PREV);
+ }
+}
+
+/**
+ * gtr_tab_go_to_first:
+ * @tab: a #GtrTab
+ *
+ * Jumps to the first message.
+ */
+void
+gtr_tab_go_to_first (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (_gtr_tab_finish_edition (tab))
+ {
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_FIRST, NULL);
+ if (msg)
+ gtr_tab_message_go_to (tab, msg,
+ FALSE, GTR_TAB_MOVE_NONE);
+ }
+}
+
+/**
+ * gtr_tab_go_to_last:
+ * @tab: a #GtrTab
+ *
+ * Jumps to the last message.
+ */
+void
+gtr_tab_go_to_last (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (_gtr_tab_finish_edition (tab))
+ {
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_LAST, NULL);
+ if (msg)
+ gtr_tab_message_go_to (tab, msg,
+ FALSE, GTR_TAB_MOVE_NONE);
+ }
+}
+
+/**
+ * gtr_tab_go_to_next_fuzzy:
+ * @tab: a #GtrTab
+ *
+ * If there is a next fuzzy message it jumps to it.
+ *
+ * Returns: TRUE if there is a next fuzzy message.
+ */
+gboolean
+gtr_tab_go_to_next_fuzzy (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (!_gtr_tab_finish_edition (tab))
+ return FALSE;
+
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_NEXT,
+ gtr_msg_is_fuzzy);
+ if (msg != NULL)
+ {
+ gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * gtr_tab_go_to_prev_fuzzy:
+ * @tab: a #GtrTab
+ *
+ * If there is a prev fuzzy message it jumps to it.
+ *
+ * Returns: TRUE if there is a prev fuzzy message.
+ */
+gboolean
+gtr_tab_go_to_prev_fuzzy (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (!_gtr_tab_finish_edition (tab))
+ return FALSE;
+
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_PREV,
+ gtr_msg_is_fuzzy);
+ if (msg != NULL)
+ {
+ gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+message_is_untranslated (GtrMsg * msg)
+{
+ return !gtr_msg_is_translated (msg);
+}
+
+static gboolean
+message_is_fuzzy_or_untranslated (GtrMsg * msg)
+{
+ return gtr_msg_is_fuzzy (msg) || !gtr_msg_is_translated (msg);
+}
+
+/**
+ * gtr_tab_go_to_next_untrans:
+ * @tab: a #GtrTab
+ *
+ * If there is a next untranslated message it jumps to it.
+ *
+ * Returns: TRUE if there is a next untranslated message.
+ */
+gboolean
+gtr_tab_go_to_next_untrans (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (!_gtr_tab_finish_edition (tab))
+ return FALSE;
+
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_NEXT,
+ message_is_untranslated);
+ if (msg != NULL)
+ {
+ gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * gtr_tab_go_to_prev_untrans:
+ * @tab: a #GtrTab
+ *
+ * If there is a prev untranslated message it jumps to it.
+ *
+ * Returns: TRUE if there is a prev untranslated message.
+ */
+gboolean
+gtr_tab_go_to_prev_untrans (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (!_gtr_tab_finish_edition (tab))
+ return FALSE;
+
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_PREV,
+ message_is_untranslated);
+ if (msg != NULL)
+ {
+ gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * gtr_tab_go_to_next_fuzzy_or_untrans:
+ * @tab: a #GtrTab
+ *
+ * If there is a next fuzzy or untranslated message it jumps to it.
+ *
+ * Returns: TRUE if there is a next fuzzy or untranslated message.
+ */
+gboolean
+gtr_tab_go_to_next_fuzzy_or_untrans (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (!_gtr_tab_finish_edition (tab))
+ return FALSE;
+
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_NEXT,
+ message_is_fuzzy_or_untranslated);
+ if (msg != NULL)
+ {
+ gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * gtr_tab_go_to_prev_fuzzy_or_untrans:
+ * @tab: a #GtrTab
+ *
+ * If there is a prev fuzzy or untranslated message it jumps to it.
+ *
+ * Returns: TRUE if there is a prev fuzzy or untranslated message.
+ */
+gboolean
+gtr_tab_go_to_prev_fuzzy_or_untrans (GtrTab * tab)
+{
+ GtrMsg *msg;
+ GtrTabPrivate *priv;
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (!_gtr_tab_finish_edition (tab))
+ return FALSE;
+
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (priv->message_table),
+ GTR_NAVIGATE_PREV,
+ message_is_fuzzy_or_untranslated);
+ if (msg != NULL)
+ {
+ gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * gtr_tab_go_to_number:
+ * @tab: a #GtrTab
+ * @number: the message number you want to jump
+ *
+ * Jumps to the message with the @number in the list, if the message does not
+ * exists it does not jump.
+ */
+void
+gtr_tab_go_to_number (GtrTab * tab, gint number)
+{
+ GtrPo *po;
+ GList *msg;
+
+ if (!_gtr_tab_finish_edition (tab))
+ return;
+
+ po = gtr_tab_get_po (tab);
+ msg = gtr_po_get_msg_from_number (po, number);
+ if (msg != NULL)
+ {
+ gtr_tab_message_go_to (tab, msg->data, FALSE, GTR_TAB_MOVE_NONE);
+ }
+}
+
+/**
+ * gtr_tab_set_info_bar:
+ * @tab: a #GtrTab
+ * @infobar: a #GtrMessageArea
+ *
+ * Sets the @infobar to be shown in the @tab.
+ */
+void
+gtr_tab_set_info_bar (GtrTab * tab, GtkWidget * infobar)
+{
+ GtrTabPrivate *priv;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ priv = gtr_tab_get_instance_private (tab);
+
+ if (priv->infobar == infobar)
+ return;
+
+ if (priv->infobar != NULL)
+ gtk_widget_destroy (priv->infobar);
+
+ priv->infobar = infobar;
+
+ if (infobar == NULL)
+ return;
+
+ gtk_box_append (GTK_BOX (tab), priv->infobar);
+
+ g_object_add_weak_pointer (G_OBJECT (priv->infobar),
+ (gpointer *) & priv->infobar);
+}
+
+/**
+ * gtr_tab_set_info:
+ * @tab: a #GtrTab
+ * @info: a string to show
+ *
+ * Sets the @info to be shown in the @infobar.
+ */
+void
+gtr_tab_set_info (GtrTab * tab,
+ const char * primary,
+ const char * secondary)
+{
+ GtkWidget *infobar;
+ infobar = create_info_info_bar (primary, secondary);
+ gtr_tab_set_info_bar (tab, infobar);
+}
+
+GtrMsg *
+gtr_tab_get_msg (GtrTab *tab)
+{
+ GtrTabPrivate *priv;
+ GList *msg_aux;
+ GtrMsg *msg;
+
+ priv = gtr_tab_get_instance_private (tab);
+ msg_aux = gtr_po_get_current_message (priv->po);
+ msg = msg_aux->data;
+
+ return msg;
+}
+
+void
+gtr_tab_set_progress (GtrTab *tab,
+ gint trans,
+ gint untrans,
+ gint fuzzy)
+{
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
+ gchar *percentage, *trans_text, *fuzzy_text, *untrans_text;
+
+ gtr_progress_set (priv->progress, trans, untrans, fuzzy);
+
+ percentage = g_strdup_printf (_("Translated: %0.2f%%"), (float)trans * 100 / (float)(trans + untrans +
fuzzy));
+ trans_text = g_strdup_printf (_("Translated: %d"), trans);
+ untrans_text = g_strdup_printf (_("Untranslated: %d"), untrans);
+ fuzzy_text = g_strdup_printf (_("Fuzzy: %d"), fuzzy);
+
+ gtk_label_set_text (GTK_LABEL (priv->progress_percentage), percentage);
+ gtk_label_set_text (GTK_LABEL (priv->progress_fuzzy), fuzzy_text);
+ gtk_label_set_text (GTK_LABEL (priv->progress_untrans), untrans_text);
+ gtk_label_set_text (GTK_LABEL (priv->progress_trans), trans_text);
+
+ g_free (percentage);
+ g_free (trans_text);
+ g_free (fuzzy_text);
+ g_free (untrans_text);
+}
+
+void
+gtr_tab_sort_by (GtrTab *tab,
+ GtrMessageTableSortBy sort)
+{
+ GtrTabPrivate *priv;
+ priv = gtr_tab_get_instance_private (tab);
+ gtr_message_table_sort_by (GTR_MESSAGE_TABLE (priv->message_table), sort);
+}
+
+void
+gtr_tab_find_replace (GtrTab *tab,
+ gboolean set)
+{
+ GtrTabPrivate *priv;
+ priv = gtr_tab_get_instance_private (tab);
+ priv->find_replace_flag = set;
+}
+
diff --git a/src/gtr-tab-old.h b/src/gtr-tab-old.h
new file mode 100644
index 00000000..22371636
--- /dev/null
+++ b/src/gtr-tab-old.h
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa 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:
+ * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Pablo Sanxiao <psanxiao gmail com>
+ */
+
+#ifndef __TAB_H__
+#define __TAB_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtr-context.h"
+#include "gtr-msg.h"
+#include "gtr-po.h"
+#include "gtr-view.h"
+#include "gtr-message-table-model.h"
+#include "gtr-search-bar.h"
+
+G_BEGIN_DECLS
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_TAB (gtr_tab_get_type ())
+#define GTR_TAB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_TAB, GtrTab))
+#define GTR_TAB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_TAB, GtrTabClass))
+#define GTR_IS_TAB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_TAB))
+#define GTR_IS_TAB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_TAB))
+#define GTR_TAB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_TAB, GtrTabClass))
+
+/*
+ * Main object structure
+ */
+typedef struct _GtrTab GtrTab;
+
+struct _GtrTab
+{
+ GtkBox parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtrTabClass GtrTabClass;
+
+struct _GtrTabClass
+{
+ GtkBoxClass parent_class;
+
+ void (*showed_message) (GtrTab * tab, GtrMsg * msg);
+ void (*message_changed) (GtrTab * tab, GtrMsg * msg);
+ void (*message_edition_finished) (GtrTab * tab, GtrMsg * msg);
+ void (*selection_changed) (GtrTab * tab);
+ void (*searchbar_toggled) (GtrTab * tab, gboolean revealed);
+};
+
+typedef enum
+{
+ GTR_TAB_MOVE_NONE,
+ GTR_TAB_MOVE_NEXT,
+ GTR_TAB_MOVE_PREV
+} GtrTabMove;
+
+typedef enum
+{
+ GTR_TAB_PLACEMENT_NONE = 0,
+ GTR_TAB_PLACEMENT_TOP,
+ GTR_TAB_PLACEMENT_BOTTOM,
+ GTR_TAB_PLACEMENT_RIGHT,
+ GTR_TAB_PLACEMENT_LEFT,
+ GTR_TAB_PLACEMENT_CENTER,
+ GTR_TAB_PLACEMENT_FLOATING
+} GtrTabPlacement;
+
+/*
+ * Public methods
+ */
+GType gtr_tab_get_type (void) G_GNUC_CONST;
+
+GtrTab *gtr_tab_new (GtrPo * po, GtkWindow *window);
+
+GtrPo *gtr_tab_get_po (GtrTab * tab);
+
+gint gtr_tab_get_active_trans_tab (GtrTab * tab);
+
+GtrContextPanel *gtr_tab_get_context_panel (GtrTab * tab);
+
+GtrView *gtr_tab_get_active_view (GtrTab * tab);
+
+GList *gtr_tab_get_all_views (GtrTab * tab,
+ gboolean original, gboolean translated);
+
+void gtr_tab_message_go_to (GtrTab * tab,
+ GtrMsg * to_go,
+ gboolean searching, GtrTabMove move);
+
+GtrTab *gtr_tab_get_from_document (GtrPo * po);
+
+gboolean gtr_tab_get_autosave_enabled (GtrTab * tab);
+
+void gtr_tab_set_autosave_enabled (GtrTab * tab, gboolean enable);
+
+gint gtr_tab_get_autosave_interval (GtrTab * tab);
+
+void gtr_tab_set_autosave_interval (GtrTab * tab, gint interval);
+
+void gtr_tab_clear_msgstr_views (GtrTab * tab);
+
+void gtr_tab_copy_to_translation (GtrTab * tab);
+
+void gtr_tab_block_movement (GtrTab * tab);
+
+void gtr_tab_unblock_movement (GtrTab * tab);
+
+void gtr_tab_go_to_next (GtrTab * tab);
+
+void gtr_tab_go_to_prev (GtrTab * tab);
+
+void gtr_tab_go_to_first (GtrTab * tab);
+
+void gtr_tab_go_to_last (GtrTab * tab);
+
+gboolean gtr_tab_go_to_next_fuzzy (GtrTab * tab);
+
+gboolean gtr_tab_go_to_prev_fuzzy (GtrTab * tab);
+
+gboolean gtr_tab_go_to_next_untrans (GtrTab * tab);
+
+gboolean gtr_tab_go_to_prev_untrans (GtrTab * tab);
+
+gboolean gtr_tab_go_to_next_fuzzy_or_untrans (GtrTab * tab);
+
+gboolean gtr_tab_go_to_prev_fuzzy_or_untrans (GtrTab * tab);
+
+void gtr_tab_go_to_number (GtrTab * tab, gint number);
+
+void gtr_tab_set_info_bar (GtrTab * tab, GtkWidget * infobar);
+
+void gtr_tab_set_info (GtrTab * tab, const char * primary, const char * secondary);
+
+GtrMsg * gtr_tab_get_msg (GtrTab *tab);
+
+void gtr_tab_set_progress (GtrTab *tab, gint trans, gint untrans, gint fuzzy);
+
+void gtr_tab_sort_by (GtrTab *tab, GtrMessageTableSortBy sort);
+
+void gtr_tab_find_replace (GtrTab *tab, gboolean set);
+
+void gtr_tab_focus_search_bar (GtrTab *tab);
+void gtr_tab_show_hide_search_bar (GtrTab * tab, gboolean show);
+void gtr_tab_find_next (GtrTab * tab);
+void gtr_tab_find_prev (GtrTab * tab);
+void gtr_tab_find_set_replace (GtrTab * tab, gboolean replace);
+
+/* Semi-public methods */
+
+gchar *_gtr_tab_get_name (GtrTab * tab);
+
+gchar *_gtr_tab_get_tooltips (GtrTab *tab);
+
+gboolean _gtr_tab_can_close (GtrTab * tab);
+
+G_END_DECLS
+
+#endif /* __TAB_H__ */
diff --git a/src/gtr-tab-old.ui b/src/gtr-tab-old.ui
new file mode 100644
index 00000000..d24ad33f
--- /dev/null
+++ b/src/gtr-tab-old.ui
@@ -0,0 +1,315 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.15.3 on Wed Sep 4 22:17:30 2013 -->
+<interface>
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="GtrTab" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkOverlay" id="overlay">
+ <property name="visible">True</property>
+ <property name="expand">True</property>
+ <child type="overlay">
+ <object class="GtkRevealer" id="search_revealer">
+ <property name="width-request">525</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="margin-end">12</property>
+ <property name="reveal-child">false</property>
+ <property name="visible">True</property>
+ <signal name="notify::child-revealed" handler="gtr_page_notify_child_revealed" swapped="true"
object="GtrTab"/>
+ <child>
+ <object class="GtrSearchBar" id="search_bar">
+ <property name="visible">True</property>
+ <signal name="stop-search" handler="gtr_page_stop_search" swapped="true" object="GtrTab"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPaned" id="hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="wide_handle">True</property>
+ <child>
+ <object class="GtkPaned" id="vertical_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="width_request">450</property>
+ <property name="wide_handle">True</property>
+ <child>
+ <object class="GtrMessageTable" id="message_table">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tab">GtrTab</property>
+ <property name="height_request">350</property>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="translation_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="text_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="text_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel" id="msgid_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="ypad">5</property>
+ <property name="label" translatable="yes">_Original Message</property>
+ <property name="use_underline">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="msgid_ctxt">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="no"></property>
+ <property name="use_underline">True</property>
+ <property name="ellipsize">end</property>
+ <style>
+ <class name="msgcontext"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="msgid_tags">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label"></property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ <style>
+ <class name="msgtags"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="text_msgid_scroll">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtrView" id="text_msgid">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="text_plural_scroll">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtrView" id="text_msgid_plural">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="msgstr_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="ypad">5</property>
+ <property name="label" translatable="yes">Translate_d Text</property>
+ <property name="use_underline">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="trans_notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_border">False</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtrContextPanel" id="context">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tab">GtrTab</property>
+ <property name="width_request">150</property>
+ </object>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child >
+ <object class="GtkEventBox" id="progress_eventbox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkBox" id="progress_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkRevealer" id="progress_revealer">
+ <property name="visible">True</property>
+ <property name="reveal_child">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">horizontal</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="progress_percentage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">translated: 0.00%</property>
+ <property name="xalign">0.5</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="progress_trans">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">Translated: 0</property>
+ <property name="xalign">0.5</property>
+ <style>
+ <class name="progress_trans"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="progress_fuzzy">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">fuzzy: 0</property>
+ <property name="xalign">0.5</property>
+ <style>
+ <class name="progress_fuzzy"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="progress_untrans">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">untranslated: 0</property>
+ <property name="xalign">0.5</property>
+ <style>
+ <class name="progress_untranslated"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index 6bd201a7..b7ab2e8a 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -127,6 +127,17 @@ typedef struct
GtrSearchBar *search_bar;
GtkSearchEntry *search;
+ /* notebook code */
+ GtkWidget *titlebar;
+ GtkWidget *save;
+ GtkWidget *sort_id;
+ GtkWidget *order_menu_popover;
+ GtkWidget *search_toggle;
+ GtkWidget *upload;
+
+ GtkWidget *undo;
+ GtkWidget *redo;
+
} GtrTabPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GtrTab, gtr_tab, GTK_TYPE_BOX)
@@ -460,27 +471,24 @@ gtr_tab_append_msgstr_page (const gchar * tab_label,
{
GtkWidget *scroll;
GtkWidget *label;
- GtkWidget *widget;
- GtrTabPrivate *priv;
+ GtkWidget *view;
label = gtk_label_new (tab_label);
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scroll);
- widget = gtr_view_new ();
- gtk_widget_show (widget);
+ view = gtr_view_new ();
+ gtk_widget_show (view);
- priv = gtr_tab_get_instance_private (tab);
-
- gtk_container_add (GTK_CONTAINER (scroll), widget);
+ gtk_container_add (GTK_CONTAINER (scroll), view);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
GTK_SHADOW_IN);
gtk_notebook_append_page (GTK_NOTEBOOK (box), scroll, label);
- return widget;
+ return view;
}
static void
@@ -725,7 +733,6 @@ gtr_tab_add_msgstr_tabs (GtrTab * tab)
do
{
-
label = g_strdup_printf (_("Plural %d"), i);
priv->trans_msgstr[i] = gtr_tab_append_msgstr_page (label,
priv->trans_notebook,
@@ -1029,6 +1036,16 @@ gtr_tab_class_init (GtrTabClass * klass)
gtk_widget_class_bind_template_child_private (widget_class, GtrTab, overlay);
gtk_widget_class_bind_template_child_private (widget_class, GtrTab, search_bar);
gtk_widget_class_bind_template_child_private (widget_class, GtrTab, search_revealer);
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, titlebar);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, sort_id);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, order_menu_popover);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, search_toggle);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, undo);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, redo);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, save);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrTab, upload);
+
gtk_widget_class_bind_template_callback (widget_class, gtr_page_notify_child_revealed);
gtk_widget_class_bind_template_callback (widget_class, gtr_page_stop_search);
@@ -1040,6 +1057,66 @@ gtr_tab_class_init (GtrTabClass * klass)
/***************************** Public funcs ***********************************/
+void
+gtr_tab_hide_sort_menu (GtrTab *tab)
+{
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
+
+ if (priv->sort_id)
+ gtk_popover_popdown (GTK_POPOVER (priv->order_menu_popover));
+}
+
+void
+gtr_tab_enable_find_button (GtrTab *tab,
+ gboolean enable)
+{
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
+
+ if (priv->search_toggle)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search_toggle), enable);
+}
+
+void
+gtr_tab_enable_save (GtrTab *tab,
+ gboolean enable)
+{
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
+ gtk_widget_set_sensitive (priv->save, enable);
+}
+
+void
+gtr_tab_update_undo_buttons (GtrTab *tab,
+ GtrView *view)
+{
+ GtkSourceBuffer *active_document;
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
+ gboolean can_undo, can_redo;
+ g_return_if_fail (view);
+
+ active_document =
+ GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ can_undo = gtk_source_buffer_can_undo (active_document);
+ can_redo = gtk_source_buffer_can_redo (active_document);
+
+ gtk_widget_set_sensitive (priv->undo, can_undo);
+ gtk_widget_set_sensitive (priv->redo, can_redo);
+}
+
+void
+gtr_tab_enable_upload (GtrTab *tab, gboolean enable)
+{
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
+ gtk_widget_set_sensitive (priv->upload, enable);
+}
+
+GtkWidget *
+gtr_tab_get_header (GtrTab *tab)
+{
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
+ return priv->titlebar;
+}
+
/**
* gtr_tab_new:
* @po: a #GtrPo
diff --git a/src/gtr-tab.h b/src/gtr-tab.h
index 22371636..94ca9994 100644
--- a/src/gtr-tab.h
+++ b/src/gtr-tab.h
@@ -169,6 +169,15 @@ void gtr_tab_find_next (GtrTab * tab);
void gtr_tab_find_prev (GtrTab * tab);
void gtr_tab_find_set_replace (GtrTab * tab, gboolean replace);
+/* notebook */
+void gtr_tab_enable_save (GtrTab *tab, gboolean enable);
+void gtr_tab_enable_upload (GtrTab *tab, gboolean enable);
+void gtr_tab_update_undo_buttons (GtrTab *tab, GtrView *view);
+GtkWidget *
+gtr_tab_get_header (GtrTab *tab);
+void gtr_tab_enable_find_button (GtrTab *tab, gboolean enable);
+void gtr_tab_hide_sort_menu (GtrTab *tab);
+
/* Semi-public methods */
gchar *_gtr_tab_get_name (GtrTab * tab);
diff --git a/src/gtr-tab.ui b/src/gtr-tab.ui
index d24ad33f..00a91ddc 100644
--- a/src/gtr-tab.ui
+++ b/src/gtr-tab.ui
@@ -312,4 +312,503 @@
</packing>
</child>
</template>
+
+ <object class="GtkPopoverMenu" id="order_menu_popover">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">vertical</property>
+
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Order messages by</property>
+ <property name="xalign">0.5</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkRadioButton" id="sort_id">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.sort_by_id</property>
+ <property name="label" translatable="yes">Appearance in the original file</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="sort_status">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.sort_by_status</property>
+ <property name="label" translatable="yes">Message status</property>
+ <property name="group">sort_id</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="sort_msgid">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.sort_by_msgid</property>
+ <property name="label" translatable="yes">Original message</property>
+ <property name="group">sort_id</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="sort_translated">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.sort_by_translated</property>
+ <property name="label" translatable="yes">Translated message</property>
+ <property name="group">sort_id</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="submenu">main</property>
+ </packing>
+ </child>
+ </object>
+
+ <object class="GtkPopoverMenu" id="main_menu_popover">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkModelButton" id="find">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.find</property>
+ <property name="text" translatable="yes">Find</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="find_and_replace">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.find_and_replace</property>
+ <property name="text" translatable="yes">Find and replace</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="translation_memory">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.build_tm</property>
+ <property name="text" translatable="yes">Build translation memory</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkModelButton" id="edit_header">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.edit_header</property>
+ <property name="text" translatable="yes">Edit header</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="new_win">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.new_window</property>
+ <property name="text" translatable="yes">New window</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="pref_button1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.preferences</property>
+ <property name="text" translatable="yes">Preferences</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="pref_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.shortcuts</property>
+ <property name="text" translatable="yes">Keyboard Shortcuts</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="about_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.about</property>
+ <property name="text" translatable="yes">About</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="help_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.help</property>
+ <property name="text" translatable="yes">Help</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="quit">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="action_name">app.quit</property>
+ <property name="text" translatable="yes">Quit</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="submenu">main</property>
+ </packing>
+ </child>
+ </object>
+
+ <object class="GtkHeaderBar" id="titlebar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Translation Editor</property>
+ <property name="show_close_button">True</property>
+
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="open_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Open a new file (<Ctrl>o)</property>
+ <property name="action_name">app.open</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">document-open-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="dl_button">
+ <property name="visible">True</property>
+ <property name="tooltip_text" translatable="yes">Open from Damned Lies (<Ctrl>d)</property>
+ <property name="action_name">app.dl</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="icon_name">folder-download-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="undo">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Undo (<Ctrl>z)</property>
+ <property name="action_name">app.undo</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-undo-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="redo">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Redo (<Ctrl><Shift>z)</property>
+ <property name="action_name">app.redo</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-redo-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="prev_untranslated">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Previous message without translation
(<Alt><Page Up>)</property>
+ <property name="action_name">app.prev_no</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">go-up-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="next_untranslated">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Next message without translation
(<Alt><Page Down>)</property>
+ <property name="action_name">app.next_no</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">go-down-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Toggle fuzzy state (<Ctrl>+u)</property>
+ <property name="action_name">app.fuzzy</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">weather-fog-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkMenuButton" id="sortby_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="popover">order_menu_popover</property>
+ <property name="tooltip_text" translatable="yes">Sort messages by</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">view-sort-ascending-symbolic</property>
+ </object>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="sortby_menu-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes">Order by menu</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkMenuButton" id="main_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="popover">main_menu_popover</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">open-menu-symbolic</property>
+ </object>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="main_menu-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes">Main Menu</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="search_toggle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Find (<Ctrl><f>)</property>
+ <property name="action_name">app.findtoggle</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-find-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="save">
+ <property name="label" translatable="yes">Save</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Save the current file (<Ctrl>s)</property>
+ <property name="action_name">app.save</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Save as (<Ctrl><Shift>s)</property>
+ <property name="action_name">app.saveas</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">document-save-as-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="upload">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Upload file (<Ctrl>b)</property>
+ <property name="action_name">app.upload_file</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">document-send-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+
+ <style>
+ <class name="titlebar"/>
+ </style>
+ </object>
+
</interface>
diff --git a/src/gtr-window-old.c b/src/gtr-window-old.c
new file mode 100644
index 00000000..c32df050
--- /dev/null
+++ b/src/gtr-window-old.c
@@ -0,0 +1,964 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa 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:
+ * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Pablo Sanxiao <psanxiao gmail com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gtr-actions.h"
+#include "gtr-application.h"
+#include "gtr-debug.h"
+#include "gtr-dirs.h"
+#include "gtr-header.h"
+#include "gtr-msg.h"
+// #include "gtr-notebook.h"
+// #include "gtr-tab.h"
+#include "gtr-po.h"
+#include "gtr-projects.h"
+#include "gtr-dl-teams.h"
+#include "gtr-settings.h"
+#include "gtr-utils.h"
+#include "gtr-window.h"
+#include "gtr-window-activatable.h"
+#include "gtr-profile-manager.h"
+#include "gtr-poeditor.h"
+
+#include "translation-memory/gtr-translation-memory.h"
+#include "translation-memory/gtr-translation-memory-dialog.h"
+#include "translation-memory/gda/gtr-gda.h"
+
+#include "codeview/gtr-codeview.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gtksourceview/gtksource.h>
+
+#define GTR_STOCK_FUZZY_NEXT "gtranslator-fuzzy-next"
+#define GTR_STOCK_FUZZY_PREV "gtranslator-fuzzy-prev"
+#define GTR_STOCK_UNTRANS_NEXT "gtranslator-untranslated-next"
+#define GTR_STOCK_UNTRANS_PREV "gtranslator-untranslated-prev"
+#define GTR_STOCK_FUZZY_UNTRANS_NEXT "gtranslator-fuzzy-untranslated-next"
+#define GTR_STOCK_FUZZY_UNTRANS_PREV "gtranslator-fuzzy-untranslated-prev"
+
+#define PROFILE_DATA "GtrWidnowProfileData"
+
+typedef struct
+{
+ GSettings *state_settings;
+ GSettings *tm_settings;
+ GtrTranslationMemory *translation_memory;
+
+ GtrCodeView *codeview;
+
+ GtkWidget *header_bar;
+ GtkWidget *main_box;
+
+ GtkWidget *header_stack;
+ GtkWidget *stack;
+
+ GtkWidget *projects;
+ GtkWidget *notebook;
+ GtkWidget *dlteams;
+
+ GtrTab *active_tab;
+
+ gint width;
+ gint height;
+ GdkWindowState window_state;
+
+ GtrProfileManager *prof_manager;
+
+ gboolean search_bar_shown;
+
+ guint dispose_has_run : 1;
+} GtrWindowPrivate;
+
+G_DEFINE_FINAL_TYPE_WITH_PRIVATE(GtrWindow, gtr_window, GTK_TYPE_APPLICATION_WINDOW)
+
+enum
+{
+ TARGET_URI_LIST = 100
+};
+
+static void update_saved_state (GtrPo *po, GParamSpec *param, gpointer window);
+
+static void
+free_match (gpointer data)
+{
+ GtrTranslationMemoryMatch *match = (GtrTranslationMemoryMatch *) data;
+
+ g_free (match->match);
+ g_slice_free (GtrTranslationMemoryMatch, match);
+}
+
+static void
+update_undo_state (GtrTab *tab,
+ GtrMsg *msg,
+ GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ GtrView *active_view = gtr_window_get_active_view (window);
+ gtr_notebook_update_undo_buttons (GTR_NOTEBOOK (priv->notebook), active_view);
+}
+
+/*
+ * gtr_window_update_statusbar_message_count:
+ *
+ * This func is used to show the global status of the message list
+ * in the statusbar widget.
+ */
+static void
+gtr_window_update_statusbar_message_count (GtrTab * tab,
+ GtrMsg * message,
+ GtrWindow * window)
+{
+ GtrTab *active_tab;
+ GtrPo *po;
+ gint translated, fuzzy, untranslated;
+
+ g_return_if_fail (GTR_IS_MSG (message));
+
+ po = gtr_tab_get_po (tab);
+
+ translated = gtr_po_get_translated_count (po);
+ fuzzy = gtr_po_get_fuzzy_count (po);
+ untranslated = gtr_po_get_untranslated_count (po);
+
+ active_tab = gtr_window_get_active_tab (window);
+ gtr_tab_set_progress (GTR_TAB (active_tab),
+ translated, untranslated, fuzzy);
+}
+
+static GtrWindow *
+get_drop_window (GtkWidget * widget)
+{
+ GtkWidget *target_window;
+
+ target_window = gtk_widget_get_toplevel (widget);
+ g_return_val_if_fail (GTR_IS_WINDOW (target_window), NULL);
+
+ return GTR_WINDOW (target_window);
+}
+
+/* Handle drops on the GtrWindow */
+static void
+drag_data_received_cb (GtkWidget * widget,
+ GdkDragContext * context,
+ gint x,
+ gint y,
+ GtkSelectionData * selection_data,
+ guint info, guint time, gpointer data)
+{
+ GtrWindow *window;
+ GSList *locations;
+
+ window = get_drop_window (widget);
+
+ if (window == NULL)
+ return;
+
+ if (info == TARGET_URI_LIST)
+ {
+ locations = gtr_utils_drop_get_locations (selection_data);
+ gtr_actions_load_locations (window, locations);
+
+ g_slist_free_full (locations, g_object_unref);
+ }
+}
+
+static void
+set_window_title (GtrWindow * window, gboolean with_path)
+{
+ GtrPo *po;
+ GtrPoState state;
+ GtrTab *active_tab;
+ GFile *file;
+ gchar *title;
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ GtkHeaderBar *header;
+
+ if (with_path)
+ {
+ gchar *basename;
+
+ active_tab = gtr_window_get_active_tab (window);
+ po = gtr_tab_get_po (active_tab);
+ state = gtr_po_get_state (gtr_tab_get_po (active_tab));
+ po = gtr_tab_get_po (active_tab);
+ file = gtr_po_get_location (po);
+ basename = g_file_get_basename (file);
+
+ if (state == GTR_PO_STATE_MODIFIED)
+ {
+ /* Translators: this is the title of the window with a modified document */
+ title = g_strdup_printf (_("*%s — Translation Editor"), basename);
+ gtr_notebook_enable_save (GTR_NOTEBOOK (priv->notebook), TRUE);
+ }
+ else
+ {
+ /* Translators: this is the title of the window with a document opened */
+ title = g_strdup_printf (_("%s — Translation Editor"), basename);
+ gtr_notebook_enable_save (GTR_NOTEBOOK (priv->notebook), FALSE);
+ }
+
+ g_free (basename);
+ g_object_unref (file);
+ }
+ else
+ {
+ title = g_strdup (_("Translation Editor"));
+ }
+
+ gtk_window_set_title (GTK_WINDOW (window), title);
+
+ // notebook headerbar
+ header = GTK_HEADER_BAR (gtr_notebook_get_header (GTR_NOTEBOOK (priv->notebook)));
+ gtk_header_bar_set_title (header, title);
+
+ g_free (title);
+}
+
+static void
+update_saved_state (GtrPo *po,
+ GParamSpec *param,
+ gpointer window)
+{
+ GtrNotebook *active_notebook;
+ active_notebook = gtr_window_get_notebook (window);
+ set_window_title (GTR_WINDOW (window), TRUE);
+ gtr_notebook_enable_upload (active_notebook, gtr_po_can_dl_upload (po));
+}
+
+static void
+notebook_switch_page (GtkNotebook * nb,
+ GtkWidget * page,
+ gint page_num, GtrWindow * window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ GtrTab *tab;
+ GList *msg;
+ GtrPo *po;
+ gint n_pages;
+
+ tab = GTR_TAB (gtk_notebook_get_nth_page (nb, page_num));
+ if (tab == priv->active_tab)
+ return;
+
+ /*
+ * Set the window title
+ */
+ n_pages = gtk_notebook_get_n_pages (nb);
+ if (n_pages == 1)
+ set_window_title (window, TRUE);
+ else
+ set_window_title (window, FALSE);
+
+ priv->active_tab = tab;
+
+ po = gtr_tab_get_po (tab);
+ msg = gtr_po_get_current_message (po);
+ gtr_window_update_statusbar_message_count (tab, msg->data, window);
+}
+
+static void
+notebook_page_removed (GtkNotebook * notebook,
+ GtkWidget * child, guint page_num, GtrWindow * window)
+{
+ gint n_pages;
+
+ /* Set the window title */
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ if (n_pages == 1)
+ set_window_title (window, TRUE);
+ else
+ set_window_title (window, FALSE);
+}
+
+static void
+notebook_tab_close_request (GtrNotebook * notebook,
+ GtrTab * tab, GtrWindow * window)
+{
+ /* Note: we are destroying the tab before the default handler
+ * seems to be ok, but we need to keep an eye on this. */
+ gtr_close_tab (tab, window);
+}
+
+
+static void
+notebook_tab_added (GtkNotebook * notebook,
+ GtkWidget * child, guint page_num, GtrWindow * window)
+{
+ GtrTab *tab = GTR_TAB (child);
+ gint n_pages;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ /* Set the window title */
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ if (n_pages == 1)
+ set_window_title (window, TRUE);
+ else
+ set_window_title (window, FALSE);
+
+ g_signal_connect_after (child,
+ "message_changed",
+ G_CALLBACK
+ (gtr_window_update_statusbar_message_count),
+ window);
+
+ g_signal_connect_after (child,
+ "message_changed",
+ G_CALLBACK (update_undo_state),
+ window);
+
+ g_signal_connect_after (child,
+ "showed-message",
+ G_CALLBACK (update_undo_state),
+ window);
+
+ update_undo_state (NULL, NULL, window);
+}
+
+static void
+gtr_window_init (GtrWindow *window)
+{
+ GtkTargetList *tl;
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ priv->search_bar_shown = FALSE;
+ priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+
+ gtk_widget_init_template (GTK_WIDGET (window));
+
+ /* Profile manager */
+ priv->prof_manager = gtr_profile_manager_get_default ();
+
+ /* Drag and drop support, set targets to NULL because we add the
+ default uri_targets below */
+ gtk_drag_dest_set (GTK_WIDGET (window),
+ GTK_DEST_DEFAULT_MOTION |
+ GTK_DEST_DEFAULT_HIGHLIGHT |
+ GTK_DEST_DEFAULT_DROP, NULL, 0, GDK_ACTION_COPY);
+
+ /* Add uri targets */
+ tl = gtk_drag_dest_get_target_list (GTK_WIDGET (window));
+
+ if (tl == NULL)
+ {
+ tl = gtk_target_list_new (NULL, 0);
+ gtk_drag_dest_set_target_list (GTK_WIDGET (window), tl);
+ gtk_target_list_unref (tl);
+ }
+
+ gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
+
+ /* Connect signals */
+ g_signal_connect (window,
+ "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), NULL);
+
+ /**
+ * Here we define different widgets that provides to append to the main
+ * stack and this widgets can also provide a custom headerbar
+ *
+ * With this widgets we have different views in the same window
+ */
+
+ /* poeditor
+ priv->notebook = GTK_WIDGET (gtr_notebook_new ());
+ gtk_widget_show (priv->notebook);
+ g_signal_connect (priv->notebook, "switch-page",
+ G_CALLBACK (notebook_switch_page), window);
+ g_signal_connect (priv->notebook, "page-added",
+ G_CALLBACK (notebook_tab_added), window);
+ g_signal_connect (priv->notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed), window);
+ g_signal_connect (priv->notebook,
+ "tab_close_request",
+ G_CALLBACK (notebook_tab_close_request), window);
+
+ gtk_stack_add_named (GTK_STACK (priv->stack), priv->notebook, "poeditor");
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_notebook_get_header (GTR_NOTEBOOK (priv->notebook)),
+ "poeditor");*/
+
+ // project selection
+ priv->projects = GTK_WIDGET (gtr_projects_new (window));
+ gtk_stack_add_named (GTK_STACK (priv->stack), priv->projects, "projects");
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_projects_get_header (GTR_PROJECTS (priv->projects)),
+ "projects");
+
+ // DL team selection
+ priv->dlteams = GTK_WIDGET (gtr_dl_teams_new (window));
+ gtk_stack_add_named (GTK_STACK (priv->stack), priv->dlteams, "dlteams");
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_dl_teams_get_header (GTR_DL_TEAMS (priv->dlteams)),
+ "dlteams");
+
+ gtk_widget_show_all (priv->stack);
+
+ // translation memory
+ priv->translation_memory = GTR_TRANSLATION_MEMORY (gtr_gda_new());
+ priv->tm_settings = g_settings_new ("org.gnome.gtranslator.plugins.translation-memory");
+ gtr_translation_memory_set_max_omits (priv->translation_memory,
+ g_settings_get_int (priv->tm_settings,
+ "max-missing-words"));
+ gtr_translation_memory_set_max_delta (priv->translation_memory,
+ g_settings_get_int (priv->tm_settings,
+ "max-length-diff"));
+ gtr_translation_memory_set_max_items (priv->translation_memory, 10);
+
+ // code view
+ // priv->codeview = gtr_code_view_new (window);
+
+ gtr_window_show_projects (window);
+}
+
+static void
+save_window_state (GtrWindow * window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ if ((priv->window_state &
+ (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
+ {
+ gtk_window_get_size (GTK_WINDOW (window), &priv->width, &priv->height);
+ g_settings_set (priv->state_settings, GTR_SETTINGS_WINDOW_SIZE,
+ "(ii)", priv->width, priv->height);
+ }
+}
+
+static void
+gtr_window_dispose (GObject * object)
+{
+ GtrWindow *window = GTR_WINDOW (object);
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ if (!priv->dispose_has_run)
+ {
+ save_window_state (window);
+ priv->dispose_has_run = TRUE;
+ }
+
+ g_clear_object (&priv->state_settings);
+ g_clear_object (&priv->prof_manager);
+ g_clear_object (&priv->translation_memory);
+ g_clear_object (&priv->tm_settings);
+ g_clear_object (&priv->codeview);
+
+ G_OBJECT_CLASS (gtr_window_parent_class)->dispose (object);
+}
+
+static void
+gtr_window_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (gtr_window_parent_class)->finalize (object);
+}
+
+static gboolean
+gtr_window_configure_event (GtkWidget * widget, GdkEventConfigure * event)
+{
+ GtrWindow *window = GTR_WINDOW (widget);
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ priv->width = event->width;
+ priv->height = event->height;
+
+ return GTK_WIDGET_CLASS (gtr_window_parent_class)->configure_event (widget,
+ event);
+}
+
+static void
+gtr_window_class_init (GtrWindowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gtr_window_finalize;
+ object_class->dispose = gtr_window_dispose;
+
+ widget_class->configure_event = gtr_window_configure_event;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
+ "/org/gnome/translator/gtr-window.ui");
+
+ /* Main layout widgets */
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, header_bar);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, main_box);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, stack);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GtrWindow, header_stack);
+}
+
+static void
+searchbar_toggled (GtrTab * tab, gboolean revealed, GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+ gtr_notebook_enable_find_button (GTR_NOTEBOOK (priv->notebook), revealed);
+}
+
+/***************************** Public funcs ***********************************/
+
+/**
+ * gtr_window_create_tab:
+ * @window: a #GtrWindow
+ * @po: a #GtrPo
+ *
+ * Adds a new #GtrTab to the #GtrNotebook and returns the
+ * #GtrTab.
+ *
+ * Returns: (transfer none): a new #GtrTab object
+ */
+GtrTab *
+gtr_window_create_tab (GtrWindow * window, GtrPo * po)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ GtrTab *tab;
+
+ // Remove all tabs when creating a new one,
+ // this way we only have one tab. This is a workaround
+ // to remove the tab functionality without change all
+ // the code
+ GList *tabs, *l;
+ tabs = gtr_window_get_all_tabs (window);
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ _gtr_window_close_tab (window, l->data);
+ g_list_free (tabs);
+
+ tab = gtr_tab_new (po, GTK_WINDOW (window));
+ gtk_widget_show (GTK_WIDGET (tab));
+
+ gtr_notebook_add_page (GTR_NOTEBOOK (priv->notebook), tab);
+ gtr_notebook_reset_sort (GTR_NOTEBOOK (priv->notebook));
+
+ g_signal_connect_after (po,
+ "notify::state",
+ G_CALLBACK
+ (update_saved_state),
+ window);
+
+ g_signal_connect (tab, "searchbar-toggled", G_CALLBACK (searchbar_toggled), window);
+
+ return tab;
+}
+
+/**
+ * gtr_window_get_active_tab:
+ * @window: a #GtrWindow
+ *
+ * Gets the active #GtrTab of the @window.
+ *
+ * Returns: (transfer none): the active #GtrTab of the @window.
+ */
+GtrTab *
+gtr_window_get_active_tab (GtrWindow * window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+ g_return_val_if_fail (priv != NULL, NULL);
+ g_return_val_if_fail (priv->notebook != NULL, NULL);
+
+ return gtr_notebook_get_page (GTR_NOTEBOOK (priv->notebook));
+}
+
+/**
+ * gtr_window_get_all_tabs:
+ * @window: a #GtrWindow
+ *
+ * Gets a list of all tabs in the @window or NULL if there is no tab opened.
+ *
+ * Returns: (transfer container) (element-type Gtranslator.Tab):
+ * a list of all tabs in the @window or NULL if there is no tab opened.
+ */
+GList *
+gtr_window_get_all_tabs (GtrWindow * window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ gint num_pages;
+ gint i = 0;
+ GList *toret = NULL;
+
+ num_pages =
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+
+ while (i < num_pages)
+ {
+ toret = g_list_append (toret,
+ gtk_notebook_get_nth_page (GTK_NOTEBOOK
+ (priv->notebook), i));
+ i++;
+ }
+
+ return toret;
+}
+
+/**
+ * gtr_window_get_header_from_active_tab:
+ * @window: a #GtrWindow
+ *
+ * Gets the #GtrHeader of the #GtrPo of in the active
+ * #GtrTab.
+ *
+ * Returns: (transfer none): the #GtrHeader of the #GtrPo of in the active
+ * #GtrTab
+ */
+GtrHeader *
+gtr_window_get_header_from_active_tab (GtrWindow * window)
+{
+ GtrTab *current_page;
+ GtrPo *po;
+ GtrHeader *header;
+
+ g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
+
+ current_page = gtr_window_get_active_tab (window);
+ if (!current_page)
+ return NULL;
+
+ po = gtr_tab_get_po (current_page);
+ header = gtr_po_get_header (po);
+
+ return header;
+}
+
+/**
+ * gtr_window_get_notebook:
+ * @window: a #GtrWindow
+ *
+ * Gets the main #GtrNotebook of the @window.
+ *
+ * Returns: (transfer none): the #GtrNotebook of the @window
+ */
+GtrNotebook *
+gtr_window_get_notebook (GtrWindow * window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ return GTR_NOTEBOOK (priv->notebook);
+}
+
+/**
+ * gtr_window_get_active_view:
+ * @window: a #GtranslationWindow
+ *
+ * Gets the active translation view in the #GtranslationWindow or
+ * NULL if there is not tab opened.
+ *
+ * Returns: (transfer none): the active translation view in the
+ * #GtranslationWindow or %NULL if there is not tab opened.
+ **/
+GtrView *
+gtr_window_get_active_view (GtrWindow * window)
+{
+ GtrTab *current_tab;
+ current_tab = gtr_window_get_active_tab (window);
+
+ if (!current_tab)
+ return NULL;
+
+ return gtr_tab_get_active_view (current_tab);
+}
+
+/**
+ * gtr_window_get_all_views:
+ * @window: the #GtranslationWindow
+ * @original: TRUE if you want original TextViews.
+ * @translated: TRUE if you want transtated TextViews.
+ *
+ * Returns all the views currently present in #GtranslationWindow
+ *
+ * Return value: (transfer container) (element-type Gtranslator.View):
+ * a newly allocated list of #GtranslationWindow objects
+ **/
+GList *
+gtr_window_get_all_views (GtrWindow * window,
+ gboolean original, gboolean translated)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ gint numtabs;
+ gint i;
+ GList *views = NULL;
+ GtkWidget *tab;
+
+ g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
+
+ numtabs = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+ i = numtabs - 1;
+
+ while (i >= 0 && numtabs != 0)
+ {
+ tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook),
+ i);
+ views =
+ g_list_concat (views,
+ gtr_tab_get_all_views (GTR_TAB (tab), original,
+ translated));
+ i--;
+ }
+
+ return views;
+}
+
+/**
+ * gtr_window_get_tab_from_location:
+ * @window: a #GtrWindow
+ * @location: the GFile of the po file of the #GtrTab
+ *
+ * Gets the #GtrTab of the #GtrWindows that matches with the
+ * @location.
+ *
+ * Returns: (transfer none): the #GtrTab which @location matches with its po file.
+ */
+GtkWidget *
+gtr_window_get_tab_from_location (GtrWindow * window, GFile * location)
+{
+ GList *tabs, *l;
+ GtrPo *po;
+ GFile *po_location;
+
+ g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
+
+ tabs = gtr_window_get_all_tabs (window);
+
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ {
+ po = gtr_tab_get_po (GTR_TAB (l->data));
+
+ po_location = gtr_po_get_location (po);
+
+ if (g_file_equal (location, po_location) == TRUE)
+ {
+ g_object_unref (po_location);
+
+ return l->data;
+ }
+ g_object_unref (po_location);
+ }
+
+ return NULL;
+}
+
+/**
+ * gtr_window_set_active_tab:
+ * @window: a #GtrWindow
+ * @tab: a #GtrTab
+ *
+ * Sets the active tab for the @window.
+ */
+void
+gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ gint page;
+
+ page = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), tab);
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);
+}
+
+/**
+ * _gtr_window_close_tab:
+ * @window: a #GtrWindow
+ * @tab: a #GtrTab
+ *
+ * Closes the opened @tab of the @window and sets the right sensitivity of the
+ * widgets.
+ */
+void
+_gtr_window_close_tab (GtrWindow * window, GtrTab * tab)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ gint i;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ i = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
+ GTK_WIDGET (tab));
+ if (i != -1)
+ gtr_notebook_remove_page (GTR_NOTEBOOK (priv->notebook), i);
+}
+
+void
+gtr_window_show_projects (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->header_stack), "projects");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "projects");
+
+ gtr_notebook_remove_all_pages (GTR_NOTEBOOK (priv->notebook));
+}
+
+void
+gtr_window_show_poeditor (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->header_stack), "poeditor");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "poeditor");
+}
+
+void
+gtr_window_show_dlteams (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->header_stack), "dlteams");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "dlteams");
+}
+
+void
+gtr_window_remove_all_pages (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ gtr_notebook_remove_all_pages (GTR_NOTEBOOK (priv->notebook));
+}
+
+void
+gtr_window_show_tm_dialog (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ GtkWidget *dlg;
+
+ dlg = gtr_translation_memory_dialog_new (GTK_WINDOW (window),
+ priv->translation_memory);
+
+ g_signal_connect (dlg, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+
+ gtk_window_present (GTK_WINDOW (dlg));
+}
+
+GtrTranslationMemory *
+gtr_window_get_tm (GtrWindow *window) {
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+ return priv->translation_memory;
+}
+
+void
+gtr_window_tm_keybind (GtrWindow *window,
+ GSimpleAction *action)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+ GtrTranslationMemory *tm = priv->translation_memory;
+ GList *tm_list;
+ const gchar *msgid;
+ GtrTab *tab = gtr_window_get_active_tab (window);
+ GtrMsg *msg;
+ const gchar *action_name;
+ GtrPo *po;
+ GtrView *view;
+ GtkTextBuffer *buffer;
+ gint index = 0;
+ GtrTranslationMemoryMatch *match = NULL;
+
+ if (!tab)
+ return;
+
+ view = gtr_tab_get_active_view (tab);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ po = gtr_tab_get_po (tab);
+ msg = gtr_tab_get_msg (tab);
+ msgid = gtr_msg_get_msgid (msg);
+ tm_list = gtr_translation_memory_lookup (tm, msgid);
+
+ action_name = g_action_get_name (G_ACTION (action));
+ if (g_strcmp0 (action_name, "tm_1") == 0)
+ index = 0;
+ else if (g_strcmp0 (action_name, "tm_2") == 0)
+ index = 1;
+ else if (g_strcmp0 (action_name, "tm_2") == 0)
+ index = 1;
+ else if (g_strcmp0 (action_name, "tm_3") == 0)
+ index = 2;
+ else if (g_strcmp0 (action_name, "tm_4") == 0)
+ index = 3;
+ else if (g_strcmp0 (action_name, "tm_5") == 0)
+ index = 4;
+ else if (g_strcmp0 (action_name, "tm_6") == 0)
+ index = 5;
+ else if (g_strcmp0 (action_name, "tm_7") == 0)
+ index = 6;
+ else if (g_strcmp0 (action_name, "tm_8") == 0)
+ index = 7;
+ else if (g_strcmp0 (action_name, "tm_9") == 0)
+ index = 8;
+
+ match = (GtrTranslationMemoryMatch *) g_list_nth_data (tm_list, index);
+ if (match)
+ {
+ gtk_text_buffer_begin_user_action (buffer);
+ gtr_msg_set_msgstr (msg, match->match);
+ gtk_text_buffer_set_text (buffer, match->match, -1);
+ gtr_po_set_state (po, GTR_PO_STATE_MODIFIED);
+ gtk_text_buffer_end_user_action (buffer);
+ }
+
+ g_list_free_full (tm_list, free_match);
+}
+
+void
+gtr_window_hide_sort_menu (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+
+ gtr_notebook_hide_sort_menu (GTR_NOTEBOOK (priv->notebook));
+}
+
+void
+gtr_window_show_search_bar (GtrWindow *window,
+ gboolean show)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+ GtrNotebook *notebook = GTR_NOTEBOOK (priv->notebook);
+ GtrTab *tab = gtr_window_get_active_tab (window);
+
+ if (tab != NULL)
+ gtr_tab_show_hide_search_bar (tab, show);
+
+ gtr_notebook_enable_find_button(notebook, show);
+
+ priv->search_bar_shown = show;
+}
+
+// Shortcut for find now calls this
+void
+gtr_window_show_focus_search_bar (GtrWindow *window,
+ gboolean show)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+ GtrTab *tab = gtr_window_get_active_tab (window);
+
+ // don't need to show if already shown but need to focus on entry
+ if (tab != NULL && priv->search_bar_shown == show)
+ gtr_tab_focus_search_bar (tab);
+ else
+ gtr_window_show_search_bar (window, show);
+}
+
+void
+gtr_window_toggle_search_bar (GtrWindow *window)
+{
+ GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
+
+ gtr_window_show_search_bar(window, !priv->search_bar_shown);
+}
diff --git a/src/gtr-window-old.h b/src/gtr-window-old.h
new file mode 100644
index 00000000..d40517f8
--- /dev/null
+++ b/src/gtr-window-old.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa 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:
+ * Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Pablo Sanxiao <psanxiao gmail com>
+ */
+
+#ifndef __GTR_WINDOW_H__
+#define __GTR_WINDOW_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtr-header.h"
+#include "gtr-notebook.h"
+#include "gtr-tab.h"
+#include "gtr-view.h"
+
+G_BEGIN_DECLS
+
+#define GTR_TYPE_WINDOW (gtr_window_get_type ())
+
+G_DECLARE_FINAL_TYPE (GtrWindow, gtr_window, GTR, WINDOW, GtkApplicationWindow)
+
+struct _GtrWindow
+{
+ GtkApplicationWindow parent_instance;
+};
+
+struct _GtrWindowClass
+{
+ GtkApplicationWindowClass parent_class;
+};
+
+GtrTab *gtr_window_create_tab (GtrWindow * window, GtrPo * po);
+
+GtrTab *gtr_window_get_active_tab (GtrWindow * window);
+
+GList *gtr_window_get_all_tabs (GtrWindow * window);
+
+GtrNotebook *gtr_window_get_notebook (GtrWindow * window);
+
+GtrHeader * gtr_window_get_header_from_active_tab (GtrWindow * window);
+
+GtkWidget *gtr_window_get_statusbar (GtrWindow * window);
+
+GtrView *gtr_window_get_active_view (GtrWindow * window);
+
+GList *gtr_window_get_all_views (GtrWindow * window,
+ gboolean original, gboolean translated);
+
+GtkWidget *gtr_window_get_tab_from_location (GtrWindow * window, GFile * location);
+
+void gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab);
+
+void _gtr_window_close_tab (GtrWindow * window, GtrTab * tab);
+
+GtrTranslationMemory * gtr_window_get_tm (GtrWindow *window);
+void gtr_window_show_tm_dialog (GtrWindow *window);
+
+void gtr_window_remove_all_pages (GtrWindow *window);
+
+void gtr_window_tm_keybind (GtrWindow *window, GSimpleAction *action);
+
+void gtr_window_hide_sort_menu (GtrWindow *window);
+
+void gtr_window_show_focus_search_bar (GtrWindow *window, gboolean show);
+void gtr_window_toggle_search_bar (GtrWindow *window);
+
+/** stack app states **/
+void gtr_window_show_projects (GtrWindow *window);
+void gtr_window_show_poeditor (GtrWindow *window);
+void gtr_window_show_dlteams (GtrWindow *window);
+
+G_END_DECLS
+#endif /* __GTR_WINDOW_H__ */
diff --git a/src/gtr-window-old.ui b/src/gtr-window-old.ui
new file mode 100644
index 00000000..61e4eeba
--- /dev/null
+++ b/src/gtr-window-old.ui
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.14"/>
+ <object class="GtkImage" id="menu_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">open-menu-symbolic</property>
+ </object>
+ <template class="GtrWindow" parent="GtkApplicationWindow">
+ <property name="height_request">600</property>
+ <property name="can_focus">False</property>
+ <property name="default_width">800</property>
+ <property name="default_height">600</property>
+ <property name="show_menubar">False</property>
+ <child type="titlebar">
+ <object class="GtkStack" id="header_stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkHeaderBar" id="header_bar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Translation Editor</property>
+ <property name="show_close_button">True</property>
+ <child>
+ <object class="GtkMenuButton" id="menu_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">False</property>
+ <property name="image">menu_image</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="main_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
+
diff --git a/src/gtr-window.c b/src/gtr-window.c
index c24a737e..dc5f376a 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -30,7 +30,7 @@
#include "gtr-dirs.h"
#include "gtr-header.h"
#include "gtr-msg.h"
-#include "gtr-notebook.h"
+// #include "gtr-notebook.h"
#include "gtr-tab.h"
#include "gtr-po.h"
#include "gtr-projects.h"
@@ -77,7 +77,7 @@ typedef struct
GtkWidget *stack;
GtkWidget *projects;
- GtkWidget *notebook;
+ GtkWidget *tab;
GtkWidget *dlteams;
GtrTab *active_tab;
@@ -118,7 +118,7 @@ update_undo_state (GtrTab *tab,
{
GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
GtrView *active_view = gtr_window_get_active_view (window);
- gtr_notebook_update_undo_buttons (GTR_NOTEBOOK (priv->notebook), active_view);
+ gtr_tab_update_undo_buttons (GTR_TAB (priv->tab), active_view);
}
/*
@@ -212,13 +212,13 @@ set_window_title (GtrWindow * window, gboolean with_path)
{
/* Translators: this is the title of the window with a modified document */
title = g_strdup_printf (_("*%s — Translation Editor"), basename);
- gtr_notebook_enable_save (GTR_NOTEBOOK (priv->notebook), TRUE);
+ gtr_tab_enable_save (GTR_TAB (priv->tab), TRUE);
}
else
{
/* Translators: this is the title of the window with a document opened */
title = g_strdup_printf (_("%s — Translation Editor"), basename);
- gtr_notebook_enable_save (GTR_NOTEBOOK (priv->notebook), FALSE);
+ gtr_tab_enable_save (GTR_TAB (priv->tab), FALSE);
}
g_free (basename);
@@ -232,7 +232,7 @@ set_window_title (GtrWindow * window, gboolean with_path)
gtk_window_set_title (GTK_WINDOW (window), title);
// notebook headerbar
- header = GTK_HEADER_BAR (gtr_notebook_get_header (GTR_NOTEBOOK (priv->notebook)));
+ header = GTK_HEADER_BAR (gtr_tab_get_header (GTR_TAB (priv->active_tab)));
gtk_header_bar_set_title (header, title);
g_free (title);
@@ -243,13 +243,12 @@ update_saved_state (GtrPo *po,
GParamSpec *param,
gpointer window)
{
- GtrNotebook *active_notebook;
- active_notebook = gtr_window_get_notebook (window);
set_window_title (GTR_WINDOW (window), TRUE);
- gtr_notebook_enable_upload (active_notebook, gtr_po_can_dl_upload (po));
+ GtrTab * tab = gtr_window_get_active_tab(GTR_WINDOW(window));
+ gtr_tab_enable_upload (tab, gtr_po_can_dl_upload (po));
}
-static void
+/*static void
notebook_switch_page (GtkNotebook * nb,
GtkWidget * page,
gint page_num, GtrWindow * window)
@@ -264,9 +263,9 @@ notebook_switch_page (GtkNotebook * nb,
if (tab == priv->active_tab)
return;
- /*
+ *
* Set the window title
- */
+ *
n_pages = gtk_notebook_get_n_pages (nb);
if (n_pages == 1)
set_window_title (window, TRUE);
@@ -278,33 +277,33 @@ notebook_switch_page (GtkNotebook * nb,
po = gtr_tab_get_po (tab);
msg = gtr_po_get_current_message (po);
gtr_window_update_statusbar_message_count (tab, msg->data, window);
-}
+}*/
-static void
+/*static void
notebook_page_removed (GtkNotebook * notebook,
GtkWidget * child, guint page_num, GtrWindow * window)
{
gint n_pages;
- /* Set the window title */
+ * Set the window title *
n_pages = gtk_notebook_get_n_pages (notebook);
if (n_pages == 1)
set_window_title (window, TRUE);
else
set_window_title (window, FALSE);
-}
+}*/
-static void
+/*static void
notebook_tab_close_request (GtrNotebook * notebook,
GtrTab * tab, GtrWindow * window)
{
- /* Note: we are destroying the tab before the default handler
- * seems to be ok, but we need to keep an eye on this. */
+ * Note: we are destroying the tab before the default handler
+ * seems to be ok, but we need to keep an eye on this. *
gtr_close_tab (tab, window);
-}
+}*/
-static void
+/* static void
notebook_tab_added (GtkNotebook * notebook,
GtkWidget * child, guint page_num, GtrWindow * window)
{
@@ -313,7 +312,7 @@ notebook_tab_added (GtkNotebook * notebook,
g_return_if_fail (GTR_IS_TAB (tab));
- /* Set the window title */
+ * Set the window title *
n_pages = gtk_notebook_get_n_pages (notebook);
if (n_pages == 1)
set_window_title (window, TRUE);
@@ -337,7 +336,7 @@ notebook_tab_added (GtkNotebook * notebook,
window);
update_undo_state (NULL, NULL, window);
-}
+}*/
static void
gtr_window_init (GtrWindow *window)
@@ -385,7 +384,7 @@ gtr_window_init (GtrWindow *window)
*/
// poeditor
- priv->notebook = GTK_WIDGET (gtr_notebook_new ());
+ /*priv->notebook = GTK_WIDGET (gtr_notebook_new ());
gtk_widget_show (priv->notebook);
g_signal_connect (priv->notebook, "switch-page",
G_CALLBACK (notebook_switch_page), window);
@@ -400,7 +399,7 @@ gtr_window_init (GtrWindow *window)
gtk_stack_add_named (GTK_STACK (priv->stack), priv->notebook, "poeditor");
gtk_stack_add_named (GTK_STACK (priv->header_stack),
gtr_notebook_get_header (GTR_NOTEBOOK (priv->notebook)),
- "poeditor");
+ "poeditor");*/
// project selection
priv->projects = GTK_WIDGET (gtr_projects_new (window));
@@ -430,7 +429,7 @@ gtr_window_init (GtrWindow *window)
gtr_translation_memory_set_max_items (priv->translation_memory, 10);
// code view
- priv->codeview = gtr_code_view_new (window);
+ //priv->codeview = gtr_code_view_new (window);
gtr_window_show_projects (window);
}
@@ -514,7 +513,7 @@ static void
searchbar_toggled (GtrTab * tab, gboolean revealed, GtrWindow *window)
{
GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
- gtr_notebook_enable_find_button (GTR_NOTEBOOK (priv->notebook), revealed);
+ gtr_tab_enable_find_button (GTR_TAB (priv->tab), revealed);
}
/***************************** Public funcs ***********************************/
@@ -546,10 +545,18 @@ gtr_window_create_tab (GtrWindow * window, GtrPo * po)
g_list_free (tabs);
tab = gtr_tab_new (po, GTK_WINDOW (window));
+ priv->active_tab = tab;
gtk_widget_show (GTK_WIDGET (tab));
+ /*
gtr_notebook_add_page (GTR_NOTEBOOK (priv->notebook), tab);
gtr_notebook_reset_sort (GTR_NOTEBOOK (priv->notebook));
+ */
+
+ gtk_stack_add_named (GTK_STACK (priv->stack), GTK_WIDGET(priv->active_tab), "poeditor");
+ gtk_stack_add_named (GTK_STACK (priv->header_stack),
+ gtr_tab_get_header (GTR_TAB (priv->active_tab)),
+ "poeditor");
g_signal_connect_after (po,
"notify::state",
@@ -574,9 +581,10 @@ gtr_window_get_active_tab (GtrWindow * window)
{
GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
g_return_val_if_fail (priv != NULL, NULL);
- g_return_val_if_fail (priv->notebook != NULL, NULL);
+ //g_return_val_if_fail (priv->notebook != NULL, NULL);
- return gtr_notebook_get_page (GTR_NOTEBOOK (priv->notebook));
+ //return gtr_notebook_get_page (GTR_NOTEBOOK (priv->notebook));
+ return priv->active_tab;
}
/**
@@ -591,12 +599,12 @@ gtr_window_get_active_tab (GtrWindow * window)
GList *
gtr_window_get_all_tabs (GtrWindow * window)
{
- GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
- gint num_pages;
- gint i = 0;
+ //GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ //gint num_pages;
+ //gint i = 0;
GList *toret = NULL;
- num_pages =
+ /*num_pages =
gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
while (i < num_pages)
@@ -605,7 +613,10 @@ gtr_window_get_all_tabs (GtrWindow * window)
gtk_notebook_get_nth_page (GTK_NOTEBOOK
(priv->notebook), i));
i++;
- }
+ }*/
+ toret = g_list_append (toret,
+ GTK_WIDGET(
+ gtr_window_get_active_tab(window)));
return toret;
}
@@ -647,13 +658,13 @@ gtr_window_get_header_from_active_tab (GtrWindow * window)
*
* Returns: (transfer none): the #GtrNotebook of the @window
*/
-GtrNotebook *
+/* GtrNotebook *
gtr_window_get_notebook (GtrWindow * window)
{
GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
return GTR_NOTEBOOK (priv->notebook);
-}
+}*/
/**
* gtr_window_get_active_view:
@@ -694,13 +705,13 @@ gtr_window_get_all_views (GtrWindow * window,
{
GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
gint numtabs;
- gint i;
+ //gint i;
GList *views = NULL;
- GtkWidget *tab;
+ //GtkWidget *tab;
g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
- numtabs = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+ /*numtabs = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
i = numtabs - 1;
while (i >= 0 && numtabs != 0)
@@ -712,7 +723,10 @@ gtr_window_get_all_views (GtrWindow * window,
gtr_tab_get_all_views (GTR_TAB (tab), original,
translated));
i--;
- }
+ }*/
+
+ views = g_list_concat (views,
+ gtr_tab_get_all_views(GTR_TAB(priv->active_tab), original, translated));
return views;
}
@@ -766,12 +780,13 @@ gtr_window_get_tab_from_location (GtrWindow * window, GFile * location)
void
gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab)
{
- GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ /*GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
gint page;
page = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), tab);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);*/
+ g_printf("setting active_tab \n");
}
/**
@@ -785,7 +800,7 @@ gtr_window_set_active_tab (GtrWindow * window, GtkWidget * tab)
void
_gtr_window_close_tab (GtrWindow * window, GtrTab * tab)
{
- GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ /*GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
gint i;
g_return_if_fail (GTR_IS_TAB (tab));
@@ -793,7 +808,7 @@ _gtr_window_close_tab (GtrWindow * window, GtrTab * tab)
i = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
GTK_WIDGET (tab));
if (i != -1)
- gtr_notebook_remove_page (GTR_NOTEBOOK (priv->notebook), i);
+ gtr_notebook_remove_page (GTR_NOTEBOOK (priv->notebook), i);*/
}
void
@@ -804,7 +819,7 @@ gtr_window_show_projects (GtrWindow *window)
gtk_stack_set_visible_child_name (GTK_STACK (priv->header_stack), "projects");
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "projects");
- gtr_notebook_remove_all_pages (GTR_NOTEBOOK (priv->notebook));
+ //gtr_notebook_remove_all_pages (GTR_NOTEBOOK (priv->notebook));
}
void
@@ -828,8 +843,8 @@ gtr_window_show_dlteams (GtrWindow *window)
void
gtr_window_remove_all_pages (GtrWindow *window)
{
- GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
- gtr_notebook_remove_all_pages (GTR_NOTEBOOK (priv->notebook));
+ //GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+ //gtr_notebook_remove_all_pages (GTR_NOTEBOOK (priv->notebook));
}
void
@@ -919,7 +934,7 @@ gtr_window_hide_sort_menu (GtrWindow *window)
{
GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
- gtr_notebook_hide_sort_menu (GTR_NOTEBOOK (priv->notebook));
+ gtr_tab_hide_sort_menu (GTR_TAB (priv->active_tab));
}
void
@@ -927,13 +942,13 @@ gtr_window_show_search_bar (GtrWindow *window,
gboolean show)
{
GtrWindowPrivate *priv = gtr_window_get_instance_private (window);
- GtrNotebook *notebook = GTR_NOTEBOOK (priv->notebook);
+ //GtrNotebook *notebook = GTR_NOTEBOOK (priv->notebook);
GtrTab *tab = gtr_window_get_active_tab (window);
if (tab != NULL)
gtr_tab_show_hide_search_bar (tab, show);
- gtr_notebook_enable_find_button(notebook, show);
+ gtr_tab_enable_find_button(tab, show);
priv->search_bar_shown = show;
}
diff --git a/src/gtr-window.h b/src/gtr-window.h
index d40517f8..986e794c 100644
--- a/src/gtr-window.h
+++ b/src/gtr-window.h
@@ -28,7 +28,7 @@
#include <gtk/gtk.h>
#include "gtr-header.h"
-#include "gtr-notebook.h"
+// #include "gtr-notebook.h"
#include "gtr-tab.h"
#include "gtr-view.h"
@@ -54,7 +54,7 @@ GtrTab *gtr_window_get_active_tab (GtrWindow * window);
GList *gtr_window_get_all_tabs (GtrWindow * window);
-GtrNotebook *gtr_window_get_notebook (GtrWindow * window);
+// GtrNotebook *gtr_window_get_notebook (GtrWindow * window);
GtrHeader * gtr_window_get_header_from_active_tab (GtrWindow * window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]