[gnome-disk-utility] Use ensure_unused() before formatting a disk
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Use ensure_unused() before formatting a disk
- Date: Wed, 7 Nov 2012 17:56:11 +0000 (UTC)
commit f62b0119b78a95bc9b1066fdf9a096dcc31dd6ab
Author: David Zeuthen <zeuthen gmail com>
Date: Wed Nov 7 12:49:23 2012 -0500
Use ensure_unused() before formatting a disk
This way users won't have to unmount/lock partitions on the disk
before formatting it with a new partitioning table.
Signed-off-by: David Zeuthen <zeuthen gmail com>
src/disks/gduformatdiskdialog.c | 49 +++++++++++++++++++++++++++++++--------
1 files changed, 39 insertions(+), 10 deletions(-)
---
diff --git a/src/disks/gduformatdiskdialog.c b/src/disks/gduformatdiskdialog.c
index 897fdb7..3cf880c 100644
--- a/src/disks/gduformatdiskdialog.c
+++ b/src/disks/gduformatdiskdialog.c
@@ -331,6 +331,41 @@ format_cb (GObject *source_object,
format_disk_data_free (data);
}
+
+static void
+ensure_unused_cb (GduWindow *window,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ FormatDiskData *data = user_data;
+ const gchar *partition_table_type;
+ const gchar *erase_type;
+ GVariantBuilder options_builder;
+
+
+ if (!gdu_window_ensure_unused_finish (window, res, NULL))
+ {
+ format_disk_data_free (data);
+ goto out;
+ }
+
+ partition_table_type = gtk_combo_box_get_active_id (GTK_COMBO_BOX (data->type_combobox));
+ erase_type = gtk_combo_box_get_active_id (GTK_COMBO_BOX (data->erase_combobox));
+
+ g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
+ if (strlen (erase_type) > 0)
+ g_variant_builder_add (&options_builder, "{sv}", "erase", g_variant_new_string (erase_type));
+ udisks_block_call_format (data->block,
+ partition_table_type,
+ g_variant_builder_end (&options_builder),
+ NULL, /* GCancellable */
+ format_cb,
+ data);
+
+ out:
+ ;
+}
+
void
gdu_format_disk_dialog_show (GduWindow *window,
UDisksObject *object)
@@ -373,13 +408,10 @@ gdu_format_disk_dialog_show (GduWindow *window,
response = gtk_dialog_run (GTK_DIALOG (data->dialog));
if (response == GTK_RESPONSE_OK)
{
- const gchar *partition_table_type;
const gchar *erase_type;
const gchar *primary_message;
- GVariantBuilder options_builder;
GString *str;
- partition_table_type = gtk_combo_box_get_active_id (GTK_COMBO_BOX (data->type_combobox));
erase_type = gtk_combo_box_get_active_id (GTK_COMBO_BOX (data->erase_combobox));
primary_message = _("Are you sure you want to format the disk?");
@@ -416,14 +448,11 @@ gdu_format_disk_dialog_show (GduWindow *window,
}
g_string_free (str, TRUE);
- g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
- if (strlen (erase_type) > 0)
- g_variant_builder_add (&options_builder, "{sv}", "erase", g_variant_new_string (erase_type));
- udisks_block_call_format (data->block,
- partition_table_type,
- g_variant_builder_end (&options_builder),
+ /* ensure the volume is unused (e.g. unmounted) before formatting it... */
+ gdu_window_ensure_unused (data->window,
+ data->object,
+ (GAsyncReadyCallback) ensure_unused_cb,
NULL, /* GCancellable */
- format_cb,
data);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]