[Xfce4-commits] <thunar:master> Improvement in unmounting.
Nick Schermer
noreply at xfce.org
Sat Oct 13 16:12:36 CEST 2012
Updating branch refs/heads/master
to 315950fe7fbf9de3386c43cf469b1e0427cbe89d (commit)
from 9226a465a50e5027e2def857f579114ccad211ea (commit)
commit 315950fe7fbf9de3386c43cf469b1e0427cbe89d
Author: Nick Schermer <nick at xfce.org>
Date: Fri Oct 12 21:43:09 2012 +0200
Improvement in unmounting.
thunar/thunar-device.c | 32 ++++++++++++++++++++++++++++++++
thunar/thunar-file.c | 2 +-
thunar/thunar-shortcuts-model.c | 15 +++++++++++----
thunar/thunar-window.c | 10 +++++++---
4 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/thunar/thunar-device.c b/thunar/thunar-device.c
index 45d382e..77cb530 100644
--- a/thunar/thunar-device.c
+++ b/thunar/thunar-device.c
@@ -24,6 +24,7 @@
#include <thunar/thunar-notify.h>
#endif
#include <thunar/thunar-device.h>
+#include <thunar/thunar-device-monitor.h>
#include <thunar/thunar-private.h>
@@ -72,6 +73,7 @@ typedef struct
ThunarDevice *device;
ThunarDeviceCallback callback;
gpointer user_data;
+ GFile *root_file;
}
ThunarDeviceOperation;
@@ -216,6 +218,7 @@ thunar_device_operation_new (ThunarDevice *device,
operation->device = g_object_ref (device);
operation->callback = callback;
operation->user_data = user_data;
+ operation->root_file = thunar_device_get_root (device);
return operation;
}
@@ -226,12 +229,32 @@ static void
thunar_device_operation_free (ThunarDeviceOperation *operation)
{
g_object_unref (operation->device);
+ if (operation->root_file != NULL)
+ g_object_unref (operation->root_file);
g_slice_free (ThunarDeviceOperation, operation);
}
static void
+thunar_device_operation_emit_pre_unmount (ThunarDeviceOperation *operation)
+{
+ ThunarDeviceMonitor *monitor;
+
+ if (operation->root_file != NULL)
+ {
+ /* make sure the pre-unmount event is emitted, this is important
+ * for the interface */
+ monitor = thunar_device_monitor_get ();
+ g_signal_emit_by_name (monitor, "device-pre-unmount",
+ operation->device, operation->root_file);
+ g_object_unref (monitor);
+ }
+}
+
+
+
+static void
thunar_device_mount_unmount_finish (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -246,6 +269,9 @@ thunar_device_mount_unmount_finish (GObject *object,
thunar_notify_unmount_finish (G_MOUNT (object));
#endif
+ /* make sure this event happened */
+ thunar_device_operation_emit_pre_unmount (operation);
+
/* finish the unmount */
if (!g_mount_unmount_with_operation_finish (G_MOUNT (object), result, &error))
{
@@ -280,6 +306,9 @@ thunar_device_mount_eject_finish (GObject *object,
thunar_notify_unmount_finish (G_MOUNT (object));
#endif
+ /* make sure this event happened */
+ thunar_device_operation_emit_pre_unmount (operation);
+
/* finish the eject */
if (!g_mount_eject_with_operation_finish (G_MOUNT (object), result, &error))
{
@@ -346,6 +375,9 @@ thunar_device_volume_eject_finish (GObject *object,
thunar_notify_eject_finish (G_VOLUME (object));
#endif
+ /* make sure this event happened */
+ thunar_device_operation_emit_pre_unmount (operation);
+
/* finish the eject */
if (!g_volume_eject_with_operation_finish (G_VOLUME (object), result, &error))
{
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index a26a3e9..220e6a0 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -342,7 +342,7 @@ thunar_file_finalize (GObject *object)
/* free the custom icon name */
g_free (file->custom_icon_name);
-
+
/* free display name and basename */
g_free (file->display_name);
g_free (file->basename);
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index 36cf943..0e26ad9 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -1463,10 +1463,11 @@ thunar_shortcuts_model_device_changed (ThunarDeviceMonitor *device_monitor,
ThunarDevice *device,
ThunarShortcutsModel *model)
{
- GtkTreeIter iter;
- GList *lp;
- gint idx;
- GtkTreePath *path;
+ GtkTreeIter iter;
+ GList *lp;
+ gint idx;
+ GtkTreePath *path;
+ ThunarShortcut *shortcut;
_thunar_return_if_fail (THUNAR_DEVICE_MONITOR (device_monitor));
_thunar_return_if_fail (model->device_monitor == device_monitor);
@@ -1484,6 +1485,12 @@ thunar_shortcuts_model_device_changed (ThunarDeviceMonitor *device_monitor,
if (G_LIKELY (lp != NULL))
{
+ shortcut = lp->data;
+
+ /* cleanup tooltip */
+ g_free (shortcut->tooltip);
+ shortcut->tooltip = NULL;
+
/* generate an iterator for the path */
GTK_TREE_ITER_INIT (iter, model->stamp, lp);
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 7df0860..99738ff 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -212,7 +212,7 @@ static void thunar_window_device_pre_unmount (ThunarDeviceMonitor
ThunarDevice *device,
GFile *root_file,
ThunarWindow *window);
-static void thunar_window_device_removed (ThunarDeviceMonitor *device_monitor,
+static void thunar_window_device_changed (ThunarDeviceMonitor *device_monitor,
ThunarDevice *device,
ThunarWindow *window);
static gboolean thunar_window_merge_idle (gpointer user_data);
@@ -764,7 +764,8 @@ thunar_window_init (ThunarWindow *window)
/* connect to the volume monitor */
window->device_monitor = thunar_device_monitor_get ();
g_signal_connect (window->device_monitor, "device-pre-unmount", G_CALLBACK (thunar_window_device_pre_unmount), window);
- g_signal_connect (window->device_monitor, "device-removed", G_CALLBACK (thunar_window_device_removed), window);
+ g_signal_connect (window->device_monitor, "device-removed", G_CALLBACK (thunar_window_device_changed), window);
+ g_signal_connect (window->device_monitor, "device-changed", G_CALLBACK (thunar_window_device_changed), window);
/* allocate a closure for the menu_item_selected() callback */
window->menu_item_selected_closure = g_cclosure_new_object (G_CALLBACK (thunar_window_menu_item_selected), G_OBJECT (window));
@@ -2807,7 +2808,7 @@ thunar_window_device_pre_unmount (ThunarDeviceMonitor *device_monitor,
static void
-thunar_window_device_removed (ThunarDeviceMonitor *device_monitor,
+thunar_window_device_changed (ThunarDeviceMonitor *device_monitor,
ThunarDevice *device,
ThunarWindow *window)
{
@@ -2818,6 +2819,9 @@ thunar_window_device_removed (ThunarDeviceMonitor *device_monitor,
_thunar_return_if_fail (THUNAR_IS_DEVICE (device));
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
+ if (thunar_device_is_mounted (device))
+ return;
+
root_file = thunar_device_get_root (device);
if (root_file != NULL)
{
More information about the Xfce4-commits
mailing list