From 0d3b73881d57bfeaedaeeb9ef0b83191f34ae185 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 19 Nov 2025 16:02:04 +0600 Subject: [PATCH 1/2] Fixed repository loading --- source/ubl-settings-update.c | 108 +++++++++++++++++++++++------------ source/ubl-settings-update.h | 8 +-- 2 files changed, 76 insertions(+), 40 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index 0e8ea9b..d56107f 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -187,19 +187,43 @@ void on_toggle_button_toggled(GtkWidget *self, main_window *widgets){ } } -void yon_load_proceed(YON_CONFIG_TYPE type){ - yon_config_clean(); - char *default_command = yon_char_unite(config_get_default_command,NULL); - if (!yon_char_is_empty(default_command)) - yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); +void yon_load_proceed(YON_CONFIG_TYPE type){ + if (type!=YON_CONFIG_CUSTOM){ + yon_config_clean(); + if (!yon_char_is_empty(config_get_default_command)) + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + } if (type==YON_CONFIG_GLOBAL){ - yon_config_load_config(type,config_get_global_command,NULL); + yon_config_load_config(type,config_get_command("global"),NULL); } else if (type==YON_CONFIG_LOCAL){ - yon_config_load_config(type,config_get_local_command,NULL); + yon_config_load_config(type,config_get_command("system"),NULL); } else if (type==YON_CONFIG_CUSTOM){ - char *path=yon_custom_config_init(GTK_FILE_CHOOSER_ACTION_OPEN); - char *command = yon_config_get_custom_command(path); - yon_config_load_config(type,command,NULL); + char *path=""; + textdomain(template_ui_LocaleName); + GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); + textdomain(LocaleName); + gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubl-settings-services"); + gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter,"*.ini"); + gtk_file_filter_set_name(filter, "*.ini"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); + gtk_widget_show(dialog); + int response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_ACCEPT){ + char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + if (!yon_char_is_empty(file)){ + path=file; + } + yon_config_clean(); + if (!yon_char_is_empty(config_get_default_command)) + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + char *command = config_get_command(path); + yon_config_load_config(type,command,NULL); + gtk_widget_destroy(dialog); + } else { + gtk_widget_destroy(dialog); + } } yon_config_set_ignore(AUTOUPDATE_timestamp); } @@ -241,8 +265,8 @@ void yon_interface_update(main_window *widgets){ char *repo_config = config(REPOSITORY_parameter); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RepositoriesRepoListConfigurationCheck),0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RepositoriesDisableSystemReposCheck),0); - if (!yon_char_is_empty(repo_config)){ - config_str repos = yon_config_get_all_by_key(REPOSITORY_search,&size); + + config_str repos = yon_config_get_all_by_key(REPOSITORY_search,&size); for (int i=0;iRepositoriesRepoListConfigurationCheck),0); } else if (!strcmp(repo_config,"enable")){ @@ -545,54 +571,48 @@ void on_web_user_check(GtkToggleButton *self, web_publication_add_window *window void on_config_save(GtkWidget *, main_window *){ main_config.save_config=2; - template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,yon_config_get_custom_command("global"),NULL); + template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL); if (window){}; } void on_config_global_save(GtkWidget *, main_window *){ main_config.save_config=0; - template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,yon_config_get_custom_command("global"),NULL); + template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL); if (window){}; } void on_config_local_save(GtkWidget *, main_window *){ main_config.save_config=1; - template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,yon_config_get_custom_command("system"),NULL); + template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL); if (window){}; } void on_config_custom_save(GtkWidget *, main_window *){ main_config.save_config=1; - template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,yon_config_get_custom_command("system"),NULL); + template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); if (window){}; } -void on_config_local_load(GtkWidget *, main_window *widgets){ - yon_load_proceed(YON_CONFIG_LOCAL); - textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - textdomain(LocaleName); - main_config.load_mode=1; - yon_interface_update(widgets); +void on_config_local_load(GtkWidget *,main_window *widgets){ + yon_load_proceed(YON_CONFIG_LOCAL); + yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + main_config.load_mode=YON_CONFIG_LOCAL; + yon_interface_update(widgets); } -void on_config_global_load(GtkWidget *, main_window *widgets){ - yon_load_proceed(YON_CONFIG_GLOBAL); - textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - textdomain(LocaleName); - main_config.load_mode=0; - yon_interface_update(widgets); +void on_config_global_load(GtkWidget *,main_window *widgets){ + yon_load_proceed(YON_CONFIG_GLOBAL); + yon_ubl_status_box_render(yon_char_get_localised_from_lib(GLOBAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + main_config.load_mode=YON_CONFIG_GLOBAL; + yon_interface_update(widgets); } void on_config_custom_load(GtkWidget *,main_window *widgets){ yon_load_proceed(YON_CONFIG_CUSTOM); - textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - textdomain(LocaleName); - main_config.load_mode=3; - yon_interface_update(widgets); + yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + main_config.load_mode=YON_CONFIG_CUSTOM; + yon_interface_update(widgets); } void on_toggle_cell_toggled(GtkCellRenderer *self,char *path, main_window *widgets){ @@ -1908,6 +1928,20 @@ void on_column_resize(GtkTreeViewColumn *,GParamSpec *,main_window *widgets){ } +void on_update_clicked(GtkWidget *, main_window *widgets){ + switch(main_config.load_mode){ + case YON_CONFIG_LOCAL: + on_config_local_load(NULL,widgets); + break; + case YON_CONFIG_GLOBAL: + on_config_global_load(NULL,widgets); + break; + case YON_CONFIG_CUSTOM: + on_config_custom_load(NULL,widgets); + break; + } +} + /**yon_main_window_complete(main_window *widgets) * [EN] * @@ -2005,6 +2039,10 @@ void yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->UpdateIntervalDefaultCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->UpdateIntervalCombo); g_signal_connect(G_OBJECT(widgets->UpdateIntervalDefaultCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->UpdateIntervalSpin); g_signal_connect(G_OBJECT(widgets->UpdateIntervalDefaultCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->BootCheck); + g_signal_connect(G_OBJECT(widgets->RepositoriesUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); + g_signal_connect(G_OBJECT(widgets->PublicationUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); + g_signal_connect(G_OBJECT(widgets->WebPublicationUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); + g_signal_connect(G_OBJECT(widgets->MirrorUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); // g_signal_connect(G_OBJECT(widgets->RepositoriesDisableSystemReposCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->RepositoriesTree); GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->WebPublicationTree)); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 179fc0c..4958bc2 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -46,11 +46,8 @@ #define sha256_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha256sum | cut -f 1 -d ' '",NULL) #define sha512_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha512sum | cut -f 1 -d ' '",NULL) -#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get [update] REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL) -#define config_get_local_command "ubconfig --source system get [update] REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL -#define config_get_global_command "ubconfig --source global get [update] REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL -#define config_get_default_command "ubconfig --source default get [update] AUTOUPDATE[repos] AUTOUPDATE[interval] AUTOUPDATE[mode] AUTOUPDATE REPOSITORY REPOSITORY[*]",NULL -#define config_get_command_no_repos(config,target) yon_char_unite("ubconfig --source ",config," get update",target,NULL) +#define config_get_command(target) yon_char_unite("ubconfig --source ",target," get [update] REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL) +#define config_get_default_command "ubconfig --source default get [update] AUTOUPDATE[repos] AUTOUPDATE[interval] AUTOUPDATE[mode] AUTOUPDATE REPOSITORY REPOSITORY[*]" #define config_get_global_only_parameters "" #define config_get_local_only_parameters "" @@ -389,4 +386,5 @@ char *yon_password_unencrypted_password_get(password_window *window); char *yon_password_hash_get(password_window *window); void yon_hash_entry_sensitiveness_update(GtkWidget *, password_window *dialog); void on_password_hash_sensitiveness(GtkWidget *,password_window *window); +void on_update_clicked(GtkWidget *, main_window *widgets); #endif \ No newline at end of file -- 2.35.1 From bc93d82ec7033882ec042bf503d4773f63433729 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 19 Nov 2025 16:37:20 +0600 Subject: [PATCH 2/2] Template update --- source/ubl-settings-update.c | 29 ++++++++++++++--------------- source/ubl-settings-update.h | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index d56107f..379b7e2 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -5,7 +5,7 @@ config main_config; //functions void on_save_done(main_window *, config_str output, int size){ - char *final_output = yon_char_parsed_to_string(output,size,""); + char *final_output = yon_char_parsed_to_string(output,size,"\n"); if (final_output){ printf("%s\n",final_output); free(final_output); @@ -24,7 +24,7 @@ void on_save_done(main_window *, config_str output, int size){ break; } textdomain(LocaleName); - yon_config_set_ignore(REPOSITORY_parameter); + // yon_config_set_ignore(REPOSITORY_parameter); } @@ -570,27 +570,26 @@ void on_web_user_check(GtkToggleButton *self, web_publication_add_window *window } void on_config_save(GtkWidget *, main_window *){ - main_config.save_config=2; - template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL); - if (window){}; + main_config.save_config=YON_CONFIG_BOTH; + yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL); } -void on_config_global_save(GtkWidget *, main_window *){ - main_config.save_config=0; - template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL); - if (window){}; +void on_config_local_save(GtkWidget *, main_window *){ + main_config.save_config=YON_CONFIG_LOCAL; + yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL); + } -void on_config_local_save(GtkWidget *, main_window *){ - main_config.save_config=1; - template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL); - if (window){}; +void on_config_global_save(GtkWidget *, main_window *){ + main_config.save_config=YON_CONFIG_GLOBAL; + yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL); + } void on_config_custom_save(GtkWidget *, main_window *){ - main_config.save_config=1; + main_config.save_config=YON_CONFIG_LOCAL; template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); - if (window){}; + if (window){}; } diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 4958bc2..581925e 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -46,7 +46,7 @@ #define sha256_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha256sum | cut -f 1 -d ' '",NULL) #define sha512_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha512sum | cut -f 1 -d ' '",NULL) -#define config_get_command(target) yon_char_unite("ubconfig --source ",target," get [update] REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL) +#define config_get_command(target) yon_char_unite("ubconfig --source ",target," -ea get [update] REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL) #define config_get_default_command "ubconfig --source default get [update] AUTOUPDATE[repos] AUTOUPDATE[interval] AUTOUPDATE[mode] AUTOUPDATE REPOSITORY REPOSITORY[*]" #define config_get_global_only_parameters "" -- 2.35.1