anjuta r3438 - in trunk: . plugins/gtodo



Author: jhs
Date: Wed Jan  9 13:25:11 2008
New Revision: 3438
URL: http://svn.gnome.org/viewvc/anjuta?rev=3438&view=rev

Log:
2008-01-09  Johannes Schmid <jhs gnome org>

	Patch from BolesÅaw KulbabiÅski <<bolekk gmail com> (GHOP):

	* plugins/gtodo/mcategory.c: (category_manager_add_item):
	Fix bug #505205 completely
	
	* AUTHORS: Added BolesÅaw


Modified:
   trunk/AUTHORS
   trunk/ChangeLog
   trunk/plugins/gtodo/mcategory.c

Modified: trunk/AUTHORS
==============================================================================
--- trunk/AUTHORS	(original)
+++ trunk/AUTHORS	Wed Jan  9 13:25:11 2008
@@ -43,6 +43,7 @@
 	Arjan Timmermann  <arjan southfly nl>
 	Armin Burgmeier  <armin arbur net>
 	Benke LÃzlà  <decike freemail hu>
+	BolesÅaw KulbabiÅski <<bolekk gmail com>
 	Chris Woodruff  <cwoodruff openpenguin com> (US)
 	Cygwin Ports maintainer  <yselkowitz users sourceforge net>
 	Dan Elphick  <dre00r ecs soton ac uk> (United Kingdom)

Modified: trunk/plugins/gtodo/mcategory.c
==============================================================================
--- trunk/plugins/gtodo/mcategory.c	(original)
+++ trunk/plugins/gtodo/mcategory.c	Wed Jan  9 13:25:11 2008
@@ -160,20 +160,31 @@
 	GtkTreeIter iter;
 	GtkTreeSelection *selection;    
 	GtkTreePath *path;
+	gchar* new_name = NULL;
 
 	gtk_list_store_append(GTK_LIST_STORE(model), &iter);
 
+	/* find the smallest available number to avoid name repetition */
+	int number = 0;
+	do
+	{
+		number ++;
+		g_free(new_name);
+		new_name = g_strdup_printf(_("<New category (%d)>"), number);
+	}
+	while(gtodo_client_category_exists(cl, new_name));
+
   /* This is shown in an editable treeview column to show the user
      he should enter the category name here */
-	gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, _("<Enter name>"), 1, 1, -1);
-
-	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
-	gtk_tree_selection_select_iter(selection, &iter);
+	gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, new_name, 1, 1, -1);
 	path = gtk_tree_model_get_path(model, &iter);
-	gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview),path  , NULL, FALSE, 0, 0);
+	gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path, NULL, FALSE, 0, 0);
+	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+	gtk_tree_selection_select_iter(selection, &iter);	
 	gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), path, gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), 0), TRUE);
-	gtk_tree_path_free(path);    
-	gtodo_client_category_new(cl, _("<Enter name>"));
+	gtk_tree_path_free(path);
+	gtodo_client_category_new(cl, new_name);
+	g_free(new_name);
 }
 
 void tree_edited_string(GtkCellRendererText *cell, const char *path_string, const char *new_text, GtkWidget *treeview)



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