From 397787a554bc8d65a1c2ea50784941d3de50a7da Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 21 Jul 2023 18:06:12 +0600 Subject: [PATCH] Implemented removal of config keys --- source/ubl-settings-repomanager.c | 4 +++- source/ubl-utils.c | 14 ++++++++++++++ source/ubl-utils.h | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-repomanager.c b/source/ubl-settings-repomanager.c index 9843c81..7a33a5f 100644 --- a/source/ubl-settings-repomanager.c +++ b/source/ubl-settings-repomanager.c @@ -131,12 +131,14 @@ void on_save(){ *(add) = 1; char *old_name=NULL; gtk_tree_model_get(GTK_TREE_MODEL(main_config.tree_store),&iter,1,&name_flagged,3,&origin_flagged,4,&repostatus,6,&old_name,7,&renamed,-1); - yon_window_config_add_custom_parameter(yon_char_unite(origin_flagged,"/",name_flagged,NULL),"repos",add,YON_TYPE_INT); if (repostatus==-1) { + yon_window_config_erase_custom_parameter(yon_char_unite(origin_flagged,"/",name_flagged,NULL),"repos"); remove_command = yon_char_unite("rm -rdf ",origin_flagged,"/",name_flagged,NULL); system (remove_command); gtk_tree_store_remove(main_config.tree_store,&iter); continue; } + else if (repostatus==1) + yon_window_config_add_custom_parameter(yon_char_unite(origin_flagged,"/",name_flagged,NULL),"repos",add,YON_TYPE_INT); // if (!strstr(name_flagged,".db.tar.gz")) name_flagged = yon_char_append(name_flagged,".db.tar.gz"); remove_command = yon_char_unite(command," remove -d ", origin_flagged, " -r ", name_flagged, NULL); add_command = yon_char_unite(command," add -d ", origin_flagged, " -r ", name_flagged, NULL); diff --git a/source/ubl-utils.c b/source/ubl-utils.c index f54b8fb..0810a44 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1411,6 +1411,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end int fullscreen; dictionary *custom_listeners; dictionary *custom_parameters; + dictionary *deleted_parameters; } __yon_main_window_config; static GtkWindow *__yon_window_config_target_window = NULL; @@ -1459,6 +1460,11 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end break; } } + if (__yon_main_window_config.deleted_parameters) + for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ + __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); + g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); + } g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); } @@ -1602,6 +1608,14 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param); } + void yon_window_config_erase_custom_parameter(char *param_name, char *section){ + __yon_custom_parameter *param = NULL; + param = yon_remalloc(param,sizeof(__yon_custom_parameter)); + param->parameter_name=param_name; + param->section=section; + yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); + } + GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); diff --git a/source/ubl-utils.h b/source/ubl-utils.h index e534334..bbda940 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -252,6 +252,8 @@ void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *w void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); +void yon_window_config_erase_custom_parameter(char *param_name, char *section); + int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find);