From 14f278883640f71027e93f899a25f3722d8a2445 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 31 Jan 2024 11:31:00 +0600 Subject: [PATCH] Config loading is threaded --- source/ubl-settings-services.c | 24 ++++++++++++++++++------ source/ubl-settings-services.h | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index 84d1626..24aaf4a 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -14,18 +14,20 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ void on_config_local_load(GtkWidget *self,main_window *widgets){ if (self){}; yon_load_proceed(YON_CONFIG_LOCAL); - yon_interface_update(widgets); + yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + g_thread_new("",(GThreadFunc)yon_interface_update,widgets); + main_config.load_mode=1; textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); textdomain(LocaleName); } void on_config_global_load(GtkWidget *self,main_window *widgets){ if (self){}; yon_load_proceed(YON_CONFIG_GLOBAL); - yon_interface_update(widgets); + yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + g_thread_new("",(GThreadFunc)yon_interface_update,widgets); + main_config.load_mode=0; textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); textdomain(LocaleName); } @@ -378,7 +380,7 @@ void on_update(GtkWidget *self,main_window *widgets){ g_thread_new("",(GThreadFunc)yon_unthreaded_config_load,widgets); } -void yon_interface_update(main_window *widgets){ +void *yon_interface_update(main_window *widgets){ int size; GtkTreeIter iter; gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->MainTree),NULL); @@ -449,7 +451,15 @@ void yon_interface_update(main_window *widgets){ } free(name_parsed); } + textdomain(template_ui_LocaleName); + if (main_config.load_mode){ + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + } else { + yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + } + textdomain(LocaleName); gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->MainTree),GTK_TREE_MODEL(widgets->liststore2)); + return NULL; } void on_column_resize(GtkTreeViewColumn *self,GParamSpec *pspec,main_window *widgets){ @@ -564,6 +574,7 @@ void config_init(){ main_config.lock_load_global=0; main_config.lock_save_global=0; main_config.lock_save_local=0; + main_config.load_mode=1; } void on_activate(GtkTreeView *self, main_window *widgets){ @@ -659,7 +670,8 @@ void yon_main_window_complete(main_window *widgets){ gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(main_config.BlockedFilter),(GtkTreeModelFilterVisibleFunc)on_blocked_filter,NULL,NULL); gtk_tree_view_set_search_entry(GTK_TREE_VIEW(widgets->MainTree),GTK_ENTRY(widgets->SearchEntry)); yon_load_proceed(YON_CONFIG_LOCAL); - yon_interface_update(widgets); + yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + g_thread_new("",(GThreadFunc)yon_interface_update,widgets); } int main(int argc, char *argv[]){ diff --git a/source/ubl-settings-services.h b/source/ubl-settings-services.h index c66d42f..aca45c8 100644 --- a/source/ubl-settings-services.h +++ b/source/ubl-settings-services.h @@ -181,7 +181,7 @@ void on_config_local_save(); void on_config_global_save(); -void yon_interface_update(main_window *widgets); +void *yon_interface_update(main_window *widgets); GtkWidget *yon_menu_button_create(char *icon_name, char *text);