gtranslator r3631 - in trunk: . plugins/alternate-language src



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

Log:
Squashed commit of the following:

commit 321436898a2c5c97692e3572c4b52fe31a9e1607
Author: Ignacio Casal Quinteiro <nacho resa gmail com>
Date:   Fri Aug 1 08:43:44 2008 +0200

    2008-08-01  Ignacio Casal Quinteiro  <nacho resa gmail com>

    	* plugins/alternate-language/alternate-language-panel.c
    	(search_message), (gtranslator_alternate_lang_panel_draw):
    	* plugins/alternate-language/alternate-language-plugin.c
    	(create_alternate_lang_plugin_panel):
    	Improved the search and added to the new lateral panel.

    	src/
    	* msg.c (gtranslator_msg_init), (gtranslator_msg_finalize):
    	* tab.c (gtranslator_tab_draw),
    	(gtranslator_tab_add_widget_to_lateral_panel),
    	(gtranslator_tab_remove_widget_from_lateral_panel):
    	* tab.h:
    	Fixed memory leak on msg.c and added public fucs to manage the
    	lateral panel.

Modified:
   trunk/ChangeLog
   trunk/plugins/alternate-language/alternate-language-panel.c
   trunk/plugins/alternate-language/alternate-language-plugin.c
   trunk/src/ChangeLog
   trunk/src/msg.c
   trunk/src/tab.c
   trunk/src/tab.h

Modified: trunk/plugins/alternate-language/alternate-language-panel.c
==============================================================================
--- trunk/plugins/alternate-language/alternate-language-panel.c	(original)
+++ trunk/plugins/alternate-language/alternate-language-panel.c	Mon Sep 22 09:40:01 2008
@@ -73,15 +73,19 @@
 	GList *messages;
 	GList *l;
 	const gchar *msgid = gtranslator_msg_get_msgid (msg);
+	gchar *msgid_collate;
 	const gchar *string;
+	gchar *string_collate;
 	GtranslatorMsgStatus status;
 	
+	msgid_collate = g_utf8_collate_key (msgid, -1);
 	messages = gtranslator_po_get_messages (panel->priv->po);
 	l = messages;
 	do
 	{
 		string = gtranslator_msg_get_msgid (l->data);
-		if (g_utf8_collate(string, msgid) == 0)
+		string_collate = g_utf8_collate_key (string, -1);
+		if (strcmp (string_collate, msgid_collate) == 0)
 		{
 			gtranslator_alternate_lang_panel_set_text (panel,
 								   gtranslator_msg_get_msgstr (l->data));
@@ -99,10 +103,14 @@
 				default: break;
 			}
 			
+			g_free (string_collate);
+			g_free (msgid_collate);
 			return;
 		}
+		g_free (string_collate);
 	} while ((l = g_list_next (l)));
 	
+	g_free (msgid_collate);
 	gtranslator_alternate_lang_panel_set_text (panel,
 						   _("Message not found"));
 	
@@ -301,8 +309,11 @@
 	gtk_widget_set_sensitive (panel->priv->textview, FALSE);
 	gtk_widget_show (panel->priv->textview);
 	
-	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
-					       panel->priv->textview);
+	gtk_container_add (GTK_CONTAINER (scroll),
+			   panel->priv->textview);
+	
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+					     GTK_SHADOW_IN);
 	
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
 					GTK_POLICY_AUTOMATIC,

Modified: trunk/plugins/alternate-language/alternate-language-plugin.c
==============================================================================
--- trunk/plugins/alternate-language/alternate-language-plugin.c	(original)
+++ trunk/plugins/alternate-language/alternate-language-plugin.c	Mon Sep 22 09:40:01 2008
@@ -59,8 +59,6 @@
 {
 	GtkWidget *alternatelang;
 	GtranslatorPo *po;
-	GtkWidget *panel;
-	GtkWidget *label;
 	
 	po = gtranslator_tab_get_po (GTR_TAB (child));
 	
@@ -69,14 +67,10 @@
 	alternatelang = gtranslator_alternate_lang_panel_new (child);
 	gtk_widget_show (alternatelang);
 	
-	panel = gtranslator_tab_get_panel (GTR_TAB(child));
-	
-	label = gtk_label_new (_("Alternate Language"));
+	gtranslator_tab_add_widget_to_lateral_panel (GTR_TAB(child),
+						     alternatelang,
+						     _("Alternate Language"));
 	
-	gtk_notebook_append_page (GTK_NOTEBOOK (panel),
-				  alternatelang,
-				  label);
-
 	g_object_set_data (G_OBJECT (child),
 			   WINDOW_DATA_KEY,
 			   alternatelang);

Modified: trunk/src/msg.c
==============================================================================
--- trunk/src/msg.c	(original)
+++ trunk/src/msg.c	Mon Sep 22 09:40:01 2008
@@ -57,11 +57,18 @@
 gtranslator_msg_init (GtranslatorMsg *msg)
 {
 	msg->priv = GTR_MSG_GET_PRIVATE (msg);
+	
+	msg->priv->tm_list = NULL;
 }
 
 static void
 gtranslator_msg_finalize (GObject *object)
 {
+	GtranslatorMsg *msg = GTR_MSG (object);
+	
+	if (msg->priv->tm_list)
+		g_strfreev (msg->priv->tm_list);
+
 	G_OBJECT_CLASS (gtranslator_msg_parent_class)->finalize (object);
 }
 

Modified: trunk/src/tab.c
==============================================================================
--- trunk/src/tab.c	(original)
+++ trunk/src/tab.c	Mon Sep 22 09:40:01 2008
@@ -33,6 +33,7 @@
 #include "po.h"
 #include "prefs-manager.h"
 #include "view.h"
+#include "translation-memory-ui.h"
 
 #include <glib.h>
 #include <glib-object.h>
@@ -58,6 +59,7 @@
 	GtkWidget *content_pane;
 	GtkWidget *panel;
 	GtkWidget *message_table;
+	GtkWidget *lateral_panel; //TM, Comments, etc.
 
 	GtkWidget *comment_pane;
 	GtkWidget *comment;
@@ -540,26 +542,31 @@
 			  G_CALLBACK (comment_pane_position_changed),
 			  tab);
 	gtk_widget_show (priv->comment_pane);
+	
+	/*
+	 * Lateral panel
+	 */
+	tab->priv->lateral_panel = gtk_notebook_new ();
+	gtk_widget_show (tab->priv->lateral_panel);
 
+	gtk_paned_pack2(GTK_PANED(priv->comment_pane), tab->priv->lateral_panel,
+			TRUE, TRUE);
+	
 	/*
 	 * Comment
-	 */	
-	comments_label = gtk_label_new ("Comments");
-	tm_label = gtk_label_new ("Translation Memory");
-
+	 */
 	priv->comment = gtranslator_comment_panel_new (GTK_WIDGET (tab));
 	gtk_widget_show (priv->comment);
+	gtranslator_tab_add_widget_to_lateral_panel (tab, priv->comment,
+						     _("Comments"));
 
+	/*
+	 * TM
+	 */
 	priv->translation_memory = gtranslator_translation_memory_ui_new (GTK_WIDGET (tab));
 	gtk_widget_show (priv->translation_memory);
-
-	notebook = gtk_notebook_new ();
-	gtk_widget_show (notebook);
-
-	gtk_paned_pack2(GTK_PANED(priv->comment_pane), notebook, TRUE, TRUE);
-	
-	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), priv->comment, comments_label);
-	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), priv->translation_memory, tm_label);
+	gtranslator_tab_add_widget_to_lateral_panel (tab, priv->translation_memory,
+						     _("Translation Memory"));
 	
 	/*
 	 * Content pane; this is where the message table and message area go
@@ -1133,3 +1140,50 @@
 		install_autosave_timeout (tab);
 	}
 }
+
+/**
+ * gtranslator_tab_add_widget_to_lateral_panel:
+ * @tab: a #GtranslatorTab
+ * @widget: a #GtkWidget
+ * @tab_name: the tab name in the notebook
+ *
+ * Adds a new widget to the laberal panel notebook.
+ */
+void
+gtranslator_tab_add_widget_to_lateral_panel (GtranslatorTab *tab,
+					     GtkWidget *widget,
+					     const gchar *tab_name)
+{
+	GtkWidget *label;
+	
+	g_return_if_fail (GTR_IS_TAB (tab));
+	g_return_if_fail (GTK_IS_WIDGET (widget));
+	
+	label = gtk_label_new (tab_name);
+	
+	gtk_notebook_append_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
+				  widget, label);
+}
+
+/**
+ * gtranslator_tab_remove_widget_from_lateral_panel:
+ * @tab: a #GtranslatorTab
+ * @widget: a #GtkWidget
+ *
+ * Removes the @widget from the lateral panel notebook of @tab.
+ */
+void
+gtranslator_tab_remove_widget_from_lateral_panel (GtranslatorTab *tab,
+						  GtkWidget *widget)
+{
+	gint page;
+	
+	g_return_if_fail (GTR_IS_TAB (tab));
+	g_return_if_fail (GTK_IS_WIDGET (widget));
+	
+	page = gtk_notebook_page_num (GTK_NOTEBOOK (tab->priv->lateral_panel),
+				      widget);
+	
+	gtk_notebook_remove_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
+				  page);
+}
\ No newline at end of file

Modified: trunk/src/tab.h
==============================================================================
--- trunk/src/tab.h	(original)
+++ trunk/src/tab.h	Mon Sep 22 09:40:01 2008
@@ -115,6 +115,13 @@
 
 void                   gtranslator_tab_set_autosave_interval (GtranslatorTab *tab, 
 							      gint interval);
+
+void                   gtranslator_tab_add_widget_to_lateral_panel (GtranslatorTab *tab,
+								    GtkWidget *widget,
+								    const gchar *tab_name);
+
+void                   gtranslator_tab_remove_widget_from_lateral_panel (GtranslatorTab *tab,
+									 GtkWidget *widget);
 							    
 gboolean              _gtranslator_tab_can_close           (GtranslatorTab *tab);
 



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