ui_listselection_free(sel);
}
+static UiBool notebooklist_move_inprogress = FALSE;
+static int notebooklist_move_pos0 = 0;
+static int notebooklist_move_pos1 = 0;
+
+static void nbconfig_notebooklist_move_result(UiEvent *event, int error, void *userdata) {
+ notebooklist_move_inprogress = FALSE;
+ if(!error) {
+ NotebookConfigDialog *wdata = event->window;
+ cxListSwap(wdata->notebooks, notebooklist_move_pos0, notebooklist_move_pos1);
+ nbconfig_update_lists(wdata);
+ } else {
+ printf("nbconfig_notebooklist_move_up_result: error %d\n", error);
+ }
+}
+
+
static void nbconfig_notebooklist_move_up(UiEvent *event, void *userdata) {
+ if(notebooklist_move_inprogress) {
+ return;
+ }
+ NotebookConfigDialog *wdata = event->window;
+ UiListSelection sel = ui_list_getselection(wdata->tab2_notebooks);
+ if(sel.count == 1 && sel.rows[0] > 0) {
+ int row = sel.rows[0];
+ notebooklist_move_pos0 = row;
+ notebooklist_move_pos1 = row-1;
+ Resource *r0 = cxListAt(wdata->notebooks, notebooklist_move_pos0);
+ Resource *r1 = cxListAt(wdata->notebooks, notebooklist_move_pos1);
+ note_store_notebook_swap_position_async(event->obj, r0->notebook, r1->notebook, nbconfig_notebooklist_move_result, NULL);
+ notebooklist_move_inprogress = TRUE;
+ }
+ ui_listselection_free(sel);
}
static void nbconfig_notebooklist_move_down(UiEvent *event, void *userdata) {
+ if(notebooklist_move_inprogress) {
+ return;
+ }
+ NotebookConfigDialog *wdata = event->window;
+ UiListSelection sel = ui_list_getselection(wdata->tab2_notebooks);
+ size_t sz = cxListSize(wdata->notebooks);
+ if(sel.count == 1 && sel.rows[0]+1 < sz) {
+ int row = sel.rows[0];
+ notebooklist_move_pos0 = row;
+ notebooklist_move_pos1 = row+1;
+ Resource *r0 = cxListAt(wdata->notebooks, notebooklist_move_pos0);
+ Resource *r1 = cxListAt(wdata->notebooks, notebooklist_move_pos1);
+ note_store_notebook_swap_position_async(event->obj, r0->notebook, r1->notebook, nbconfig_notebooklist_move_result, NULL);
+ notebooklist_move_inprogress = TRUE;
+ }
+ ui_listselection_free(sel);
}