honor shadowed mounts (Was Re: gphoto2 backend fixes)



(Moving to nautilus-list)

On Tue, 2009-02-10 at 14:45 -0500, David Zeuthen wrote:
> The next item on my list is to make the rest of the desktop handles
> shadowed mounts. There are two ways to fix this
> 
>  1. Go through all GVolumeMonitor users and make them honor the
>     g_mount_is_shadowed() flag; or
> 
>  2. Add new API to GVolumeMonitor
> 
>      get_shadowed_mounts()
>      ::shadowed-mount-added
>      ::shadowed-mount-removed
>      ::shadowed-mount-pre-unmount
>      ::shadowed-mount-changed
> 
>     and a) port the volume monitors we have in gio+gvfs to this.
> 
> So I think 2. is probably the best solution but I wanted to check here
> first.

Or maybe that's confusing and it's easier to just fix up existing users.
Here's the patch for Nautilus to honor g_mount_is_shadowed().

     David

Index: src/nautilus-pathbar.c
===================================================================
--- src/nautilus-pathbar.c	(revision 14933)
+++ src/nautilus-pathbar.c	(working copy)
@@ -1355,6 +1355,10 @@
 	mounts = g_volume_monitor_get_mounts (volume_monitor);
 	for (l = mounts; l != NULL; l = l->next) {
 		mount = l->data;
+                if (g_mount_is_shadowed (mount)) {
+			g_object_unref (mount);
+			continue;
+                }
 		if (result) {
 			g_object_unref (mount);
 			continue;
Index: src/file-manager/fm-tree-view.c
===================================================================
--- src/file-manager/fm-tree-view.c	(revision 14933)
+++ src/file-manager/fm-tree-view.c	(working copy)
@@ -587,6 +587,9 @@
 	GFile *root;
 	GIcon *icon;
 
+	if (g_mount_is_shadowed (mount))
+		return;
+
 	icon = g_mount_get_icon (mount);
 	root = g_mount_get_root (mount);
 	mount_uri = g_file_get_uri (root);
Index: src/nautilus-places-sidebar.c
===================================================================
--- src/nautilus-places-sidebar.c	(revision 14933)
+++ src/nautilus-places-sidebar.c	(working copy)
@@ -451,6 +451,10 @@
 	mounts = g_volume_monitor_get_mounts (volume_monitor);
 	for (l = mounts; l != NULL; l = l->next) {
 		mount = l->data;
+		if (g_mount_is_shadowed (mount)) {
+			g_object_unref (mount);
+			continue;
+		}
 		volume = g_mount_get_volume (mount);
 		if (volume != NULL) {
 		    	g_object_unref (volume);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14933)
+++ ChangeLog	(working copy)
@@ -1,3 +1,16 @@
+2009-02-10  David Zeuthen  <davidz redhat com>
+
+	Don't use shadowed mounts.
+
+	* libnautilus-private/nautilus-desktop-link-monitor.c (has_mount),
+	(create_mount_link), (remove_mount_link), (mount_added_callback),
+	(mount_removed_callback), (mount_changed_callback):
+	* libnautilus-private/nautilus-directory-async.c (get_mount_at):
+	* src/file-manager/fm-tree-view.c (add_root_for_mount):
+	* src/nautilus-pathbar.c (is_file_path_mounted_mount):
+	* src/nautilus-places-sidebar.c (update_places):
+	Honor g_mount_is_shadowed().
+
 2009-02-09  Thomas H.P. Andersen  <phomes gmail com>
 
 	* src/file-manager/fm-empty-view.c: (fm_empty_view_add_file):
Index: libnautilus-private/nautilus-directory-async.c
===================================================================
--- libnautilus-private/nautilus-directory-async.c	(revision 14933)
+++ libnautilus-private/nautilus-directory-async.c	(working copy)
@@ -4146,10 +4146,15 @@
 
 	found = NULL;
 	for (l = mounts; l != NULL; l = l->next) {
-		root = g_mount_get_root (l->data);
+		GMount *mount = G_MOUNT (l->data);
 
+		if (g_mount_is_shadowed (mount))
+			continue;
+
+		root = g_mount_get_root (mount);
+
 		if (g_file_equal (target, root)) {
-			found = g_object_ref (l->data);
+			found = g_object_ref (mount);
 			break;
 		}
 		
Index: libnautilus-private/nautilus-desktop-link-monitor.c
===================================================================
--- libnautilus-private/nautilus-desktop-link-monitor.c	(revision 14933)
+++ libnautilus-private/nautilus-desktop-link-monitor.c	(working copy)
@@ -182,36 +182,49 @@
 	return unique_name;
 }
 
+static gboolean
+has_mount (NautilusDesktopLinkMonitor *monitor,
+	   GMount                     *mount)
+{
+	gboolean ret;
+	GMount *other_mount;
+	GList *l;
+
+	ret = FALSE;
+
+	for (l = monitor->details->mount_links; l != NULL; l = l->next) {
+		other_mount = nautilus_desktop_link_get_mount (l->data);
+		if (mount == other_mount) {
+			g_object_unref (other_mount);
+			ret = TRUE;
+			break;
+		}
+		g_object_unref (other_mount);
+	}
+
+	return ret;
+}
+
 static void
 create_mount_link (NautilusDesktopLinkMonitor *monitor,
 		   GMount *mount)
 {
 	NautilusDesktopLink *link;
 
-	link = NULL;
+	if (has_mount (monitor, mount))
+		return;
 
-	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
+	if ((!g_mount_is_shadowed (mount)) &&
+	    eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
 		link = nautilus_desktop_link_new_from_mount (mount);
 		monitor->details->mount_links = g_list_prepend (monitor->details->mount_links, link);
 	}
 }
 
-
-
 static void
-mount_added_callback (GVolumeMonitor *volume_monitor,
-		      GMount *mount, 
-		      NautilusDesktopLinkMonitor *monitor)
+remove_mount_link (NautilusDesktopLinkMonitor *monitor,
+		   GMount *mount)
 {
-	create_mount_link (monitor, mount);
-}
-
-
-static void
-mount_removed_callback (GVolumeMonitor *volume_monitor,
-			GMount *mount, 
-			NautilusDesktopLinkMonitor *monitor)
-{
 	GList *l;
 	NautilusDesktopLink *link;
 	GMount *other_mount;
@@ -233,15 +246,38 @@
 	}
 }
 
+
+
 static void
-mount_changed_callback (GVolumeMonitor *volume_monitor,
+mount_added_callback (GVolumeMonitor *volume_monitor,
+		      GMount *mount, 
+		      NautilusDesktopLinkMonitor *monitor)
+{
+	create_mount_link (monitor, mount);
+}
+
+
+static void
+mount_removed_callback (GVolumeMonitor *volume_monitor,
 			GMount *mount, 
 			NautilusDesktopLinkMonitor *monitor)
 {
-	/* TODO: update the mount */
+	remove_mount_link (monitor, mount);
 }
 
 static void
+mount_changed_callback (GVolumeMonitor *volume_monitor,
+			GMount *mount, 
+			NautilusDesktopLinkMonitor *monitor)
+{
+	/* TODO: update the mount with other details */
+
+	/* remove a mount if it goes into the shadows */
+	if (g_mount_is_shadowed (mount) && has_mount (monitor, mount)) {
+		remove_mount_link (monitor, mount);
+	}}
+
+static void
 update_link_visibility (NautilusDesktopLinkMonitor *monitor,
 			NautilusDesktopLink       **link_ref,
 			NautilusDesktopLinkType     link_type,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]