GNOME Bugzilla – Bug 304147
gtksourceview does_obey XDG_DATA_DIRS
Last modified: 2009-10-13 17:33:16 UTC
Please describe the problem: gtksourceview should try to get .lang files from XDG_DATA_DIRS per the spec. This allows people to make programs in prefixes work correctly Steps to reproduce: Configure an app that installs to a prefix and has a .lang file. Note it doesn't work. Actual results: Expected results: Does this happen every time? Other information:
Created attachment 48119 [details] [review] Proposed patch against CVS HEAD (v1)
looks mostly good, but I know little about XDG_DATA_DIRS. Ben does the patch suits your needs? The only doubt I have is if the orders in which we add the dirs matter: in that case XDG_DATA_DIR should be prepended *after* DATADIR, so that we firts look in ~, then in XDG and finally fall back to /usr. As a nitpick, it may also be worth do something like this: #define LANGUAGE_DIR "/gtksourceview-1.0/language-specs" #define DEFAULT_LANGUAGE_DIR DATADIR LANGUAGE_DIR #define USER_LANGUAGE_DIR LANGUAGE_DIR and use LANGUAGE_DIR also for XDG instead of hardcoding "/gtksourceview-1.0/language-specs"
In terms of order, the user's home directory should come *before* the /usr one. This allows them to override system preferences. Also, what aobut XDG_DATA_HOME? Other than that, I think I am happy.
> In terms of order, the user's home directory should come *before* the /usr one. That's exactly what I meant: since we are *prepending* to the list,we should add it last so that it is the first one checked :-)
Now that I think of it the patch is pretty much bogus: XDG_DATA_DIR should not be obtained with g_getenv, since it may also be a list of dirs separated by ":". Glib has an apposite function: g_get_user_data_dir ()
or maybe g_get_system_data_dirs (). paolo: /me is confused so I'm not going to cook up a quick patch right now as I said on irc
g_get_user_data_dir () returns either XDG_DATA_HOME or ~/.local/share if it's not set. g_get_system_data_dirs () returns either XDG_DATA_DIRS or "/usr/local/share/:/usr/share/" if not set. So gtksourceview should use the latter one to look for .lang files.
Created attachment 53254 [details] [review] patch Here is the patch, works nicely for me and should make life easier for win32.
Created attachment 54741 [details] [review] committed patch fixed by committing this patch (which adds the directories specified in XDG_DATA_DIRS in the right order)
The above patch contains a silly of by one error in the xdg directory lookup :( I already committed the fix since it's obvious (drop the - 1 from the for loop). Paolo do you want me to roll a 1.5.2 for this?