application/window.c

changeset 8
726b24766437
parent 7
905ac52c910f
child 9
0676408f50ad
--- a/application/window.c	Mon Jan 29 12:09:24 2024 +0100
+++ b/application/window.c	Mon Jan 29 18:50:04 2024 +0100
@@ -28,8 +28,17 @@
 
 #include "window.h"
 
+#include "davcontroller.h"
+
 #include <ui/stock.h>
 
+static UiIcon* folder_icon;
+static UiIcon* file_icon;
+
+void window_init(void) {
+	folder_icon = ui_foldericon(16);
+	file_icon = ui_fileicon(16);
+}
 
 UiObject* window_create(void) {
 	UiObject* obj = ui_window("iDAV", NULL);
@@ -38,19 +47,22 @@
 	memset(wdata, 0, sizeof(MainWindow));
 	obj->window = wdata;
 
-	wdata->dav_queue = ui_threadpool_create(1);
+	wdata->progress = ui_int_new(obj->ctx, "progress");
 
 	// navigation bar
 	ui_hbox(obj, .fill = UI_OFF, .margin = 8) {
 		ui_button(obj, .icon = "Back");
 		ui_button(obj, .icon = "Forward");
 
-		ui_path_textfield(obj, .fill = UI_ON);
+		ui_path_textfield(obj, .fill = UI_ON, .varname = "path");
+
+		ui_progressspinner(obj, .value = wdata->progress);
 	}
 
 	// main content
 	UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING, "Last Modified", UI_STRING, "Size", -1);
-	ui_table(obj, .fill = UI_ON, .model = model);
+	model->getvalue = (ui_getvaluefunc)window_resource_table_getvalue;
+	ui_table(obj, .fill = UI_ON, .model = model, .varname = "reslist");
 
 	// status bar
 	ui_hbox(obj, .fill = UI_OFF) {
@@ -61,3 +73,28 @@
 
 	return obj;
 }
+
+void* window_resource_table_getvalue(DavResource *res, int col) {
+	switch (col) {
+		case 0: { // icon
+			return res->iscollection ? folder_icon : file_icon;
+		}
+		case 1: { // resource name
+			return res->name;
+		}
+		case 2: { // type
+			return ""; // TODO
+		}
+		case 3: { // last modified
+			return ""; // TODO
+		}
+		case 4: { // size
+			return ""; // TODO
+		}
+	}
+	return NULL;
+}
+
+void window_progress(MainWindow *win, int on) {
+	ui_set(win->progress, on);
+}

mercurial