[gnome-disk-utility] Use ensure_unused() before restoring a disk image onto a device



commit 8d33062cc87b814b745d066b15d702673e173fac
Author: David Zeuthen <zeuthen gmail com>
Date:   Mon Nov 19 17:21:05 2012 -0500

    Use ensure_unused() before restoring a disk image onto a device
    
    This way users won't have to unmount/lock whatever is on a device
    before overwriting it with the disk image.
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 src/disks/gdurestorediskimagedialog.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 5729479..2ccc4ff 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -771,6 +771,22 @@ start_copying (DialogData *data)
 }
 
 static void
+ensure_unused_cb (GduWindow     *window,
+                  GAsyncResult  *res,
+                  gpointer       user_data)
+{
+  DialogData *data = user_data;
+  if (gdu_window_ensure_unused_finish (window, res, NULL))
+    {
+      start_copying (data);
+    }
+  else
+    {
+      dialog_data_complete_and_unref (data);
+    }
+}
+
+static void
 on_dialog_response (GtkDialog     *dialog,
                     gint           response,
                     gpointer       user_data)
@@ -810,7 +826,12 @@ on_dialog_response (GtkDialog     *dialog,
       gtk_widget_show (data->copying_vbox);
       gtk_widget_hide (data->infobar_vbox);
 
-      start_copying (data);
+      /* ensure the device is unused (e.g. unmounted) before copying data to it... */
+      gdu_window_ensure_unused (data->window,
+                                data->object,
+                                (GAsyncReadyCallback) ensure_unused_cb,
+                                NULL, /* GCancellable */
+                                data);
       break;
 
     case GTK_RESPONSE_CLOSE:



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