From b190d64534cc18f841a5b9619fcad0d6f496d9e3 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 8 Jul 2025 14:05:52 +0600 Subject: [PATCH] Choosement check fixes --- source/ubl-settings-repomanager-add-window.c | 27 ++++++++++++++++ source/ubl-settings-repomanager-move.c | 5 +++ source/ubl-settings-repomanager-remove.c | 33 +++++++++++++++----- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-repomanager-add-window.c b/source/ubl-settings-repomanager-add-window.c index 18e1870..34af8c1 100644 --- a/source/ubl-settings-repomanager-add-window.c +++ b/source/ubl-settings-repomanager-add-window.c @@ -157,6 +157,22 @@ void on_add_packages_accept(GtkWidget *self, dictionary *dict){ const char *repo = gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->RepositoryCombo)); const char *arch = gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->ArchitectureCombo)); + if (yon_char_is_empty(storage)||yon_char_is_empty(repo)||yon_char_is_empty(arch)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->StorageCombo); + return; + } + if (yon_char_is_empty(repo)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->RepositoryCombo); + return; + } + if (yon_char_is_empty(arch)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->ArchitectureCombo); + return; + } + const char *repo_sign = gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->RepoSignCombo)); const char *package_sign = gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->PackageSignCombo)); GtkTreeIter iter; @@ -169,6 +185,12 @@ void on_add_packages_accept(GtkWidget *self, dictionary *dict){ yon_char_parsed_add_or_create_if_exists(parsed, &size,path); } + if (!size){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PACKAGES_REMOVE_ERROR_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->PackagesTree); + return; + } + char *packages = yon_char_parsed_to_string(parsed,size," "); char *command = NULL; if (repo_sign&&package_sign){ @@ -220,6 +242,11 @@ void yon_add_window_set_selected(main_window *widgets, repo_add_window *window){ storage = ((arch_struct*)storage_str)->storage_path; repo = ((arch_struct*)storage_str)->repo_name; arch = ((arch_struct*)storage_str)->name; + } else if (depth==1){ + storage = ((repo_struct*)storage_str)->storage_path; + repo = ((arch_struct*)storage_str)->name; + } else if (depth == 0){ + storage = storage_str->path; } if (!yon_char_is_empty(storage)) gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->StorageCombo),storage); while(gtk_events_pending()) gtk_main_iteration(); diff --git a/source/ubl-settings-repomanager-move.c b/source/ubl-settings-repomanager-move.c index 14fe774..07f0e9a 100644 --- a/source/ubl-settings-repomanager-move.c +++ b/source/ubl-settings-repomanager-move.c @@ -281,6 +281,11 @@ void yon_move_window_set_selected(main_window *widgets, repo_add_window *window) storage = ((arch_struct*)storage_str)->storage_path; repo = ((arch_struct*)storage_str)->repo_name; arch = ((arch_struct*)storage_str)->name; + } else if (depth==1){ + storage = ((repo_struct*)storage_str)->storage_path; + repo = ((arch_struct*)storage_str)->name; + } else if (depth == 0){ + storage = storage_str->path; } if (!yon_char_is_empty(storage)) gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->MoveSourceStorageEntry),storage); while(gtk_events_pending()) gtk_main_iteration(); diff --git a/source/ubl-settings-repomanager-remove.c b/source/ubl-settings-repomanager-remove.c index 3fdb693..b1812bc 100644 --- a/source/ubl-settings-repomanager-remove.c +++ b/source/ubl-settings-repomanager-remove.c @@ -17,7 +17,22 @@ void on_remove_accept(GtkWidget *self, dictionary *dict){ const char *arch = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->ArchitectureCombo)); const char *sign = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->RepoSignCombo)); - if (!yon_char_is_empty(storage_path)){ + if (yon_char_is_empty(storage_path)||yon_char_is_empty(repo)||yon_char_is_empty(arch)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->StorageCombo); + return; + } + if (yon_char_is_empty(repo)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->RepositoryCombo); + return; + } + if (yon_char_is_empty(arch)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->ArchitectureCombo); + return; + } + GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(window->PackagesList); int size; @@ -29,16 +44,18 @@ void on_remove_accept(GtkWidget *self, dictionary *dict){ char *filename = yon_char_divide(target,yon_char_find_last(target,'/')); yon_char_parsed_add_or_create_if_exists(packages,&size,target); } - if (size){ + if (!size){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PACKAGES_REMOVE_ERROR_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->PackagesTree); + return; + } char *final = yon_char_parsed_to_string(packages,size," "); char *command = remove_packages_command(storage_path,arch,repo,final,sign); if (system(yon_debug_output("%s\n",command))){ - yon_ubl_status_box_render(PACKAGES_REMOVE_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - } else { - yon_ubl_status_box_render(PACKAGES_REMOVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - } - } - } + yon_ubl_status_box_render(PACKAGES_REMOVE_ERROR_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + } else { + yon_ubl_status_box_render(PACKAGES_REMOVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + } gtk_widget_destroy(window->MainWindow); free(window); yon_interface_update(widgets);