[evolution-patches] Patch for ENameSelectorEntry




Hi there,

This patch improves the ENameSelectorEntry.

Please review. Once approved I can commit this for you.



-- 
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.53
diff -u -r1.53 ChangeLog
--- ChangeLog	11 Jul 2005 08:25:32 -0000	1.53
+++ ChangeLog	12 Jul 2005 07:36:30 -0000
@@ -1,3 +1,7 @@
+2005-06-06  Philip Van Hoof  <pvanhoof gnome org
+
+	* e-name-selector-entry.c: Making it more easy to remove destinations
+
 2005-07-11  Sushma Rai  <rsushma novell com>
 
 	* e-name-selector-dialog.c (e_name_selector_dialog_init): Making the
Index: e-name-selector-entry.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-name-selector-entry.c,v
retrieving revision 1.21
diff -u -r1.21 e-name-selector-entry.c
--- e-name-selector-entry.c	9 Jul 2005 11:36:40 -0000	1.21
+++ e-name-selector-entry.c	12 Jul 2005 07:36:32 -0000
@@ -896,6 +896,8 @@
 
 	destination = find_destination_at_position (name_selector_entry, pos);
 	if (destination) {
+		/* g_assert (destination); */
+
 		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,
@@ -957,6 +959,8 @@
 
 	destination = find_destination_by_index (name_selector_entry, index);
 	if (destination) {
+		/* g_assert (destination); */
+
 		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,
@@ -1111,7 +1115,8 @@
 {
 	const gchar *text;
 	gint         index_start, index_end;
-	gunichar     str_context [2], str_b_context [2];;
+	gunichar     str_context [2], str_b_context [2];
+	gchar        buf [7];
 	gint         len;
 	gint         i;
 
@@ -1133,6 +1138,43 @@
 					    name_selector_entry);
 		}
 	}
+
+	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;
+		
+	  }
+	}
+	
+
 
 	index_start = get_index_at_position (text, start_pos);
 	index_end   = get_index_at_position (text, end_pos);


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