Sun, 27 Oct 2024 20:41:41 +0100
repo add should clear the form first
application/settings.c | file | annotate | diff | comparison | revisions | |
application/settings.h | file | annotate | diff | comparison | revisions |
--- a/application/settings.c Sun Oct 27 20:34:38 2024 +0100 +++ b/application/settings.c Sun Oct 27 20:41:41 2024 +0100 @@ -65,6 +65,7 @@ SettingsWindow *settings = event->window; settings->repo_new = TRUE; settings->selected_repo = -1; + settings_clear_repository(settings); // switch to editing tab ui_set(settings->repo_tabview, 1); } @@ -410,12 +411,14 @@ } repo = dav_repository_new(config); dav_config_add_repository(config, repo); - } else { + } else if(settings->selected_repo >= 0) { repo = ui_list_get(settings->repos, settings->selected_repo); if(!repo) { fprintf(stderr, "Error: cannot get repository at index %d\n", settings->selected_repo); return; } + } else { + return; } // always store name/url nodes @@ -477,6 +480,19 @@ settings->selected_repo = -1; } +void settings_clear_repository(SettingsWindow *settings) { + ui_set(settings->repo_name, ""); + ui_set(settings->repo_url, ""); + ui_set(settings->repo_user, ""); + ui_set(settings->repo_password, ""); + ui_set(settings->repo_cacert, ""); + ui_list_setselection(settings->repo_credentials, 0); + ui_list_setselection(settings->repo_keys, 0); + ui_list_setselection(settings->repo_tls_versions, 0); + ui_set(settings->repo_encryption, 0); + ui_set(settings->repo_disable_verification, 0); +} + void settings_update_repolist(SettingsWindow *settings) { DavConfig *config = settings->config;
--- a/application/settings.h Sun Oct 27 20:34:38 2024 +0100 +++ b/application/settings.h Sun Oct 27 20:41:41 2024 +0100 @@ -81,6 +81,8 @@ */ void settings_store_repository(SettingsWindow *settings); +void settings_clear_repository(SettingsWindow *settings); + void settings_update_repolist(SettingsWindow *settings);