[gtranslator] Modify GtrTab to use GtrMessageTable navigation
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Modify GtrTab to use GtrMessageTable navigation
- Date: Sun, 22 Apr 2012 17:08:15 +0000 (UTC)
commit 7fb3d0ca37c5fbd141b4747dee396327a6160a28
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Apr 22 18:48:34 2012 +0200
Modify GtrTab to use GtrMessageTable navigation
This change enables sort-independent navigation on the
message list.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=672075
src/gtr-actions-file.c | 2 +-
src/gtr-actions-search.c | 10 ++--
src/gtr-tab.c | 118 +++++++++++++++++++++++-----------------------
src/gtr-tab.h | 2 +-
4 files changed, 66 insertions(+), 66 deletions(-)
---
diff --git a/src/gtr-actions-file.c b/src/gtr-actions-file.c
index 1e63c6c..1080730 100644
--- a/src/gtr-actions-file.c
+++ b/src/gtr-actions-file.c
@@ -91,7 +91,7 @@ gtr_open (GFile * location, GtrWindow * window, GError ** error)
* Show the current message.
*/
current = gtr_po_get_current_message (po);
- gtr_tab_message_go_to (tab, current, FALSE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, current->data, FALSE, GTR_TAB_MOVE_NONE);
/*
* Grab the focus
diff --git a/src/gtr-actions-search.c b/src/gtr-actions-search.c
index a4a84f9..9545636 100644
--- a/src/gtr-actions-search.c
+++ b/src/gtr-actions-search.c
@@ -277,7 +277,7 @@ find_in_list (GtrWindow * window,
else
l = l->prev;
}
- gtr_tab_message_go_to (tab, l, TRUE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, l->data, TRUE, GTR_TAB_MOVE_NONE);
}
else
{
@@ -288,7 +288,7 @@ find_in_list (GtrWindow * window,
found = run_search (GTR_VIEW (viewsaux->data), found);
if (found)
{
- gtr_tab_message_go_to (tab, l, FALSE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, l->data, FALSE, GTR_TAB_MOVE_NONE);
run_search (GTR_VIEW (viewsaux->data), aux);
return TRUE;
}
@@ -316,7 +316,7 @@ find_in_list (GtrWindow * window,
else
l = l->prev;
}
- gtr_tab_message_go_to (tab, l, TRUE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, l->data, TRUE, GTR_TAB_MOVE_NONE);
viewsaux = views;
}
}
@@ -530,11 +530,11 @@ do_replace_all (GtrSearchDialog * dialog, GtrWindow * window)
aux = g_list_first (aux);
else
aux = aux->next;
- gtr_tab_message_go_to (tab, aux, TRUE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, aux->data, TRUE, GTR_TAB_MOVE_NONE);
}
while (current_msg != aux);
- gtr_tab_message_go_to (tab, aux, FALSE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, aux->data, FALSE, GTR_TAB_MOVE_NONE);
if (count > 0)
{
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index c41e49d..3c4fef0 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -1205,15 +1205,14 @@ gtr_tab_get_all_views (GtrTab * tab, gboolean original, gboolean translated)
**/
void
gtr_tab_message_go_to (GtrTab * tab,
- GList * to_go, gboolean searching, GtrTabMove move)
+ GtrMsg * to_go, gboolean searching, GtrTabMove move)
{
GtrPo *po;
GList *current_msg;
static gboolean first_msg = TRUE;
g_return_if_fail (tab != NULL);
- g_return_if_fail (to_go != NULL);
- g_return_if_fail (GTR_IS_MSG (to_go->data));
+ g_return_if_fail (GTR_IS_MSG (to_go));
po = tab->priv->po;
@@ -1255,14 +1254,14 @@ gtr_tab_message_go_to (GtrTab * tab,
{
gtk_notebook_set_current_page (GTK_NOTEBOOK
(tab->priv->trans_notebook), 0);
- gtr_tab_show_message (tab, to_go->data);
+ gtr_tab_show_message (tab, to_go);
}
else if (current_page == 0 && move == GTR_TAB_MOVE_PREV)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK
(tab->priv->trans_notebook),
n_pages - 1);
- gtr_tab_show_message (tab, to_go->data);
+ gtr_tab_show_message (tab, to_go);
}
else
{
@@ -1278,7 +1277,7 @@ gtr_tab_message_go_to (GtrTab * tab,
}
}
else
- gtr_tab_show_message (tab, to_go->data);
+ gtr_tab_show_message (tab, to_go);
first_msg = FALSE;
}
else
@@ -1289,7 +1288,7 @@ gtr_tab_message_go_to (GtrTab * tab,
*/
if (!searching)
g_signal_emit (G_OBJECT (tab), signals[SHOWED_MESSAGE], 0,
- GTR_MSG (to_go->data));
+ GTR_MSG (to_go));
}
/**
@@ -1640,13 +1639,12 @@ gtr_tab_unblock_movement (GtrTab * tab)
void
gtr_tab_go_to_next (GtrTab * tab)
{
- GtrPo *po;
+ GtrMsg *msg;
- po = gtr_tab_get_po (tab);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->priv->message_table),
+ GTR_NAVIGATE_NEXT, NULL);
- gtr_tab_message_go_to (tab,
- g_list_next
- (gtr_po_get_current_message (po)),
+ gtr_tab_message_go_to (tab, msg,
FALSE, GTR_TAB_MOVE_NEXT);
}
@@ -1659,13 +1657,12 @@ gtr_tab_go_to_next (GtrTab * tab)
void
gtr_tab_go_to_prev (GtrTab * tab)
{
- GtrPo *po;
+ GtrMsg *msg;
- po = gtr_tab_get_po (tab);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->priv->message_table),
+ GTR_NAVIGATE_PREV, NULL);
- gtr_tab_message_go_to (tab,
- g_list_previous
- (gtr_po_get_current_message (po)),
+ gtr_tab_message_go_to (tab, msg,
FALSE, GTR_TAB_MOVE_PREV);
}
@@ -1678,13 +1675,11 @@ gtr_tab_go_to_prev (GtrTab * tab)
void
gtr_tab_go_to_first (GtrTab * tab)
{
- GtrPo *po;
-
- po = gtr_tab_get_po (tab);
+ GtrMsg *msg;
- gtr_tab_message_go_to (tab,
- g_list_first
- (gtr_po_get_current_message (po)),
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->priv->message_table),
+ GTR_NAVIGATE_FIRST, NULL);
+ gtr_tab_message_go_to (tab, msg,
FALSE, GTR_TAB_MOVE_NONE);
}
@@ -1697,13 +1692,12 @@ gtr_tab_go_to_first (GtrTab * tab)
void
gtr_tab_go_to_last (GtrTab * tab)
{
- GtrPo *po;
+ GtrMsg *msg;
- po = gtr_tab_get_po (tab);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->priv->message_table),
+ GTR_NAVIGATE_LAST, NULL);
- gtr_tab_message_go_to (tab,
- g_list_last
- (gtr_po_get_current_message (po)),
+ gtr_tab_message_go_to (tab, msg,
FALSE, GTR_TAB_MOVE_NONE);
}
@@ -1718,12 +1712,12 @@ gtr_tab_go_to_last (GtrTab * tab)
gboolean
gtr_tab_go_to_next_fuzzy (GtrTab * tab)
{
- GtrPo *po;
- GList *msg;
+ GtrMsg *msg;
- po = gtr_tab_get_po (tab);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->priv->message_table),
+ GTR_NAVIGATE_NEXT,
+ gtr_msg_is_fuzzy);
- msg = gtr_po_get_next_fuzzy (po);
if (msg != NULL)
{
gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
@@ -1744,12 +1738,11 @@ gtr_tab_go_to_next_fuzzy (GtrTab * tab)
gboolean
gtr_tab_go_to_prev_fuzzy (GtrTab * tab)
{
- GtrPo *po;
- GList *msg;
-
- po = gtr_tab_get_po (tab);
+ GtrMsg *msg;
- msg = gtr_po_get_prev_fuzzy (po);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->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);
@@ -1759,6 +1752,18 @@ gtr_tab_go_to_prev_fuzzy (GtrTab * tab)
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
@@ -1770,12 +1775,11 @@ gtr_tab_go_to_prev_fuzzy (GtrTab * tab)
gboolean
gtr_tab_go_to_next_untrans (GtrTab * tab)
{
- GtrPo *po;
- GList *msg;
-
- po = gtr_tab_get_po (tab);
+ GtrMsg *msg;
- msg = gtr_po_get_next_untrans (po);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->priv->message_table),
+ GTR_NAVIGATE_NEXT,
+ message_is_untranslated);
if (msg != NULL)
{
gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
@@ -1796,12 +1800,11 @@ gtr_tab_go_to_next_untrans (GtrTab * tab)
gboolean
gtr_tab_go_to_prev_untrans (GtrTab * tab)
{
- GtrPo *po;
- GList *msg;
-
- po = gtr_tab_get_po (tab);
+ GtrMsg *msg;
- msg = gtr_po_get_prev_untrans (po);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->priv->message_table),
+ GTR_NAVIGATE_PREV,
+ message_is_untranslated);
if (msg != NULL)
{
gtr_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
@@ -1822,12 +1825,11 @@ gtr_tab_go_to_prev_untrans (GtrTab * tab)
gboolean
gtr_tab_go_to_next_fuzzy_or_untrans (GtrTab * tab)
{
- GtrPo *po;
- GList *msg;
-
- po = gtr_tab_get_po (tab);
+ GtrMsg *msg;
- msg = gtr_po_get_next_fuzzy_or_untrans (po);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->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);
@@ -1848,12 +1850,11 @@ gtr_tab_go_to_next_fuzzy_or_untrans (GtrTab * tab)
gboolean
gtr_tab_go_to_prev_fuzzy_or_untrans (GtrTab * tab)
{
- GtrPo *po;
- GList *msg;
-
- po = gtr_tab_get_po (tab);
+ GtrMsg *msg;
- msg = gtr_po_get_prev_fuzzy_or_untrans (po);
+ msg = gtr_message_table_navigate (GTR_MESSAGE_TABLE (tab->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);
@@ -1878,11 +1879,10 @@ gtr_tab_go_to_number (GtrTab * tab, gint number)
GList *msg;
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, FALSE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, msg->data, FALSE, GTR_TAB_MOVE_NONE);
}
}
diff --git a/src/gtr-tab.h b/src/gtr-tab.h
index 16a61d0..98b90fa 100644
--- a/src/gtr-tab.h
+++ b/src/gtr-tab.h
@@ -110,7 +110,7 @@ GList *gtr_tab_get_all_views (GtrTab * tab,
gboolean original, gboolean translated);
void gtr_tab_message_go_to (GtrTab * tab,
- GList * to_go,
+ GtrMsg * to_go,
gboolean searching, GtrTabMove move);
GtrTab *gtr_tab_get_from_document (GtrPo * po);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]