cxListInsert(nblist, new_insert_pos, wdata->selected_notebook);
ui_list_update(wdata->tab1_notebooks);
- wdata->valuechange = TRUE;
- ui_list_setselection(wdata->tab1_notebooks, new_insert_pos);
- wdata->valuechange = FALSE;
+ ui_list_setselection2(wdata->tab1_notebooks, new_insert_pos, FALSE);
}
static void nbconfig_tab_view_changed(UiEvent *event, void *userdata) {
ui_list_update(wdata->tab1_notebooks);
int n = ui_list_count(wdata->tab1_notebooks);
- wdata->valuechange = TRUE;
- ui_list_setselection(wdata->tab1_notebooks, n-1);
- wdata->valuechange = FALSE;
+ ui_list_setselection2(wdata->tab1_notebooks, n-1, FALSE);
n = ui_list_count(wdata->tab1_groups);
ui_list_setselection(wdata->tab1_groups, n-1);
}
}
- wdata->valuechange = TRUE;
- ui_list_setselection(wdata->tab1_groups, grouplist_index);
- ui_list_setselection(wdata->tab1_notebooks, insert_pos);
- wdata->valuechange = FALSE;
+ ui_list_setselection2(wdata->tab1_groups, grouplist_index, FALSE);
+ ui_list_setselection2(wdata->tab1_notebooks, insert_pos, FALSE);
}
ui_set(wdata->tab1_notebook_name, name);
// ---------------------------- Repo Config -----------------------------------
+void nbconfig_repository_save(NotebookConfigDialog *nbconfig) {
+
+}
+
+static void nbconfig_load_repository(NotebookConfigDialog *wdata, Repository *repo) {
+ wdata->valuechange = TRUE;
+
+ ui_set(wdata->tab3_repo_name, repo->name);
+ ui_set(wdata->tab3_repo_local_path, repo->local_path);
+ ui_set(wdata->tab3_repo_url, repo->url);
+ ui_set(wdata->tab3_repo_isencrypted, repo->encryption);
+ // TODO: key
+
+ wdata->selected_repository = repo;
+ // save repository name
+ UiContext *ctx = wdata->obj->ctx;
+ ui_free(ctx, wdata->selected_repository_name);
+ wdata->selected_repository_name = ui_strdup(ctx, repo->name);
+
+ wdata->valuechange = FALSE;
+}
+
static void nbconfig_repolist_add(UiEvent *event, void *userdata) {
}
}
+static void nbconfig_repolist_onselect(UiEvent *event, void *userdata) {
+ NotebookConfigDialog *wdata = userdata;
+ if(wdata->valuechange) {
+ return;
+ }
+
+ nbconfig_repository_save(wdata);
+
+ Repository *repo;
+ if(nbconfig_list_activate_event(event, wdata->tab3_repositories, (void**)&repo)) {
+ return;
+ }
+ wdata->selected_repository = repo;
+ nbconfig_load_repository(wdata, repo);
+}
+
+
static void nbconfig_repolist_dir_selected(UiEvent *event, void *userdata) {
NotebookConfigDialog *wdata = userdata;
UiFileList *flist = event->eventdata;
// fill data
Resource *group1 = NULL;
- Resource *notebook1 = NULL;
+ Repository *repo1 = NULL;
CxIterator i = cxListIterator(store->root->children);
cx_foreach(Resource *, res, i) {
cxListAdd(wdata->groups, res);
cxListAdd(wdata->notebooks, nb);
}
}
+
+ i = cxListIterator(store->repositories);
+ cx_foreach(Repository *, repo, i) {
+ cxListAdd(wdata->repositories, repo);
+ if(!repo1) {
+ repo1 = repo;
+ }
+ }
+
nbconfig_update_lists(wdata);
ui_list_append(wdata->tab1_types, "Notes");
ui_tab(obj, "Repositories") {
ui_hbox(obj, .margin = 10, .spacing = 10, .fill = TRUE) {
ui_vbox(obj) {
- ui_listview(obj, .list = wdata->tab3_repositories, .getvalue = repolist_get_value, .fill = TRUE, .onactivate = NULL);
+ ui_listview(obj, .list = wdata->tab3_repositories, .getvalue = repolist_get_value, .fill = TRUE, .onselection = nbconfig_repolist_onselect);
ui_hbox(obj) {
ui_button(obj, .icon = UI_ICON_NEW_FOLDER, .onclick = nbconfig_repolist_add);
ui_button(obj, .icon = UI_ICON_DELETE, .onclick = nbconfig_repolist_delete);
ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = TRUE, .def_vfill = TRUE) {
ui_rlabel(obj, .label = "Name");
- ui_textfield(obj, .value = wdata->tab3_repo_name, .onchange = nbconfig_repolist_name_changed);
+ ui_textfield(obj, .value = wdata->tab3_repo_name, .onchange = nbconfig_repolist_name_changed, .width = 300);
ui_newline(obj);
- ui_rlabel(obj, .label = "Local Path");
- ui_textfield(obj, .value = wdata->tab3_repo_local_path);
+ ui_rlabel(obj, .label = "Local path");
+ ui_textfield(obj, .value = wdata->tab3_repo_local_path, .hfill = TRUE);
ui_button(obj, .icon = "document-open", .onclick = nbconfig_repolist_open_dir);
ui_newline(obj);
- ui_rlabel(obj, .label = "URL");
- ui_textfield(obj, .value = wdata->tab3_repo_url);
+ ui_rlabel(obj, .label = "WebDAV URL");
+ ui_textfield(obj, .value = wdata->tab3_repo_url, .hfill = TRUE);
ui_newline(obj);
- ui_checkbox(obj, .label = "Encryption", .colspan = 2);
+ ui_checkbox(obj, .label = "Enable encryption", .colspan = 2, .enable_state = NBCONFIG_STATE_REPOSITORY_ENCRYPTION);
ui_newline(obj);
- ui_rlabel(obj, .label = "Encryption Key");
- ui_dropdown(obj, .list = wdata->tab3_repo_encryption_key);
+ ui_rlabel(obj, .label = "Encryption key");
+ ui_dropdown(obj, .list = wdata->tab3_repo_encryption_key, .states = UI_GROUPS(NBCONFIG_STATE_REPOSITORY_ENCRYPTION), .hfill = TRUE);
}
}
}
ui_list_setselection2(wdata->tab1_notebooks, 0, FALSE);
+ ui_list_setselection2(wdata->tab3_repositories, 0, FALSE);
if(group1) {
nbconfig_load_notebook(wdata, group1);
}
+ if(repo1) {
+ nbconfig_load_repository(wdata, repo1);
+ }
ui_show(obj);
}