gtranslator r3695 - in trunk/src: . dialogs



Author: icq
Date: Mon Sep 22 09:43:29 2008
New Revision: 3695
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3695&view=rev

Log:
2008-08-18  Ignacio Casal Quinteiro  <nacho resa gmail com>

	* actions-edit.c (gtranslator_message_copy_to_translation):
	* actions-file.c (gtranslator_open):
	* actions-go.c (gtranslator_message_go_to_first),
	(gtranslator_message_go_to_previous),
	(gtranslator_message_go_to_next),
(gtranslator_message_go_to_last),
	(gtranslator_message_go_to_next_fuzzy),
	(gtranslator_message_go_to_prev_fuzzy),
	(gtranslator_message_go_to_next_untranslated),
	(gtranslator_message_go_to_prev_untranslated):
	* actions-search.c (find_in_list), (do_replace_all):
	* dialogs/assistant.c (on_assistant_apply),
	(gtranslator_assistant_class_init):
	* message-table.c (gtranslator_message_table_selection_changed),
	(sort_message_list):
	* tab.c (gtranslator_tab_message_go_to),
	(gtranslator_tab_go_to_next), (gtranslator_tab_go_to_prev),
	(gtranslator_tab_go_to_first), (gtranslator_tab_go_to_last),
	(gtranslator_tab_go_to_next_fuzzy),
	(gtranslator_tab_go_to_prev_fuzzy),
	(gtranslator_tab_go_to_next_untrans),
	(gtranslator_tab_go_to_prev_untrans):
	* tab.h:
	Now actions-go.c is not managing directly the list, it calls the
	respective funcs in tab.ch.
	Now when you change within messages and the current message has
	plurals	it is going to change within the plural tabs instead of
	changing to the	next message.

Modified:
   trunk/src/ChangeLog
   trunk/src/actions-edit.c
   trunk/src/actions-file.c
   trunk/src/actions-go.c
   trunk/src/actions-search.c
   trunk/src/dialogs/assistant.c
   trunk/src/message-table.c
   trunk/src/tab.c
   trunk/src/tab.h

Modified: trunk/src/actions-edit.c
==============================================================================
--- trunk/src/actions-edit.c	(original)
+++ trunk/src/actions-edit.c	Mon Sep 22 09:43:29 2008
@@ -153,7 +153,7 @@
 	if(gtranslator_msg_is_fuzzy(msg->data) && gtranslator_prefs_manager_get_unmark_fuzzy())
 		gtranslator_msg_set_fuzzy(msg->data, FALSE);
 		
-	gtranslator_tab_message_go_to(current, msg, FALSE);
+	gtranslator_tab_message_go_to(current, msg, FALSE, GTR_TAB_MOVE_NONE);
 	
 	/*
 	 * Emit that message was changed.

Modified: trunk/src/actions-file.c
==============================================================================
--- trunk/src/actions-file.c	(original)
+++ trunk/src/actions-file.c	Mon Sep 22 09:43:29 2008
@@ -93,7 +93,7 @@
 	 * Show the current message.
 	 */
 	current = gtranslator_po_get_current_message(po);
-	gtranslator_tab_message_go_to (tab, current, FALSE);
+	gtranslator_tab_message_go_to (tab, current, FALSE, GTR_TAB_MOVE_NONE);
 	
 	/*
 	 * Grab the focus

Modified: trunk/src/actions-go.c
==============================================================================
--- trunk/src/actions-go.c	(original)
+++ trunk/src/actions-go.c	Mon Sep 22 09:43:29 2008
@@ -39,9 +39,7 @@
 	
 	current = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(current);
-	gtranslator_tab_message_go_to(current,
-				      g_list_first(gtranslator_po_get_current_message(po)),
-				      FALSE);
+	gtranslator_tab_go_to_first (current);
 	set_sensitive_according_to_message(window, po);
 }
 
@@ -54,9 +52,7 @@
 	
 	current = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(current);
-	gtranslator_tab_message_go_to(current,
-				      g_list_previous(gtranslator_po_get_current_message(po)),
-				      FALSE);
+	gtranslator_tab_go_to_prev (current);
 	set_sensitive_according_to_message(window, po);
 }
 
@@ -69,9 +65,7 @@
 	
 	current = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(current);
-	gtranslator_tab_message_go_to(current,
-				      g_list_next(gtranslator_po_get_current_message(po)),
-				      FALSE);
+	gtranslator_tab_go_to_next (current);
 	set_sensitive_according_to_message(window, po);
 }
 
@@ -84,36 +78,21 @@
 	
 	current = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(current);
-	gtranslator_tab_message_go_to(current,
-				      g_list_last(gtranslator_po_get_current_message(po)),
-				      FALSE);
+	gtranslator_tab_go_to_last (current);
 	set_sensitive_according_to_message(window, po);
 }
 
-void 
-gtranslator_message_go_to_no(GtkAction *action,
-			     GtranslatorWindow *window)
-{
-	/*gtranslator_message_go_to(g_list_nth(current_page->po->messages,
-					     GPOINTER_TO_UINT(number)));*/
-}
-
 void
 gtranslator_message_go_to_next_fuzzy(GtkAction *action,
 				     GtranslatorWindow *window)
 {
 	GtranslatorTab *current;
 	GtranslatorPo *po;
-	GList *msg;
 	
-	current = gtranslator_window_get_active_tab(window);
-	po = gtranslator_tab_get_po(current);
-	msg = gtranslator_po_get_next_fuzzy(po);
-	if(msg != NULL)
-	{
-		gtranslator_tab_message_go_to(current, msg, FALSE);
-		set_sensitive_according_to_message(window, po);
-	}
+	current = gtranslator_window_get_active_tab (window);
+	po = gtranslator_tab_get_po (current);
+	if (gtranslator_tab_go_to_next_fuzzy (current))
+		set_sensitive_according_to_message (window, po);
 }
 
 void
@@ -122,16 +101,11 @@
 {
 	GtranslatorTab *current;
 	GtranslatorPo *po;
-	GList *msg;
 	
 	current = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(current);
-	msg = gtranslator_po_get_prev_fuzzy(po);
-	if(msg != NULL)
-	{
-		gtranslator_tab_message_go_to(current, msg, FALSE);
-		set_sensitive_according_to_message(window, po);
-	}
+	if (gtranslator_tab_go_to_prev_fuzzy (current))
+		set_sensitive_according_to_message (window, po);
 }
 
 void
@@ -144,12 +118,8 @@
 	
 	current = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(current);
-	msg = gtranslator_po_get_next_untrans(po);
-	if(msg != NULL)
-	{
-		gtranslator_tab_message_go_to(current, msg, FALSE);
-		set_sensitive_according_to_message(window, po);
-	}
+	if (gtranslator_tab_go_to_next_untrans (current))
+		set_sensitive_according_to_message (window, po);
 }
 
 void
@@ -162,10 +132,6 @@
 	
 	current = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(current);
-	msg = gtranslator_po_get_prev_untrans(po);
-	if(msg != NULL)
-	{
-		gtranslator_tab_message_go_to(current, msg, FALSE);
-		set_sensitive_according_to_message(window, po);
-	}
+	if (gtranslator_tab_go_to_prev_untrans (current))
+		set_sensitive_according_to_message (window, po);
 }

Modified: trunk/src/actions-search.c
==============================================================================
--- trunk/src/actions-search.c	(original)
+++ trunk/src/actions-search.c	Mon Sep 22 09:43:29 2008
@@ -288,7 +288,7 @@
 				}
 				else l = l->prev;
 			}
-			gtranslator_tab_message_go_to(tab, l, TRUE);
+			gtranslator_tab_message_go_to(tab, l, TRUE, GTR_TAB_MOVE_NONE);
 		}
 		else{
 			while(viewsaux != NULL)
@@ -298,7 +298,7 @@
 				found = run_search(GTR_VIEW(viewsaux->data), found);
 				if(found)
 				{
-					gtranslator_tab_message_go_to (tab, l, FALSE);
+					gtranslator_tab_message_go_to (tab, l, FALSE, GTR_TAB_MOVE_NONE);
 					run_search (GTR_VIEW (viewsaux->data), aux);
 					return TRUE;
 				}
@@ -323,7 +323,7 @@
 				}
 				else l = l->prev;
 			}
-			gtranslator_tab_message_go_to(tab, l, TRUE);
+			gtranslator_tab_message_go_to(tab, l, TRUE, GTR_TAB_MOVE_NONE);
 			viewsaux = views;
 		}
 	}while(l != current);
@@ -544,10 +544,10 @@
 		if(aux->next == NULL)
 			aux = g_list_first(aux);
 		else aux = aux->next;
-		gtranslator_tab_message_go_to(tab, aux, TRUE);
+		gtranslator_tab_message_go_to(tab, aux, TRUE, GTR_TAB_MOVE_NONE);
 	}while(current_msg != aux);
 
-	gtranslator_tab_message_go_to(tab, aux, FALSE);
+	gtranslator_tab_message_go_to(tab, aux, FALSE, GTR_TAB_MOVE_NONE);
 	
 	if (count > 0)
 	{

Modified: trunk/src/dialogs/assistant.c
==============================================================================
--- trunk/src/dialogs/assistant.c	(original)
+++ trunk/src/dialogs/assistant.c	Mon Sep 22 09:43:29 2008
@@ -76,12 +76,6 @@
 	GtkWindow *parent;
 }IdleData;
 
-static void
-on_assistant_close (GtkAssistant* assistant)
-{
-	gtk_widget_destroy (GTK_WIDGET (assistant));
-}
-
 static gboolean
 add_to_database (gpointer data_pointer)
 {
@@ -206,7 +200,6 @@
 	
 	gtk_widget_show (as->priv->add_db_progressbar);
 	
-	g_signal_handlers_block_by_func (assistant, on_assistant_close, NULL);
 	g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
 			 (GSourceFunc)add_to_database,
 			 data,
@@ -756,7 +749,6 @@
 	assistant_class->prepare = on_assistant_prepare;
 	assistant_class->apply = on_assistant_apply;
 	assistant_class->cancel = on_assistant_cancel;
-	//assistant_class->close = on_assistant_cancel;
 }
 
 void

Modified: trunk/src/message-table.c
==============================================================================
--- trunk/src/message-table.c	(original)
+++ trunk/src/message-table.c	Mon Sep 22 09:43:29 2008
@@ -76,7 +76,8 @@
 		if (msg != NULL && g_utf8_collate (gtranslator_msg_get_msgid (msg->data),
 						   gtranslator_msg_get_msgid (current_msg->data)))
 		{
-			gtranslator_tab_message_go_to (table->priv->tab, msg, FALSE);
+			gtranslator_tab_message_go_to (table->priv->tab, msg,
+						       FALSE, GTR_TAB_MOVE_NONE);
 		}
 	}
 }
@@ -246,7 +247,7 @@
 
 	gtranslator_tab_message_go_to (table->priv->tab,
 				       g_list_first (messages),
-				       FALSE);
+				       FALSE, GTR_TAB_MOVE_NONE);
 }
 
 static void

Modified: trunk/src/tab.c
==============================================================================
--- trunk/src/tab.c	(original)
+++ trunk/src/tab.c	Mon Sep 22 09:43:29 2008
@@ -1100,9 +1100,10 @@
  * in the #GtranslatorView.
 **/
 void 
-gtranslator_tab_message_go_to(GtranslatorTab *tab,
-			      GList * to_go,
-			      gboolean searching)
+gtranslator_tab_message_go_to (GtranslatorTab *tab,
+			       GList * to_go,
+			       gboolean searching,
+			       GtranslatorTabMove move)
 {
 	GtranslatorPo *po;
 	GList *current_msg;
@@ -1125,7 +1126,50 @@
 	
 	if (!tab->priv->blocking || first_msg)
 	{
-		gtranslator_tab_show_message (tab, to_go->data);
+		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 (tab->priv->trans_notebook));
+		current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook));
+		n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (tab->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 (tab->priv->trans_notebook),
+							       0);
+				gtranslator_tab_show_message (tab, to_go->data);
+			}
+			else if (current_page == 0 && move == GTR_TAB_MOVE_PREV)
+			{
+				gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook),
+							       n_pages - 1);
+				gtranslator_tab_show_message (tab, to_go->data);
+			}
+			else
+			{
+				if (move == GTR_TAB_MOVE_NEXT)
+					gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook),
+								       current_page + 1);
+				else
+					gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook),
+								       current_page - 1);
+				return;
+			}
+		}
+		else
+			gtranslator_tab_show_message (tab, to_go->data);
 		first_msg = FALSE;
 	}
 	else
@@ -1393,4 +1437,188 @@
 	g_return_if_fail (GTR_IS_TAB (tab));
 	
 	tab->priv->blocking = FALSE;
+}
+
+/**
+ * gtranslator_tab_go_to_next:
+ * @tab: a #GtranslatorTab
+ *
+ * Moves to the next message or plural tab in case the message has plurals.
+ */
+void
+gtranslator_tab_go_to_next (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	gtranslator_tab_message_go_to (tab,
+				       g_list_next (gtranslator_po_get_current_message (po)),
+				       FALSE,
+				       GTR_TAB_MOVE_NEXT);
+}
+
+/**
+ * gtranslator_tab_go_to_prev:
+ * @tab: a #GtranslatorTab
+ *
+ * Moves to the previous message or plural tab in case the message has plurals.
+ */
+void
+gtranslator_tab_go_to_prev (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	gtranslator_tab_message_go_to (tab,
+				       g_list_previous (gtranslator_po_get_current_message (po)),
+				       FALSE,
+				       GTR_TAB_MOVE_PREV);
+}
+
+/**
+ * gtranslator_tab_go_to_first:
+ * @tab: a #GtranslatorTab
+ *
+ * Jumps to the first message.
+ */
+void
+gtranslator_tab_go_to_first (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	gtranslator_tab_message_go_to (tab,
+				       g_list_first (gtranslator_po_get_current_message (po)),
+				       FALSE,
+				       GTR_TAB_MOVE_NONE);
+}
+
+/**
+ * gtranslator_tab_go_to_last:
+ * @tab: a #GtranslatorTab 
+ *
+ * Jumps to the last message.
+ */
+void
+gtranslator_tab_go_to_last (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	gtranslator_tab_message_go_to (tab,
+				       g_list_last (gtranslator_po_get_current_message (po)),
+				       FALSE,
+				       GTR_TAB_MOVE_NONE);
+}
+
+/**
+ * gtranslator_tab_go_to_next_fuzzy:
+ * @tab: a #GtranslatorTab
+ *
+ * If there is a next fuzzy message it jumps to it.
+ *
+ * Returns: TRUE if there is a next fuzzy message.
+ */
+gboolean
+gtranslator_tab_go_to_next_fuzzy (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	GList *msg;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	msg = gtranslator_po_get_next_fuzzy (po);
+	if(msg != NULL)
+	{
+		gtranslator_tab_message_go_to (tab, msg, FALSE,
+					       GTR_TAB_MOVE_NONE);
+		return TRUE;
+	}
+	
+	return FALSE;
+}
+
+/**
+ * gtranslator_tab_go_to_prev_fuzzy:
+ * @tab: a #GtranslatorTab
+ *
+ * If there is a prev fuzzy message it jumps to it.
+ *
+ * Returns: TRUE if there is a prev fuzzy message.
+ */
+gboolean
+gtranslator_tab_go_to_prev_fuzzy (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	GList *msg;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	msg = gtranslator_po_get_prev_fuzzy (po);
+	if(msg != NULL)
+	{
+		gtranslator_tab_message_go_to (tab, msg, FALSE,
+					       GTR_TAB_MOVE_NONE);
+		return TRUE;
+	}
+	
+	return FALSE;
+}
+
+/**
+ * gtranslator_tab_go_to_next_untrans:
+ * @tab: a #GtranslatorTab
+ *
+ * If there is a next untranslated message it jumps to it.
+ *
+ * Returns: TRUE if there is a next untranslated message.
+ */
+gboolean
+gtranslator_tab_go_to_next_untrans (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	GList *msg;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	msg = gtranslator_po_get_next_untrans (po);
+	if(msg != NULL)
+	{
+		gtranslator_tab_message_go_to (tab, msg, FALSE,
+					       GTR_TAB_MOVE_NONE);
+		return TRUE;
+	}
+	
+	return FALSE;
+}
+
+/**
+ * gtranslator_tab_go_to_prev_untrans:
+ * @tab: a #GtranslatorTab
+ *
+ * If there is a prev untranslated message it jumps to it.
+ *
+ * Returns: TRUE if there is a prev untranslated message.
+ */
+gboolean
+gtranslator_tab_go_to_prev_untrans (GtranslatorTab *tab)
+{
+	GtranslatorPo *po;
+	GList *msg;
+	
+	po = gtranslator_tab_get_po (tab);
+	
+	msg = gtranslator_po_get_prev_untrans (po);
+	if(msg != NULL)
+	{
+		gtranslator_tab_message_go_to (tab, msg, FALSE,
+					       GTR_TAB_MOVE_NONE);
+		return TRUE;
+	}
+	
+	return FALSE;
 }
\ No newline at end of file

Modified: trunk/src/tab.h
==============================================================================
--- trunk/src/tab.h	(original)
+++ trunk/src/tab.h	Mon Sep 22 09:43:29 2008
@@ -73,6 +73,13 @@
 					    GtranslatorMsg *msg);
 };
 
+typedef enum
+{
+	GTR_TAB_MOVE_NONE,
+	GTR_TAB_MOVE_NEXT,
+	GTR_TAB_MOVE_PREV
+}GtranslatorTabMove;
+
 /*
  * Public methods
  */
@@ -104,7 +111,8 @@
 
 void                   gtranslator_tab_message_go_to       (GtranslatorTab *tab,
 							    GList * to_go,
-							    gboolean searching);
+							    gboolean searching,
+							    GtranslatorTabMove move);
 							    
 GtranslatorTab        *gtranslator_tab_get_from_document   (GtranslatorPo *po);
 
@@ -133,6 +141,22 @@
 void                   gtranslator_tab_block_movement      (GtranslatorTab *tab);
 
 void                   gtranslator_tab_unblock_movement    (GtranslatorTab *tab);
+
+void                   gtranslator_tab_go_to_next          (GtranslatorTab *tab);
+
+void                   gtranslator_tab_go_to_prev          (GtranslatorTab *tab);
+
+void                   gtranslator_tab_go_to_first         (GtranslatorTab *tab);
+
+void                   gtranslator_tab_go_to_last          (GtranslatorTab *tab);
+
+gboolean               gtranslator_tab_go_to_next_fuzzy    (GtranslatorTab *tab);
+
+gboolean               gtranslator_tab_go_to_prev_fuzzy    (GtranslatorTab *tab);
+
+gboolean               gtranslator_tab_go_to_next_untrans  (GtranslatorTab *tab);
+
+gboolean               gtranslator_tab_go_to_prev_untrans  (GtranslatorTab *tab);
 							    
 gboolean              _gtranslator_tab_can_close           (GtranslatorTab *tab);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]