From: Olaf Wintermann Date: Fri, 17 Jan 2025 20:46:54 +0000 (+0100) Subject: handle the default dirs list like bookmarks X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=b1395f5d9d7933ceaab42a617635dc531f2813e8;p=mizunara.git handle the default dirs list like bookmarks --- diff --git a/mizunara/bookmarks.c b/mizunara/bookmarks.c index 8e8b059..5159407 100644 --- a/mizunara/bookmarks.c +++ b/mizunara/bookmarks.c @@ -37,12 +37,22 @@ #include #include -static CxList *bookmarks; +static CxList *cfg_default_dirs; + +static CxList *cfg_bookmarks; void bookmarks_init(void) { - bookmarks = cxArrayListCreateSimple(sizeof(MZBookmark), 8); + cfg_default_dirs = cxArrayListCreateSimple(sizeof(MZBookmark), 8); + cfg_bookmarks = cxArrayListCreateSimple(sizeof(MZBookmark), 8); + + bookmarks_import_xdg_user_dirs(cfg_bookmarks, NULL); - bookmarks_import_xdg_user_dirs(bookmarks, NULL); + MZBookmark def; + def.icon = "user-home-symbolic"; + def.path = strdup(getenv("HOME")); + def.name = util_resource_name(def.path); + def.sort = 0; + cxListAdd(cfg_default_dirs, &def); } void bookmarks_import_xdg_user_dirs(CxList *list, const char *optional_path) { @@ -86,7 +96,7 @@ void bookmarks_import_xdg_user_dirs(CxList *list, const char *optional_path) { } else { bookmark_path = cx_strdup(value); } - + const char *icon = "folder-symbolic"; if(!cx_strcmp(key, CX_STR("XDG_DOWNLOAD_DIR"))) { icon = "folder-download-symbolic"; @@ -119,9 +129,14 @@ void bookmarks_import_xdg_user_dirs(CxList *list, const char *optional_path) { close(fd); } -void bookmarks_init_windowdata(UiList *list) { - CxIterator i = cxListIterator(bookmarks); - cx_foreach(MZBookmark *, bookmark, i) { - ui_list_append(list, bookmark); +void bookmarks_init_windowdata(UiList *default_dirs, UiList *bookmarks) { + CxIterator i = cxListIterator(cfg_default_dirs); + cx_foreach(MZBookmark*, bookmark, i) { + ui_list_append(default_dirs, bookmark); + } + + i = cxListIterator(cfg_bookmarks); + cx_foreach(MZBookmark*, bookmark, i) { + ui_list_append(bookmarks, bookmark); } } diff --git a/mizunara/bookmarks.h b/mizunara/bookmarks.h index f304a4a..c72236e 100644 --- a/mizunara/bookmarks.h +++ b/mizunara/bookmarks.h @@ -47,7 +47,7 @@ void bookmarks_init(void); void bookmarks_import_xdg_user_dirs(CxList *list, const char *optional_path); -void bookmarks_init_windowdata(UiList *list); +void bookmarks_init_windowdata(UiList *default_dirs, UiList *bookmarks); #ifdef __cplusplus }