comparison src/editors.c @ 1276:4177057ca11b

editor_list_get() now returns a sorted list, this way items appear in the same order in all menus.
author zas_
date Tue, 03 Feb 2009 08:41:21 +0000
parents 8fcdfacce91d
children c5852c543775
comparison
equal deleted inserted replaced
1275:fa0e7b8e785e 1276:4177057ca11b
370 strcmp(editor->key, CMD_FOLDER) == 0) return; 370 strcmp(editor->key, CMD_FOLDER) == 0) return;
371 371
372 *listp = g_list_prepend(*listp, editor); 372 *listp = g_list_prepend(*listp, editor);
373 } 373 }
374 374
375 static gint editor_sort(gconstpointer a, gconstpointer b)
376 {
377 const EditorDescription *ea = a;
378 const EditorDescription *eb = b;
379 int ret;
380
381 ret = strcmp(ea->menu_path, eb->menu_path);
382 if (ret != 0) return ret;
383
384 return g_utf8_collate(ea->name, eb->name);
385 }
386
375 GList *editor_list_get(void) 387 GList *editor_list_get(void)
376 { 388 {
377 GList *editors_list = NULL; 389 GList *editors_list = NULL;
378 g_hash_table_foreach(editors, editor_list_add_cb, &editors_list); 390 g_hash_table_foreach(editors, editor_list_add_cb, &editors_list);
391 editors_list = g_list_sort(editors_list, editor_sort);
392
379 return editors_list; 393 return editors_list;
380 } 394 }
381 395
382 /* ------------------------------ */ 396 /* ------------------------------ */
383 397