xdg-user-dirs update
Roberto Piscitello
robepisc at freemail.it
Wed Mar 7 01:55:11 PST 2007
Alexander Larsson <alexl <at> redhat.com> writes:
>
> I've set up a webpage for xdg-user-dirs:
> http://freedesktop.org/wiki/Software_2fxdg_2duser_2ddirs
> It has the latest released version.
>
> I've also created xdg-user-dirs-gtk:
> ftp://ftp.gnome.org/pub/gnome/sources/xdg-user-dirs-gtk/
> Which has some integration of xdg-user-dirs with gnome/gtk.
>
> Both of these are now built in Fedora 7 and I've started to add patches
> to the Fedora Gnome to make use of it. (Can't go upstream atm, since
> upstream is frozen, but others can pick up the patches if they want.)
Wow, great work!
I almost like all the ideas you implemented and think you took the right
direction.
However there is something I like less:
* all those dirs are automatically created on login, not when needed;
* applications need to be modified to take advantage of the new feature;
* it's not a complex system, but IMHO could be even simpler;
* it's not clear (at least to me...) which is the API for applications.
So I propose a little different approach (which I already tried to push in a
similar form, in a lonely and unnoticed comment in an already dead thread on
the Desktop ML last month...).
Applications should have a X-XDG-MetaType (*not* to be confused with MimeType)
line in their .desktop file.
The list of possible metatypes is well defined: music, images, documents,
videos, archives, projects.
It is possible to specify more than one value, separated by commas.
For example:
Rhythmbox -> X-XDG-MetaType=music
Totem -> X-XDG-MetaType=videos,music
OO.o -> X-XDG-MetaType=documents,images
The GIMP -> X-XDG-MetaType=images
EOG -> X-XDG-MetaType=images
FileRoller -> X-XDG-MetaType=archives
Anjuta -> X-XDG-MetaType=projects
Then all the magic happens within the file chooser; when called, it chooses
which folder to show you following this order of preference (in order to lessen
some of the navigation issues described[1] by Federico at GUADEC 2006):
1. the folder which was last used for this operation (opening/saving) in the
current application session;
2. the folder intended for this kind of files, if any (e.g. ~/Music/);
3. $HOME
Point 2 is the one being discussed here.
Let's suppose we're the GIMP and have X-XDG-MetaType=images; then the
file-chooser should try to find out which is the folder where the user puts his
images.
At first it looks inside ~/.local/default-dirs/ and sees if it can find a
symbolic link named "images".
For example: ~/.local/default-dirs/images -> ~/Images.
If it can't find it, then it asks the user:
________________________________________________________
|______________________________________________________X_|
| |
| It is the first time you save an image. Where do you |
| want to put this kind of files, by default? |
| _______________ |
| o | ~/Images | |
| '~~~~~~~~~~~~~~~' |
| o Nowhere in particular ________ |
| | Ok | |
| '~~~~~~~~' |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
The proposed "~/Images" is localized with gettext. I'm italian, so I would see
"~/Immagini".
The choice "Nowhere in particular" means $HOME.
If the user likes the default or simply presses Ok without caring, then
~/Images (~/Immagini for me) is created together with the symbolic link
~/.local/default-dirs/images -> ~/Images.
If, instead, the user changed the proposed default to "~/Graphics", then the
symbolic link would be: ~/.local/default-dirs/images -> ~/Graphics.
Of course ~/Graphics is created if it doesn't exist.
All this could happen without the app even knowing.
If an application needs more control, a new property called metatype could be
added to the file-chooser (containing one or more of these flags:
XDG_METATYPE_IMAGES, XDG_METATYPE_DOCUMENTS, XDG_METATYPE_VIDEOS,
XDG_METATYPE_ARCHIVES, XDG_METATYPE_PROJECTS) for the caller application to
set. This setting would prevail on the one in the .desktop file.
Command line tools could reach these "well-known" folders through
.local/default-dirs links.
Old and ISV applications could, if desired, take advantage of the new system
with a simple adjustment to their .desktop file.
THIS vs. YOUR APPROACH:
~~~~~~~~~~~~~~~~~~~~~~~
Pro:
* Even less intrusive and simple to use for applications.
* All changes are done at the toolkit level (inside the file-chooser) and in
.desktop files; applications can remain untouched.
* The "well-known" folders are not created on startup, but on first use by
interested applications (and without they even know, since the work is done
by the file-chooser).
* The file-chooser can default to the right folder for each cathegory of
applications (Music for Rhythmbox, Photos for f-spot etc.); it can even list
it (or them, since one app can have more than one metatype) in the bookmarks
pane.
* Everything just works whenever the user does a "mv ~/Graphics ~/MyPhotos",
since the link in .local/default-dirs becomes dangling and the file_chooser,
realizing that, shows its question about Images again next time. (checking
for renames through inotify would also be good, of course, but not required).
Same:
* directories are translated;
* the directory name the user sees is the one on disk;
* easy to use for shell scripts;
* Nautilus could trivially assign an automatic emblem to those special folders.
Contra:
* The user is asked a question, but:
- he can blindly clic on Ok, since the default is reasonable and already
translated;
- this happens only *once per metatype* (not once per application, as it
is today, for example, for music programs);
- this happens only when an app needs that folder;
- IMHO it's a feature, since I prefer to be asked instead of seeing random
folders appear in my $HOME;
Hi,
robepisc
[1] http://primates.ximian.com/~federico/docs/gnome-deployments-2006/
/index.html#navigation
More information about the xdg
mailing list