diff --git a/meson.build b/meson.build index eed8780b9e8695f320ddef36211d1121d83a170f..efd774c2cdc26e5a8214d32e7c1e7d4c4b873cb1 100644 --- a/meson.build +++ b/meson.build @@ -1,12 +1,12 @@ project('rugby', 'c', license:'LGPL') add_project_arguments('-Wdeprecated-declarations', language: 'c') -add_project_arguments('-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_44', language: 'c') -add_project_arguments('-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_44', language: 'c') +add_project_arguments('-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46', language: 'c') +add_project_arguments('-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_46', language: 'c') add_project_arguments('-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_16', language: 'c') add_project_arguments('-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_16', language: 'c') -gio_dep = dependency('gio-2.0', version: '>=2.44') +gio_dep = dependency('gio-2.0', version: '>=2.46') gtk_dep = dependency('gtk+-3.0', version: '>=3.16') subdir('data') diff --git a/src/rugby-scoring.c b/src/rugby-scoring.c index 454dbbbe827dcf32f7724d9ee181617761a718ae..7beac8f584b2b2464b9cec99ec6c3b17db054135 100644 --- a/src/rugby-scoring.c +++ b/src/rugby-scoring.c @@ -19,8 +19,35 @@ #include "rugby-possibility.h" #include "rugby-scoring.h" +static gint +compare_func (gconstpointer a, + gconstpointer b, + gpointer user_data) +{ + gint atries, autries; + gint btries, butries; + + g_object_get ((gpointer) a, + "tries", &atries, + "utries", &autries, + NULL); + g_object_get ((gpointer) b, + "tries", &btries, + "utries", &butries, + NULL); + + gint trydiff = (atries + autries) - (btries + butries); + + // Sort by total tries first, then converted + if (trydiff != 0) + return trydiff; + else + return atries - btries; +} + void -rugby_scoring_get_possibilities (GListStore *store, gint score) +rugby_scoring_get_possibilities (GListStore *store, + gint score) { gint max_tries = score / TRY_POINTS; gint max_utries = score / UTRY_POINTS; @@ -47,6 +74,8 @@ rugby_scoring_get_possibilities (GListStore *store, gint score) } } } + + g_list_store_sort (store, compare_func, NULL); } gint