implement repo Generate Key button

Tue, 29 Oct 2024 19:07:11 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 29 Oct 2024 19:07:11 +0100
changeset 73
ede7885491b1
parent 72
d5307e9ee384
child 74
4466ebbd9fd5

implement repo Generate Key button

application/settings.c file | annotate | diff | comparison | revisions
application/settings.h file | annotate | diff | comparison | revisions
--- a/application/settings.c	Tue Oct 29 17:51:02 2024 +0100
+++ b/application/settings.c	Tue Oct 29 19:07:11 2024 +0100
@@ -349,6 +349,14 @@
         dav_config_add_key(wdata->settings->config, newkey);
         settings_reload_repo_keys(wdata->settings);
         settings_reload_keys(wdata->settings);
+        
+        if(wdata->add_to_repo && (wdata->settings->selected_repo >= 0 || wdata->settings->repo_new)) {
+            CxList *repo_keys = wdata->settings->repo_keys->data;
+            ssize_t index = cxListFind(repo_keys, name);
+            if(index >= 0) {
+                ui_list_setselection(wdata->settings->repo_keys, index);
+            }
+        }
     }
     
     ui_close(event->obj);
@@ -381,6 +389,7 @@
     wdata->message = ui_string_new(dialog->ctx, NULL);
     wdata->secretstore = ui_int_new(dialog->ctx, NULL);
     wdata->type = ui_list_new(dialog->ctx, NULL);
+    wdata->add_to_repo = userdata ? TRUE : FALSE;
     dialog->window = wdata;
     
     ui_list_append(wdata->type, "AES256");
@@ -604,7 +613,7 @@
                                 ui_llabel(obj, .label = "Default key");
                                 ui_hbox(obj, .spacing = 4) {
                                     ui_combobox(obj, .list = wdata->repo_keys, .groups = UI_GROUPS(SETTINGS_STATE_REPO_ENCRYPTION));
-                                    ui_button(obj, .label = "Generate Key", .groups = UI_GROUPS(SETTINGS_STATE_REPO_ENCRYPTION));
+                                    ui_button(obj, .label = "Generate Key", .onclick = keys_add, .onclickdata = "repo", .groups = UI_GROUPS(SETTINGS_STATE_REPO_ENCRYPTION));
                                 }
                                 ui_newline(obj);
                                 
@@ -745,6 +754,8 @@
     settings->repo_tls_versions = ui_list_new(obj->ctx, NULL);
     settings->repo_encryption = ui_int_new(obj->ctx, NULL);
     settings->repo_disable_verification = ui_int_new(obj->ctx, NULL);
+    CxList *repo_keys = settings->repo_keys->data;
+    repo_keys->collection.cmpfunc = (cx_compare_func)strcmp;
      
     ui_list_append(settings->repo_tls_versions, "Default");
     ui_list_append(settings->repo_tls_versions, "TLSv1.3");
--- a/application/settings.h	Tue Oct 29 17:51:02 2024 +0100
+++ b/application/settings.h	Tue Oct 29 19:07:11 2024 +0100
@@ -133,6 +133,8 @@
      */
     UiList *type;
     UiInteger *secretstore;
+    
+    DavBool add_to_repo;
 } SettingsNewKeyDialog;
     
 void settings_window_open();

mercurial