Zone list sorting changes

pull/148/head
parent a8bb3fb5d8
commit 42011b57de

@ -3,6 +3,33 @@
config main_config;
// functions
int yon_char_parsed_compare(const void *a, const void *b){
const config_str str_a = (const config_str)a;
const config_str str_b = (const config_str)b;
// if (strstr(*str_a,"+")&&strstr(*str_b,"-")) return 1;
// else if (strstr(*str_a,"-")&&strstr(*str_b,"+")) return -1;
// if (strstr(*str_a,"-")&&strstr(*str_b,"-")) return strcmp(*str_b,*str_a);
if ((strstr(*str_a,"-")||strstr(*str_a,"+"))&&(strstr(*str_b,"-")||strstr(*str_b,"+"))){
int a = atoi(*str_a+3);
int b = atoi(*str_b+3);
if (a>b) return 1;
else if (b>a) return -1;
else return 0;
}
return strcmp(*str_a, *str_b);
}
config_str yon_char_parsed_sort(config_str parsed, int size){
config_str new_parsed = yon_char_parsed_copy(parsed,size);
qsort(new_parsed,size,sizeof(char*),yon_char_parsed_compare);
return new_parsed;
}
//Config functions
void yon_save_parameters(main_window *widgets){
int mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->DHCPCombo));
switch(mode){
@ -188,10 +215,12 @@ void on_region_changed(GtkComboBox *self, main_window *widgets){
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo));
if (yon_file_is_directory(active)){
config_str parsed = yon_file_ls(active,&size);
config_str parsed_sorted = yon_char_parsed_sort(parsed,size);
yon_char_parsed_free(parsed,size);
for (int i=0;i<size;i++){
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo),parsed[i],_(parsed[i]));
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo),parsed_sorted[i],_(parsed_sorted[i]));
}
if (size) yon_char_parsed_free(parsed,size);
if (size) yon_char_parsed_free(parsed_sorted,size);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ZoneCombo),0);
}
free(active);

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

@ -633,12 +633,6 @@ msgstr ""
msgid "Funafuti"
msgstr ""
msgid "GMT-1"
msgstr ""
msgid "GMT-3"
msgstr ""
msgid "Gaborone"
msgstr ""

@ -638,12 +638,6 @@ msgstr "Фритаун"
msgid "Funafuti"
msgstr "Фунафути"
msgid "GMT-1"
msgstr "ГМТ-1"
msgid "GMT-3"
msgstr "ГМТ-3"
msgid "Gaborone"
msgstr "Габороне"

Loading…
Cancel
Save