[evolution-patches] Improvements to the e-name-selector-entry




Hi there,


This patch will improve the e-name-selector-entry.

This is the problem with current version (in HEAD):

When I type "Person a (found)" it means we have a EDestination with a name and an E-mail. When I type "Person a", it means we don't (it's just a name, it's not found in the list or it doesn't have a valid E-mail address).

At this moment, when you have this situation in your ENameSelectorEntry instance:


"Person a (found), Person b ( found), Person c (found)"

And you remove the 3th ','-character. You'll get this:

"Person a (found), Person b Person c"

This one-character removal caused that two EDestination instances got invalid. Whereas the user probably wanted to just remove or correct the EDestination instance of "Person b (found)".


Therefore I altered the behaviour a little bit. What will happen after this patch is

"Person a (found), Person b (found) , Person c (found)

ps. For people who don't have HTML E-mails: the entry in the middle has a blue background as in: it's selected

When you now press backspace or delete again, the selection will of course be removed. Like this:

"Person a (found),, Person c (found)"

So basically it means that the EDestination instance is cleared now. It still exists, but it's E-mail and Name are NULL.

If you now set your cursor like this

"Person a (found),,| Person c (found)"

And you press delete again, it will remove the EDestination instance from the model.

The user, however (and this is why it's not immediately removed), can also enter new EDestination information.

So this is the situation after the removal of the selected Person b (found):

"Person a (found),,| Person c (found)"

When the user starts pressing characters now, the entry will get completed (the combobox stuff) and the leftover EDestination will be formed again.

The result is, indeed, that you can very quickly remove lots of EDestinations from the list. Pressing backspace will remove entire EDestinations per keypress. Pressing BackSpace+DelKey will remove both the EDestination information and the EDestination instance from the model.

Yet the user gets warned about such a full deletion with the "Select" it, warning: You see, the EDestination in the entry gets selected first, then (after a new backspace/del keypress) removed. So there's visual feedback of what is going to happen.


Anyway ... if you look at the patch: you'll notice it's more difficult to explain all this, then it was to code it. So my suggestion is, try it out! Compile the stuff in evolution-data-server/libedataserverui and launch the test-name-selector binary. You'll get two windows. A small one and a dialog. Use the small one to test this stuff.



-- 
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: 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	5 Jun 2005 11:48:10 -0000
@@ -1123,7 +1123,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 +1134,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,11 +1147,48 @@
 		}
 	}
 
-	if (str_context [0] == ',' && str_context [1] == ' ') {
-		/* If we're deleting the trailing space in ", ", delete the whole ", " sequence. */
-		start_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) {
+	  
+		/* 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);
+		
+	  } else {
+	  
+		/* However, if the destination was emptied, we allow the user to
+		 * remove the placeholder too (else the ','-characters aren't
+		 * removable anymore) */
+		 
+		remove_destination_at_position (name_selector_entry, end_pos-1);
+		gtk_editable_delete_text (GTK_EDITABLE (name_selector_entry),
+				  start_pos, end_pos);
+	  }
+	  
+	  /* 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;
 
+	}
+	
 	index_start = get_index_at_position (text, start_pos);
 	index_end   = get_index_at_position (text, end_pos);
 
@@ -1161,12 +1199,16 @@
 	 *
 	 * 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));
@@ -1187,7 +1229,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]