From c65d78a1381c9f4d10463c543c4411c25b98e164 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 14 Mar 2024 14:34:03 +0600 Subject: [PATCH] Fixed rendering of missing saving parameters --- source/libublsettingsui-gtk3.c | 92 +++++++++++++++++----------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/source/libublsettingsui-gtk3.c b/source/libublsettingsui-gtk3.c index 4ee9e2d..c16c2c4 100644 --- a/source/libublsettingsui-gtk3.c +++ b/source/libublsettingsui-gtk3.c @@ -352,61 +352,63 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ struct loaded_config *current_loaded = yon_config_convert_parameter(current_config,current_size); struct loaded_config *current = NULL; - for_dictionaries(current,current_loaded){ - dictionary *dict = yon_dictionary_get((dictionary**)&config_compare,current->key); - gboolean status=0; - status = yon_config_get_status(current->key); - if (dict&&!yon_char_is_empty((char*)dict->data)&&status!=-2){ - if (strcmp((char*)dict->data,(char*)current->data)){ + if (current_loaded){ + for_dictionaries(current,current_loaded){ + dictionary *dict = yon_dictionary_get((dictionary**)&config_compare,current->key); + gboolean status=0; + status = yon_config_get_status(current->key); + if (dict&&!yon_char_is_empty((char*)dict->data)&&status!=-2){ + if (strcmp((char*)dict->data,(char*)current->data)){ + GtkTreeIter iter; + if (status==0||status==-2) status = 0; + else status=1; + char *compare_string = yon_char_unite("",(char*)dict->data,"\n",(char*)current->data,NULL); + gtk_list_store_append(window->list,&iter); + gtk_list_store_set(window->list,&iter,0,status,1,current->key,2,(char*)dict->data,3,(char*)current->data,4,compare_string,6,1,-1); + free(compare_string); + } + } else if ((strcmp((char*)current->data,""))&&status!=-2){ GtkTreeIter iter; if (status==0||status==-2) status = 0; else status=1; - char *compare_string = yon_char_unite("",(char*)dict->data,"\n",(char*)current->data,NULL); + char *compare_string = yon_char_unite("\n",(char*)current->data,NULL); gtk_list_store_append(window->list,&iter); - gtk_list_store_set(window->list,&iter,0,status,1,current->key,2,(char*)dict->data,3,(char*)current->data,4,compare_string,6,1,-1); + gtk_list_store_set(window->list,&iter,0,status,1,current->key,3,(char*)current->data,4,compare_string,6,1,-1); free(compare_string); } - } else if ((strcmp((char*)current->data,""))&&status!=-2){ - GtkTreeIter iter; - if (status==0||status==-2) status = 0; - else status=1; - char *compare_string = yon_char_unite("\n",(char*)current->data,NULL); - gtk_list_store_append(window->list,&iter); - gtk_list_store_set(window->list,&iter,0,status,1,current->key,3,(char*)current->data,4,compare_string,6,1,-1); - free(compare_string); } - } - if (config_compare){ - for_dictionaries(current,config_compare){ - GtkTreeIter iter; - dictionary *dict = yon_dictionary_get((dictionary**)¤t_loaded,current->key); - if (!dict){ - GdkRGBA rgba; - rgba.alpha=0.8; - rgba.red=1; - rgba.blue=0.3; - rgba.green=0.65; - char *rgba_string = gdk_rgba_to_string(&rgba); - int status=0; - char *compare_string = yon_char_unite((char*)current->data,"\n",NULL); - gtk_list_store_append(window->list,&iter); - gtk_list_store_set(window->list,&iter,0,0,1,current->key,3,(char*)current->data,4,compare_string,5,rgba_string,6,1,-1); - free(compare_string); + if (config_compare){ + for_dictionaries(current,config_compare){ + GtkTreeIter iter; + dictionary *dict = yon_dictionary_get((dictionary**)¤t_loaded,current->key); + if (!dict){ + GdkRGBA rgba; + rgba.alpha=0.8; + rgba.red=1; + rgba.blue=0.3; + rgba.green=0.65; + char *rgba_string = gdk_rgba_to_string(&rgba); + int status=0; + char *compare_string = yon_char_unite((char*)current->data,"\n",NULL); + gtk_list_store_append(window->list,&iter); + gtk_list_store_set(window->list,&iter,0,0,1,current->key,2,(char*)current->data,4,compare_string,5,rgba_string,6,1,-1); + free(compare_string); + } } } } - GtkTreeIter iter; - if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter)){ - gtk_widget_destroy(window->Window); - textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(NOTHING_TO_SAVE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - textdomain(template_app_information.app_locale); - return NULL; - } - gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),GTK_TREE_MODEL(window->list)); - gtk_widget_show(window->Window); - on_save_window_parameter_switched(NULL,NULL,window); - return window; + GtkTreeIter iter; + if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter)){ + gtk_widget_destroy(window->Window); + textdomain(template_ui_LocaleName); + yon_ubl_status_box_render(NOTHING_TO_SAVE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + textdomain(template_app_information.app_locale); + return NULL; + } + gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),GTK_TREE_MODEL(window->list)); + gtk_widget_show(window->Window); + on_save_window_parameter_switched(NULL,NULL,window); + return window; } int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data){