Sorting fixes

pull/164/head
parent 658923ea6f
commit c7c9ab7414

@ -8,14 +8,24 @@ int yon_char_parsed_compare(const void *a, const void *b){
const config_str str_a = (const config_str)a; const config_str str_a = (const config_str)a;
const config_str str_b = (const config_str)b; const config_str str_b = (const config_str)b;
if ((strstr(*str_a,"-")||strstr(*str_a,"+"))&&(strstr(*str_b,"-")||strstr(*str_b,"+"))){ if ((strstr(_(*str_a),"-")||strstr(_(*str_a),"+"))&&(strstr(_(*str_b),"-")||strstr(_(*str_b),"+"))){
int a = atoi(*str_a+3); int a = atoi(_(*str_a)+3);
int b = atoi(*str_b+3); int b = atoi(_(*str_b)+3);
if (a>b) return 1; if (a>b) return 1;
else if (b>a) return -1; else if (b>a) return -1;
else return 0; else return 0;
} }
return strcmp(*str_a, *str_b); return strcoll(_(*str_a), _(*str_b));
}
config_str yon_char_parsed_localize(config_str parsed, int size){
config_str new_parsed = yon_char_parsed_copy(parsed,size);
for (int i=0;i<size;i++){
char *temp = yon_char_new(_(new_parsed[i]));
free(new_parsed[i]);
new_parsed[i]=temp;
}
return new_parsed;
} }
config_str yon_char_parsed_sort(config_str parsed, int size){ config_str yon_char_parsed_sort(config_str parsed, int size){
@ -467,11 +477,13 @@ void yon_main_window_complete(main_window *widgets){
int size; int size;
config_str parsed = yon_dir_get_contents(zone_path,&size); config_str parsed = yon_dir_get_contents(zone_path,&size);
config_str sorted = yon_char_parsed_sort(parsed,size);
config_str localized = yon_char_parsed_localize(sorted,size);
for (int i=0;i<size;i++){ for (int i=0;i<size;i++){
if (!strstr(parsed[i],".")&&strcmp(parsed[i],"posix")&&strcmp(parsed[i],"right")){ if (!strstr(sorted[i],".")&&strcmp(sorted[i],"posix")&&strcmp(sorted[i],"right")){
char *path = yon_char_append(zone_path,parsed[i]); char *path = yon_char_append(zone_path,sorted[i]);
if (yon_file_is_directory(path)){ if (yon_file_is_directory(path)){
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->RegionCombo),parsed[i],_(parsed[i])); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->RegionCombo),sorted[i],(localized[i]));
} }
free(path); free(path);
} }
@ -486,6 +498,7 @@ void yon_main_window_complete(main_window *widgets){
} }
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
setlocale(LC_COLLATE, "ru_RU.UTF-8");
local=setlocale(LC_ALL, ""); local=setlocale(LC_ALL, "");
textdomain (LocaleName); textdomain (LocaleName);
config_init(); config_init();

@ -140,6 +140,7 @@ void on_date_accept(GtkWidget *,main_window *widgets);
void on_date_cancel(GtkWidget *, main_window *widgets); void on_date_cancel(GtkWidget *, main_window *widgets);
config_str yon_char_parsed_localize(config_str parsed, int size);
config_str yon_char_parsed_sort(config_str parsed, int size); config_str yon_char_parsed_sort(config_str parsed, int size);
int yon_char_parsed_compare(const void *a, const void *b); int yon_char_parsed_compare(const void *a, const void *b);

Loading…
Cancel
Save