[gcompris] core, menus are now sorted by names



commit 5f208cfdae295572c3ba2e6cbf712222f8a81541
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Fri Oct 19 23:33:34 2012 +0200

    core, menus are now sorted by names
    
    It is a pain to have the menus in a different order depending
    on how the file are parsed on disk.
    
    We now sort the menus by difficulty like before but now if the
    menus have the same difficulty we sort them by name.

 src/gcompris/menu.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/gcompris/menu.c b/src/gcompris/menu.c
index 2630ad4..27309ef 100644
--- a/src/gcompris/menu.c
+++ b/src/gcompris/menu.c
@@ -357,10 +357,19 @@ gc_menu_section_get(gchar *section)
   return NULL;
 }
 
+/**
+ * Sort by difficulty and then by name
+ */
 static int
 boardlist_compare_func(const void *a, const void *b)
 {
-  return strcasecmp(((GcomprisBoard *) a)->difficulty, ((GcomprisBoard *) b)->difficulty);
+  int diff_cmp = strcasecmp(((GcomprisBoard *) a)->difficulty,
+			    ((GcomprisBoard *) b)->difficulty);
+  if ( diff_cmp == 0 )
+    return strcasecmp(((GcomprisBoard *) a)->name,
+		      ((GcomprisBoard *) b)->name);
+  else
+    return diff_cmp;
 }
 
 /** Return true is there are at least one activity in the given section



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