Sorting will now fallback to basic sort order if the fancy sorts are identical
This commit is contained in:
parent
6ce49cd43d
commit
443b729de5
30
src/wofi.c
30
src/wofi.c
@ -962,23 +962,43 @@ static gint do_sort(GtkFlowBoxChild* child1, GtkFlowBoxChild* child2, gpointer d
|
||||
const gchar* text2 = wofi_property_box_get_property(WOFI_PROPERTY_BOX(box2), "filter");
|
||||
uint64_t index1 = strtol(wofi_property_box_get_property(WOFI_PROPERTY_BOX(box1), "index"), NULL, 10);
|
||||
uint64_t index2 = strtol(wofi_property_box_get_property(WOFI_PROPERTY_BOX(box2), "index"), NULL, 10);
|
||||
|
||||
if(text1 == NULL || text2 == NULL) {
|
||||
return index1 - index2;
|
||||
}
|
||||
if(filter == NULL || strcmp(filter, "") == 0) {
|
||||
|
||||
uint64_t fallback = 0;
|
||||
switch(sort_order) {
|
||||
case SORT_ORDER_DEFAULT:
|
||||
return index1 - index2;
|
||||
fallback = index1 - index2;
|
||||
break;
|
||||
case SORT_ORDER_ALPHABETICAL:
|
||||
return strcmp(text1, text2);
|
||||
if(insensitive) {
|
||||
fallback = strcasecmp(text1, text2);
|
||||
} else {
|
||||
fallback = strcmp(text1, text2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(filter == NULL || strcmp(filter, "") == 0) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
gint primary = 0;
|
||||
switch(matching) {
|
||||
case MATCHING_MODE_CONTAINS:
|
||||
return contains_sort(text1, text2);
|
||||
primary = contains_sort(text1, text2);
|
||||
if(primary == 0) {
|
||||
return fallback;
|
||||
}
|
||||
return primary;
|
||||
case MATCHING_MODE_FUZZY:
|
||||
return fuzzy_sort(text1, text2);
|
||||
primary = fuzzy_sort(text1, text2);
|
||||
if(primary == 0) {
|
||||
return fallback;
|
||||
}
|
||||
return primary;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user