|
|
|
@ -25,22 +25,28 @@ int yon_region_save(main_window *widgets){
|
|
|
|
|
|
|
|
|
|
|
|
void on_region_changed(GtkComboBox *self, main_window *widgets){
|
|
|
|
void on_region_changed(GtkComboBox *self, main_window *widgets){
|
|
|
|
char *active = (char*)gtk_combo_box_get_active_id(self);
|
|
|
|
char *active = (char*)gtk_combo_box_get_active_id(self);
|
|
|
|
active = yon_char_append("/usr/share/zoneinfo/",active);
|
|
|
|
size_t size;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo));
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->ZoneCombo));
|
|
|
|
if (yon_file_is_directory(active)){
|
|
|
|
config_str parsed = yon_timezone_get_zones_from_region(active,&size);
|
|
|
|
config_str parsed = yon_file_ls(active,&size);
|
|
|
|
for (size_t i=0;i<size;i++){
|
|
|
|
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[i],_(parsed[i]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size) yon_char_parsed_free(parsed,size);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ZoneCombo),0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(active);
|
|
|
|
if (size) yon_char_parsed_free(parsed,size);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ZoneCombo),0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gboolean on_time_zone_status_hover(GtkWidget *, GdkEvent *, main_window *widgets){
|
|
|
|
|
|
|
|
gtk_style_context_add_class(gtk_widget_get_style_context(widgets->TimeZoneMapOverlayBox),"timezoneoverlay_hover");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gboolean on_time_zone_status_hover_end(GtkWidget *, GdkEvent *, main_window *widgets){
|
|
|
|
|
|
|
|
gtk_style_context_remove_class(gtk_widget_get_style_context(widgets->TimeZoneMapOverlayBox),"timezoneoverlay_hover");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gboolean on_map_box_ckicked_skip(){
|
|
|
|
gboolean on_map_box_ckicked_skip(){
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -55,7 +61,6 @@ GMutex map_source_mutex;
|
|
|
|
guint map_status_source = -1;
|
|
|
|
guint map_status_source = -1;
|
|
|
|
|
|
|
|
|
|
|
|
gboolean yon_map_status_hide_timeout(main_window *widgets){
|
|
|
|
gboolean yon_map_status_hide_timeout(main_window *widgets){
|
|
|
|
printf("hide\n");
|
|
|
|
|
|
|
|
g_mutex_lock(&map_source_mutex);
|
|
|
|
g_mutex_lock(&map_source_mutex);
|
|
|
|
map_status_source=-1;
|
|
|
|
map_status_source=-1;
|
|
|
|
g_mutex_unlock(&map_source_mutex);
|
|
|
|
g_mutex_unlock(&map_source_mutex);
|
|
|
|
@ -67,7 +72,6 @@ void yon_map_status_show(main_window *widgets, char *icon_name, char *title, cha
|
|
|
|
g_mutex_lock(&map_source_mutex);
|
|
|
|
g_mutex_lock(&map_source_mutex);
|
|
|
|
if (map_status_source!=(guint)-1){
|
|
|
|
if (map_status_source!=(guint)-1){
|
|
|
|
g_source_remove(map_status_source);
|
|
|
|
g_source_remove(map_status_source);
|
|
|
|
printf("remove\n");
|
|
|
|
|
|
|
|
map_status_source=(guint)-1;
|
|
|
|
map_status_source=(guint)-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_mutex_unlock(&map_source_mutex);
|
|
|
|
g_mutex_unlock(&map_source_mutex);
|
|
|
|
@ -83,7 +87,6 @@ void yon_map_status_show(main_window *widgets, char *icon_name, char *title, cha
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_mutex_lock(&map_source_mutex);
|
|
|
|
g_mutex_lock(&map_source_mutex);
|
|
|
|
map_status_source = g_timeout_add_seconds(3,(GSourceFunc)yon_map_status_hide_timeout,widgets);
|
|
|
|
map_status_source = g_timeout_add_seconds(3,(GSourceFunc)yon_map_status_hide_timeout,widgets);
|
|
|
|
printf("%d\n",map_status_source);
|
|
|
|
|
|
|
|
g_mutex_unlock(&map_source_mutex);
|
|
|
|
g_mutex_unlock(&map_source_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -94,7 +97,7 @@ void on_zone_changed(GtkWidget *, main_window *widgets){
|
|
|
|
const char *zone = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->ZoneCombo));
|
|
|
|
const char *zone = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->ZoneCombo));
|
|
|
|
if (!yon_char_is_empty(region)&&!yon_char_is_empty(zone)){
|
|
|
|
if (!yon_char_is_empty(region)&&!yon_char_is_empty(zone)){
|
|
|
|
char *timezone = yon_char_unite(region,"/",zone,NULL);
|
|
|
|
char *timezone = yon_char_unite(region,"/",zone,NULL);
|
|
|
|
cc_timezone_map_set_timezone(CC_TIMEZONE_MAP(widgets->RegionMapTarget),timezone);
|
|
|
|
yon_map_update(widgets,timezone);
|
|
|
|
free(timezone);
|
|
|
|
free(timezone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// g_signal_handlers_unblock_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets);
|
|
|
|
// g_signal_handlers_unblock_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets);
|
|
|
|
@ -130,6 +133,33 @@ void on_map_selection_changed(GtkWidget *,CcTimezoneLocation *location,main_wind
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void yon_map_update(main_window *widgets, const char *timezone){
|
|
|
|
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func(G_OBJECT(widgets->ZoneCombo),G_CALLBACK(on_zone_changed),widgets);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func(G_OBJECT(widgets->RegionEntry),G_CALLBACK(on_region_entry_changed),widgets);
|
|
|
|
|
|
|
|
textdomain(timezone_locale_name);
|
|
|
|
|
|
|
|
char *region = yon_timezone_get_zone(timezone);
|
|
|
|
|
|
|
|
char *country = yon_timezone_get_country(timezone);
|
|
|
|
|
|
|
|
char *city = yon_timezone_get_city(timezone);
|
|
|
|
|
|
|
|
char *zone_name = yon_char_unite(_(city),", ", _(country),NULL);
|
|
|
|
|
|
|
|
textdomain(LocaleName);
|
|
|
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->RegionEntry),zone_name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->RegionCombo),region);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->ZoneCombo),city);
|
|
|
|
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE
|
|
|
|
|
|
|
|
cc_timezone_map_set_timezone(CC_TIMEZONE_MAP(widgets->RegionMapTarget),timezone);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->RegionEntry),G_CALLBACK(on_region_entry_changed),widgets);
|
|
|
|
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->ZoneCombo),G_CALLBACK(on_zone_changed),widgets);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
textdomain(LocaleName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_region_entry_changed(GtkWidget *, main_window *widgets){
|
|
|
|
void on_region_entry_changed(GtkWidget *, main_window *widgets){
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
int found = 0;
|
|
|
|
int found = 0;
|
|
|
|
@ -139,10 +169,9 @@ void on_region_entry_changed(GtkWidget *, main_window *widgets){
|
|
|
|
char *target_entry = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->RegionEntry));
|
|
|
|
char *target_entry = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->RegionEntry));
|
|
|
|
if (!strcmp(target,target_entry)){
|
|
|
|
if (!strcmp(target,target_entry)){
|
|
|
|
g_object_set_data(G_OBJECT(widgets->RegionEntry),zone_parameter,yon_char_new(timezone));
|
|
|
|
g_object_set_data(G_OBJECT(widgets->RegionEntry),zone_parameter,yon_char_new(timezone));
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE
|
|
|
|
yon_map_update(widgets,timezone);
|
|
|
|
cc_timezone_map_set_timezone(CC_TIMEZONE_MAP(widgets->RegionMapTarget),timezone);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
found = 1;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found){
|
|
|
|
if (!found){
|
|
|
|
@ -152,7 +181,6 @@ void on_region_entry_changed(GtkWidget *, main_window *widgets){
|
|
|
|
|
|
|
|
|
|
|
|
void yon_region_init(main_window *widgets){
|
|
|
|
void yon_region_init(main_window *widgets){
|
|
|
|
yon_timezone_init();
|
|
|
|
yon_timezone_init();
|
|
|
|
|
|
|
|
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->RegionCombo));
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->RegionCombo));
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->KeyboardNumLockCombo));
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->KeyboardNumLockCombo));
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE // insert timezonemap's interactive map
|
|
|
|
#ifdef TIMEZONEMAP_INCLUDE // insert timezonemap's interactive map
|
|
|
|
@ -178,17 +206,30 @@ void yon_region_init(main_window *widgets){
|
|
|
|
size_t size;
|
|
|
|
size_t size;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
config_str parsed = yon_timezone_get_all(&size);
|
|
|
|
config_str parsed = yon_timezone_get_all(&size);
|
|
|
|
|
|
|
|
bind_textdomain_codeset(timezone_locale_name,"UTF-8");
|
|
|
|
|
|
|
|
textdomain(timezone_locale_name);
|
|
|
|
|
|
|
|
GHashTable *timezones_list = g_hash_table_new(g_str_hash,g_str_equal);
|
|
|
|
for (size_t i=0;i<size;i++){
|
|
|
|
for (size_t i=0;i<size;i++){
|
|
|
|
char *zone_country = yon_timezone_get_country(parsed[i]);
|
|
|
|
char *zone_country = yon_timezone_get_country(parsed[i]);
|
|
|
|
char *zone_city = yon_timezone_get_city(parsed[i]);
|
|
|
|
char *zone_city = yon_timezone_get_city(parsed[i]);
|
|
|
|
|
|
|
|
char *zone = yon_timezone_get_zone(parsed[i]);
|
|
|
|
char *zone_name = yon_char_unite(_(zone_city),", ", _(zone_country),NULL);
|
|
|
|
char *zone_name = yon_char_unite(_(zone_city),", ", _(zone_country),NULL);
|
|
|
|
gtk_list_store_append(widgets->RegionTimezoneCompletionList,&iter);
|
|
|
|
gtk_list_store_append(widgets->RegionTimezoneCompletionList,&iter);
|
|
|
|
gtk_list_store_set(widgets->RegionTimezoneCompletionList,&iter,0,zone_name,1,parsed[i],-1);
|
|
|
|
gtk_list_store_set(widgets->RegionTimezoneCompletionList,&iter,0,zone_name,1,parsed[i],-1);
|
|
|
|
// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets))
|
|
|
|
g_hash_table_add(timezones_list,zone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t zones_size;
|
|
|
|
|
|
|
|
parsed = (config_str)g_hash_table_get_keys_as_array(timezones_list,(guint*)&zones_size);
|
|
|
|
|
|
|
|
qsort(parsed,zones_size,sizeof(char*),(__compar_fn_t)yon_char_parsed_compare);
|
|
|
|
|
|
|
|
for (size_t i=0;i<zones_size;i++){
|
|
|
|
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->RegionCombo),parsed[i],_(parsed[i]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
yon_char_parsed_free(parsed,zones_size);
|
|
|
|
|
|
|
|
textdomain(LocaleName);
|
|
|
|
while(gtk_events_pending()) gtk_main_iteration();
|
|
|
|
while(gtk_events_pending()) gtk_main_iteration();
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->RegionCombo),0);
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->RegionCombo),0);
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
|
|
|
char *zone = yon_char_new(config(zone_parameter));
|
|
|
|
char *zone = yon_char_new(config(zone_parameter));
|
|
|
|
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(zone)){
|
|
|
|
if (!yon_char_is_empty(zone)){
|
|
|
|
|