gvfs r2350 - in trunk: . monitor/hal monitor/proxy
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r2350 - in trunk: . monitor/hal monitor/proxy
- Date: Thu, 26 Mar 2009 13:50:04 +0000 (UTC)
Author: carlosg
Date: Thu Mar 26 13:50:04 2009
New Revision: 2350
URL: http://svn.gnome.org/viewvc/gvfs?rev=2350&view=rev
Log:
2009-03-26 Carlos Garnacho <carlosg gnome org>
Bug 576083 â pre-unmount signals not being triggered
* monitor/hal/ghalmount.c (unmount_do) (unmount_do_cb): Emit
::mount-pre-unmount and wait 500msec before actually trying to
unmount.
* monitor/proxy/gproxyshadowmount.c (real_mount_pre_unmount_cb): Proxy
the shadowed mount pre-unmount signal.
* monitor/proxy/gproxyvolumemonitor.c (filter_function): GMount
doesn't have the ::pre-unmount signal yet, so don't emit it.
Modified:
trunk/ChangeLog
trunk/monitor/hal/ghalmount.c
trunk/monitor/proxy/gproxyshadowmount.c
trunk/monitor/proxy/gproxyvolumemonitor.c
Modified: trunk/monitor/hal/ghalmount.c
==============================================================================
--- trunk/monitor/hal/ghalmount.c (original)
+++ trunk/monitor/hal/ghalmount.c Thu Mar 26 13:50:04 2009
@@ -775,6 +775,7 @@
guint error_channel_source_id;
GString *error_string;
gboolean using_legacy;
+ gchar **argv;
} UnmountOp;
static void
@@ -824,6 +825,7 @@
g_source_remove (data->error_channel_source_id);
g_io_channel_unref (data->error_channel);
g_string_free (data->error_string, TRUE);
+ g_strfreev (data->argv);
close (data->error_fd);
g_spawn_close_pid (pid);
@@ -846,28 +848,16 @@
return TRUE;
}
-static void
-unmount_do (GMount *mount,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data,
- char **argv,
- gboolean using_legacy)
+static gboolean
+unmount_do_cb (gpointer user_data)
{
- UnmountOp *data;
+ UnmountOp *data = (UnmountOp *) user_data;
GPid child_pid;
GError *error;
- data = g_new0 (UnmountOp, 1);
- data->object = g_object_ref (mount);
- data->callback = callback;
- data->user_data = user_data;
- data->cancellable = cancellable;
- data->using_legacy = using_legacy;
-
error = NULL;
if (!g_spawn_async_with_pipes (NULL, /* working dir */
- argv,
+ data->argv,
NULL, /* envp */
G_SPAWN_DO_NOT_REAP_CHILD|G_SPAWN_SEARCH_PATH,
NULL, /* child_setup */
@@ -886,15 +876,43 @@
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_error_free (error);
+ g_strfreev (data->argv);
g_free (data);
- return;
+
+ return FALSE;
}
data->error_string = g_string_new ("");
data->error_channel = g_io_channel_unix_new (data->error_fd);
data->error_channel_source_id = g_io_add_watch (data->error_channel, G_IO_IN, unmount_read_error, data);
g_child_watch_add (child_pid, unmount_cb, data);
+
+ return FALSE;
}
+static void
+unmount_do (GMount *mount,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data,
+ char **argv,
+ gboolean using_legacy)
+{
+ GHalMount *hal_mount = G_HAL_MOUNT (mount);
+ UnmountOp *data;
+
+ data = g_new0 (UnmountOp, 1);
+ data->object = g_object_ref (mount);
+ data->callback = callback;
+ data->user_data = user_data;
+ data->cancellable = cancellable;
+ data->using_legacy = using_legacy;
+ data->argv = g_strdupv (argv);
+
+ if (hal_mount->volume_monitor != NULL)
+ g_signal_emit_by_name (hal_mount->volume_monitor, "mount-pre-unmount", mount);
+
+ g_timeout_add (500, unmount_do_cb, data);
+}
static void
g_hal_mount_unmount (GMount *mount,
Modified: trunk/monitor/proxy/gproxyshadowmount.c
==============================================================================
--- trunk/monitor/proxy/gproxyshadowmount.c (original)
+++ trunk/monitor/proxy/gproxyshadowmount.c Thu Mar 26 13:50:04 2009
@@ -49,6 +49,7 @@
GProxyVolume *volume;
GMount *real_mount;
+ gulong pre_unmount_signal_id;
gboolean real_mount_shadowed;
GFile *root;
};
@@ -111,6 +112,15 @@
{
}
+static void
+real_mount_pre_unmount_cb (GVolumeMonitor *volume_monitor,
+ GMount *mount,
+ GProxyShadowMount *shadow_mount)
+{
+ if (mount == shadow_mount->real_mount)
+ g_signal_emit_by_name (shadow_mount->volume_monitor, "mount-pre-unmount", shadow_mount);
+}
+
void
g_proxy_shadow_mount_remove (GProxyShadowMount *mount)
{
@@ -120,6 +130,12 @@
signal_emit_in_idle (mount->real_mount, "changed", NULL);
signal_emit_in_idle (mount->volume_monitor, "mount-changed", mount->real_mount);
mount->real_mount_shadowed = FALSE;
+
+ if (mount->pre_unmount_signal_id != 0)
+ {
+ g_signal_handler_disconnect (mount, mount->pre_unmount_signal_id);
+ mount->pre_unmount_signal_id = 0;
+ }
}
}
@@ -151,6 +167,9 @@
signal_emit_in_idle (mount->real_mount, "changed", NULL);
signal_emit_in_idle (mount->volume_monitor, "mount-changed", mount->real_mount);
+ mount->pre_unmount_signal_id = g_signal_connect (mount->volume_monitor, "mount-pre-unmount",
+ G_CALLBACK (real_mount_pre_unmount_cb), mount);
+
g_object_set_data (G_OBJECT (mount),
"g-proxy-shadow-mount-volume-monitor-name",
(gpointer) g_type_name (G_TYPE_FROM_INSTANCE (volume_monitor)));
Modified: trunk/monitor/proxy/gproxyvolumemonitor.c
==============================================================================
--- trunk/monitor/proxy/gproxyvolumemonitor.c (original)
+++ trunk/monitor/proxy/gproxyvolumemonitor.c Thu Mar 26 13:50:04 2009
@@ -815,10 +815,7 @@
{
mount = g_hash_table_lookup (monitor->mounts, id);
if (mount != NULL)
- {
- signal_emit_in_idle (mount, "pre-unmount", NULL);
- signal_emit_in_idle (monitor, "mount-pre-unmount", mount);
- }
+ signal_emit_in_idle (monitor, "mount-pre-unmount", mount);
}
else if (strcmp (member, "MountRemoved") == 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]