implement window new button

Tue, 30 Jan 2024 14:01:04 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 30 Jan 2024 14:01:04 +0100
changeset 14
872d570ae843
parent 13
5a8762fcfecc
child 15
78684a24dc52

implement window new button

application/application.c file | annotate | diff | comparison | revisions
application/application.h file | annotate | diff | comparison | revisions
application/window.h file | annotate | diff | comparison | revisions
--- a/application/application.c	Tue Jan 30 13:31:25 2024 +0100
+++ b/application/application.c	Tue Jan 30 14:01:04 2024 +0100
@@ -54,17 +54,17 @@
 
 	window_init();
 
+	// create document for global settings (repolist, ...)
+	DavApp *app = application_create_app_document();
+	UiContext *global = ui_global_context();
+	ui_attach_document(global, app);
+
 	// create new window
 	UiObject *win = window_create();
 	// create new browser document and attach it to the main window
 	DavBrowser *doc = davbrowser_create(win);
 	ui_attach_document(win->ctx, doc);
 
-	// create document for global settings (repolist, ...)
-	DavApp *app = application_create_app_document();
-	UiContext *global = ui_global_context();
-	ui_attach_document(global, app);
-
 	ui_show(win);
 }
 
@@ -79,7 +79,7 @@
 
 	// toolbar
 	ui_toolbar_item("Home", .icon = "Home");
-	ui_toolbar_item("NewWindow", .icon = "NewWindow");
+	ui_toolbar_item("NewWindow", .icon = "NewWindow", .onclick = action_window_new);
     ui_toolbar_menu("Repo", .label = "Repository") {
         ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected);
     }
@@ -141,6 +141,15 @@
 }
 
 
+void action_window_new(UiEvent *event, void *data) {
+	UiObject *win = window_create();
+	// create new browser document and attach it to the main window
+	DavBrowser *doc = davbrowser_create(win);
+	ui_attach_document(win->ctx, doc);
+
+	ui_show(win);
+}
+
 void action_repo_selected(UiEvent *event, void *data) {
 	DavCfgRepository *repo = event->eventdata;
 	DavBrowser *browser = event->document;
--- a/application/application.h	Tue Jan 30 13:31:25 2024 +0100
+++ b/application/application.h	Tue Jan 30 14:01:04 2024 +0100
@@ -90,6 +90,8 @@
 DavContext* application_dav_context(void);
 
 
+void action_window_new(UiEvent *event, void *data);
+
 void action_repo_selected(UiEvent *event, void *data);
 
 #ifdef	__cplusplus
--- a/application/window.h	Tue Jan 30 13:31:25 2024 +0100
+++ b/application/window.h	Tue Jan 30 14:01:04 2024 +0100
@@ -48,6 +48,7 @@
 
 void window_init(void);
 
+
 UiObject* window_create(void);
 
 void* window_resource_table_getvalue(DavResource *res, int col);

mercurial