@ -40,18 +40,37 @@ void on_region_changed(GtkComboBox *self, main_window *widgets){
}
}
# ifdef TIMEZONEMAP_INCLUDE
# ifdef TIMEZONEMAP_INCLUDE
gboolean on_map_box_ckicked_skip ( ) {
return 0 ;
}
void on_map_selection_changed ( GtkWidget * , CcTimezoneLocation * location , main_window * ) ;
void on_map_selection_changed ( GtkWidget * , CcTimezoneLocation * location , main_window * ) ;
void yon_map_status_hide ( main_window * widgets ) {
void yon_map_status_hide ( main_window * widgets ) {
gtk_widget_hide ( widgets - > TimeZoneMapOverlayBox ) ;
gtk_widget_hide ( widgets - > TimeZoneMapOverlayBox ) ;
}
}
void yon_map_status_hide_timeout ( main_window * widgets ) {
GMutex map_source_mutex ;
g_idle_add_once ( ( GSourceOnceFunc ) yon_map_status_hide , widgets ) ;
guint map_status_source = - 1 ;
gboolean yon_map_status_hide_timeout ( main_window * widgets ) {
printf ( " hide \n " ) ;
g_mutex_lock ( & map_source_mutex ) ;
map_status_source = - 1 ;
g_mutex_unlock ( & map_source_mutex ) ;
g_idle_add_once ( ( GSourceOnceFunc ) yon_map_status_hide , widgets ) ;
return G_SOURCE_REMOVE ;
}
}
void yon_map_status_show ( main_window * widgets , char * icon_name , char * title , char * title_info ) {
void yon_map_status_show ( main_window * widgets , char * icon_name , char * title , char * title_info ) {
g_mutex_lock ( & map_source_mutex ) ;
if ( map_status_source ! = ( guint ) - 1 ) {
g_source_remove ( map_status_source ) ;
printf ( " remove \n " ) ;
map_status_source = ( guint ) - 1 ;
}
g_mutex_unlock ( & map_source_mutex ) ;
gtk_widget_show ( widgets - > TimeZoneMapOverlayBox ) ;
gtk_widget_show ( widgets - > TimeZoneMapOverlayBox ) ;
gtk_label_set_text ( GTK_LABEL ( widgets - > TimeZoneMapOverlayTitleLabel ) , title ) ;
gtk_label_set_text ( GTK_LABEL ( widgets - > TimeZoneMapOverlayTitleLabel ) , title ) ;
gtk_label_set_text ( GTK_LABEL ( widgets - > TimeZoneMapOverlayInfoLabel ) , title_info ) ;
gtk_label_set_text ( GTK_LABEL ( widgets - > TimeZoneMapOverlayInfoLabel ) , title_info ) ;
@ -62,7 +81,10 @@ void yon_map_status_show(main_window *widgets, char *icon_name, char *title, cha
} else {
} else {
gtk_widget_hide ( widgets - > TimeZoneMapOverlayImage ) ;
gtk_widget_hide ( widgets - > TimeZoneMapOverlayImage ) ;
}
}
g_timeout_add_seconds_once ( 5 , ( GSourceOnceFunc ) yon_map_status_hide_timeout , widgets ) ;
g_mutex_lock ( & map_source_mutex ) ;
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 ) ;
}
}
void on_zone_changed ( GtkWidget * , main_window * widgets ) {
void on_zone_changed ( GtkWidget * , main_window * widgets ) {
@ -96,11 +118,12 @@ void on_map_selection_changed(GtkWidget *,CcTimezoneLocation *location,main_wind
gtk_tree_model_get ( GTK_TREE_MODEL ( widgets - > RegionTimezoneCompletionList ) , & iter , 0 , & render , 1 , & tz , - 1 ) ;
gtk_tree_model_get ( GTK_TREE_MODEL ( widgets - > RegionTimezoneCompletionList ) , & iter , 0 , & render , 1 , & tz , - 1 ) ;
if ( ! strcmp ( timezone , tz ) ) {
if ( ! strcmp ( timezone , tz ) ) {
gtk_entry_set_text ( GTK_ENTRY ( widgets - > RegionEntry ) , render ) ;
gtk_entry_set_text ( GTK_ENTRY ( widgets - > RegionEntry ) , render ) ;
char * utc = yon_timezone_get_utc ( tz ) ;
yon_map_status_show ( widgets , NULL , MAP_TITLE_LABEL ( utc ) , render ) ;
}
}
}
}
yon_map_status_show ( widgets , NULL , MAP_TITLE_LABEL , MAP_INFO_LABEL ) ;
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 - > ZoneCombo ) , G_CALLBACK ( on_zone_changed ) , widgets ) ;
g_signal_handlers_unblock_by_func ( G_OBJECT ( widgets - > RegionEntry ) , G_CALLBACK ( on_region_entry_changed ) , widgets ) ;
g_signal_handlers_unblock_by_func ( G_OBJECT ( widgets - > RegionEntry ) , G_CALLBACK ( on_region_entry_changed ) , widgets ) ;
}
}
@ -128,9 +151,11 @@ 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 ( ) ;
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
# ifdef TIMEZONEMAP_INCLUDE // insert timezonemap's interactive map
GList * list = gtk_container_get_children ( GTK_CONTAINER ( widgets - > RegionMapBox ) ) ;
GList * list = gtk_container_get_children ( GTK_CONTAINER ( widgets - > RegionMapBox ) ) ;
if ( list ) {
if ( list ) {
GList * iter ;
GList * iter ;
@ -147,28 +172,19 @@ void yon_region_init(main_window *widgets){
if ( ! yon_char_is_empty ( config_param ) ) {
if ( ! yon_char_is_empty ( config_param ) ) {
cc_timezone_map_set_timezone ( CC_TIMEZONE_MAP ( widgets - > RegionMapTarget ) , config_param ) ;
cc_timezone_map_set_timezone ( CC_TIMEZONE_MAP ( widgets - > RegionMapTarget ) , config_param ) ;
}
}
# else // if timezonemap does not installed, static image inserts
# endif
# endif
int size ;
size_t size ;
config_str parsed = NULL ;
GtkTreeIter iter ;
parsed = yon_dir_get_contents ( zone_path , & size ) ;
config_str parsed = yon_timezone_get_all ( & size ) ;
for ( int i = 0 ; i < size ; i + + ) {
for ( size_t i = 0 ; i < size ; i + + ) {
if ( ! strstr ( parsed [ i ] , " . " ) & & strcmp ( parsed [ i ] , " posix " ) & & strcmp ( parsed [ i ] , " right " ) ) {
char * zone_country = yon_timezone_get_country ( parsed [ i ] ) ;
char * path = yon_char_append ( zone_path , parsed [ i ] ) ;
char * zone_city = yon_timezone_get_city ( parsed [ i ] ) ;
if ( yon_file_is_directory ( path ) ) {
char * zone_name = yon_char_unite ( _ ( zone_city ) , " , " , _ ( zone_country ) , NULL ) ;
gtk_combo_box_text_append ( GTK_COMBO_BOX_TEXT ( widgets - > RegionCombo ) , parsed [ i ] , _ ( parsed [ i ] ) ) ;
gtk_list_store_append ( widgets - > RegionTimezoneCompletionList , & iter ) ;
char * active = yon_char_append ( " /usr/share/zoneinfo/ " , parsed [ i ] ) ;
gtk_list_store_set ( widgets - > RegionTimezoneCompletionList , & iter , 0 , zone_name , 1 , parsed [ i ] , - 1 ) ;
int zone_size ;
// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets))
config_str zone_parsed = yon_file_ls ( active , & zone_size ) ;
GtkTreeIter iter ;
for ( int j = 0 ; j < zone_size ; j + + ) {
char * zone_name = yon_char_unite ( _ ( zone_parsed [ j ] ) , " , " , _ ( parsed [ i ] ) , NULL ) ;
char * zone_string = yon_char_unite ( parsed [ i ] , " / " , zone_parsed [ j ] , NULL ) ;
gtk_list_store_append ( widgets - > RegionTimezoneCompletionList , & iter ) ;
gtk_list_store_set ( widgets - > RegionTimezoneCompletionList , & iter , 0 , zone_name , 1 , zone_string , - 1 ) ;
}
}
free ( path ) ;
}
}
}
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 ) ;