GNOME Bugzilla – Bug 148545
x-nautilus-desktop:/// useless to scripts via NAUTILUS_SCRIPT_CURRENT_URI
Last modified: 2005-08-26 16:05:03 UTC
This is essentially a duplicate bug of #142747. The precise problem is that from a scripting perspective when a user uses a Nautilus-Script on their desktop the variable NAUTILUS_SCRIPT_CURRENT_URI is set to x-nautilus-desktop:/// which is useless. The solution would be to have NAUTILUS_SCRIPT_CURRENT_URI populated with the actual file:/// uri to their desktop (be it file:///home/user/Desktop/ or just file:///home/user/ depending on the state of the gconf key '/apps/nautilus/preferences/desktop_is_home_dir'). While I'm not a C programmer by any means, I've at least attempted to implement this solution to the best of my abilities. Attached is the patch for the changes I've tried to make. My implementation of this solution doesn't work due to a lockup somewhere and because I'm not very proficient with debugging C let alone GNOME apps I'm just submitting it as is in the hopes that someone can correct my mistake(s) and apply it to Nautilus. However, I have no idea how this should have been properly fixed and with that said, I'll state that if this patch isn't accepted I will certainly not be offended in any way, shape or form. Just trying to be helpful to get this bug fixed.
Created attachment 29923 [details] [review] patch that *trys* to fix the x-nautilus-desktop:/// NAUTILUS_SCRIPT_CURRENT_URI bug.
*** Bug 142747 has been marked as a duplicate of this bug. ***
The .Trash doesn't work either. We need a fix for that folder too, because if you want to "shred" files there using a nautilus script, or open a terminal there, Nautilus won't let you.
Kevin: Thanks for the patch. Could you send this to nautilus-list@gnome.org with a subject line of "[PATCH] ...." and a link to the URL of this bug, so that one of the maintainers will be sure to see this? Thanks.
Was this ever sent to the list?
Thanks for your efforts. Kevin: The string semantics look horrible. You should rather use: char *path; if (desktop_is_home_dir ()) { uri = g_filename_to_uri (g_get_home_dir (), NULL, NULL); } else { path = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), "Desktop", NULL); uri = g_filename_to_uri (path, NULL, NULL); g_free (path); } also, you should add check for being not-NULL before calling eel_str_has_prefix.
Eugenia: Thanks for hinting out the .trash issue - which may be a bit more tricky, since there lurk around subfolders from all kinds of trash-supporting file systems.
In fact you should simply use nautilus_get_desktop_directory_uri() & eel_uri_is_desktop()
Created attachment 47152 [details] [review] Proposed (untested) patch (against HEAD). I've lost hope that Kevin rewrites his patch. So I'm submitting a new proposal. I'm not sure whether the g_filename_to_uri semantics are desirable, or whether there should be added a helper similar to nautilus_get_desktop_directory_uri, which also ensures that the ~/.Trash directory is actually in place.
Created attachment 50698 [details] [review] Proposed patch Hrm I'm not sure whether NAUTILUS_SCRIPT_CURRENT_URI should be changed, considering that there might be a point in finding out whether the currently displayed directory is the virtual or the physical desktop directory. I'd rather propose to only resolve the local selected paths/links on the desktop and in the trash. Proposed patch attached, which resolves the desktop links (trash, home, computer) and ensures that for x-nautilus-desktop:///, the files merged in from the physical desktop directory are added to NAUTILUS_SCRIPT_SELECTED_FILE_PATHS, and for trash:///, the files merged from ~/.Trash are also added to NAUTILUS_SCRIPT_SELECTED_FILE_PATHS. Eugenia: On trash/my first patch (attachment 47152 [details] [review]): We can't simply resolve trash:/// to one location (~/.Trash), which was done in my first patch. trash:/// contains merged trash directories from other locations as well, for instance removable USB media. Maybe you could describe a use-case for this which is not resolved by my 2nd patch?
I don't know, I am not going to re-compile my Nautilus to try this (I am leaving for vacations atm). Here is my script: http://www.gnomefiles.org/app.php?soft_id=116 have a go and tell us if it works.
I forgot to say, in the meantime there was a trick to make the above nautilus script to recognize trash/ desktop, however IMHO this should have worked out of the box.
I commited something based on the last patch. It also expands the directory for the desktop, but not the trash (since the trash really is multiple normal directories). However, scripts in the trash should mostly work anyway, since the pathnames of the selected files are correctly set in the file list. Expanding desktop links to their target is a bit strange, but I can't really think of any other behaviour that makes sense.