From c3b63593e72b830df69d2a9ae25bcc0c72d16dc6 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 27 Nov 2023 12:20:51 +0600 Subject: [PATCH] Repeat paths highlighting redone --- source/ubl-settings-logging.c | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index dd48ac5..efffe58 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -456,15 +456,31 @@ void on_logrotate_configuration_path_add(GtkWidget *self, logrotate_configure_wi } void on_path_editing_done(GtkCellRendererText* self,gchar* path,gchar* new_text,logrotate_configure_window *window){ - GtkTreeIter iter; + GtkTreeIter iter, itar; char *cur_path; gtk_tree_model_get_iter(GTK_TREE_MODEL(window->list),&iter,gtk_tree_path_new_from_string(path)); gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); - if (cur_path&&!strcmp(cur_path,"")&&!strcmp(new_text,"")) + if (!strcmp(new_text,"")||cur_path&&!strcmp(cur_path,"")) gtk_list_store_remove(window->list,&iter); - else if (new_text&&strcmp(new_text,"")) - gtk_list_store_set(window->list,&iter,0,new_text,-1); + else if (new_text&&strcmp(new_text,"")){ + int deleted=0; + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ + char *path; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&path,-1); + if (path&&new_text) + if (!strcmp(path,new_text)){ + yon_ubl_status_list_store_highlight_incorrect(window->list,gtk_tree_iter_copy(&itar)); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + gtk_list_store_remove(window->list,&iter); + deleted=1; + } + } + if (!deleted) + gtk_list_store_set(window->list,&iter,0,new_text,-1); + + } GValue *val = g_malloc0(sizeof(GValue)); g_object_get_property(G_OBJECT(self),"editable",val); g_value_set_boolean(val,0); @@ -779,20 +795,6 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ return; } } - if (paths){ - int psize=0; - int fo=0; - int so=0; - config_str paths_parsed = yon_char_parse(paths,&psize,","); - if (yon_char_parsed_check_repeats(paths_parsed,psize,&fo,&so)){ - gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),lastiter,yon_char_from_int(fo)); - gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),lastitar,yon_char_from_int(so)); - yon_ubl_status_list_store_highlight_incorrect(window->list,lastiter); - yon_ubl_status_list_store_highlight_incorrect(window->list,lastitar); - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - return; - } - } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck))){ int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo)); switch (active){