Wed, 27 Nov 2024 18:53:11 +0100
implement action_transfer_selected
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2024 Olaf Wintermann. All rights reserved. |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "application.h" |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include <string.h> |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include <stdbool.h> |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
34 | #include <libidav/webdav.h> |
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
35 | |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include "window.h" |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
37 | #include "config.h" |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
38 | #include "davcontroller.h" |
60
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
39 | #include "settings.h" |
94
7fdf1489b82f
move app settings to separate source file
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
40 | #include "appsettings.h" |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
42 | static DavContext* davctx; |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | |
60
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
44 | static DavApp *app; |
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
45 | |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
46 | void application_init(void) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
47 | davctx = dav_context_new(); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
48 | dav_context_set_mtsafe(davctx, true); |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
49 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
50 | application_create_menu(); |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
51 | } |
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
52 | |
60
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
53 | DavApp* get_application(void) { |
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
54 | return app; |
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
55 | } |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | void application_startup(UiEvent* event, void* data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
58 | if (load_config(davctx)) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
59 | // TODO: error |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
60 | exit(-1); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
61 | } |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
62 | |
94
7fdf1489b82f
move app settings to separate source file
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
63 | appsettings_init(); |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
64 | window_init(); |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
65 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
66 | // create document for global settings (repolist, ...) |
60
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
67 | app = application_create_app_document(); |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
68 | UiContext *global = ui_global_context(); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
69 | ui_attach_document(global, app); |
14
872d570ae843
implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
70 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
71 | // create new window |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
72 | UiObject *win = window_create(); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
73 | // create new browser document and attach it to the main window |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
74 | DavBrowser *doc = davbrowser_create(win); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
75 | ui_attach_document(win->ctx, doc); |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
77 | ui_show(win); |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | } |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
80 | static void* davrepo_getname(void *elm, int unused) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
81 | DavCfgRepository *repo = elm; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
82 | return repo->name.value.ptr; |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
83 | } |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
84 | |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | void application_create_menu(void) { |
33
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
86 | // menu |
68 | 87 | ui_menu("File") { |
88 | ui_menuitem(.label = "New Window", .onclick = action_window_new); | |
89 | ui_menuseparator(); | |
90 | ui_menuitem(.label = "New Folder", .onclick = action_mkcol, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
91 | ui_menuitem(.label = "New File", .onclick = action_newfile, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
92 | ui_menuitem(.label = "Delete", .onclick = action_delete, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
93 | ui_menuseparator(); | |
94 | ui_menuitem(.label = "Upload File", .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
95 | ui_menuitem(.label = "Upload Folder", .onclick = action_upload_dir, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
96 | ui_menuitem(.label = "Download", .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); | |
97 | ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); | |
98 | ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); | |
99 | ui_menuseparator(); | |
100 | ui_menuitem(.label = "Close", .onclick = action_window_close); | |
101 | } | |
102 | ||
103 | ui_menu("Edit") { | |
104 | ui_menuitem(.label = "Preferences", .onclick = action_open_settings); | |
105 | } | |
106 | ||
107 | ui_menu("Go") { | |
108 | ui_menuitem(.label = "Parent", .onclick = action_go_parent, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
109 | ui_menuitem(.label = "Back", .onclick = action_go_back, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
110 | ui_menuitem(.label = "Forward", .onclick = action_go_forward, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
111 | ui_menuseparator(); | |
112 | ui_menu("Repositories") { | |
113 | ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected); | |
114 | } | |
115 | } | |
95
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
116 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
117 | ui_menu("View") { |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
118 | ui_menu_itemlist(.varname = "transferlist", .getvalue = transfers_getlabel, .onselect = action_transfer_selected); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
119 | } |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
120 | |
33
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
121 | // toolbar |
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
122 | ui_toolbar_item("Home", .icon = UI_ICON_HOME); |
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
123 | ui_toolbar_item("NewWindow", .icon = UI_ICON_NEW_WINDOW, .onclick = action_window_new); |
68 | 124 | ui_toolbar_item("Refresh", .icon = UI_ICON_REFRESH, .onclick = action_refresh, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
125 | ui_toolbar_menu("Repo", .label = "Repository") { |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
126 | ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected); |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
127 | } |
68 | 128 | ui_toolbar_item("NewFolder", .icon = UI_ICON_NEW_FOLDER, .onclick = action_mkcol, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
129 | ui_toolbar_item("NewFile", .icon = UI_ICON_ADD, .onclick = action_newfile, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
130 | ui_toolbar_item("Upload", .label = "Upload", .icon = UI_ICON_UPLOAD, .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
131 | ui_toolbar_item("Download", .icon = UI_ICON_SAVE_LOCAL, .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); | |
132 | ui_toolbar_item("Remove", .icon = UI_ICON_DELETE, .onclick = action_delete, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); | |
33
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
133 | ui_toolbar_toggleitem("LocalBrowser", .icon = UI_ICON_DOCK_LEFT, .label = "Local Browser"); |
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
134 | ui_toolbar_toggleitem("PreviewPane", .icon = UI_ICON_DOCK_RIGHT); |
4
31137432bea8
add more toolbar items
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
135 | |
33
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
136 | ui_toolbar_appmenu() { |
47
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
137 | ui_menuitem("New Window", .onclick = action_window_new); |
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
138 | ui_menuseparator(); |
68 | 139 | ui_menuitem("Download", .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
140 | ui_menuitem("Upload Files", .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
141 | ui_menuitem("Upload Directory", .onclick = action_upload_dir, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); | |
142 | ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); | |
143 | ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); | |
47
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
144 | ui_menuseparator(); |
95
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
145 | ui_menu("Downloads/Uploads") { |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
146 | ui_menu_itemlist(.varname = "transferlist", .getvalue = transfers_getlabel, .onselect = action_transfer_selected); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
147 | } |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
148 | ui_menuseparator(); |
68 | 149 | ui_menuitem("Preferences", .onclick = action_open_settings); |
33
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
150 | } |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
151 | |
43
ef01d2c90128
some minor toolbar adjustments, toolkit icons update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
35
diff
changeset
|
152 | //ui_toolbar_add_default("Home", UI_TOOLBAR_LEFT); |
46
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
153 | //ui_toolbar_add_default("NewWindow", UI_TOOLBAR_LEFT); |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
154 | //ui_toolbar_add_default("Refresh", UI_TOOLBAR_LEFT); |
33
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
155 | ui_toolbar_add_default("Repo", UI_TOOLBAR_LEFT); |
4
31137432bea8
add more toolbar items
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
156 | |
33
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
157 | ui_toolbar_add_default("NewFolder", UI_TOOLBAR_CENTER); |
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
158 | ui_toolbar_add_default("NewFile", UI_TOOLBAR_CENTER); |
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
159 | ui_toolbar_add_default("Remove", UI_TOOLBAR_CENTER); |
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
160 | ui_toolbar_add_default("Download", UI_TOOLBAR_CENTER); |
cdeb0dc47ef5
replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
161 | ui_toolbar_add_default("Upload", UI_TOOLBAR_CENTER); |
4
31137432bea8
add more toolbar items
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
162 | |
43
ef01d2c90128
some minor toolbar adjustments, toolkit icons update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
35
diff
changeset
|
163 | //ui_toolbar_add_default("LocalBrowser", UI_TOOLBAR_RIGHT); |
ef01d2c90128
some minor toolbar adjustments, toolkit icons update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
35
diff
changeset
|
164 | //ui_toolbar_add_default("PreviewPane", UI_TOOLBAR_RIGHT); |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | } |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
168 | |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | DavApp* application_create_app_document(void) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
170 | DavApp *doc = ui_document_new(sizeof(DavApp)); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
171 | UiContext *ctx = ui_document_context(doc); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
172 | doc->repos = ui_list_new(ctx, "repolist"); |
95
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
173 | doc->transfers = ui_list_new(ctx, "transferlist"); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
174 | CxList *transfers = doc->transfers->data; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
175 | transfers->collection.cmpfunc = cx_cmp_ptr; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
176 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
177 | // create repo list |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
178 | application_update_repolist(doc); |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
179 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
180 | return doc; |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | } |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
182 | |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
183 | void application_update_repolist(DavApp *app) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
184 | DavConfig *config = get_config(); |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
185 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
186 | ui_list_clear(app->repos); |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
187 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
188 | for (DavCfgRepository *repo = config->repositories; repo; repo = repo->next) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
189 | ui_list_append(app->repos, repo); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
190 | } |
60
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
191 | |
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
192 | ui_notify(app->repos->observers, NULL); |
6
09ac07345656
add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
193 | } |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
194 | |
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
195 | |
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
196 | DavContext* application_dav_context(void) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
197 | return davctx; |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
198 | } |
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
199 | |
95
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
200 | void* transfers_getlabel(void *data, int col) { |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
201 | DavTransfer *trans = data; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
202 | return trans->label; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
203 | } |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
204 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
205 | void application_register_transfer(DavTransfer *trans) { |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
206 | DavApp *app = get_application(); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
207 | ui_list_append(app->transfers, trans); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
208 | application_update_transferlist(); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
209 | } |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
210 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
211 | void application_remove_transfer(DavTransfer *trans) { |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
212 | DavApp *app = get_application(); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
213 | CxList *transfers = app->transfers->data; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
214 | cxListFindRemove(transfers, trans); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
215 | application_update_transferlist(); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
216 | } |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
217 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
218 | /* |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
219 | static int transfers_cmp(const DavTransfer *left, const DavTransfer *right) { |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
220 | return cx_cmp_double(&right->progress, &left->progress); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
221 | } |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
222 | */ |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
223 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
224 | void application_update_transferlist(void) { |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
225 | DavApp *app = get_application(); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
226 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
227 | /* |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
228 | CxList *transfers = app->transfers->data; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
229 | transfers->collection.cmpfunc = (cx_compare_func)transfers_cmp; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
230 | cxListSort(transfers); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
231 | transfers->collection.cmpfunc = cx_cmp_ptr; |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
232 | */ |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
233 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
234 | ui_list_update(app->transfers); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
235 | ui_list_notify(app->transfers); |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
236 | } |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
237 | |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
238 | |
14
872d570ae843
implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
239 | void action_window_new(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
240 | UiObject *win = window_create(); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
241 | // create new browser document and attach it to the main window |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
242 | DavBrowser *doc = davbrowser_create(win); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
243 | ui_attach_document(win->ctx, doc); |
14
872d570ae843
implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
244 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
245 | ui_show(win); |
14
872d570ae843
implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
246 | } |
872d570ae843
implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
247 | |
68 | 248 | void action_window_close(UiEvent *event, void *data) { |
249 | ui_close(event->obj); | |
250 | } | |
251 | ||
17
7cfd36aa005b
add refresh button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
252 | void action_refresh(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
253 | DavBrowser *browser = event->document; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
254 | if (browser->current) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
255 | davbrowser_query_path(event->obj, browser, browser->current->path); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
256 | } |
17
7cfd36aa005b
add refresh button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
257 | } |
7cfd36aa005b
add refresh button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
258 | |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
259 | void action_repo_selected(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
260 | DavCfgRepository *repo = event->eventdata; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
261 | DavBrowser *browser = event->document; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
262 | davbrowser_connect2repo(event->obj, browser, repo, ""); |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
263 | } |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
264 | |
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
265 | static void file_selected(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
266 | UiFileList *files = event->eventdata; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
267 | if (files && files->nfiles > 0) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
268 | // files will be freed by the filedialog handler, therefore we need a copy |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
269 | UiFileList uploadList = ui_filelist_copy(*files); // uploadList will be freed by davbrowser_upload_files |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
270 | davbrowser_upload_files(event->obj, event->document, uploadList); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
271 | } |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
272 | |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
273 | } |
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
274 | |
29
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
275 | |
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
276 | |
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
277 | static void download_location_selected(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
278 | DavBrowser *browser = event->document; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
279 | DavResource *reslist = data; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
280 | UiFileList *flist = event->eventdata; |
29
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
281 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
282 | if (flist && flist->nfiles > 0) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
283 | davbrowser_download(event->obj, browser, reslist, flist->files[0]); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
284 | } else { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
285 | dav_session_destroy(reslist->session); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
286 | } |
29
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
287 | } |
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
288 | |
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
289 | void action_download(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
290 | DavBrowser *browser = event->document; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
291 | UiListSelection sel = ui_list_getselection(browser->resources); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
292 | if (sel.count > 0) {; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
293 | const char *initialFileName = NULL; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
294 | if (sel.count == 1) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
295 | DavResource *res = ui_list_get(browser->resources, sel.rows[0]); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
296 | if (res && !res->iscollection) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
297 | initialFileName = res->name; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
298 | } |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
299 | } |
29
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
300 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
301 | // create a copy of the current session and all selected resources |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
302 | DavSession *sn = dav_session_clone(browser->sn); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
303 | DavResource *first = NULL; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
304 | DavResource *last = NULL; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
305 | for (int i = 0; i < sel.count; i++) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
306 | // get selected resource |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
307 | DavResource *res = ui_list_get(browser->resources, sel.rows[i]); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
308 | // copy resource |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
309 | DavResource *res_copy = dav_resource_new(sn, res->path); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
310 | res_copy->iscollection = res->iscollection; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
311 | res_copy->contentlength = res->contentlength; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
312 | res_copy->lastmodified = res->lastmodified; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
313 | res_copy->creationdate = res->creationdate; |
29
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
314 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
315 | // link resources |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
316 | if (!first) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
317 | first = res_copy; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
318 | } |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
319 | if (last) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
320 | res_copy->prev = last; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
321 | last->next = res_copy; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
322 | } |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
323 | last = res_copy; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
324 | } |
29
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
325 | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
326 | if (initialFileName) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
327 | ui_savefiledialog(event->obj, initialFileName, download_location_selected, first); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
328 | } else { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
329 | ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_FOLDER, download_location_selected, first); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
330 | } |
53
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
331 | |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
332 | ui_listselection_free(sel); |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
333 | } |
29
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
334 | } |
3fc287f06305
add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
335 | |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
336 | void action_upload_file(UiEvent *event, void *data) { |
68 | 337 | DavBrowser *browser = event->document; |
338 | if(!browser->sn) { | |
339 | return; | |
340 | } | |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
341 | ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_MULTI, file_selected, NULL); |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
342 | } |
26
40d6af793c1a
implement resource deletion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
343 | |
47
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
344 | void action_upload_dir(UiEvent *event, void *data) { |
68 | 345 | DavBrowser *browser = event->document; |
346 | if(!browser->sn) { | |
347 | return; | |
348 | } | |
47
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
349 | ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_FOLDER|UI_FILEDIALOG_SELECT_MULTI, file_selected, NULL); |
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
350 | } |
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
351 | |
26
40d6af793c1a
implement resource deletion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
352 | void action_delete(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
353 | DavBrowser *browser = event->document; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
354 | UiListSelection sel = ui_list_getselection(browser->resources); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
355 | if (sel.count > 0) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
356 | davbrowser_delete(event->obj, browser, sel); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
357 | } |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
358 | ui_listselection_free(sel); |
26
40d6af793c1a
implement resource deletion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
359 | } |
28
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
360 | |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
361 | void action_selectall(UiEvent *event, void *data) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
362 | DavBrowser *browser = event->document; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
363 | int nres = ui_list_count(browser->resources); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
364 | for(int i=0;i<nres;i++) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
365 | ui_list_setselection(browser->resources, i); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
366 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
367 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
368 | |
89
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
369 | void action_rename(UiEvent *event, void *data) { |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
370 | DavBrowser *browser = event->document; |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
371 | UiListSelection sel = ui_list_getselection(browser->resources); |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
372 | if (sel.count == 1) { |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
373 | davbrowser_rename(event->obj, browser, sel); |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
374 | } else if(sel.count > 1) { |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
375 | fprintf(stderr, "Renaming multiple resources is not implemented yet\n"); |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
376 | } |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
377 | } |
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
378 | |
46
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
379 | static void newfiledialog_result(UiEvent *event, void *data) { |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
380 | DavBrowser *browser = event->document; |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
381 | char *path = event->eventdata; |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
382 | if (event->intval == 1) { |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
383 | davbrowser_newfile(event->obj, browser, path); |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
384 | } |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
385 | } |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
386 | |
28
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
387 | void action_newfile(UiEvent *event, void *data) { |
46
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
388 | DavBrowser *browser = event->document; |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
389 | if(!browser->sn) { |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
390 | return; |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
391 | } |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
392 | |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
393 | ui_dialog(event->obj, |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
394 | .content = "New File", |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
395 | .input = TRUE, |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
396 | .button1_label = "Create File", |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
397 | .button2_label = "Cancel", |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
398 | .result = newfiledialog_result); |
28
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
399 | } |
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
400 | |
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
401 | |
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
402 | static void newfolderdialog_result(UiEvent *event, void *data) { |
35
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
403 | DavBrowser *browser = event->document; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
404 | char *path = event->eventdata; |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
405 | if (event->intval == 1) { |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
406 | davbrowser_mkcol(event->obj, browser, path); |
834d9c15a69f
some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
407 | } |
28
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
408 | } |
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
409 | |
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
410 | void action_mkcol(UiEvent *event, void *data) { |
46
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
411 | DavBrowser *browser = event->document; |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
412 | if(!browser->sn) { |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
413 | return; |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
414 | } |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
415 | |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
416 | |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
417 | ui_dialog(event->obj, |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
418 | .content = "New Folder", |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
419 | .input = TRUE, |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
420 | .button1_label = "Create Folder", |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
421 | .button2_label = "Cancel", |
31bc86844659
implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
422 | .result = newfolderdialog_result); |
28
1ecc1183f046
implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
423 | } |
47
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
424 | |
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
425 | void action_open_settings(UiEvent *event, void *data) { |
60
ee4e4742391e
add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
426 | settings_window_open(); |
47
3ac472683246
add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
427 | } |
53
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
428 | |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
429 | void action_open_properties(UiEvent *event, void *data) { |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
430 | char *type = data; |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
431 | DavBrowser *browser = event->document; |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
432 | |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
433 | UiListSelection sel = ui_list_getselection(browser->resources); |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
434 | for(int i=0;i<sel.count;i++) { |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
435 | DavResource *res = ui_list_get(browser->resources, sel.rows[i]); |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
436 | if(res) { |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
437 | davbrowser_open_resource(event->obj, browser, res, type); |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
438 | } |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
439 | } |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
440 | ui_listselection_free(sel); |
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
441 | } |
95
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
442 | |
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
443 | void action_transfer_selected(UiEvent *event, void *data) { |
96
493959648de6
implement action_transfer_selected
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
444 | DavApp *app = get_application(); |
493959648de6
implement action_transfer_selected
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
445 | DavTransfer *trans = ui_list_get(app->transfers, event->intval); |
493959648de6
implement action_transfer_selected
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
446 | if(trans) { |
493959648de6
implement action_transfer_selected
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
447 | ui_show(trans->window); |
493959648de6
implement action_transfer_selected
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
448 | } |
95
e92c72705da4
add upload/download list, resolves #512
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
449 | } |