Fri, 29 Nov 2024 22:21:36 +0100
fix gtk4 dependency
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 "window.h" |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
31 | #include "davcontroller.h" |
94
7fdf1489b82f
move app settings to separate source file
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
32 | #include "appsettings.h" |
97
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
33 | #include "xml.h" |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
34 | |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | #include <ui/stock.h> |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
36 | #include <ui/dnd.h> |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | |
13
5a8762fcfecc
update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
38 | #include <libidav/utils.h> |
5a8762fcfecc
update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
39 | |
56
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
40 | #include <cx/printf.h> |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
41 | |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
42 | static UiIcon* folder_icon; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
43 | static UiIcon* file_icon; |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
44 | |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
45 | static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data); |
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
46 | |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
47 | static UiMenuBuilder *contextmenu; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
48 | |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
49 | void window_init(void) { |
37 | 50 | folder_icon = ui_foldericon(16); |
51 | file_icon = ui_fileicon(16); | |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
52 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
53 | // initialize the browser context menu |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
54 | ui_contextmenu(&contextmenu) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
55 | ui_menuitem(.label = "New Folder", .onclick = action_mkcol, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
56 | ui_menuitem(.label = "New File", .onclick = action_newfile, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
57 | ui_menuseparator(); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
58 | //ui_menuitem(.label = "Cut", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
59 | //ui_menuitem(.label = "Copy", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
60 | //ui_menuitem(.label = "Paste", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
61 | ui_menuitem(.label = "Download", .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
62 | ui_menuitem(.label = "Delete", .onclick = action_delete, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
63 | ui_menuitem(.label = "Select All", .onclick = action_selectall, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
64 | ui_menuseparator(); |
89
2fbb3cac05a5
implement rename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
65 | ui_menuitem(.label = "Rename", .onclick = action_rename, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
66 | ui_menuseparator(); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
67 | ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
68 | ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
69 | } |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
70 | } |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | |
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | UiObject* window_create(void) { |
37 | 73 | UiObject* obj = ui_window("iDAV", NULL); |
74 | ui_window_size(obj, 900, 700); | |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | |
37 | 76 | MainWindow* wdata = ui_malloc(obj->ctx, sizeof (MainWindow)); |
77 | memset(wdata, 0, sizeof (MainWindow)); | |
78 | obj->window = wdata; | |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
79 | |
37 | 80 | wdata->progress = ui_int_new(obj->ctx, "progress"); |
81 | ||
82 | // navigation bar | |
7
905ac52c910f
port more dav config code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
83 | |
45
ab71409644b0
update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
40
diff
changeset
|
84 | ui_hbox(obj, .fill = UI_OFF, .margin = 8, .spacing = 8) { |
ab71409644b0
update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
40
diff
changeset
|
85 | ui_hbox(obj, .fill = UI_OFF, .style_class="linked") { |
ab71409644b0
update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
40
diff
changeset
|
86 | ui_button(obj, .icon = UI_ICON_GO_BACK, .onclick = action_go_back); |
ab71409644b0
update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
40
diff
changeset
|
87 | ui_button(obj, .icon = UI_ICON_GO_FORWARD, .onclick = action_go_forward); |
ab71409644b0
update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
40
diff
changeset
|
88 | } |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | |
37 | 90 | ui_path_textfield(obj, .fill = UI_ON, .getpathelm = dav_get_pathelm, .onactivate = action_path_selected, .varname = "path"); |
91 | ui_progressspinner(obj, .value = wdata->progress); | |
92 | } | |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | |
37 | 94 | // main content |
92
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
95 | UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING_FREE, "Flags", UI_STRING, "Type", UI_STRING_FREE, "Last Modified", UI_STRING_FREE, "Size", -1); |
80
1a908b060122
adjust browser columns
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
96 | model->columnsize[0] = -1; |
92
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
97 | model->columnsize[2] = 150; |
37 | 98 | model->getvalue = (ui_getvaluefunc) window_resource_table_getvalue; |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
99 | ui_table(obj, |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
100 | .fill = UI_ON, |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
101 | .model = model, |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
102 | .onselection = action_list_selection, |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
103 | .onactivate = action_list_activate, |
90
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
104 | .ondragstart = action_dnd_start, |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
105 | .ondragcomplete = action_dnd_end, |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
106 | .ondrop = action_dnd_drop, |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
107 | .varname = "reslist", |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
108 | .multiselection = TRUE, |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
109 | .contextmenu = contextmenu); |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | |
37 | 111 | // status bar |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | |
37 | 113 | ui_hbox(obj, .fill = UI_OFF) { |
114 | ui_label(obj, .label = ""); | |
115 | } | |
116 | ||
117 | return obj; | |
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | } |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
119 | |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
120 | void* window_resource_table_getvalue(DavResource *res, int col) { |
37 | 121 | switch (col) { |
38
acd8c4a9d3fe
fix path textfield
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
122 | case 0: { // icon |
37 | 123 | return res->iscollection ? folder_icon : file_icon; |
124 | } | |
38
acd8c4a9d3fe
fix path textfield
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
125 | case 1: { // resource name |
37 | 126 | return res->name; |
127 | } | |
92
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
128 | case 2: { // flags |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
129 | char *keyprop = dav_get_string_property_ns( |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
130 | res, |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
131 | DAV_NS, |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
132 | "crypto-key"); |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
133 | DavXmlNode *lockdiscovery = dav_get_property(res, "D:lockdiscovery"); |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
134 | char *executable = dav_get_string_property_ns( |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
135 | res, |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
136 | "http://apache.org/dav/props/", |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
137 | "executable"); |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
138 | cxmutstr flags = cx_asprintf("%s%s%s", |
94
7fdf1489b82f
move app settings to separate source file
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
139 | appsettings_get_cryptoflag(keyprop ? 1 : 0), |
7fdf1489b82f
move app settings to separate source file
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
140 | appsettings_get_lockflag(lockdiscovery ? 1 : 0), |
7fdf1489b82f
move app settings to separate source file
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
141 | appsettings_get_execflag(executable ? 1 : 0)); |
92
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
142 | return flags.ptr; |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
143 | } |
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
144 | case 3: { // type |
37 | 145 | return res->iscollection ? "Collection" : (res->contenttype ? res->contenttype : "Resource"); |
146 | } | |
92
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
147 | case 4: { // last modified |
37 | 148 | return util_date_str(res->lastmodified); |
149 | } | |
92
43aee6c8c166
add encryption and lock indicator, resolves #501
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
150 | case 5: { // size |
37 | 151 | return util_size_str(res->iscollection, res->contentlength); |
152 | } | |
153 | } | |
154 | return NULL; | |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
155 | } |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
156 | |
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
157 | void window_progress(MainWindow *win, int on) { |
37 | 158 | ui_set(win->progress, on); |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
159 | } |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
160 | |
90
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
161 | void action_dnd_start(UiEvent *event, void *data) { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
162 | //ui_selection_settext(event->eventdata, "hello world", -1); |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
163 | char *uri = "file:///export/home/olaf/test.txt"; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
164 | ui_selection_seturis(event->eventdata, &uri, 1); |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
165 | } |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
166 | |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
167 | void action_dnd_end(UiEvent *event, void *data) { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
168 | |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
169 | } |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
170 | |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
171 | |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
172 | |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
173 | |
54
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
174 | static void resourceviewer_close(UiEvent *event, void *data) { |
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
175 | DavResourceViewer *doc = data; |
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
176 | doc->window_closed = TRUE; |
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
177 | if(doc->loaded) { |
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
178 | dav_resourceviewer_destroy(doc); |
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
179 | } |
77
5de33c2d94c6
fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
180 | |
5de33c2d94c6
fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
181 | if (doc->tmp_file) { |
5de33c2d94c6
fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
182 | unlink(doc->tmp_file); |
5de33c2d94c6
fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
183 | free(doc->tmp_file); |
5de33c2d94c6
fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
184 | } |
54
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
185 | } |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
186 | |
52
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
187 | void resourceviewer_new(DavBrowser *browser, const char *path, DavResourceViewType type) { |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
188 | const char *name = util_resource_name(path); |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
189 | UiObject *win = ui_simple_window(name, NULL); |
77
5de33c2d94c6
fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
190 | ui_window_size(win, 600, 600); |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
191 | |
97
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
192 | ui_headerbar(win, .showtitle = TRUE) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
193 | ui_headerbar_start(win) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
194 | ui_button(win, .label = "Save", .onclick = action_resourceviewer_save, .groups = UI_GROUPS(RESOURCEVIEWER_STATE_MODIFIED)); |
78
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
195 | } |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
196 | } |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
197 | |
97
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
198 | DavResourceViewer *doc = dav_resourceviewer_create(win, browser->sn, path, type); |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
199 | ui_attach_document(win->ctx, doc); |
54
3ca3acefc66a
add resourceviewer cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
53
diff
changeset
|
200 | ui_context_closefunc(win->ctx, resourceviewer_close, doc); |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
201 | |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
202 | ui_tabview(win, .tabview = UI_TABVIEW_INVISIBLE, .varname = "tabview") { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
203 | /* loading / message tab */ |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
204 | ui_tab(win, NULL) { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
205 | ui_hbox(win, .margin = 16, .spacing = 10, .fill = UI_OFF) { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
206 | ui_progressspinner(win, .varname = "loading"); |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
207 | ui_label(win, .varname = "message"); |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
208 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
209 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
210 | |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
211 | /* preview tab */ |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
212 | ui_tab(win, NULL) { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
213 | ui_tabview0(win) { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
214 | if(type == DAV_RESOURCE_VIEW_TEXT) { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
215 | ui_tab(win, "Content") { |
78
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
216 | ui_textarea(win, .varname = "text", .onchange = action_resourceviewer_text_modified); |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
217 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
218 | } else if(type == DAV_RESOURCE_VIEW_IMAGE) { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
219 | ui_tab(win, "Preview") { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
220 | ui_imageviewer(win, .varname = "image"); |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
221 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
222 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
223 | |
52
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
224 | ui_tab(win, "Info") { |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
225 | ui_grid(win, .margin = 16, .columnspacing = 30, .rowspacing = 6) { |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
226 | ui_llabel(win, .label = "URL"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
227 | ui_llabel(win, .varname = "info_url"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
228 | ui_newline(win); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
229 | |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
230 | ui_llabel(win, .label = "Name"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
231 | ui_llabel(win, .varname = "info_name"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
232 | ui_newline(win); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
233 | |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
234 | ui_llabel(win, .label = "Type"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
235 | ui_llabel(win, .varname = "info_type"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
236 | ui_newline(win); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
237 | |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
238 | ui_llabel(win, .label = "Encrypted"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
239 | ui_llabel(win, .varname = "info_encrypted"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
240 | ui_newline(win); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
241 | |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
242 | ui_llabel(win, .label = "ETag"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
243 | ui_llabel(win, .varname = "info_etag"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
244 | ui_newline(win); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
245 | |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
246 | ui_llabel(win, .label = "Size"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
247 | ui_llabel(win, .varname = "info_size"); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
248 | ui_newline(win); |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
249 | } |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
250 | } |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
251 | |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
252 | ui_tab(win, "Properties") { |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
253 | UiModel* model = ui_model(win->ctx, UI_STRING, "Namespace", UI_STRING, "Name", UI_STRING, "Value", -1); |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
254 | model->getvalue = (ui_getvaluefunc) resourceviewer_proplist_getvalue; |
97
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
255 | ui_table(win, .fill = UI_ON, .model = model, .varname = "properties", .onselection = action_resourceviewer_property_select, .onactivate = action_resourceviewer_property_activate); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
256 | ui_hbox(win, .fill = UI_OFF, .margin = 4, .spacing = 4) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
257 | ui_button(win, .label = "Add", .onclick = action_resourceviewer_property_add); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
258 | ui_button(win, .label = "Edit", .onclick = action_resourceviewer_property_edit, .groups = UI_GROUPS(RESOURCEVIEWER_STATE_PROP_SELECTED)); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
259 | ui_button(win, .label = "Remove", .onclick = action_resourceviewer_property_remove, .groups = UI_GROUPS(RESOURCEVIEWER_STATE_PROP_SELECTED)); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
260 | } |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
261 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
262 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
263 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
264 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
265 | |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
266 | dav_resourceviewer_load(win, doc); |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
267 | |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
268 | ui_show(win); |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
269 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
270 | |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
271 | void* resourceviewer_proplist_getvalue(DavPropertyList *property, int col) { |
52
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
272 | switch(col) { |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
273 | case 0: { |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
274 | return property->ns; |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
275 | } |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
276 | case 1: { |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
277 | return property->name; |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
278 | } |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
279 | case 2: { |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
280 | return property->value_simplified ? property->value_simplified : property->value_full; |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
281 | } |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
282 | } |
0c881944fa10
add resourceviewer info and properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
283 | |
51
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
284 | return NULL; |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
285 | } |
e324291ca9f8
add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
286 | |
56
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
287 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
288 | typedef struct AuthDialogWindow { |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
289 | UiString *user; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
290 | UiString *password; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
291 | } AuthDialogWindow; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
292 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
293 | static void auth_dialog_action(UiEvent *event, void *data) { |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
294 | SessionAuthData *auth = data; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
295 | AuthDialogWindow *wdata = event->window; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
296 | int result = 0; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
297 | if(event->intval == 4) { |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
298 | char *user = ui_get(wdata->user); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
299 | char *password = ui_get(wdata->password); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
300 | davbrowser_auth_set_user_pwd(auth, user, password); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
301 | result = 1; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
302 | } |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
303 | ui_condvar_signal(auth->cond, NULL, result); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
304 | ui_close(event->obj); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
305 | } |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
306 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
307 | void auth_dialog(SessionAuthData *auth) { |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
308 | UiObject *obj = ui_dialog_window(auth->obj, |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
309 | .title = "Authentication", |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
310 | .lbutton1 = "Cancel", |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
311 | .rbutton4 = "Connect", |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
312 | .default_button = 4, |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
313 | .show_closebutton = UI_OFF, |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
314 | .onclick = auth_dialog_action, |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
315 | .onclickdata = auth); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
316 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
317 | AuthDialogWindow *wdata = ui_malloc(obj->ctx, sizeof(AuthDialogWindow)); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
318 | wdata->user = ui_string_new(obj->ctx, NULL); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
319 | wdata->password = ui_string_new(obj->ctx, NULL); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
320 | obj->window = wdata; |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
321 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
322 | ui_grid(obj, .margin = 20, .columnspacing = 12, .rowspacing = 12) { |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
323 | cxmutstr heading = cx_asprintf("Authentication required for: %s", auth->sn->base_url); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
324 | ui_llabel(obj, .label = heading.ptr, .colspan = 2); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
325 | free(heading.ptr); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
326 | ui_newline(obj); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
327 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
328 | ui_llabel(obj, .label = "User"); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
329 | ui_textfield(obj, .value = wdata->user, .hexpand = TRUE); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
330 | ui_newline(obj); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
331 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
332 | ui_llabel(obj, .label = "Password"); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
333 | ui_passwordfield(obj, .value = wdata->password, .hexpand = TRUE); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
334 | } |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
335 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
336 | if(auth->user) { |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
337 | ui_set(wdata->user, auth->user); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
338 | } |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
339 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
340 | ui_show(obj); |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
341 | } |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
342 | |
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
343 | |
87
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
344 | void transfer_window_init(UiObject *dialog, ui_callback btncallback) { |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
345 | ui_window_size(dialog, 550, 120); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
346 | ui_grid(dialog, .margin = 10, .spacing = 10, .fill = TRUE) { |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
347 | ui_llabel(dialog, .varname = "label_top_left", .hexpand = TRUE); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
348 | ui_rlabel(dialog, .varname = "label_top_right"); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
349 | ui_newline(dialog); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
350 | |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
351 | ui_progressbar(dialog, .varname = "progressbar", .min = 0, .max = 100, .colspan = 2, .hexpand = TRUE); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
352 | ui_newline(dialog); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
353 | |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
354 | ui_llabel(dialog, .varname = "label_bottom_left", .hexpand = TRUE); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
355 | ui_rlabel(dialog, .varname = "label_bottom_right"); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
356 | ui_newline(dialog); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
357 | |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
358 | ui_label(dialog, .vexpand = TRUE); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
359 | ui_newline(dialog); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
360 | |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
361 | ui_hbox(dialog, .colspan = 2, .hexpand = TRUE) { |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
362 | ui_label(dialog, .hexpand = TRUE); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
363 | ui_button(dialog, .label = "Cancel", .onclick = btncallback); |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
364 | } |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
365 | } |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
366 | } |
5360027fb282
download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
367 | |
56
294d5515583a
add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
368 | |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
369 | static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data) { |
83
a612adaee43d
fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
370 | if (len == 0) { |
a612adaee43d
fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
371 | *ret_nelm = 0; |
a612adaee43d
fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
372 | return NULL; |
a612adaee43d
fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
373 | } |
a612adaee43d
fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
374 | |
37 | 375 | cxstring fpath = cx_strn(full_path, len); |
376 | int protocol = 0; | |
377 | if (cx_strcaseprefix(fpath, CX_STR("http://"))) { | |
378 | protocol = 7; | |
379 | } else if (cx_strcaseprefix(fpath, CX_STR("https://"))) { | |
380 | protocol = 8; | |
381 | } | |
382 | ||
383 | size_t start = 0; | |
384 | size_t end = 0; | |
385 | for (size_t i = protocol; i < len; i++) { | |
386 | if (full_path[i] == '/') { | |
387 | end = i; | |
388 | break; | |
389 | } | |
390 | } | |
391 | ||
392 | int skip = 0; | |
393 | if (end == 0) { | |
394 | // no '/' found or first char is '/' | |
395 | end = len > 0 && full_path[0] == '/' ? 1 : len; | |
396 | } else if (end + 1 <= len) { | |
397 | skip++; // skip first '/' | |
398 | } | |
399 | ||
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
400 | |
37 | 401 | cxmutstr base = cx_strdup(cx_strn(full_path, end)); |
57
d5a7dbc945ef
store elm path with trailing path separator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
402 | cxmutstr base_path = cx_strcat(2, cx_strcast(base), CX_STR("/")); |
37 | 403 | cxstring path = cx_strsubs(fpath, end + skip); |
59
6bd37fe6d905
allow regular resource url input in the path bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
404 | |
6bd37fe6d905
allow regular resource url input in the path bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
405 | cxstring trail = cx_str(len > 0 && full_path[len-1] == '/' ? "/" : ""); |
37 | 406 | |
407 | cxstring *pathelms; | |
408 | size_t nelm = 0; | |
409 | ||
410 | if (path.length > 0) { | |
411 | nelm = cx_strsplit_a(cxDefaultAllocator, path, CX_STR("/"), 4096, &pathelms); | |
412 | if (nelm == 0) { | |
413 | *ret_nelm = 0; | |
414 | return NULL; | |
415 | } | |
416 | } | |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
417 | |
37 | 418 | UiPathElm* elms = (UiPathElm*) calloc(nelm + 1, sizeof (UiPathElm)); |
419 | size_t n = nelm + 1; | |
420 | elms[0].name = base.ptr; | |
421 | elms[0].name_len = base.length; | |
422 | elms[0].path = base_path.ptr; | |
423 | elms[0].path_len = base_path.length; | |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
424 | |
37 | 425 | int j = 1; |
426 | for (int i = 0; i < nelm; i++) { | |
427 | cxstring c = pathelms[i]; | |
428 | if (c.length == 0) { | |
429 | if (i == 0) { | |
430 | c.length = 1; | |
431 | } else { | |
432 | n--; | |
433 | continue; | |
34
98e041f2f9a2
fix dav path separator function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
434 | } |
98e041f2f9a2
fix dav path separator function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
435 | } |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
436 | |
37 | 437 | cxmutstr m = cx_strdup(c); |
438 | elms[j].name = m.ptr; | |
439 | elms[j].name_len = m.length; | |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
440 | |
37 | 441 | size_t elm_path_len = c.ptr + c.length - full_path; |
59
6bd37fe6d905
allow regular resource url input in the path bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
442 | cxmutstr elm_path = cx_strcat(2, cx_strn(full_path, elm_path_len), i+1 < nelm ? CX_STR("/") : trail); |
37 | 443 | elms[j].path = elm_path.ptr; |
444 | elms[j].path_len = elm_path.length; | |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
445 | |
37 | 446 | j++; |
447 | } | |
448 | *ret_nelm = n; | |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
449 | |
37 | 450 | return elms; |
9
0676408f50ad
add path-textfield getelm function, that supports urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
451 | } |
11
26acbfa75c1f
add handler for the path bar activate events
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
452 | |
68 | 453 | void action_go_parent(UiEvent *event, void *data) { |
454 | DavBrowser *browser = event->document; | |
455 | davbrowser_navigation_parent(event->obj, browser); | |
456 | } | |
457 | ||
15
78684a24dc52
implement navigation back/forward buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
458 | void action_go_back(UiEvent *event, void *data) { |
37 | 459 | DavBrowser *browser = event->document; |
460 | davbrowser_navigation_back(event->obj, browser); | |
15
78684a24dc52
implement navigation back/forward buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
461 | } |
78684a24dc52
implement navigation back/forward buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
462 | |
78684a24dc52
implement navigation back/forward buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
463 | void action_go_forward(UiEvent *event, void *data) { |
37 | 464 | DavBrowser *browser = event->document; |
465 | davbrowser_navigation_forward(event->obj, browser); | |
15
78684a24dc52
implement navigation back/forward buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
466 | } |
11
26acbfa75c1f
add handler for the path bar activate events
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
467 | |
26acbfa75c1f
add handler for the path bar activate events
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
468 | void action_path_selected(UiEvent *event, void *data) { |
37 | 469 | DavBrowser *browser = event->document; |
470 | char *path = event->eventdata; | |
471 | if (path && strlen(path) > 0) { | |
472 | davbrowser_query_url(event->obj, browser, path); | |
473 | } | |
11
26acbfa75c1f
add handler for the path bar activate events
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
474 | } |
13
5a8762fcfecc
update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
475 | |
68 | 476 | void action_list_selection(UiEvent *event, void *data) { |
477 | UiListSelection *selection = event->eventdata; | |
478 | if (selection->count > 0) { | |
479 | ui_set_group(event->obj->ctx, APP_STATE_BROWSER_SELECTION); | |
480 | } else { | |
481 | ui_unset_group(event->obj->ctx, APP_STATE_BROWSER_SELECTION); | |
482 | } | |
483 | } | |
484 | ||
13
5a8762fcfecc
update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
485 | void action_list_activate(UiEvent *event, void *data) { |
37 | 486 | UiListSelection *selection = event->eventdata; |
487 | DavBrowser *browser = event->document; | |
13
5a8762fcfecc
update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
488 | |
37 | 489 | if (selection->count == 1) { |
490 | DavResource *res = ui_list_get(browser->resources, selection->rows[0]); | |
491 | if (res) { | |
492 | if (res->iscollection) { | |
493 | davbrowser_query_path(event->obj, browser, res->path); | |
494 | } else { | |
53
da05df77652e
add menu items to open resource properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
495 | davbrowser_open_resource(event->obj, browser, res, NULL); |
37 | 496 | } |
497 | } | |
498 | } | |
13
5a8762fcfecc
update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
499 | } |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
500 | |
90
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
501 | static int filelist_uri2path(UiFileList *files) { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
502 | for(int i=0;i<files->nfiles;i++) { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
503 | char *uri = files->files[i]; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
504 | if(uri[0] == '/') { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
505 | continue; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
506 | } |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
507 | |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
508 | cxstring uri_s = cx_str(uri); |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
509 | if(!cx_strprefix(uri_s, CX_STR("file://"))) { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
510 | return 1; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
511 | } |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
512 | |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
513 | files->files[i] = cx_strdup(cx_strsubs(uri_s, 7)).ptr; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
514 | free(uri); |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
515 | } |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
516 | |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
517 | return 0; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
518 | } |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
519 | |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
520 | void action_dnd_drop(UiEvent *event, void *data) { |
90
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
521 | UiDnD *dnd = event->eventdata; |
37 | 522 | UiFileList files = ui_selection_geturis(dnd); |
90
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
523 | if(files.nfiles == 0) { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
524 | return; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
525 | } |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
526 | |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
527 | if(filelist_uri2path(&files)) { |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
528 | ui_dnd_accept(dnd, FALSE); |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
529 | ui_filelist_free(files); |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
530 | return; |
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
89
diff
changeset
|
531 | } |
37 | 532 | |
533 | davbrowser_upload_files(event->obj, event->document, files); | |
18
af411868ab9b
implement dnd upload (without progressbar)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
534 | } |
78
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
535 | |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
536 | |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
537 | /* ------------------------ resource viewer actions ------------------------ */ |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
538 | |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
539 | void action_resourceviewer_text_modified(UiEvent *event, void *data) { |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
540 | DavResourceViewer *doc = event->document; |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
541 | if(doc->loaded) { |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
542 | ui_set_group(event->obj->ctx, RESOURCEVIEWER_STATE_MODIFIED); |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
543 | } |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
544 | } |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
545 | |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
546 | void action_resourceviewer_save(UiEvent *event, void *data) { |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
547 | DavResourceViewer *doc = event->document; |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
548 | dav_resourceviewer_save(event->obj, doc); |
ad7ced6cf00b
implement resourceviewer textfile save button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
549 | } |
97
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
550 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
551 | void action_resourceviewer_property_select(UiEvent *event, void *data) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
552 | DavResourceViewer *doc = event->document; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
553 | UiListSelection *selection = event->eventdata; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
554 | if(selection->count == 1) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
555 | ui_set_group(event->obj->ctx, RESOURCEVIEWER_STATE_PROP_SELECTED); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
556 | doc->selected_property = ui_list_get(doc->properties, selection->rows[0]); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
557 | } else { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
558 | ui_unset_group(event->obj->ctx, RESOURCEVIEWER_STATE_PROP_SELECTED); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
559 | doc->selected_property = NULL; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
560 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
561 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
562 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
563 | void action_resourceviewer_property_activate(UiEvent *event, void *data) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
564 | action_resourceviewer_property_select(event, data); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
565 | action_resourceviewer_property_edit(event, data); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
566 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
567 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
568 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
569 | typedef struct PropertyDialog { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
570 | UiInteger *type; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
571 | UiString *ns; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
572 | UiString *name; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
573 | UiText *value; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
574 | } PropertyDialog; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
575 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
576 | static void propertydialog_action(UiEvent *event, void *data) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
577 | DavResourceViewer *res = data; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
578 | if(event->intval == 4) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
579 | char *ns = ui_get(res->property_ns); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
580 | char *name = ui_get(res->property_name); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
581 | int type = ui_get(res->property_type); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
582 | char *nsdef = ui_get(res->property_nsdef); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
583 | char *value = ui_get(res->property_value); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
584 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
585 | if(strlen(ns) == 0) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
586 | ui_set(res->property_errormsg, "Namespace must not be empty!"); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
587 | return; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
588 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
589 | if(strlen(name) == 0) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
590 | ui_set(res->property_errormsg, "Name must not be empty!"); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
591 | return; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
592 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
593 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
594 | char *textvalue = NULL; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
595 | DavXmlNode *xmlvalue = NULL; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
596 | if(type == 0) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
597 | // text value |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
598 | textvalue = value; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
599 | } else { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
600 | // xml value |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
601 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
602 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
603 | DavBool add = FALSE; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
604 | if(res->edit_property) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
605 | if(strcmp(res->edit_property->ns, ns) || strcmp(res->edit_property->name, name)) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
606 | // name or namespace changed, remove existing and create new property |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
607 | dav_resourceviewer_property_remove(res, res->edit_property); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
608 | add = TRUE; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
609 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
610 | } else { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
611 | add = TRUE; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
612 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
613 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
614 | if(add) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
615 | if(textvalue) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
616 | dav_resourceviewer_property_add_text(res, ns, name, textvalue); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
617 | } else { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
618 | dav_resourceviewer_property_add_xml(res, ns, name, nsdef, xmlvalue); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
619 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
620 | } else { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
621 | if(textvalue) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
622 | dav_resourceviewer_property_update_text(res, res->edit_property, textvalue); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
623 | } else { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
624 | dav_resourceviewer_property_update_xml(res, res->edit_property, xmlvalue); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
625 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
626 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
627 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
628 | ui_close(event->obj); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
629 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
630 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
631 | static void prop_type_changed(UiEvent *event, void *data) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
632 | DavResourceViewer *res = data; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
633 | switch(ui_get(res->property_type)) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
634 | case 0: { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
635 | ui_unset_group(event->obj->ctx, RESOURCEVIEWER_STATE_PROP_XML); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
636 | break; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
637 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
638 | case 1: { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
639 | ui_set_group(event->obj->ctx, RESOURCEVIEWER_STATE_PROP_XML); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
640 | char *ns = ui_get(res->property_ns); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
641 | char *nsdef = ui_get(res->property_nsdef); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
642 | if(strlen(nsdef) == 0) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
643 | cxmutstr def = cx_asprintf("xmlns:x0=\"%s\"", ns); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
644 | ui_set(res->property_nsdef, def.ptr); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
645 | free(def.ptr); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
646 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
647 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
648 | break; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
649 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
650 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
651 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
652 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
653 | static void edit_property_dialog(DavResourceViewer *res, const char *title, DavPropertyList *prop) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
654 | res->edit_property = prop; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
655 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
656 | UiObject *obj = ui_dialog_window(res->obj, |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
657 | .title = title, |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
658 | .show_closebutton = UI_OFF, |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
659 | .lbutton1 = "Cancel", |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
660 | .rbutton4 = "Save", |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
661 | .default_button = 4, |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
662 | .onclick = propertydialog_action, |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
663 | .onclickdata = res, |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
664 | .width = 600, |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
665 | .height = 500); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
666 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
667 | ui_grid(obj, .margin = 16, .columnspacing = 8, .rowspacing = 12) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
668 | ui_llabel(obj, .label = "Namespace"); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
669 | ui_textfield(obj, .hexpand = TRUE, .value = res->property_ns); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
670 | ui_newline(obj); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
671 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
672 | ui_llabel(obj, .label = "Property Name"); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
673 | ui_textfield(obj, .hexpand = TRUE, .value = res->property_name); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
674 | ui_newline(obj); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
675 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
676 | ui_llabel(obj, .label = "Type"); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
677 | ui_hbox(obj, .spacing = 8, .colspan = 2) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
678 | ui_radiobutton(obj, .label = "Text", .value = res->property_type, .onchange = prop_type_changed, .onchangedata = res); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
679 | ui_radiobutton(obj, .label = "XML", .value = res->property_type, .onchange = prop_type_changed, .onchangedata = res); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
680 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
681 | ui_newline(obj); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
682 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
683 | ui_llabel(obj, .label = "Namespace Declarations"); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
684 | ui_textfield(obj, .hexpand = TRUE, .value = res->property_nsdef, .groups = UI_GROUPS(RESOURCEVIEWER_STATE_PROP_XML)); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
685 | ui_newline(obj); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
686 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
687 | ui_textarea(obj, .value = res->property_value, .hexpand = TRUE, .vexpand = TRUE, .colspan = 2); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
688 | ui_newline(obj); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
689 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
690 | ui_llabel(obj, .colspan = 2, .value = res->property_errormsg); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
691 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
692 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
693 | if(prop && prop->ns && prop->name) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
694 | ui_set(res->property_ns, prop->ns); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
695 | ui_set(res->property_name, prop->name); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
696 | if(prop->value_full) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
697 | ui_set(res->property_type, 0); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
698 | ui_set(res->property_nsdef, ""); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
699 | ui_set(res->property_value, prop->value_full); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
700 | ui_unset_group(obj->ctx, RESOURCEVIEWER_STATE_PROP_XML); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
701 | } else if(prop->xml) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
702 | ui_set(res->property_type, 1); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
703 | cxmutstr xml; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
704 | cxmutstr nsdef; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
705 | property_xml2str(prop->xml, prop->ns, &xml, &nsdef); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
706 | ui_set(res->property_nsdef, nsdef.ptr); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
707 | ui_set(res->property_value, xml.ptr); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
708 | free(xml.ptr); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
709 | free(nsdef.ptr); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
710 | ui_set_group(obj->ctx, RESOURCEVIEWER_STATE_PROP_XML); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
711 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
712 | } else { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
713 | ui_set(res->property_ns, ""); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
714 | ui_set(res->property_name, ""); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
715 | ui_set(res->property_nsdef, ""); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
716 | ui_set(res->property_type, 0); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
717 | ui_set(res->property_value, ""); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
718 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
719 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
720 | ui_set(res->property_errormsg, ""); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
721 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
722 | ui_show(obj); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
723 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
724 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
725 | void action_resourceviewer_property_add(UiEvent *event, void *data) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
726 | DavResourceViewer *doc = event->document; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
727 | edit_property_dialog(doc, "Add Property", NULL); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
728 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
729 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
730 | void action_resourceviewer_property_edit(UiEvent *event, void *data) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
731 | DavResourceViewer *doc = event->document; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
732 | edit_property_dialog(doc, "Edit Property", doc->selected_property); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
733 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
734 | |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
735 | void action_resourceviewer_property_remove(UiEvent *event, void *data) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
736 | DavResourceViewer *doc = event->document; |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
737 | if(!doc->selected_property) { |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
738 | return; // shouldn't happen |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
739 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
740 | dav_resourceviewer_property_remove(doc, doc->selected_property); |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
741 | } |
5a3d27b8e6b0
implement UI for editing properties, relates to #497
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
742 |