zone loading changes

pull/177/head
parent 3eabce70fe
commit 8e4232aee3
No known key found for this signature in database
GPG Key ID: FF1D842BF4DDE92B

@ -307,8 +307,8 @@ void on_date_clicked(GtkWidget *,main_window *widgets){
}
void on_region_changed(GtkComboBox *self, main_window *widgets){
char *active = (char*)gtk_combo_box_get_active_id(self);
active = yon_char_append("/usr/share/zoneinfo/",active);
char *active_name = (char*)gtk_combo_box_get_active_id(self);
char *active = yon_char_append("/usr/share/zoneinfo/",active_name);
int size;
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo));
if (yon_file_is_directory(active)){
@ -316,12 +316,25 @@ void on_region_changed(GtkComboBox *self, main_window *widgets){
config_str parsed_sorted = yon_char_parsed_sort(parsed,size);
yon_char_parsed_free(parsed,size);
for (int i=0;i<size;i++){
char *name_string = NULL;
if (strstr(parsed_sorted[i],"GMT")){
char *temp = yon_char_unite("UTC",parsed_sorted[i]+3," (",parsed_sorted[i],")",NULL);
free(parsed_sorted[i]);
parsed_sorted[i]=temp;
} else if (strcmp(active_name,"Etc")){
char *zonereg = yon_char_unite(active,"/",parsed_sorted[i],NULL);
if (g_setenv("TZ",zonereg,1)){
time_t curtime = time(NULL);
struct tm *local = localtime(&curtime);
char *hour_str = yon_char_from_long(local->tm_gmtoff/3600);
char *minute = yon_char_from_long((local->tm_gmtoff%3600)/60);
name_string = yon_char_unite("(UTC ",local->tm_gmtoff>0?"+":"-",hour_str,":",minute,") ",_(parsed_sorted[i]),NULL);
free(hour_str);
free(minute);
free(zonereg);
}
}
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo),parsed_sorted[i],_(parsed_sorted[i]));
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo),parsed_sorted[i],name_string?name_string:_(parsed_sorted[i]));
}
if (size) yon_char_parsed_free(parsed_sorted,size);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ZoneCombo),0);

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <libintl.h>
#include <getopt.h>
#include <time.h>
#include <libintl.h>
#include <libublsettings.h>
#include <libublsettings-gtk3.h>

Loading…
Cancel
Save