application/window.c

changeset 90
f501f0efc9a8
parent 89
2fbb3cac05a5
child 92
43aee6c8c166
equal deleted inserted replaced
89:2fbb3cac05a5 90:f501f0efc9a8
98 ui_table(obj, 98 ui_table(obj,
99 .fill = UI_ON, 99 .fill = UI_ON,
100 .model = model, 100 .model = model,
101 .onselection = action_list_selection, 101 .onselection = action_list_selection,
102 .onactivate = action_list_activate, 102 .onactivate = action_list_activate,
103 .ondragstart = action_dnd_start,
104 .ondragcomplete = action_dnd_end,
103 .ondrop = action_dnd_drop, 105 .ondrop = action_dnd_drop,
104 .varname = "reslist", 106 .varname = "reslist",
105 .multiselection = TRUE, 107 .multiselection = TRUE,
106 .contextmenu = contextmenu); 108 .contextmenu = contextmenu);
107 109
136 } 138 }
137 139
138 void window_progress(MainWindow *win, int on) { 140 void window_progress(MainWindow *win, int on) {
139 ui_set(win->progress, on); 141 ui_set(win->progress, on);
140 } 142 }
143
144 void action_dnd_start(UiEvent *event, void *data) {
145 //ui_selection_settext(event->eventdata, "hello world", -1);
146 char *uri = "file:///export/home/olaf/test.txt";
147 ui_selection_seturis(event->eventdata, &uri, 1);
148 }
149
150 void action_dnd_end(UiEvent *event, void *data) {
151
152 }
153
141 154
142 155
143 156
144 static void resourceviewer_close(UiEvent *event, void *data) { 157 static void resourceviewer_close(UiEvent *event, void *data) {
145 DavResourceViewer *doc = data; 158 DavResourceViewer *doc = data;
465 } 478 }
466 } 479 }
467 } 480 }
468 } 481 }
469 482
483 static int filelist_uri2path(UiFileList *files) {
484 for(int i=0;i<files->nfiles;i++) {
485 char *uri = files->files[i];
486 if(uri[0] == '/') {
487 continue;
488 }
489
490 cxstring uri_s = cx_str(uri);
491 if(!cx_strprefix(uri_s, CX_STR("file://"))) {
492 return 1;
493 }
494
495 files->files[i] = cx_strdup(cx_strsubs(uri_s, 7)).ptr;
496 free(uri);
497 }
498
499 return 0;
500 }
501
470 void action_dnd_drop(UiEvent *event, void *data) { 502 void action_dnd_drop(UiEvent *event, void *data) {
471 UiListDnd *listdnd = event->eventdata; 503 UiDnD *dnd = event->eventdata;
472 UiDnD *dnd = listdnd->dnd;
473 UiFileList files = ui_selection_geturis(dnd); 504 UiFileList files = ui_selection_geturis(dnd);
505 if(files.nfiles == 0) {
506 return;
507 }
508
509 if(filelist_uri2path(&files)) {
510 ui_dnd_accept(dnd, FALSE);
511 ui_filelist_free(files);
512 return;
513 }
474 514
475 davbrowser_upload_files(event->obj, event->document, files); 515 davbrowser_upload_files(event->obj, event->document, files);
476 } 516 }
477 517
478 518

mercurial