[gnome-disk-utility] Don't exit multi-selection mode if the user cancels the operation dialog



commit ade869cab2f051ae1e195f7b780f3a70d5f13065
Author: David Zeuthen <zeuthen gmail com>
Date:   Fri Oct 12 17:58:30 2012 -0400

    Don't exit multi-selection mode if the user cancels the operation dialog
    
    This way the user can still see what disks were selected (at least how
    many and the size) and if he decides he doesn't want to do the
    operation, his selection is still intact.
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 src/disks/gducreateraidarraydialog.c    |    5 ++++-
 src/disks/gducreateraidarraydialog.h    |    4 ++--
 src/disks/gduerasemultipledisksdialog.c |    5 ++++-
 src/disks/gduerasemultipledisksdialog.h |    2 +-
 src/disks/gduwindow.c                   |   12 ++++++------
 5 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/disks/gducreateraidarraydialog.c b/src/disks/gducreateraidarraydialog.c
index 6b300c2..500481b 100644
--- a/src/disks/gducreateraidarraydialog.c
+++ b/src/disks/gducreateraidarraydialog.c
@@ -437,10 +437,11 @@ mdraid_create_cb (GObject      *source_object,
   g_free (array_objpath);
 }
 
-void
+gboolean
 gdu_create_raid_array_dialog_show (GduWindow *window,
                                    GList     *blocks)
 {
+  gboolean ret = FALSE;
   DialogData *data;
   guint n;
 
@@ -530,6 +531,7 @@ gdu_create_raid_array_dialog_show (GduWindow *window,
                                                (GAsyncReadyCallback) mdraid_create_cb,
                                                dialog_data_ref (data));
             g_ptr_array_free (p, TRUE);
+            ret = TRUE;
             goto out;
           }
           break;
@@ -541,4 +543,5 @@ gdu_create_raid_array_dialog_show (GduWindow *window,
  out:
   dialog_data_close (data);
   dialog_data_unref (data);
+  return ret;
 }
diff --git a/src/disks/gducreateraidarraydialog.h b/src/disks/gducreateraidarraydialog.h
index 1d15229..65ca86f 100644
--- a/src/disks/gducreateraidarraydialog.h
+++ b/src/disks/gducreateraidarraydialog.h
@@ -15,8 +15,8 @@
 
 G_BEGIN_DECLS
 
-void   gdu_create_raid_array_dialog_show (GduWindow *window,
-                                          GList     *objects);
+gboolean gdu_create_raid_array_dialog_show (GduWindow *window,
+                                            GList     *objects);
 
 G_END_DECLS
 
diff --git a/src/disks/gduerasemultipledisksdialog.c b/src/disks/gduerasemultipledisksdialog.c
index d427852..88b0129 100644
--- a/src/disks/gduerasemultipledisksdialog.c
+++ b/src/disks/gduerasemultipledisksdialog.c
@@ -238,11 +238,12 @@ erase_devices (DialogData  *data,
     }
 }
 
-void
+gboolean
 gdu_erase_multiple_disks_dialog_show (GduWindow *window,
                                       GList     *blocks)
 {
   DialogData *data;
+  gboolean ret = FALSE;
 
   data = g_new0 (DialogData, 1);
   data->ref_count = 1;
@@ -313,10 +314,12 @@ gdu_erase_multiple_disks_dialog_show (GduWindow *window,
           g_string_free (str, TRUE);
           gtk_widget_hide (data->dialog);
           erase_devices (data, erase_type);
+          ret = TRUE;
           goto out;
         }
     }
 
  out:
   dialog_data_unref (data);
+  return ret;
 }
diff --git a/src/disks/gduerasemultipledisksdialog.h b/src/disks/gduerasemultipledisksdialog.h
index f7fa898..599c57a 100644
--- a/src/disks/gduerasemultipledisksdialog.h
+++ b/src/disks/gduerasemultipledisksdialog.h
@@ -15,7 +15,7 @@
 
 G_BEGIN_DECLS
 
-void     gdu_erase_multiple_disks_dialog_show (GduWindow  *window,
+gboolean gdu_erase_multiple_disks_dialog_show (GduWindow  *window,
                                                GList      *blocks);
 
 G_END_DECLS
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 546c443..86d129c 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -4483,9 +4483,9 @@ on_overlay_toolbar_erase_button_clicked (GtkButton *menu_item,
   GList *selected_blocks;
 
   selected_blocks = gdu_device_tree_model_get_selected_blocks (window->model);
-  /* exit multiple selection mode */
-  device_tree_selection_toolbar_select_done_toggle (window, FALSE);
-  gdu_erase_multiple_disks_dialog_show (window, selected_blocks);
+  /* exit multiple selection mode UNLESS user cancelled */
+  if (gdu_erase_multiple_disks_dialog_show (window, selected_blocks))
+    device_tree_selection_toolbar_select_done_toggle (window, FALSE);
   g_list_free_full (selected_blocks, g_object_unref);
 }
 
@@ -4507,8 +4507,8 @@ on_ms_raid_menu_item_create_activated (GtkMenuItem *menu_item,
   GList *selected_blocks;
 
   selected_blocks = gdu_device_tree_model_get_selected_blocks (window->model);
-  /* exit multiple selection mode */
-  device_tree_selection_toolbar_select_done_toggle (window, FALSE);
-  gdu_create_raid_array_dialog_show (window, selected_blocks);
+  /* exit multiple selection mode UNLESS user cancelled */
+  if (gdu_create_raid_array_dialog_show (window, selected_blocks))
+    device_tree_selection_toolbar_select_done_toggle (window, FALSE);
   g_list_free_full (selected_blocks, g_object_unref);
 }



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