// create window data object
MainWindow *wdata = ui_malloc(obj->ctx, sizeof(MainWindow));
memset(wdata, 0, sizeof(MainWindow));
+ windowdata_init(obj->ctx, wdata);
obj->window = wdata;
// create browser document
FileBrowser *browser = filebrowser_new(url);
ui_attach_document(obj->ctx, browser);
+ // add UI
+ ui_sidebar0(obj) {
+ UiSubList sublists[] = {
+ { .value = wdata->default_dirs, .userdata = window_sidebar_default_dirs_item },
+ { .value = wdata->user_dirs, .userdata = window_sidebar_user_dirs_item, .separator = TRUE }
+ };
+ ui_sourcelist(obj, .sublists = sublists, .numsublists = 2, .getvalue = window_sidebar_getvalue);
+ }
+
+
return obj;
}
+
+
+void windowdata_init(UiContext *ctx, MainWindow *win) {
+ win->default_dirs = ui_list_new(ctx, NULL);
+ win->user_dirs = ui_list_new(ctx, NULL);
+
+ // TODO: init lists
+ ui_list_append(win->default_dirs, "Test");
+ ui_list_append(win->user_dirs, "Test");
+}
+
+/*
+ * callback for ui_sourcelist
+ *
+ * sublist_userdata: sublist identifier (sidebar_list_default_dirs, sidebar_list_user_dirs)
+ */
+void window_sidebar_getvalue(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item) {
+ ui_sublist_getvalue_func getvalue = sublist_userdata;
+ getvalue(NULL, rowdata, index, item);
+}
+
+void window_sidebar_default_dirs_item(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item) {
+ item->icon = strdup("user-home-symbolic");
+ item->label = strdup("Home");
+}
+
+void window_sidebar_user_dirs_item(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item) {
+ item->icon = strdup("folder-documents-symbolic");
+ item->label = strdup("Documents");
+}
UiObject* window_create(const char *url);
+void windowdata_init(UiContext *ctx, MainWindow *win);
+
+void window_sidebar_getvalue(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item);
+
+void window_sidebar_default_dirs_item(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item);
+void window_sidebar_user_dirs_item(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item);
+
#ifdef __cplusplus
}