GNOME Bugzilla – Bug 591458
Unmounting a drive sends Nautilus to /media instead of computer://
Last modified: 2010-02-22 09:55:49 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
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.
Created attachment 140726 [details] [review] Proposed patch for bug. Please review
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.
Created attachment 140765 [details] [review] code formatting
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
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?
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 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.
Created attachment 145051 [details] [review] 3rd version
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.
@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/
A. Walton, is Nikos correct? In light of his comment, is the patch acceptable?
(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!
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.
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.
Created attachment 153970 [details] [review] Fix missing semi-colon
looks good, pushed.