From 2267dba47e4afdf1b8f7639afaf1a78120aa2908 Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Mon, 2 Feb 2026 18:16:39 +0600 Subject: [PATCH] WIP region changes --- source/ubinstall-gtk-region.c | 67 +++++++++++++++++++++++++---------- source/ubinstall-gtk.c | 5 ++- source/ubinstall-gtk.h | 8 ++++- ubinstall-gtk.glade | 30 ++++++++++++++++ 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/source/ubinstall-gtk-region.c b/source/ubinstall-gtk-region.c index 92d2d26..d5b5bfe 100644 --- a/source/ubinstall-gtk-region.c +++ b/source/ubinstall-gtk-region.c @@ -1,6 +1,8 @@ #include "ubinstall-gtk.h" - #ifdef TIMEZONEMAP_INCLUDE +// #define TIMEZONEMAP_INCLUDE +#ifdef TIMEZONEMAP_INCLUDE #include "timezonemap/cc-timezone-map.h" +#include "timezonemap/tz.h" #endif int yon_region_save(main_window *widgets){ @@ -21,22 +23,6 @@ int yon_region_save(main_window *widgets){ return 1; } - #ifdef TIMEZONEMAP_INCLUDE -void on_map_selection_changed(GtkWidget *,CcTimezoneLocation *location,main_window *); -void on_zone_changed(GtkWidget *, main_window *widgets){ - g_signal_handlers_block_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets); - - const char *region = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->RegionCombo)); - 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); - free(timezone); - } - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets); -} - #endif - 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); @@ -54,6 +40,20 @@ void on_region_changed(GtkComboBox *self, main_window *widgets){ } #ifdef TIMEZONEMAP_INCLUDE +void on_map_selection_changed(GtkWidget *,CcTimezoneLocation *location,main_window *); +void on_zone_changed(GtkWidget *, main_window *widgets){ + g_signal_handlers_block_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets); + + const char *region = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->RegionCombo)); + 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); + free(timezone); + } + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->RegionMapTarget),G_CALLBACK(on_map_selection_changed),widgets); +} + void on_map_selection_changed(GtkWidget *,CcTimezoneLocation *location,main_window *widgets){ if (!location) return; g_signal_handlers_block_by_func(G_OBJECT(widgets->ZoneCombo),G_CALLBACK(on_zone_changed),widgets); @@ -65,13 +65,33 @@ void on_map_selection_changed(GtkWidget *,CcTimezoneLocation *location,main_wind g_signal_handlers_unblock_by_func(G_OBJECT(widgets->ZoneCombo),G_CALLBACK(on_zone_changed),widgets); } + #endif +void on_region_entry_changed(GtkWidget *, main_window *widgets){ + GtkTreeIter iter; + int found = 0; + for_iter(widgets->RegionTimezoneCompletionList, &iter){ + char *target, *timezone; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->RegionTimezoneCompletionList),&iter,0,&target,1,&timezone,-1); + 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 + found = 1; + } + } + if (!found){ + g_object_set_data(G_OBJECT(widgets->RegionEntry),zone_parameter,NULL); + } +} + void yon_region_init(main_window *widgets){ 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 - yon_debug_output("%s\n","TIMEZONEMAP enabled"); GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->RegionMapBox)); if (list){ GList *iter; @@ -87,7 +107,6 @@ void yon_region_init(main_window *widgets){ char *config_param = config(zone_parameter); if (!yon_char_is_empty(config_param)){ cc_timezone_map_set_timezone(CC_TIMEZONE_MAP(widgets->RegionMapTarget),config_param); - // cc_timezone_map_set_location(CC_TIMEZONE_MAP(widgets->RegionMapTarget),lon, lat); } #endif int size; @@ -98,6 +117,16 @@ void yon_region_init(main_window *widgets){ char *path = yon_char_append(zone_path,parsed[i]); if (yon_file_is_directory(path)){ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->RegionCombo),parsed[i],_(parsed[i])); + char *active = yon_char_append("/usr/share/zoneinfo/",parsed[i]); + int zone_size; + config_str zone_parsed = yon_file_ls(active,&zone_size); + GtkTreeIter iter; + for (int j=0;jRegionTimezoneCompletionList,&iter); + gtk_list_store_set(widgets->RegionTimezoneCompletionList,&iter,0,zone_name,1,zone_string,-1); + } } free(path); } diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 8fe7423..3e20f91 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -585,8 +585,10 @@ void yon_main_window_create(main_window *widgets){ widgets->RegionCombo=yon_gtk_builder_get_widget(builder,"RegionCombo"); widgets->ZoneCombo=yon_gtk_builder_get_widget(builder,"ZoneCombo"); widgets->RegionSensitiveSwitch = yon_gtk_builder_get_widget(builder,"RegionSensitiveSwitch"); + widgets->RegionEntry = yon_gtk_builder_get_widget(builder,"RegionEntry"); + widgets->RegionTimezoneCompletionList = GTK_LIST_STORE(gtk_builder_get_object(builder,"RegionTimezoneCompletionList")); + widgets->RegionTimezoneCompletionFilter = GTK_TREE_MODEL_FILTER(gtk_builder_get_object(builder,"RegionTimezoneCompletionFilter")); - // widgets->UserImage=yon_gtk_builder_get_widget(builder,"UserImage"); widgets->UserRootNameEntry=yon_gtk_builder_get_widget(builder,"UserRootNameEntry"); widgets->UserRootLoginEntry=yon_gtk_builder_get_widget(builder,"UserRootLoginEntry"); widgets->UserRootPasswordCombo=yon_gtk_builder_get_widget(builder,"UserRootPasswordCombo"); @@ -774,6 +776,7 @@ void yon_main_window_create(main_window *widgets){ #ifdef TIMEZONEMAP_INCLUDE g_signal_connect(G_OBJECT(widgets->ZoneCombo),"changed",G_CALLBACK(on_zone_changed),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); g_signal_connect(G_OBJECT(widgets->RegionSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->ZoneCombo); g_signal_connect(G_OBJECT(widgets->RegionSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->RegionMapBox); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 78a9f0e..37aa815 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -504,6 +504,10 @@ typedef struct GtkWidget *RegionSensitiveSwitch; GtkWidget *RegionCombo; GtkWidget *ZoneCombo; + GtkWidget *RegionEntry; + GtkListStore *RegionTimezoneCompletionList; + GtkTreeModelFilter *RegionTimezoneCompletionFilter; + GtkWidget *InstallationRadio; GtkWidget *InstallationNearRadio; @@ -1476,4 +1480,6 @@ void yon_update_translation(main_window *widgets); void yon_translation_init(GtkBuilder *builder); void yon_licence_load(main_window *widgets); void on_network_removed(GtkWidget *,network_info *info); -char *yon_bootloader_get_os_name(char *parameter); \ No newline at end of file +char *yon_bootloader_get_os_name(char *parameter); +gboolean on_region_refilter(GtkTreeModel* model, GtkTreeIter* iter, main_window *widgets); +void on_region_entry_changed(GtkWidget *, main_window *widgets); \ No newline at end of file diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index a51f622..84623aa 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -273,6 +273,24 @@ center com.ublinux.libublsettingsui-gtk3.pan-left-symbolic + + + + + + + + + + RegionTimezoneCompletionList + 0 + + + + 0 + + + @@ -3772,6 +3790,18 @@ agreement + + False + True + 2 + + + + + True + True + entrycompletion1 + False True