Re: [evolution-patches] Importer patches



> On the shell patch, just sort the CORBA array before iterating over
> it.  No need to iterate over the list twice, or to have that temporary
> 'info array' at all.

Ok, here is an updated patch. I didn't know if it was ok to modify the
corba array, that's the main reason why I used a temporary list.

Christophe
Index: shell/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/shell/ChangeLog,v
retrieving revision 1.1426
diff -u -r1.1426 ChangeLog
--- shell/ChangeLog	30 Apr 2004 19:07:22 -0000	1.1426
+++ shell/ChangeLog	3 May 2004 11:55:02 -0000
@@ -1,3 +1,9 @@
+2004-05-01  Christophe Fergeau  <teuf gnome org>
+	
+	* e-shell-importer.c: sort the various available importer plugins by
+ 	name in the importer druid combo box so that the list doesn't change
+ 	from one evolution run to another.
+
 2004-04-30  Dan Winship  <danw ximian com>
 
 	* apps_evolution_shell.schemas.in.in: Remove default folders,
Index: shell/e-shell-importer.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-importer.c,v
retrieving revision 1.70
diff -u -r1.70 e-shell-importer.c
--- shell/e-shell-importer.c	19 Apr 2004 21:51:34 -0000	1.70
+++ shell/e-shell-importer.c	3 May 2004 11:55:02 -0000
@@ -536,6 +536,27 @@
 		data->choosen_iid = g_strdup (iid);
 }
 
+static int
+compare_info_name (const void *data1, const void  *data2)
+{
+	const Bonobo_ServerInfo *info1 = (Bonobo_ServerInfo *)data1;
+	const Bonobo_ServerInfo *info2 = (Bonobo_ServerInfo *)data2;
+	const char *name1 = get_name_from_component_info (info1);
+	const char *name2 = get_name_from_component_info (info2);
+
+	/* If we can't find a name for a plug-in, its iid will be used
+	 * for display. Put such plug-ins at the end of the list since
+	 * their displayed name won't be really user-friendly
+	 */
+	if (name1 == NULL) {
+		return -1;
+	}
+	if (name2 == NULL) {
+		return 1;
+	}
+	return g_utf8_collate (name1, name2);
+}
+
 static GtkWidget *
 create_plugin_menu (ImportData *data)
 {
@@ -552,6 +573,13 @@
 
 	CORBA_exception_init (&ev);
 	info_list = bonobo_activation_query (IMPORTER_REPO_ID_QUERY, NULL, &ev);
+	/* Sort info list to get a consistent ordering of the items in the
+	 * combo box from one run of evolution to another.
+	 */
+	qsort (info_list->_buffer, info_list->_length, 
+	       sizeof (Bonobo_ServerInfo),
+	       compare_info_name);
+
 	for (i = 0; i < info_list->_length; i++) {
 		const Bonobo_ServerInfo *info;
 		char *name = NULL;

Attachment: signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=



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