From 813a4bd83c32f239cf390a37078f56e89294b82c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 24 Nov 2023 15:35:14 +0600 Subject: [PATCH] Fixing of repeat paths checking --- source/ubl-settings-logging.c | 22 +++++++++++++++------- source/ubl-utils.c | 12 +++++++----- source/ubl-utils.h | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index f72b4f9..8c89468 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -734,8 +734,10 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } 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)){ + if (yon_char_parsed_check_repeats(paths_parsed,psize,&fo,&so)){ yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->LogPathsTree)); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; @@ -1745,6 +1747,18 @@ void on_log_save(GtkWidget *self, dictionary *dict){ if (strcmp(cur,"")) pathse=yon_char_unite(pathse ? yon_char_append(pathse,"\n"):"",cur,NULL); } + + int fo=0; + int so=0; + int paths_size; + config_str paths_parsed = yon_char_parse(pathse,&paths_size,"\n"); + if (yon_char_parsed_check_repeats(paths_parsed,paths_size,&fo,&so)){ + GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + yon_ubl_status_highlight_incorrect((GtkWidget*)g_list_nth_data(list,so)); + yon_ubl_status_highlight_incorrect((GtkWidget*)g_list_nth_data(list,fo)); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } GtkTreeIter iter; char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); char *desc = (char*)gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)); @@ -1765,14 +1779,8 @@ void on_log_save(GtkWidget *self, dictionary *dict){ } int paths_size=0; config_str paths_parsed = yon_char_parse(paths,&paths_size,"\n"); - if (yon_char_parsed_check_repeats(paths_parsed,paths_size)){ - yon_ubl_status_highlight_incorrect(window->LogPathsBox); - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - return; - } int pathse_size=0; config_str pathse_parsed = yon_char_parse(pathse,&pathse_size,"\n"); - if (yon_char_parsed_includes_char_parsed(pathse_parsed,paths_parsed,pathse_size,paths_size)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->LogPathsBox); diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 2e7d9d4..4f3fa2e 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -776,11 +776,13 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ * Проверяет есть ли в массиве строк [parameters], размера [size] * повторения */ -int yon_char_parsed_check_repeats(char **parameters, int size){ - for (int i=0;i