52 exit(-1); |
52 exit(-1); |
53 } |
53 } |
54 |
54 |
55 window_init(); |
55 window_init(); |
56 |
56 |
|
57 // create document for global settings (repolist, ...) |
|
58 DavApp *app = application_create_app_document(); |
|
59 UiContext *global = ui_global_context(); |
|
60 ui_attach_document(global, app); |
|
61 |
57 // create new window |
62 // create new window |
58 UiObject *win = window_create(); |
63 UiObject *win = window_create(); |
59 // create new browser document and attach it to the main window |
64 // create new browser document and attach it to the main window |
60 DavBrowser *doc = davbrowser_create(win); |
65 DavBrowser *doc = davbrowser_create(win); |
61 ui_attach_document(win->ctx, doc); |
66 ui_attach_document(win->ctx, doc); |
62 |
|
63 // create document for global settings (repolist, ...) |
|
64 DavApp *app = application_create_app_document(); |
|
65 UiContext *global = ui_global_context(); |
|
66 ui_attach_document(global, app); |
|
67 |
67 |
68 ui_show(win); |
68 ui_show(win); |
69 } |
69 } |
70 |
70 |
71 static void* davrepo_getname(void *elm, int unused) { |
71 static void* davrepo_getname(void *elm, int unused) { |
77 // menu |
77 // menu |
78 |
78 |
79 |
79 |
80 // toolbar |
80 // toolbar |
81 ui_toolbar_item("Home", .icon = "Home"); |
81 ui_toolbar_item("Home", .icon = "Home"); |
82 ui_toolbar_item("NewWindow", .icon = "NewWindow"); |
82 ui_toolbar_item("NewWindow", .icon = "NewWindow", .onclick = action_window_new); |
83 ui_toolbar_menu("Repo", .label = "Repository") { |
83 ui_toolbar_menu("Repo", .label = "Repository") { |
84 ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected); |
84 ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected); |
85 } |
85 } |
86 ui_toolbar_item("Refresh", .icon = "Refresh"); |
86 ui_toolbar_item("Refresh", .icon = "Refresh"); |
87 ui_toolbar_item("NewFolder", .icon = "NewFolder"); |
87 ui_toolbar_item("NewFolder", .icon = "NewFolder"); |
139 DavContext* application_dav_context(void) { |
139 DavContext* application_dav_context(void) { |
140 return davctx; |
140 return davctx; |
141 } |
141 } |
142 |
142 |
143 |
143 |
|
144 void action_window_new(UiEvent *event, void *data) { |
|
145 UiObject *win = window_create(); |
|
146 // create new browser document and attach it to the main window |
|
147 DavBrowser *doc = davbrowser_create(win); |
|
148 ui_attach_document(win->ctx, doc); |
|
149 |
|
150 ui_show(win); |
|
151 } |
|
152 |
144 void action_repo_selected(UiEvent *event, void *data) { |
153 void action_repo_selected(UiEvent *event, void *data) { |
145 DavCfgRepository *repo = event->eventdata; |
154 DavCfgRepository *repo = event->eventdata; |
146 DavBrowser *browser = event->document; |
155 DavBrowser *browser = event->document; |
147 davbrowser_connect2repo(event->obj, browser, repo); |
156 davbrowser_connect2repo(event->obj, browser, repo); |
148 } |
157 } |