GNOME Bugzilla – Bug 555715
support dynamic xdg directories
Last modified: 2010-07-10 23:39:39 UTC
Currently xdg dirs are static, you have to logout if you change one of them. this is a limitation because they could be dynamic. this could be done simply in two ways 1) 2 functions: - g_set_user_special_dir - g_invalidate_user_special_dir_cache 2) a patch to the current g_get_user_special_dir so that it re-loads the user dirs when a directory is not found (this adds IO but it's transparent). see this patch http://bugzilla.gnome.org/attachment.cgi?id=120296
I've already explained in bug 541276 why the api doesn't really allow for changes in the user special dirs - this is the same for all the other statically allocated data we provide, like home dirs, user name, etc "this is a limitation because they could be dynamic" is hardly a good explanation for why this would be important to fix. There are important shortcomings in GLib, but this is not one of them...
Trying to make any of the g_get_user_foo and friends "dynamic" is bound to be ugly, because these functions are just not designed for this. There is no way to notice if the directory changed either. I wonder, what about solving this with a special GFile, such as g_file_new_for_special_user_dir? I'm not sure if a subclass is needed but a GFile can easily be monitored and always returns a newly allocated string.
We have meanwhile added g_reload_user_special_dirs_cache(), which is about as much as we can do here.