[Xfce4-commits] <thunar:master> Drop the internal volume check.
Nick Schermer
noreply at xfce.org
Fri Dec 14 21:14:01 CET 2012
Updating branch refs/heads/master
to 6473fa8a6394abf7df389d0e28a07bad827f7aa7 (commit)
from 459ed5158577f6c598be60df1b4f3fb2ca8b1eec (commit)
commit 6473fa8a6394abf7df389d0e28a07bad827f7aa7
Author: Nick Schermer <nick at xfce.org>
Date: Fri Dec 14 21:11:52 2012 +0100
Drop the internal volume check.
Its not reliable for a lot of users, so drop this check; people
can use the hide feature to not show them in the pane if they
don't want to.
thunar/thunar-device-monitor.c | 70 ---------------------------------------
thunar/thunar-device.c | 14 +-------
thunar/thunar-shortcuts-model.c | 3 +-
thunar/thunar-shortcuts-view.c | 16 +++++++--
4 files changed, 16 insertions(+), 87 deletions(-)
diff --git a/thunar/thunar-device-monitor.c b/thunar/thunar-device-monitor.c
index a246b95..6ac8e82 100644
--- a/thunar/thunar-device-monitor.c
+++ b/thunar/thunar-device-monitor.c
@@ -351,67 +351,6 @@ thunar_device_monitor_update_hidden (gpointer key,
-#ifdef HAVE_GIO_UNIX
-static gboolean
-thunar_device_monitor_mount_is_internal (GMount *mount)
-{
- const gchar *point_mount_path;
- gboolean is_internal = FALSE;
- GFile *root;
- GList *lp;
- GList *mount_points;
- gchar *mount_path;
-
- _thunar_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
-
- /* determine the mount path */
- root = g_mount_get_root (mount);
- mount_path = g_file_get_path (root);
- g_object_unref (root);
-
- /* assume non-internal if we cannot determine the path */
- if (mount_path == NULL)
- return FALSE;
-
- if (g_unix_is_mount_path_system_internal (mount_path))
- {
- /* mark as internal */
- is_internal = TRUE;
- }
- else
- {
- /* get a list of all mount points */
- mount_points = g_unix_mount_points_get (NULL);
-
- /* search for the mount point associated with the mount entry */
- for (lp = mount_points; !is_internal && lp != NULL; lp = lp->next)
- {
- point_mount_path = g_unix_mount_point_get_mount_path (lp->data);
-
- /* check if this is the mount point we are looking for */
- if (g_strcmp0 (mount_path, point_mount_path) == 0)
- {
- /* mark as internal if the user cannot mount this device */
- if (!g_unix_mount_point_is_user_mountable (lp->data))
- is_internal = TRUE;
- }
-
- /* free the mount point, we no longer need it */
- g_unix_mount_point_free (lp->data);
- }
-
- /* free the mount point list */
- g_list_free (mount_points);
- }
-
- g_free (mount_path);
-
- return is_internal;
-}
-#endif
-
-
-
static gboolean
thunar_device_monitor_volume_is_visible (GVolume *volume)
{
@@ -419,7 +358,6 @@ thunar_device_monitor_volume_is_visible (GVolume *volume)
gboolean can_mount = FALSE;
gboolean can_unmount = FALSE;
gboolean is_removable = FALSE;
- gboolean is_internal = FALSE;
GDrive *drive;
GMount *mount;
@@ -429,10 +367,6 @@ thunar_device_monitor_volume_is_visible (GVolume *volume)
mount = g_volume_get_mount (volume);
if (mount != NULL)
{
-#ifdef HAVE_GIO_UNIX
- is_internal = thunar_device_monitor_mount_is_internal (mount);
-#endif
-
/* check if the volume can be unmounted */
can_unmount = g_mount_can_unmount (mount);
@@ -440,10 +374,6 @@ thunar_device_monitor_volume_is_visible (GVolume *volume)
g_object_unref (mount);
}
- /* don't show internal volumes */
- if (is_internal)
- return FALSE;
-
/* check if the volume can be ejected */
can_eject = g_volume_can_eject (volume);
diff --git a/thunar/thunar-device.c b/thunar/thunar-device.c
index 3b5790e..94dd9a7 100644
--- a/thunar/thunar-device.c
+++ b/thunar/thunar-device.c
@@ -410,7 +410,6 @@ gboolean
thunar_device_can_eject (const ThunarDevice *device)
{
gboolean can_eject = FALSE;
- GMount *volume_mount;
GDrive *drive;
_thunar_return_val_if_fail (THUNAR_IS_DEVICE (device), FALSE);
@@ -423,21 +422,10 @@ thunar_device_can_eject (const ThunarDevice *device)
can_eject = g_drive_can_eject (drive) || g_drive_can_stop (drive);
g_object_unref (drive);
}
-
- if (!can_eject)
+ else
{
/* check if the volume can eject */
can_eject = g_volume_can_eject (device->device);
- if (!can_eject)
- {
- /* check if the mount can eject/unmount */
- volume_mount = g_volume_get_mount (device->device);
- if (volume_mount != NULL)
- {
- can_eject = g_mount_can_eject (volume_mount) || g_mount_can_unmount (volume_mount);
- g_object_unref (volume_mount);
- }
- }
}
}
else if (G_IS_MOUNT (device->device))
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index 94d4be1..605d5a4 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -1808,7 +1808,8 @@ thunar_shortcuts_model_iter_for_file (ThunarShortcutsModel *model,
}
/* but maybe we have a mounted(!) volume with a matching mount point */
- if (shortcut->device != NULL)
+ if (shortcut->device != NULL
+ && !thunar_device_get_hidden (shortcut->device))
{
mount_point = thunar_device_get_root (shortcut->device);
if (mount_point != NULL)
diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index 70c77bc..7de04b1 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -1055,6 +1055,9 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
gboolean is_header;
GFile *mount_point;
GtkTreeModel *shortcuts_model;
+ gboolean can_mount;
+ gboolean can_unmount;
+ gboolean can_eject;
/* check if this is an item menu or a header menu */
gtk_tree_model_get (model, iter, THUNAR_SHORTCUTS_MODEL_COLUMN_IS_HEADER, &is_header, -1);
@@ -1105,6 +1108,13 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
switch (group)
{
case THUNAR_SHORTCUT_GROUP_DEVICES_VOLUMES:
+ can_mount = thunar_device_can_mount (device);
+ can_unmount = thunar_device_can_unmount (device);
+ can_eject = thunar_device_can_eject (device);
+
+ if (!can_mount && !can_unmount && !can_eject)
+ break;
+
/* append a menu separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -1112,19 +1122,19 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
/* append the "Mount" item */
item = gtk_image_menu_item_new_with_mnemonic (_("_Mount"));
- gtk_widget_set_visible (item, thunar_device_can_mount (device));
+ gtk_widget_set_visible (item, can_mount);
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_mount), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
/* append the "Unmount" item */
item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount"));
- gtk_widget_set_visible (item, thunar_device_can_unmount (device));
+ gtk_widget_set_visible (item, can_unmount);
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_unmount), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
/* append the "Disconnect" (eject + safely remove drive) item */
item = gtk_image_menu_item_new_with_mnemonic (_("_Eject"));
- gtk_widget_set_visible (item, thunar_device_can_eject (device));
+ gtk_widget_set_visible (item, can_eject);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_eject), view);
break;
More information about the Xfce4-commits
mailing list