[evolution-patches] Improvements for the ENameSelectorEntry




Needs approval.

Also read the thread "Improvements to the e-name-selector-entry"



-- 
Philip Van Hoof, Software Developer @ Cronos
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: philip dot vanhoof at cronos dot be
junk: philip dot vanhoof at gmail dot com
http://www.pvanhoof.be/
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/ChangeLog,v
retrieving revision 1.45
diff -u -r1.45 ChangeLog
--- ChangeLog	9 Jun 2005 10:43:09 -0000	1.45
+++ ChangeLog	19 Jun 2005 15:40:56 -0000
@@ -1,3 +1,13 @@
+2005-06-06  Philip Van Hoof  <pvanhoof gnome org
+
+	* e-name-selector-entry.c: Making it more easy to remove destinations
+
+2005-06-07  Sushma Rai  <rsushma novell com>
+
+	* e-name-selector-dialog.c (e_name_selector_dialog_init): Making the
+	name selector dialog modal, useful when gets invoked from modal 
+	dialogs.
+
 2005-06-09  Ross Burton  <ross burtonini com>
 
 	* e-categories-dialog.c:
Index: e-name-selector-entry.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-name-selector-entry.c,v
retrieving revision 1.17
diff -u -r1.17 e-name-selector-entry.c
--- e-name-selector-entry.c	4 May 2005 08:43:58 -0000	1.17
+++ e-name-selector-entry.c	19 Jun 2005 15:40:58 -0000
@@ -906,14 +906,16 @@
 	EDestination *destination;
 
 	destination = find_destination_at_position (name_selector_entry, pos);
-	g_assert (destination);
+	if (destination) {
+		g_assert (destination);
 
-	g_signal_handlers_block_by_func (name_selector_entry->destination_store,
+		g_signal_handlers_block_by_func (name_selector_entry->destination_store,
 					 destination_row_deleted, name_selector_entry);
-	e_destination_store_remove_destination (name_selector_entry->destination_store,
+		e_destination_store_remove_destination (name_selector_entry->destination_store,
 						destination);
-	g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
+		g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
 					   destination_row_deleted, name_selector_entry);
+	}
 }
 
 static void
@@ -967,14 +969,16 @@
 	EDestination *destination;
 
 	destination = find_destination_by_index (name_selector_entry, index);
-	g_assert (destination);
+	if (destination) {
+		g_assert (destination);
 
-	g_signal_handlers_block_by_func (name_selector_entry->destination_store,
+		g_signal_handlers_block_by_func (name_selector_entry->destination_store,
 					 destination_row_deleted, name_selector_entry);
-	e_destination_store_remove_destination (name_selector_entry->destination_store,
+		e_destination_store_remove_destination (name_selector_entry->destination_store,
 						destination);
-	g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
+		g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
 					   destination_row_deleted, name_selector_entry);
+	}
 }
 
 /* Returns the number of characters inserted */
@@ -1123,7 +1127,7 @@
 {
 	const gchar *text;
 	gint         index_start, index_end;
-	gunichar     str_context [2];
+	gunichar     str_context [2], str_b_context [2];
 	gchar        buf [7];
 	gint         len;
 	gint         i;
@@ -1134,6 +1138,7 @@
 	text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
 	len = g_utf8_strlen (text, -1);
 	get_utf8_string_context (text, start_pos, str_context, 2);
+	get_utf8_string_context (text, end_pos-1, str_b_context, 2);
 
 	g_signal_handlers_block_by_func (name_selector_entry, user_delete_text, name_selector_entry);
 
@@ -1146,13 +1151,42 @@
 		}
 	}
 
-	if (str_context [0] == ',' && str_context [1] == ' ') {
-		/* If we're deleting the trailing space in ", ", delete the whole ", " sequence. */
-		start_pos--;
-	}
-
 	index_start = get_index_at_position (text, start_pos);
 	index_end   = get_index_at_position (text, end_pos);
+	
+	g_signal_stop_emission_by_name (name_selector_entry, "delete_text");
+	
+	/* If the user is trying to delete a ','-character, we assume the user 
+	 * wants to remove the entire destination.
+	 */
+	
+	if ((str_b_context [0] == ',' && str_b_context [1] == ' ') || str_b_context [1] == ',') {
+	
+	  EDestination *dest = find_destination_at_position (name_selector_entry, end_pos-1);
+	  const char *email = e_destination_get_email (dest);
+	  if (email && (strcmp (email, "")!=0)) {
+	  
+		/* Therefore, in case it's a real destination, we select it. 
+		 * Deleting this selection afterwards will leave the destination
+		 * empty. */
+	 
+		gint t = (str_b_context [1]==',')?end_pos-1:end_pos-2, b=t;
+		do {
+			t--;
+		} while (t >= 1 && text[t-1] != ',');
+		
+		gtk_editable_select_region (GTK_EDITABLE(name_selector_entry), t, b);
+
+		/* Since this is a special-case, we don't want the rest of this method
+		 * to happen. However, we do need to reenable the signal which we
+		 * disabled above! */
+		
+		goto end_of_user_delete_text;
+		
+	  }
+	}
+	
+
 
 	/* If the deletion touches more than one destination, the first one is changed
 	 * and the rest are removed. If the last destination wasn't completely deleted,
@@ -1162,15 +1196,17 @@
 	 * Here, we let the model know about removals. */
 	for (i = index_end; i > index_start; i--)
 		remove_destination_by_index (name_selector_entry, i);
-
+	
 	/* Do the actual deletion */
+	
+	
 	gtk_editable_delete_text (GTK_EDITABLE (name_selector_entry),
 				  start_pos, end_pos);
-	g_signal_stop_emission_by_name (name_selector_entry, "delete_text");
+	
 
 	/* Let model know about changes */
 	text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
-	if (!*text) {
+	if (!*text || strlen(text) <= 0) {
 		/* If the entry was completely cleared, remove the initial destination too */
 		remove_destination_by_index (name_selector_entry, 0);
 		generate_attribute_list (name_selector_entry);
@@ -1187,7 +1223,8 @@
 		g_source_remove (name_selector_entry->type_ahead_complete_cb_id);
 		name_selector_entry->type_ahead_complete_cb_id = 0;
 	}
-
+	
+end_of_user_delete_text:
 	g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
 }
 


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