52 |
59 |
53 UIEXPORT char* ui_selection_gettext(UiDnD* dnd) { |
60 UIEXPORT char* ui_selection_gettext(UiDnD* dnd) { |
54 return nullptr; |
61 return nullptr; |
55 } |
62 } |
56 |
63 |
57 UIEXPORT char** ui_selection_geturis(UiDnD* dnd, size_t* nelm) { |
64 |
58 return nullptr; |
65 UIEXPORT UiFileList ui_selection_geturis(UiDnD *dnd) { |
|
66 UiFileList flist; |
|
67 flist.files = nullptr; |
|
68 flist.nfiles = 0; |
|
69 |
|
70 if (dnd->dataview.Contains(StandardDataFormats::StorageItems())) { |
|
71 UiFileList *flist_ptr = &flist; |
|
72 |
|
73 // we need to execute this in a different thread |
|
74 // this could block the main gui thread, but shouldn't happen with a simple uri list |
|
75 std::thread getDataThread([dnd, flist_ptr]() { |
|
76 auto items = dnd->dataview.GetStorageItemsAsync().get(); |
|
77 |
|
78 char **uris = (char**)calloc(items.Size(), sizeof(char*)); |
|
79 flist_ptr->files = uris; |
|
80 flist_ptr->nfiles = items.Size(); |
|
81 |
|
82 int i = 0; |
|
83 for (IStorageItem const& item : items) { |
|
84 winrt::hstring path = item.Path(); |
|
85 uris[i++] = wchar2utf8(path.c_str(), path.size()); |
|
86 } |
|
87 }); |
|
88 getDataThread.join(); |
|
89 } |
|
90 return flist; |
59 } |
91 } |