From fc6090a9b623c4a5ba22af1f9eba2558780bb214 Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Fri, 6 Feb 2026 18:34:06 +0600 Subject: [PATCH] WIP region map updating changes --- locale/ubinstall-gtk_ru.po | 4 +- source/ubinstall-gtk-region.c | 81 ++++++++++++++++++++++++++--------- source/ubinstall-gtk.c | 3 ++ source/ubinstall-gtk.h | 5 ++- ubinstall-gtk.css | 6 +++ 5 files changed, 76 insertions(+), 23 deletions(-) diff --git a/locale/ubinstall-gtk_ru.po b/locale/ubinstall-gtk_ru.po index d2bb0f5..a5743d3 100644 --- a/locale/ubinstall-gtk_ru.po +++ b/locale/ubinstall-gtk_ru.po @@ -1,6 +1,6 @@ -# Language translations for ubinstal package. +# Language translations for ubinstall-gtk package. # Copyright (C) 2022, UBTech LLC -# This file is distributed under the same license as the ubinstal package. +# This file is distributed under the same license as the ubinstall-gtk package. # UBLinux Team , 2022 # #, fuzzy diff --git a/source/ubinstall-gtk-region.c b/source/ubinstall-gtk-region.c index eded13f..06937b4 100644 --- a/source/ubinstall-gtk-region.c +++ b/source/ubinstall-gtk-region.c @@ -25,22 +25,28 @@ int yon_region_save(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); - int size; + size_t size; 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); - for (int i=0;iZoneCombo),parsed[i],_(parsed[i])); - } - if (size) yon_char_parsed_free(parsed,size); - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ZoneCombo),0); + config_str parsed = yon_timezone_get_zones_from_region(active,&size); + for (size_t i=0;iZoneCombo),parsed[i],_(parsed[i])); } - free(active); + if (size) yon_char_parsed_free(parsed,size); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ZoneCombo),0); } #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(){ return 0; } @@ -55,7 +61,6 @@ GMutex map_source_mutex; 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); @@ -67,7 +72,6 @@ void yon_map_status_show(main_window *widgets, char *icon_name, char *title, cha 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); @@ -83,7 +87,6 @@ void yon_map_status_show(main_window *widgets, char *icon_name, char *title, cha } 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); } @@ -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)); if (!yon_char_is_empty(region)&&!yon_char_is_empty(zone)){ 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); } // 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 +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){ GtkTreeIter iter; 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)); if (!strcmp(target,target_entry)){ g_object_set_data(G_OBJECT(widgets->RegionEntry),zone_parameter,yon_char_new(timezone)); - #ifdef TIMEZONEMAP_INCLUDE - cc_timezone_map_set_timezone(CC_TIMEZONE_MAP(widgets->RegionMapTarget),timezone); - #endif + yon_map_update(widgets,timezone); found = 1; + } } if (!found){ @@ -152,7 +181,6 @@ void on_region_entry_changed(GtkWidget *, 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->KeyboardNumLockCombo)); #ifdef TIMEZONEMAP_INCLUDE // insert timezonemap's interactive map @@ -178,17 +206,30 @@ void yon_region_init(main_window *widgets){ size_t size; GtkTreeIter iter; 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;iRegionTimezoneCompletionList,&iter); 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;iRegionCombo),parsed[i],_(parsed[i])); + } + yon_char_parsed_free(parsed,zones_size); + textdomain(LocaleName); while(gtk_events_pending()) gtk_main_iteration(); 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)); if (!yon_char_is_empty(zone)){ diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index a7d4d63..c0fd160 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -780,6 +780,8 @@ void yon_main_window_create(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->RegionCombo),"changed",G_CALLBACK(on_region_changed),widgets); #ifdef TIMEZONEMAP_INCLUDE g_signal_connect(G_OBJECT(widgets->ZoneCombo),"changed",G_CALLBACK(on_zone_changed),widgets); + g_signal_connect(G_OBJECT(widgets->TimeZoneMapOverlayBox),"enter-notify-event",G_CALLBACK(on_time_zone_status_hover),widgets); + g_signal_connect(G_OBJECT(widgets->TimeZoneMapOverlayBox),"leave-notify-event",G_CALLBACK(on_time_zone_status_hover_end),widgets); #endif g_signal_connect(G_OBJECT(widgets->RegionEntry),"changed",G_CALLBACK(on_region_entry_changed),widgets); g_signal_connect(G_OBJECT(widgets->RegionSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->RegionCombo); @@ -927,6 +929,7 @@ void yon_main_window_create(main_window *widgets){ gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(widgets->LanguagesTree),(GtkTreeViewSearchEqualFunc)on_languages_search_func,widgets,NULL); gtk_overlay_add_overlay(GTK_OVERLAY(widgets->RegionMapOverlay),widgets->TimeZoneMapOverlayBox); + gtk_overlay_set_overlay_pass_through(GTK_OVERLAY(widgets->RegionMapOverlay),widgets->TimeZoneMapOverlayBox,1); gtk_widget_hide(widgets->TimeZoneMapOverlayBox); { diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index c24250c..18a769a 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -1491,4 +1491,7 @@ char *yon_size_get_name_from_letter(char letter); void yon_map_status_hide(main_window *widgets); gboolean yon_map_status_hide_timeout(main_window *widgets); void yon_map_status_show(main_window *widgets, char *icon_name, char *title, char *title_info); -gboolean on_map_box_ckicked_skip(); \ No newline at end of file +gboolean on_map_box_ckicked_skip(); +gboolean on_time_zone_status_hover(GtkWidget *, GdkEvent *, main_window *widgets); +gboolean on_time_zone_status_hover_end(GtkWidget *, GdkEvent *, main_window *widgets); +void yon_map_update(main_window *widgets, const char *timezone); \ No newline at end of file diff --git a/ubinstall-gtk.css b/ubinstall-gtk.css index ad241fa..61ab5cb 100644 --- a/ubinstall-gtk.css +++ b/ubinstall-gtk.css @@ -382,4 +382,10 @@ button { background-color: @theme_fg_color; opacity:0.7; border-radius:10px; +} + +.timezoneoverlay_hover { + background-color: @theme_fg_color; + opacity:0.3; + border-radius:10px; } \ No newline at end of file