application/application.c

Tue, 12 Nov 2024 15:05:57 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 12 Nov 2024 15:05:57 +0100
changeset 79
483d7342b439
parent 68
79a9aadf1c70
permissions
-rw-r--r--

update toolkit (winui dialog window)

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"
2
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
6
09ac07345656 add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
41 static DavContext* davctx;
2
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
60
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 53
diff changeset
43 static DavApp *app;
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 53
diff changeset
44
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
45 void application_init(void) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
46 davctx = dav_context_new();
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
47 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
48
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
49 application_create_menu();
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
50 }
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
51
60
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 53
diff changeset
52 DavApp* get_application(void) {
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 53
diff changeset
53 return app;
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 53
diff changeset
54 }
2
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 void application_startup(UiEvent* event, void* data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
57 if (load_config(davctx)) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
58 // TODO: error
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
59 exit(-1);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
60 }
6
09ac07345656 add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
61
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
62 window_init();
8
726b24766437 implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
63
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
64 // 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
65 app = application_create_app_document();
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
66 UiContext *global = ui_global_context();
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
67 ui_attach_document(global, app);
14
872d570ae843 implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
68
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
69 // create new window
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
70 UiObject *win = window_create();
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
71 // 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
72 DavBrowser *doc = davbrowser_create(win);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
73 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
74
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
75 ui_show(win);
2
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 }
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77
8
726b24766437 implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
78 static void* davrepo_getname(void *elm, int unused) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
79 DavCfgRepository *repo = elm;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
80 return repo->name.value.ptr;
8
726b24766437 implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
81 }
726b24766437 implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
82
2
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 void application_create_menu(void) {
33
cdeb0dc47ef5 replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
84 // menu
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
85 ui_menu("File") {
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
86 ui_menuitem(.label = "New Window", .onclick = action_window_new);
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
87 ui_menuseparator();
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
88 ui_menuitem(.label = "New Folder", .onclick = action_mkcol, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
89 ui_menuitem(.label = "New File", .onclick = action_newfile, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
90 ui_menuitem(.label = "Delete", .onclick = action_delete, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
91 ui_menuseparator();
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
92 ui_menuitem(.label = "Upload File", .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
93 ui_menuitem(.label = "Upload Folder", .onclick = action_upload_dir, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
94 ui_menuitem(.label = "Download", .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
95 ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
96 ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
97 ui_menuseparator();
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
98 ui_menuitem(.label = "Close", .onclick = action_window_close);
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
99 }
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
100
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
101 ui_menu("Edit") {
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
102 ui_menuitem(.label = "Preferences", .onclick = action_open_settings);
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
103 }
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
104
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
105 ui_menu("Go") {
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
106 ui_menuitem(.label = "Parent", .onclick = action_go_parent, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
107 ui_menuitem(.label = "Back", .onclick = action_go_back, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
108 ui_menuitem(.label = "Forward", .onclick = action_go_forward, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
109 ui_menuseparator();
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
110 ui_menu("Repositories") {
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
111 ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected);
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
112 }
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
113 }
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
114
33
cdeb0dc47ef5 replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
115 // toolbar
cdeb0dc47ef5 replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
116 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
117 ui_toolbar_item("NewWindow", .icon = UI_ICON_NEW_WINDOW, .onclick = action_window_new);
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
118 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
119 ui_toolbar_menu("Repo", .label = "Repository") {
8
726b24766437 implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
120 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
121 }
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
122 ui_toolbar_item("NewFolder", .icon = UI_ICON_NEW_FOLDER, .onclick = action_mkcol, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
123 ui_toolbar_item("NewFile", .icon = UI_ICON_ADD, .onclick = action_newfile, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
124 ui_toolbar_item("Upload", .label = "Upload", .icon = UI_ICON_UPLOAD, .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
125 ui_toolbar_item("Download", .icon = UI_ICON_SAVE_LOCAL, .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
126 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
127 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
128 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
129
33
cdeb0dc47ef5 replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
130 ui_toolbar_appmenu() {
47
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
131 ui_menuitem("New Window", .onclick = action_window_new);
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
132 ui_menuseparator();
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
133 ui_menuitem("Download", .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
134 ui_menuitem("Upload Files", .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
135 ui_menuitem("Upload Directory", .onclick = action_upload_dir, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
136 ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
137 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
138 ui_menuseparator();
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
139 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
140 }
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
141
43
ef01d2c90128 some minor toolbar adjustments, toolkit icons update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
142 //ui_toolbar_add_default("Home", UI_TOOLBAR_LEFT);
46
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
143 //ui_toolbar_add_default("NewWindow", UI_TOOLBAR_LEFT);
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
144 //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
145 ui_toolbar_add_default("Repo", UI_TOOLBAR_LEFT);
4
31137432bea8 add more toolbar items
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
146
33
cdeb0dc47ef5 replace hard coded icon names with macros
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
147 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
148 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
149 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
150 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
151 ui_toolbar_add_default("Upload", UI_TOOLBAR_CENTER);
4
31137432bea8 add more toolbar items
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
152
43
ef01d2c90128 some minor toolbar adjustments, toolkit icons update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
153 //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
154 //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
155 }
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157
6
09ac07345656 add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
158
2
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 DavApp* application_create_app_document(void) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
160 DavApp *doc = ui_document_new(sizeof(DavApp));
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
161 UiContext *ctx = ui_document_context(doc);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
162 doc->repos = ui_list_new(ctx, "repolist");
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
163
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
164 // create repo list
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
165 application_update_repolist(doc);
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
166
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
167 return doc;
2
fbdfaacc4182 update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 }
6
09ac07345656 add config related code from dav / load config and fill repo list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
169
7
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
170 void application_update_repolist(DavApp *app) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
171 DavConfig *config = get_config();
7
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
172
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
173 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
174
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
175 for (DavCfgRepository *repo = config->repositories; repo; repo = repo->next) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
176 ui_list_append(app->repos, repo);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
177 }
60
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 53
diff changeset
178
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 53
diff changeset
179 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
180 }
7
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
181
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
182
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
183 DavContext* application_dav_context(void) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
184 return davctx;
7
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
185 }
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
186
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
187
14
872d570ae843 implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
188 void action_window_new(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
189 UiObject *win = window_create();
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
190 // 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
191 DavBrowser *doc = davbrowser_create(win);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
192 ui_attach_document(win->ctx, doc);
14
872d570ae843 implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
193
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
194 ui_show(win);
14
872d570ae843 implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
195 }
872d570ae843 implement window new button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
196
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
197 void action_window_close(UiEvent *event, void *data) {
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
198 ui_close(event->obj);
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
199 }
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
200
17
7cfd36aa005b add refresh button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
201 void action_refresh(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
202 DavBrowser *browser = event->document;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
203 if (browser->current) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
204 davbrowser_query_path(event->obj, browser, browser->current->path);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
205 }
17
7cfd36aa005b add refresh button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
206 }
7cfd36aa005b add refresh button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
207
7
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
208 void action_repo_selected(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
209 DavCfgRepository *repo = event->eventdata;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
210 DavBrowser *browser = event->document;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
211 davbrowser_connect2repo(event->obj, browser, repo, "");
7
905ac52c910f port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 6
diff changeset
212 }
18
af411868ab9b implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
213
af411868ab9b implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
214 static void file_selected(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
215 UiFileList *files = event->eventdata;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
216 if (files && files->nfiles > 0) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
217 // 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
218 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
219 davbrowser_upload_files(event->obj, event->document, uploadList);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
220 }
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
221
18
af411868ab9b implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
222 }
af411868ab9b implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
223
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
224
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
225
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
226 static void download_location_selected(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
227 DavBrowser *browser = event->document;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
228 DavResource *reslist = data;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
229 UiFileList *flist = event->eventdata;
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
230
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
231 if (flist && flist->nfiles > 0) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
232 davbrowser_download(event->obj, browser, reslist, flist->files[0]);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
233 } else {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
234 dav_session_destroy(reslist->session);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
235 }
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
236 }
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
237
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
238 void action_download(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
239 DavBrowser *browser = event->document;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
240 UiListSelection sel = ui_list_getselection(browser->resources);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
241 if (sel.count > 0) {;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
242 const char *initialFileName = NULL;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
243 if (sel.count == 1) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
244 DavResource *res = ui_list_get(browser->resources, sel.rows[0]);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
245 if (res && !res->iscollection) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
246 initialFileName = res->name;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
247 }
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
248 }
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
249
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
250 // 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
251 DavSession *sn = dav_session_clone(browser->sn);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
252 DavResource *first = NULL;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
253 DavResource *last = NULL;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
254 for (int i = 0; i < sel.count; i++) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
255 // get selected resource
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
256 DavResource *res = ui_list_get(browser->resources, sel.rows[i]);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
257 // copy resource
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
258 DavResource *res_copy = dav_resource_new(sn, res->path);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
259 res_copy->iscollection = res->iscollection;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
260 res_copy->contentlength = res->contentlength;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
261 res_copy->lastmodified = res->lastmodified;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
262 res_copy->creationdate = res->creationdate;
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
263
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
264 // link resources
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
265 if (!first) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
266 first = res_copy;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
267 }
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
268 if (last) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
269 res_copy->prev = last;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
270 last->next = res_copy;
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 last = res_copy;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
273 }
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
274
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
275 if (initialFileName) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
276 ui_savefiledialog(event->obj, initialFileName, download_location_selected, first);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
277 } else {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
278 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
279 }
53
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
280
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
281 ui_listselection_free(sel);
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
282 }
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
283 }
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
284
18
af411868ab9b implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
285 void action_upload_file(UiEvent *event, void *data) {
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
286 DavBrowser *browser = event->document;
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
287 if(!browser->sn) {
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
288 return;
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
289 }
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
290 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
291 }
26
40d6af793c1a implement resource deletion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 23
diff changeset
292
47
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
293 void action_upload_dir(UiEvent *event, void *data) {
68
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
294 DavBrowser *browser = event->document;
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
295 if(!browser->sn) {
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
296 return;
79a9aadf1c70 add main menu
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
297 }
47
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
298 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
299 }
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
300
26
40d6af793c1a implement resource deletion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 23
diff changeset
301 void action_delete(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
302 DavBrowser *browser = event->document;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
303 UiListSelection sel = ui_list_getselection(browser->resources);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
304 if (sel.count > 0) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
305 davbrowser_delete(event->obj, browser, sel);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
306 }
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
307 ui_listselection_free(sel);
26
40d6af793c1a implement resource deletion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 23
diff changeset
308 }
28
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
309
46
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
310 static void newfiledialog_result(UiEvent *event, void *data) {
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
311 DavBrowser *browser = event->document;
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
312 char *path = event->eventdata;
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
313 if (event->intval == 1) {
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
314 davbrowser_newfile(event->obj, browser, path);
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
315 }
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
316 }
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
317
28
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
318 void action_newfile(UiEvent *event, void *data) {
46
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
319 DavBrowser *browser = event->document;
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
320 if(!browser->sn) {
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
321 return;
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
322 }
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
323
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
324 ui_dialog(event->obj,
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
325 .content = "New File",
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
326 .input = TRUE,
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
327 .button1_label = "Create File",
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
328 .button2_label = "Cancel",
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
329 .result = newfiledialog_result);
28
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
330 }
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
331
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
332
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
333 static void newfolderdialog_result(UiEvent *event, void *data) {
35
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
334 DavBrowser *browser = event->document;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
335 char *path = event->eventdata;
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
336 if (event->intval == 1) {
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
337 davbrowser_mkcol(event->obj, browser, path);
834d9c15a69f some toolkit fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
338 }
28
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
339 }
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
340
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
341 void action_mkcol(UiEvent *event, void *data) {
46
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
342 DavBrowser *browser = event->document;
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
343 if(!browser->sn) {
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
344 return;
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
345 }
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
346
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
347
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
348 ui_dialog(event->obj,
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
349 .content = "New Folder",
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
350 .input = TRUE,
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
351 .button1_label = "Create Folder",
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
352 .button2_label = "Cancel",
31bc86844659 implement action_newfile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
353 .result = newfolderdialog_result);
28
1ecc1183f046 implement new-collection toolbar button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
354 }
47
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
355
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
356 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
357 settings_window_open();
47
3ac472683246 add upload dir action
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
358 }
53
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
359
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
360 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
361 char *type = data;
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
362 DavBrowser *browser = event->document;
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
363
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
364 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
365 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
366 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
367 if(res) {
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
368 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
369 }
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
370 }
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
371 ui_listselection_free(sel);
da05df77652e add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 47
diff changeset
372 }

mercurial