GNOME Bugzilla – Bug 578482
Need for more user dirs
Last modified: 2017-11-16 10:41:09 UTC
On Maemo there are a number of special directories, such as Sounds, Documents, Images and Videos. The platform doesn't currently make use of the freedesktop specification for user dirs. A major stumbling block is this: the standardized directory names are not enough to map Maemo's special directories. For instance "Games" is for the sake of this example a folder containing save games. If an application on Maemo wanted to use g_get_user_special_dir () it would have no way of looking up the "Games" folder. As far as I can see, it's not possible to extend the available directory names. unless Glib is modified. Would it make sense to add support for more special folders? Would it make sense to add a way to add additional folders, for example by means of a function that might be called g_get_user_special_dir_from_string and Glib would actually read folder names from a certain file.
Created attachment 132768 [details] [review] Implement g_get_user_named_dir This implements g_get_user_named_dir which takes the string as found in user-dirs.dirs as argument, ie. "XDG_DESKTOP_DIR". Au contraire to g_get_user_special_dir any string found in the user-dirs.dirs is supported. The strings are stored in a hash table, separate from the already existing dirs. I wonder, should the signature be non-const, to allow for updating the values at runtime? File monitoring could be added. Unfortunately this won't work for g_get_user_special_dirs since it's const.
Maybe it would better to stay with g_get_user_special_dir(), but make GUserDirectory extensible like GtkIconSize: GUserDirectory g_user_special_dir_register (const gchar *name); This would allow platforms like Maemo or Suggar to safely provide additional GUserDirectory constants.
Maemo is dead, and with it the motivation for this patch. If other platforms want to try something similar in future, I would only really be open to adding new API for them in GLib if they expand the spec to cover their use case.