evolution-data-server r9461 - trunk/libedataserverui



Author: mcrha
Date: Mon Sep  1 09:30:18 2008
New Revision: 9461
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9461&view=rev

Log:
2008-09-01  Milan Crha  <mcrha redhat com>

	** Fix for bug #326692

	* e-name-selector-entry.c: (sanitize_entry), (user_focus_out):
	Sync model data with entry text and remove all empty
	destinations from the model on user's exit from the entry.



Modified:
   trunk/libedataserverui/ChangeLog
   trunk/libedataserverui/e-name-selector-entry.c

Modified: trunk/libedataserverui/e-name-selector-entry.c
==============================================================================
--- trunk/libedataserverui/e-name-selector-entry.c	(original)
+++ trunk/libedataserverui/e-name-selector-entry.c	Mon Sep  1 09:30:18 2008
@@ -1470,6 +1470,52 @@
 	priv->is_completing = FALSE;
 }
 
+static void
+sanitize_entry (ENameSelectorEntry *name_selector_entry)
+{
+	int n;
+	GList *l, *known, *del = NULL;
+	GString *str = g_string_new ("");
+
+	g_signal_handlers_block_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+	g_signal_handlers_block_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+
+	known = e_destination_store_list_destinations (name_selector_entry->destination_store);
+	for (l = known, n = 0; l != NULL; l = l->next, n++) {
+		EDestination *dest = l->data;
+
+		if (!dest || !e_destination_get_address (dest))
+			del = g_list_prepend (del, GINT_TO_POINTER (n));
+		else {
+			char *text;
+
+			text = get_destination_textrep (dest);
+			if (text) {
+				if (str->str && str->str[0])
+					g_string_append (str, ", ");
+
+				g_string_append (str, text);
+			}
+			g_free (text);
+		}
+	}
+	g_list_free (known);
+
+	for (l = del; l != NULL; l = l->next) {
+		e_destination_store_remove_destination_nth (name_selector_entry->destination_store, GPOINTER_TO_INT (l->data));
+	}
+	g_list_free (del);
+
+	gtk_entry_set_text (GTK_ENTRY (name_selector_entry), str->str);
+
+	g_string_free (str, TRUE);
+
+	g_signal_handlers_unblock_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+	g_signal_handlers_unblock_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+
+	generate_attribute_list (name_selector_entry);
+}
+
 static gboolean
 user_focus_in (ENameSelectorEntry *name_selector_entry, GdkEventFocus *event_focus)
 {
@@ -1503,6 +1549,10 @@
 
 	clear_completion_model (name_selector_entry);
 
+	if (!event_focus->in) {
+		sanitize_entry (name_selector_entry);
+	}
+
 	return FALSE;
 }
 



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