]> uap-core.de Git - mizunara.git/commitdiff
handle the default dirs list like bookmarks
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 17 Jan 2025 20:46:54 +0000 (21:46 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 17 Jan 2025 20:46:54 +0000 (21:46 +0100)
mizunara/bookmarks.c
mizunara/bookmarks.h

index 8e8b0592ff38761df1e05026fdc252f140613956..51594072c4ba5e609e43cc761f8bcc367746773e 100644 (file)
 #include <cx/properties.h>
 #include <libidav/utils.h>
 
-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);
     }
 }
index f304a4adc20f86f144223e1eba4f3c6cc03bc2d0..c72236e5dfb0f41747693f3ea4dd53e610744fda 100644 (file)
@@ -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
 }