After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 148545 - x-nautilus-desktop:/// useless to scripts via NAUTILUS_SCRIPT_CURRENT_URI
x-nautilus-desktop:/// useless to scripts via NAUTILUS_SCRIPT_CURRENT_URI
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: Scripts facilities
2.11.x
Other All
: High normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
: 142747 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-07-27 06:18 UTC by Kevin C. Krinke
Modified: 2005-08-26 16:05 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
patch that *trys* to fix the x-nautilus-desktop:/// NAUTILUS_SCRIPT_CURRENT_URI bug. (2.59 KB, patch)
2004-07-27 06:20 UTC, Kevin C. Krinke
needs-work Details | Review
Proposed (untested) patch (against HEAD). (1.14 KB, patch)
2005-06-02 17:56 UTC, Christian Neumair
none Details | Review
Proposed patch (1.87 KB, patch)
2005-08-14 19:08 UTC, Christian Neumair
none Details | Review

Description Kevin C. Krinke 2004-07-27 06:18:33 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.
Comment 1 Kevin C. Krinke 2004-07-27 06:20:28 UTC
Created attachment 29923 [details] [review]
patch that *trys* to fix the x-nautilus-desktop:/// NAUTILUS_SCRIPT_CURRENT_URI bug.
Comment 2 Justin Wake 2004-07-27 07:29:15 UTC
*** Bug 142747 has been marked as a duplicate of this bug. ***
Comment 3 Eugenia Loli-Queru 2004-07-27 07:31:34 UTC
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.
Comment 4 Matthew Gatto 2004-09-25 11:02:37 UTC
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.
Comment 5 Kjartan Maraas 2005-01-04 00:47:52 UTC
Was this ever sent to the list?
Comment 6 Christian Neumair 2005-05-22 21:18:08 UTC
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.
Comment 7 Christian Neumair 2005-05-22 21:19:40 UTC
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.
Comment 8 Martin Wehner 2005-05-22 21:45:20 UTC
In fact you should simply use nautilus_get_desktop_directory_uri() &
eel_uri_is_desktop()
Comment 9 Christian Neumair 2005-06-02 17:56:29 UTC
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.
Comment 10 Christian Neumair 2005-08-14 19:08:38 UTC
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?
Comment 11 Eugenia Loli-Queru 2005-08-14 20:08:40 UTC
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.
Comment 12 Eugenia Loli-Queru 2005-08-14 20:45:36 UTC
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.
Comment 13 Alexander Larsson 2005-08-26 16:05:03 UTC
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.