103 lines
3.4 KiB
Diff
103 lines
3.4 KiB
Diff
From 5f3b178590df746544a48338f39025bf03aca46c Mon Sep 17 00:00:00 2001
|
|
From: Emmanuele Bassi <ebassi@gnome.org>
|
|
Date: Fri, 3 Apr 2026 12:17:31 +0100
|
|
Subject: [PATCH] Support XDG_PROJECTS_DIR
|
|
|
|
A new XDG user directory type, for non-document project files.
|
|
|
|
See: https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/work_items/3
|
|
---
|
|
gio/glocalfileinfo.c | 4 ++++
|
|
glib/gosxutils.m | 3 ++-
|
|
glib/gutils.c | 2 ++
|
|
glib/gutils.h | 9 +++++++++
|
|
glib/gutilsprivate.c | 5 +++++
|
|
5 files changed, 22 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
|
|
index d2efb169eb..ec482988a6 100644
|
|
--- a/gio/glocalfileinfo.c
|
|
+++ b/gio/glocalfileinfo.c
|
|
@@ -1840,6 +1840,10 @@ get_icon_name (const char *path,
|
|
{
|
|
name = use_symbolic ? "folder-pictures-symbolic" : "folder-pictures";
|
|
}
|
|
+ else if (g_strcmp0 (path, g_get_user_special_dir (G_USER_DIRECTORY_PROJECTS)) == 0)
|
|
+ {
|
|
+ name = use_symbolic ? "folder-projects-symbolic" : "folder-projects";
|
|
+ }
|
|
else if (g_strcmp0 (path, g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE)) == 0)
|
|
{
|
|
name = use_symbolic ? "folder-publicshare-symbolic" : "folder-publicshare";
|
|
diff --git a/glib/gosxutils.m b/glib/gosxutils.m
|
|
index 4d2d962ef4..13860a31ce 100644
|
|
--- a/glib/gosxutils.m
|
|
+++ b/glib/gosxutils.m
|
|
@@ -43,7 +43,7 @@ find_folder (NSSearchPathDirectory type)
|
|
}
|
|
|
|
void
|
|
-load_user_special_dirs_macos(gchar **table)
|
|
+load_user_special_dirs_macos (gchar **table)
|
|
{
|
|
table[G_USER_DIRECTORY_DESKTOP] = find_folder (NSDesktopDirectory);
|
|
table[G_USER_DIRECTORY_DOCUMENTS] = find_folder (NSDocumentDirectory);
|
|
@@ -53,4 +53,5 @@ load_user_special_dirs_macos(gchar **table)
|
|
table[G_USER_DIRECTORY_PUBLIC_SHARE] = find_folder (NSSharedPublicDirectory);
|
|
table[G_USER_DIRECTORY_TEMPLATES] = NULL;
|
|
table[G_USER_DIRECTORY_VIDEOS] = find_folder (NSMoviesDirectory);
|
|
+ table[G_USER_DIRECTORY_PROJECTS] = find_folder (NSDocumentDirectory);
|
|
}
|
|
diff --git a/glib/gutils.c b/glib/gutils.c
|
|
index 02da41b688..90bd3bc3e7 100644
|
|
--- a/glib/gutils.c
|
|
+++ b/glib/gutils.c
|
|
@@ -2243,6 +2243,8 @@ load_user_special_dirs_unlocked (void)
|
|
|
|
g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = get_special_folder (&FOLDERID_Templates);
|
|
g_user_special_dirs[G_USER_DIRECTORY_VIDEOS] = get_special_folder (&FOLDERID_Videos);
|
|
+
|
|
+ g_user_special_dirs[G_USER_DIRECTORY_PROJECTS] = get_special_folder (&FOLDERID_Documents);
|
|
}
|
|
|
|
#else /* default is unix */
|
|
diff --git a/glib/gutils.h b/glib/gutils.h
|
|
index dce1541ed7..f111938cae 100644
|
|
--- a/glib/gutils.h
|
|
+++ b/glib/gutils.h
|
|
@@ -248,6 +248,15 @@ typedef enum {
|
|
G_USER_DIRECTORY_TEMPLATES,
|
|
G_USER_DIRECTORY_VIDEOS,
|
|
|
|
+ /**
|
|
+ * G_USER_DIRECTORY_PROJECTS:
|
|
+ *
|
|
+ * The user's Projects directory.
|
|
+ *
|
|
+ * Since: 2.90
|
|
+ */
|
|
+ G_USER_DIRECTORY_PROJECTS,
|
|
+
|
|
G_USER_N_DIRECTORIES
|
|
} GUserDirectory;
|
|
|
|
diff --git a/glib/gutilsprivate.c b/glib/gutilsprivate.c
|
|
index 3b9206c45c..f8dac99ec0 100644
|
|
--- a/glib/gutilsprivate.c
|
|
+++ b/glib/gutilsprivate.c
|
|
@@ -89,6 +89,11 @@ load_user_special_dirs_from_string (const gchar *string, const gchar *home_dir,
|
|
directory = G_USER_DIRECTORY_VIDEOS;
|
|
p += strlen ("XDG_VIDEOS_DIR");
|
|
}
|
|
+ else if (strncmp (p, "XDG_PROJECTS_DIR", strlen ("XDG_PROJECTS_DIR")) == 0)
|
|
+ {
|
|
+ directory = G_USER_DIRECTORY_PROJECTS;
|
|
+ p += strlen ("XDG_PROJECTS_DIR");
|
|
+ }
|
|
else
|
|
continue;
|
|
|
|
--
|
|
GitLab
|
|
|