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 591458 - Unmounting a drive sends Nautilus to /media instead of computer://
Unmounting a drive sends Nautilus to /media instead of computer://
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
2.26.x
Other All
: Normal minor
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-08-11 15:08 UTC by David Siegel
Modified: 2010-02-22 09:55 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
Comparing view of /media and computer:/// (121.17 KB, image/png)
2009-08-11 15:15 UTC, David Siegel
  Details
Proposed patch for bug. (1.17 KB, patch)
2009-08-14 00:08 UTC, Nikos Verschore
needs-work Details | Review
code formatting (1.27 KB, patch)
2009-08-14 12:04 UTC, Nikos Verschore
none Details | Review
Improved version (1.41 KB, patch)
2009-08-16 22:49 UTC, Nikos Verschore
needs-work Details | Review
3rd version (1.05 KB, patch)
2009-10-08 14:08 UTC, Nikos Verschore
reviewed Details | Review
Go to computer:/// on unmount (1.97 KB, patch)
2010-02-15 23:07 UTC, Luke Symes
none Details | Review
Trimmed patch down to bare essentials (1.47 KB, patch)
2010-02-16 21:58 UTC, Luke Symes
none Details | Review
Fix missing semi-colon (1.47 KB, patch)
2010-02-16 22:13 UTC, Luke Symes
none Details | Review

Description David Siegel 2009-08-11 15:08:53 UTC
When viewing the contents of a drive while it is being unmounted, Nautilus will move to /media when the drive is no longer available. This exposes the user to a few confusing folders that don't look like "media" at all. Instead, when a device is unmounted Nautilus should navigate to computer:///, where the user can see other devices with nice labels and familiar icons.

Other information:
Launchpad Bug:

 [1] https://bugs.edge.launchpad.net/hundredpapercuts/+bug/386517
Comment 1 David Siegel 2009-08-11 15:15:11 UTC
Created attachment 140451 [details]
Comparing view of /media and computer:///

Put yourself in the shoes of the inexperienced user, and ask yourself which view you'd prefer to see after ejecting a drive that you were viewing in Nautilus.
Comment 2 Nikos Verschore 2009-08-14 00:08:38 UTC
Created attachment 140726 [details] [review]
Proposed patch for bug.

Please review
Comment 3 A. Walton 2009-08-14 00:59:39 UTC
It's kind of a nasty way of doing it, but I'm not immediately seeing an easier way. Need to look at the problem more closely.

Also, the patch doesn't follow Nautilus code formatting rules and introduces a variable in the middle of the block.
Comment 4 Nikos Verschore 2009-08-14 12:04:47 UTC
Created attachment 140765 [details] [review]
code formatting
Comment 5 Nikos Verschore 2009-08-14 12:11:24 UTC
If been thinking about a proper way.

if the computer:// protocol could handle the disks (e.g. computer://disk), we would not need the hack. When the disk unmount, nautilus will go to the upper directory computer://.

It also makes sense for abstracting the disk into the computer protocol, 
because the users don't need to know the real mounting location and the computer:// protocol was made for abstracting the hard disks.

Only advanced user need to know the real mounting mount, so they can use the terminal. Therefor are 2 possible solutions:
1. Let the terminal understand the gvfs schemes (so you can 'cd computer://' or 'cd ftp://')
2. Put 'mount location' into the disk properties window
Comment 6 Marcus Carlson 2009-08-15 16:16:10 UTC
In the same way we check whether the file is in trash or not, can't we save which filesystem (eg mount point, HAL_UDI?) the directory belongs to and when the path is changed compare it to the parent and if they don't match, then goto computer://. Would that be better? A. Walton?
Comment 7 Nikos Verschore 2009-08-16 22:49:41 UTC
Created attachment 140924 [details] [review]
Improved version

This is an improved version of the 'hack'
- Use g_file_equal instead of ugly check between files uris
- Don't go to location computer:// when it doens't exist (e.g. when gfvs isn't loaded)

In my previous comment, I explained about a possible solution. It would extend the computer:// so it takes subdirs. bug 422099 also proposed this solution. Alex, the designer of the schema, was against it. He designed computer:// as short-cuts to other devices. Also implementing computer:// subdirs would create double path. (e.g. computer://disk and /media/disk). Therefor I stopped looking in that direction.

I'm now also thinking in Marcus Carlson direction. Just store the mount_parent location of a mounted disk when opening a disk. So unmounting a location from computer:// (e.g. sidebar) should go to computer://, while unmounting from /media/ should go to /media

This would also mean a possible fix for bug 422099. Entering a drive through computer:// and pressing up, should go to computer://. Entering a drive through /media/ and pressing up, should go to /media/

The only problem is knowing what folder we have to choose. That's what a new field 'mount_parent' in NautilusFileDetails location should remember.

Agree on the solution?
Comment 8 Cosimo Cecchi 2009-10-07 15:13:20 UTC
Comment on attachment 140924 [details] [review]
Improved version

Thanks for the patches.

I agree with the rationale behind the bug, and it seems to me a fine policy to go back to "computer:///" if a drive is unmounted.
I can't think of a more elegant way to do that right now, but anyway there are some things wrong in the patch as well;

>+#define COMPUTER_URI         "computer:"

Should be "computer:///"

>+#define MEDIA_URI            "file:///media"

I don't see much point in using #defines here, as you will use that string only once anyway.

>+					GFile *media_folder;

Please declare all the variables at the top of the function.

>+					if (g_file_equal (media_folder,go_to_file)==TRUE) {

Drop the "== TRUE" and always put a space between arguments passed in to functions.

>+						GFile *computer = g_file_new_for_uri (COMPUTER_URI);

Declare this at top.

>+						
>+						if (g_file_query_exists (computer,NULL)==TRUE) {
>+							go_to_file = computer;
>+						}

This is very wrong, as g_file_query_exists does blocking I/O. We always assume "computer:///" exists in other places in Nautilus as well, so just drop that call. Also, you should unref go_to_file before assigning computer to it.
Comment 9 Nikos Verschore 2009-10-08 14:08:44 UTC
Created attachment 145051 [details] [review]
3rd version
Comment 10 A. Walton 2009-10-11 23:36:42 UTC
Comment on attachment 145051 [details] [review]
3rd version

The whole approach seems wrong and hackish to me. Looks like going to /media would now just redirect you to computer:///, which is probably not what you want to do if you're deliberately going to /media (and this totally fails for the case when we're mounting elsewhere).

We want to make it so that when a location is unmounted, we do something special, not whenever we're just navigating around.
Comment 11 Nikos Verschore 2009-10-13 11:05:01 UTC
@A. Walton: The patch will not redirect you from /media/  to computer:// when you're just browsing. It will only do that, when you are inside a mounted disk and that disk is unmounted. Than you will go to computer:// instead of /media/
Comment 12 David Siegel 2010-01-22 15:23:40 UTC
A. Walton, is Nikos correct? In light of his comment, is the patch acceptable?
Comment 13 Luke Symes 2010-02-12 09:29:28 UTC
(In reply to comment #10)
> (From update of attachment 145051 [details] [review])
> The whole approach seems wrong and hackish to me. Looks like going to /media
> would now just redirect you to computer:///, which is probably not what you
> want to do if you're deliberately going to /media (and this totally fails for
> the case when we're mounting elsewhere).
> 
> We want to make it so that when a location is unmounted, we do something
> special, not whenever we're just navigating around.

I tested this patch out on nautilus 2.28.1 and it worked as Nikos said. I could navigate to and from /media/ with no surprises. The *only* change was that when a disk was *unmounted* (only then) I was directed to computer:///

Please review the patch again!
Comment 14 Luke Symes 2010-02-15 23:07:36 UTC
Created attachment 153878 [details] [review]
Go to computer:/// on unmount

I have looked through the code, and I believe I have come up with a proper solution. The attached patch will cause window slots displaying mount contents to be redirected to computer:/// on unmount.

I also included a change to the code that checks if a slot should be closed on unmount. Previously the code only checked if you were viewing a sub-directory, now it also checks if you are in the top-most directory of the mount.

Please review the patch and tell me what you think.
Comment 15 Luke Symes 2010-02-16 21:58:05 UTC
Created attachment 153968 [details] [review]
Trimmed patch down to bare essentials

Took out the changes which fix bug 318094 (should close windows on unmount). I'm moving a separate patch over to that bug. Also this patch very slightly modified for coding style.
Comment 16 Luke Symes 2010-02-16 22:13:28 UTC
Created attachment 153970 [details] [review]
Fix missing semi-colon
Comment 17 Alexander Larsson 2010-02-22 09:55:34 UTC
looks good, pushed.