gtranslator r3796 - in trunk: . plugins/insert-params plugins/insert-tags



Author: icq
Date: Wed Sep 24 08:15:31 2008
New Revision: 3796
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3796&view=rev

Log:
2008-09-24  Ignacio Casal Quinteiro  <nacho resa gmail com>

	* plugins/insert-params/insert-params-plugin.c 
(showed_message_cb):
	* plugins/insert-tags/insert-tags-plugin.c (parse_list),
	(showed_message_cb), (impl_activate):
	Do not add shortcuts in the menu, are useless, and use utf-8 to not 
	duplicate tags or params.


Modified:
   trunk/ChangeLog
   trunk/plugins/insert-params/insert-params-plugin.c
   trunk/plugins/insert-tags/insert-tags-plugin.c

Modified: trunk/plugins/insert-params/insert-params-plugin.c
==============================================================================
--- trunk/plugins/insert-params/insert-params-plugin.c	(original)
+++ trunk/plugins/insert-params/insert-params-plugin.c	Wed Sep 24 08:15:31 2008
@@ -243,15 +243,25 @@
 	g_regex_match (regex, msgid, 0, &match_info);
 	while (g_match_info_matches (match_info))
 	{
+		gchar *word_collate;
+		
 		word = g_match_info_fetch (match_info, 0);
+		word_collate = g_utf8_collate_key (word, -1);
 		for (i = 0; i < g_slist_length (params); i++)
 		{
-			if (strcmp (g_slist_nth_data (params, i), word) == 0)
+			gchar *param_collate;
+			gchar *param = g_slist_nth_data (params, i);
+			
+			param_collate = g_utf8_collate_key (param, -1);
+			if (strcmp (param_collate, word_collate) == 0)
 			{
 				g_free (word);
 				word = NULL;
 			}
+			g_free (param_collate);
 		}
+		g_free (word_collate);
+		
 		if (word != NULL)
 			params = g_slist_append (params, word);
 		g_match_info_next (match_info, NULL);

Modified: trunk/plugins/insert-tags/insert-tags-plugin.c
==============================================================================
--- trunk/plugins/insert-tags/insert-tags-plugin.c	(original)
+++ trunk/plugins/insert-tags/insert-tags-plugin.c	Wed Sep 24 08:15:31 2008
@@ -168,7 +168,6 @@
 	GtkWidget *menuitem;
 	GtkWidget *menu;
 	GSList *l = tags;
-	guint i = 1;
 	
 	manager = gtranslator_window_get_ui_manager (window);
 	
@@ -189,28 +188,15 @@
 	gtk_widget_set_sensitive (next_tag, TRUE);
 	
 	menu = gtk_menu_new ();
-	gtk_menu_set_accel_group (GTK_MENU (menu),
-				  gtk_ui_manager_get_accel_group(manager));
 	
 	do{
-		gchar *accel_path;
-		
 		menuitem = gtk_menu_item_new_with_label ((const gchar *)l->data);
 		gtk_widget_show (menuitem);
 		
-		accel_path = g_strdup_printf ("<Gtranslator-sheet>/Edit/_Insert Tags/%s",
-					      (const gchar *)l->data);
-		
-		gtk_menu_item_set_accel_path (GTK_MENU_ITEM (menuitem), accel_path);
-		gtk_accel_map_add_entry (accel_path, i+48, GDK_CONTROL_MASK | GDK_MOD1_MASK);
-
-		g_free (accel_path);
-		
 		g_signal_connect (menuitem, "activate",
 				  G_CALLBACK (on_menuitem_activated), window);
 		
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-		i++;
 	}while ((l = g_slist_next (l)));
 	
 	gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_tags), menu);
@@ -225,6 +211,7 @@
 	GRegex *regex;
 	GMatchInfo *match_info;
 	gchar *word;
+	gint i;
 	
 	if (tags != NULL)
 	{
@@ -248,8 +235,27 @@
 	g_regex_match (regex, msgid, 0, &match_info);
 	while (g_match_info_matches (match_info))
 	{
+		gchar *word_collate;
+		
 		word = g_match_info_fetch (match_info, 0);
-		tags = g_slist_append (tags, word);
+		word_collate = g_utf8_collate_key (word, -1);
+		for (i = 0; i < g_slist_length (tags); i++)
+		{
+			gchar *tag_collate;
+			gchar *tag = g_slist_nth_data (tags, i);
+			
+			tag_collate = g_utf8_collate_key (tag, -1);
+			if (strcmp (tag_collate, word_collate) == 0)
+			{
+				g_free (word);
+				word = NULL;
+			}
+			g_free (tag_collate);
+		}
+		g_free (word_collate);
+		
+		if (word != NULL)
+			tags = g_slist_append (tags, word);
 		g_match_info_next (match_info, NULL);
 	}
 	g_match_info_free (match_info);
@@ -301,7 +307,7 @@
 							 &error);
 	if (error)
 	{
-		g_warning (error->message);
+		g_warning ("%s", error->message);
 		g_error_free (error);
 		g_free (data);
 		return;



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