[gvfs] daemon: implement show-unmount-progress in GVfsJobUnmount
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] daemon: implement show-unmount-progress in GVfsJobUnmount
- Date: Mon, 16 Jul 2012 12:44:53 +0000 (UTC)
commit 39a92eb5ac5741b79832825f8408598aab83c52c
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Jul 9 21:07:49 2012 -0400
daemon: implement show-unmount-progress in GVfsJobUnmount
https://bugzilla.gnome.org/show_bug.cgi?id=676111
daemon/gvfsjobunmount.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
daemon/gvfsjobunmount.h | 3 ++
2 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsjobunmount.c b/daemon/gvfsjobunmount.c
index 85873f9..f1e794c 100644
--- a/daemon/gvfsjobunmount.c
+++ b/daemon/gvfsjobunmount.c
@@ -125,6 +125,60 @@ g_vfs_job_unmount_new (DBusConnection *connection,
}
static void
+unmount_progress_clear (GVfsJobUnmount *op_job)
+{
+ gchar *message;
+
+ if (op_job->unmount_progress_id > 0)
+ {
+ g_source_remove (op_job->unmount_progress_id);
+ op_job->unmount_progress_id = 0;
+ }
+
+ if (!op_job->unmount_progress_fired)
+ return;
+
+ g_debug ("gvfsjobunmount progress clear");
+
+ message = g_strdup_printf (_("%s has been unmounted\n"),
+ g_vfs_backend_get_display_name (op_job->backend));
+ g_mount_source_show_unmount_progress (op_job->mount_source,
+ message, 0, 0);
+ g_free (message);
+}
+
+static gboolean
+unmount_progress_timeout (gpointer user_data)
+{
+ GVfsJobUnmount *op_job = user_data;
+ gchar *message;
+
+ op_job->unmount_progress_id = 0;
+ op_job->unmount_progress_fired = TRUE;
+
+ g_debug ("gvfsjobunmount progress timeout reached");
+
+ message = g_strdup_printf (_("Unmounting %s\nPlease wait"),
+ g_vfs_backend_get_display_name (op_job->backend));
+ /* TODO: report estimated bytes and time left */
+ g_mount_source_show_unmount_progress (op_job->mount_source,
+ message, -1, -1);
+ g_free (message);
+
+ return FALSE;
+}
+
+static void
+unmount_progress_start (GVfsJobUnmount *op_job)
+{
+ if (op_job->unmount_progress_id > 0)
+ return;
+
+ g_debug ("gvfsjobunmount progress timeout start");
+ op_job->unmount_progress_id = g_timeout_add (1500, unmount_progress_timeout, op_job);
+}
+
+static void
run (GVfsJob *job)
{
GVfsJobUnmount *op_job = G_VFS_JOB_UNMOUNT (job);
@@ -133,10 +187,14 @@ run (GVfsJob *job)
if (class->unmount == NULL)
return;
+ unmount_progress_start (op_job);
+
class->unmount (op_job->backend,
op_job,
op_job->flags,
op_job->mount_source);
+
+ unmount_progress_clear (op_job);
}
static gboolean
diff --git a/daemon/gvfsjobunmount.h b/daemon/gvfsjobunmount.h
index ca8a23e..236d471 100644
--- a/daemon/gvfsjobunmount.h
+++ b/daemon/gvfsjobunmount.h
@@ -46,6 +46,9 @@ struct _GVfsJobUnmount
GVfsBackend *backend;
GMountUnmountFlags flags;
GMountSource *mount_source;
+
+ guint unmount_progress_id;
+ gboolean unmount_progress_fired;
};
struct _GVfsJobUnmountClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]