[gnome-disk-utility] Make Create/Restore Disk Image dialogs non-modal



commit 1ffaca5de51848d23de7fb0aa444ef5d8e467ebe
Author: David Zeuthen <zeuthen gmail com>
Date:   Sun Jul 29 13:30:47 2012 -0400

    Make Create/Restore Disk Image dialogs non-modal
    
    This is useful if you want to create/restore several disk images at
    the same time.
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 data/ui/create-disk-image-dialog.ui   |  129 +++++++++---------------
 data/ui/restore-disk-image-dialog.ui  |   47 +--------
 src/disks/gduatasmartdialog.c         |   18 ++--
 src/disks/gdubenchmarkdialog.c        |    2 +-
 src/disks/gduchangepassphrasedialog.c |   12 +-
 src/disks/gducreatediskimagedialog.c  |   99 +++++++++++-------
 src/disks/gducreatepartitiondialog.c  |    4 +-
 src/disks/gducrypttabdialog.c         |   20 ++--
 src/disks/gdudisksettingsdialog.c     |    6 +-
 src/disks/gdufilesystemdialog.c       |    6 +-
 src/disks/gduformatdiskdialog.c       |   10 +-
 src/disks/gduformatvolumedialog.c     |   10 +-
 src/disks/gdufstabdialog.c            |   18 ++--
 src/disks/gdupartitiondialog.c        |    6 +-
 src/disks/gdurestorediskimagedialog.c |  138 +++++++++++++++-----------
 src/disks/gduunlockdialog.c           |    6 +-
 src/disks/gduutils.c                  |   79 +++++++++++++++
 src/disks/gduutils.h                  |    9 ++
 src/disks/gduwindow.c                 |  176 +++++++++------------------------
 src/disks/gduwindow.h                 |    9 --
 20 files changed, 388 insertions(+), 416 deletions(-)
---
diff --git a/data/ui/create-disk-image-dialog.ui b/data/ui/create-disk-image-dialog.ui
index d5d1efd..b24f116 100644
--- a/data/ui/create-disk-image-dialog.ui
+++ b/data/ui/create-disk-image-dialog.ui
@@ -6,8 +6,6 @@
     <property name="can_focus">False</property>
     <property name="border_width">12</property>
     <property name="resizable">False</property>
-    <property name="modal">True</property>
-    <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -15,63 +13,6 @@
         <property name="orientation">vertical</property>
         <property name="spacing">12</property>
         <child>
-          <object class="GtkLabel" id="label2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="label" translatable="yes">&lt;big&gt;Create Disk Image&lt;/big&gt;</property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="button1">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="start_copying_button">
-                <property name="label" translatable="yes">_Start Creating...</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
           <object class="GtkNotebook" id="notebook">
             <property name="can_focus">False</property>
             <property name="margin_left">12</property>
@@ -91,9 +32,7 @@
                     <property name="label" translatable="yes">_Name</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">destination_name_entry</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
+                    <style><class name="dim-label"/></style>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -110,9 +49,7 @@
                     <property name="label" translatable="yes">Save in _folder</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">destination_folder_fcbutton</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
+                    <style><class name="dim-label"/></style>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -153,21 +90,6 @@
                     <property name="height">1</property>
                   </packing>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
               </object>
             </child>
             <child type="tab">
@@ -251,7 +173,52 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button1">
+                <property name="label">gtk-cancel</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="start_copying_button">
+                <property name="label" translatable="yes">_Start Creating...</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">1</property>
           </packing>
         </child>
       </object>
diff --git a/data/ui/restore-disk-image-dialog.ui b/data/ui/restore-disk-image-dialog.ui
index ff3d464..3dfc1c9 100644
--- a/data/ui/restore-disk-image-dialog.ui
+++ b/data/ui/restore-disk-image-dialog.ui
@@ -6,8 +6,6 @@
     <property name="can_focus">False</property>
     <property name="border_width">12</property>
     <property name="resizable">False</property>
-    <property name="modal">True</property>
-    <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -30,20 +28,6 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="label" translatable="yes">&lt;big&gt;Restore Disk Image&lt;/big&gt;</property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
           <object class="GtkNotebook" id="notebook">
             <property name="can_focus">False</property>
             <property name="margin_left">12</property>
@@ -63,9 +47,7 @@
                     <property name="label" translatable="yes">_Image to restore</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">source_file_fcbutton</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
+                    <style><class name="dim-label"/></style>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -89,27 +71,6 @@
                     <property name="height">1</property>
                   </packing>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
               </object>
             </child>
             <child type="tab">
@@ -193,7 +154,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="position">1</property>
           </packing>
         </child>
         <child internal-child="action_area">
@@ -203,6 +164,7 @@
             <child>
               <object class="GtkButton" id="button1">
                 <property name="label">gtk-cancel</property>
+                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -218,6 +180,7 @@
             <child>
               <object class="GtkButton" id="start_copying_button">
                 <property name="label" translatable="yes">_Start Restoring...</property>
+                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -236,7 +199,7 @@
             <property name="expand">False</property>
             <property name="fill">True</property>
             <property name="pack_type">end</property>
-            <property name="position">3</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </object>
diff --git a/src/disks/gduatasmartdialog.c b/src/disks/gduatasmartdialog.c
index c697768..6e8d358 100644
--- a/src/disks/gduatasmartdialog.c
+++ b/src/disks/gduatasmartdialog.c
@@ -1309,9 +1309,9 @@ refresh_cb (UDisksDriveAta  *ata,
   error = NULL;
   if (!udisks_drive_ata_call_smart_update_finish (ata, res, &error))
     {
-      gdu_window_show_error (window,
-                             _("Error refreshing SMART data"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error refreshing SMART data"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -1341,9 +1341,9 @@ smart_cancel_cb (UDisksDriveAta  *ata,
   error = NULL;
   if (!udisks_drive_ata_call_smart_selftest_abort_finish (ata, res, &error))
     {
-      gdu_window_show_error (window,
-                             _("Error aborting SMART self-test"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error aborting SMART self-test"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -1360,9 +1360,9 @@ smart_start_cb (UDisksDriveAta  *ata,
   error = NULL;
   if (!udisks_drive_ata_call_smart_selftest_start_finish (ata, res, &error))
     {
-      gdu_window_show_error (window,
-                             _("Error starting SMART self-test"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error starting SMART self-test"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
diff --git a/src/disks/gdubenchmarkdialog.c b/src/disks/gdubenchmarkdialog.c
index 457cddb..1a8d185 100644
--- a/src/disks/gdubenchmarkdialog.c
+++ b/src/disks/gdubenchmarkdialog.c
@@ -851,7 +851,7 @@ update_dialog (DialogData *data)
       if (!data->closed)
         {
           if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-            gdu_window_show_error (data->window, C_("benchmarking", "An error occurred"), error);
+            gdu_utils_show_error (GTK_WINDOW (data->window), C_("benchmarking", "An error occurred"), error);
         }
       g_clear_error (&error);
 
diff --git a/src/disks/gduchangepassphrasedialog.c b/src/disks/gduchangepassphrasedialog.c
index cc7f0ce..9bb222f 100644
--- a/src/disks/gduchangepassphrasedialog.c
+++ b/src/disks/gduchangepassphrasedialog.c
@@ -168,7 +168,7 @@ update_configuration_item_cb (GObject      *source_object,
                                                            res,
                                                            &error))
     {
-      gdu_window_show_error (data->window, _("Error updating /etc/crypttab"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->window), _("Error updating /etc/crypttab"), error);
       g_error_free (error);
     }
   change_passphrase_data_free (data);
@@ -187,7 +187,7 @@ change_passphrase_cb (GObject      *source_object,
                                                        res,
                                                        &error))
     {
-      gdu_window_show_error (data->window, _("Error changing passphrase"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->window), _("Error changing passphrase"), error);
       g_error_free (error);
     }
 
@@ -273,9 +273,9 @@ on_get_secret_configuration_cb (GObject      *source_object,
                                                           res,
                                                           &error))
     {
-      gdu_window_show_error (data->window,
-                             _("Error retrieving configuration data"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (data->window),
+                            _("Error retrieving configuration data"),
+                            error);
       g_error_free (error);
       change_passphrase_data_free (data);
       goto out;
@@ -300,7 +300,7 @@ on_get_secret_configuration_cb (GObject      *source_object,
         }
     }
 
-  gdu_window_show_error (data->window, _("/etc/crypttab configuration data is malformed"), NULL);
+  gdu_utils_show_error (GTK_WINDOW (data->window), _("/etc/crypttab configuration data is malformed"), NULL);
   change_passphrase_data_free (data);
 
  out:
diff --git a/src/disks/gducreatediskimagedialog.c b/src/disks/gducreatediskimagedialog.c
index 18bfc42..ead0cf5 100644
--- a/src/disks/gducreatediskimagedialog.c
+++ b/src/disks/gducreatediskimagedialog.c
@@ -88,6 +88,9 @@ typedef struct
   guint64 buffer_bytes_to_write;
 
   GduEstimator *estimator;
+
+  gulong response_signal_handler_id;
+  gboolean completed;
 } CreateDiskImageData;
 
 static CreateDiskImageData *
@@ -102,10 +105,16 @@ create_disk_image_data_unref (CreateDiskImageData *data)
 {
   if (g_atomic_int_dec_and_test (&data->ref_count))
     {
+      /* hide the dialog */
       if (data->dialog != NULL)
         {
-          gtk_widget_hide (data->dialog);
-          gtk_widget_destroy (data->dialog);
+          GtkWidget *dialog;
+          if (data->response_signal_handler_id != 0)
+            g_signal_handler_disconnect (data->dialog, data->response_signal_handler_id);
+          dialog = data->dialog;
+          data->dialog = NULL;
+          gtk_widget_hide (dialog);
+          gtk_widget_destroy (dialog);
         }
       g_clear_object (&data->cancellable);
       g_clear_object (&data->output_file_stream);
@@ -137,8 +146,12 @@ create_disk_image_data_unref (CreateDiskImageData *data)
 static void
 create_disk_image_data_complete (CreateDiskImageData *data)
 {
-  g_cancellable_cancel (data->cancellable);
-  gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_CANCEL);
+  if (!data->completed)
+    {
+      data->completed = TRUE;
+      g_cancellable_cancel (data->cancellable);
+      create_disk_image_data_unref (data);
+    }
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -244,8 +257,8 @@ write_cb (GOutputStream  *output_stream,
   if (error != NULL)
     {
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window,
-                               _("Error writing to backup image"), error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog),
+                              _("Error writing to image"), error);
       g_error_free (error);
       create_disk_image_data_complete (data);
       goto out;
@@ -338,7 +351,7 @@ read_cb (GInputStream  *input_stream,
                            (guint64) data->total_bytes_read,
                            udisks_block_get_preferred_device (data->block));
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window, s, error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog), s, error);
       g_free (s);
       g_error_free (error);
       create_disk_image_data_complete (data);
@@ -402,7 +415,7 @@ open_cb (UDisksBlock  *block,
                                                  &error))
     {
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window, _("Error opening device"), error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error opening device"), error);
       g_error_free (error);
       create_disk_image_data_complete (data);
       goto out;
@@ -417,7 +430,7 @@ open_cb (UDisksBlock  *block,
   if (ioctl (fd, BLKGETSIZE64, &data->block_size) != 0)
     {
       error = g_error_new (G_IO_ERROR, g_io_error_from_errno (errno), "%s", strerror (errno));
-      gdu_window_show_error (data->window, _("Error determining size of device"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error determining size of device"), error);
       g_error_free (error);
       create_disk_image_data_complete (data);
       goto out;
@@ -519,7 +532,7 @@ start_copying (CreateDiskImageData *data)
   if (data->output_file_stream == NULL)
     {
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window, _("Error opening file for writing"), error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error opening file for writing"), error);
       g_error_free (error);
       g_object_unref (folder);
       create_disk_image_data_complete (data);
@@ -540,12 +553,36 @@ start_copying (CreateDiskImageData *data)
   return ret;
 }
 
+static void
+on_dialog_response (GtkDialog     *dialog,
+                    gint           response,
+                    gpointer       user_data)
+{
+  CreateDiskImageData *data = user_data;
+  if (response == GTK_RESPONSE_OK)
+    {
+      if (check_overwrite (data))
+        {
+          gtk_label_set_markup (GTK_LABEL (data->copying_label), _("Copying data from device..."));
+
+          /* Advance to the progress page */
+          gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), 1);
+          gtk_widget_hide (data->start_copying_button);
+
+          start_copying (data);
+        }
+    }
+  else
+    {
+      create_disk_image_data_complete (data);
+    }
+}
+
 void
 gdu_create_disk_image_dialog_show (GduWindow    *window,
                                    UDisksObject *object)
 {
   CreateDiskImageData *data;
-  gint response;
   gchar *s;
 
   data = g_new0 (CreateDiskImageData, 1);
@@ -572,37 +609,21 @@ gdu_create_disk_image_dialog_show (GduWindow    *window,
   create_disk_image_populate (data);
   create_disk_image_update (data);
 
-  /* Make sure we attach to parent */
-  gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (window));
+  /* Translators: This is the window title for the non-modal "Create Disk Image" dialog. The %s is the device. */
+  s = g_strdup_printf (_("Create Disk Image (%s)"),
+                       udisks_block_get_preferred_device (data->block));
+  gtk_window_set_title (GTK_WINDOW (data->dialog), s);
+  g_free (s);
   gtk_dialog_set_default_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK);
-  gtk_widget_show_all (data->dialog);
-  /* Only select the precomputed filename, not the .img extension */
+  /* Only select the precomputed filename, not the .img / .iso extension */
   gtk_editable_select_region (GTK_EDITABLE (data->destination_name_entry), 0,
                               strlen (gtk_entry_get_text (GTK_ENTRY (data->destination_name_entry))) - 4);
 
- again:
-  response = gtk_dialog_run (GTK_DIALOG (data->dialog));
-  if (response != GTK_RESPONSE_OK)
-    goto out;
-
-  if (!check_overwrite (data))
-    goto again;
+  data->response_signal_handler_id = g_signal_connect (data->dialog,
+                                                       "response",
+                                                       G_CALLBACK (on_dialog_response),
+                                                       data);
 
-  s = g_strdup_printf (_("Copying data from device <i>%s</i>..."),
-                       udisks_block_get_preferred_device (data->block));
-  gtk_label_set_markup (GTK_LABEL (data->copying_label), s);
-  g_free (s);
-
-  /* Advance to the progress page */
-  gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), 1);
-  gtk_widget_hide (data->start_copying_button);
-
-  if (!start_copying (data))
-    goto out;
-
-  gtk_dialog_run (GTK_DIALOG (data->dialog));
-  create_disk_image_data_complete (data);
-
- out:
-  create_disk_image_data_unref (data);
+  gtk_widget_show_all (data->dialog);
+  gtk_window_present (GTK_WINDOW (data->dialog));
 }
diff --git a/src/disks/gducreatepartitiondialog.c b/src/disks/gducreatepartitiondialog.c
index b45f92e..e56292c 100644
--- a/src/disks/gducreatepartitiondialog.c
+++ b/src/disks/gducreatepartitiondialog.c
@@ -212,7 +212,7 @@ format_cb (GObject      *source_object,
                                         res,
                                         &error))
     {
-      gdu_window_show_error (data->window, _("Error formatting partition"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->window), _("Error formatting partition"), error);
       g_error_free (error);
     }
   create_partition_data_free (data);
@@ -240,7 +240,7 @@ create_partition_cb (GObject      *source_object,
                                                             res,
                                                             &error))
     {
-      gdu_window_show_error (data->window, _("Error creating partition"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->window), _("Error creating partition"), error);
       g_error_free (error);
       create_partition_data_free (data);
       goto out;
diff --git a/src/disks/gducrypttabdialog.c b/src/disks/gducrypttabdialog.c
index a948a2f..80fb317 100644
--- a/src/disks/gducrypttabdialog.c
+++ b/src/disks/gducrypttabdialog.c
@@ -273,7 +273,7 @@ crypttab_dialog_present (CrypttabDialogData *data)
                   goto again;
                 }
               gtk_widget_hide (data->dialog);
-              gdu_window_show_error (data->window,
+              gdu_utils_show_error (GTK_WINDOW (data->window),
                                      _("Error removing /etc/crypttab entry"),
                                      error);
               g_error_free (error);
@@ -357,9 +357,9 @@ crypttab_dialog_present (CrypttabDialogData *data)
                       goto again;
                     }
                   gtk_widget_hide (data->dialog);
-                  gdu_window_show_error (data->window,
-                                         _("Error adding /etc/crypttab entry"),
-                                         error);
+                  gdu_utils_show_error (GTK_WINDOW (data->window),
+                                        _("Error adding /etc/crypttab entry"),
+                                        error);
                   g_error_free (error);
                   goto out;
                 }
@@ -380,9 +380,9 @@ crypttab_dialog_present (CrypttabDialogData *data)
                       goto again;
                     }
                   gtk_widget_hide (data->dialog);
-                  gdu_window_show_error (data->window,
-                                         _("Error updating /etc/crypttab entry"),
-                                         error);
+                  gdu_utils_show_error (GTK_WINDOW (data->window),
+                                        _("Error updating /etc/crypttab entry"),
+                                        error);
                   g_error_free (error);
                   goto out;
                 }
@@ -418,9 +418,9 @@ crypttab_dialog_on_get_secrets_cb (UDisksBlock       *block,
                                                           res,
                                                           &error))
     {
-      gdu_window_show_error (data->window,
-                             _("Error retrieving configuration data"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (data->window),
+                            _("Error retrieving configuration data"),
+                            error);
       g_error_free (error);
       crypttab_dialog_free (data);
       goto out;
diff --git a/src/disks/gdudisksettingsdialog.c b/src/disks/gdudisksettingsdialog.c
index 5acf148..b17eb1c 100644
--- a/src/disks/gdudisksettingsdialog.c
+++ b/src/disks/gdudisksettingsdialog.c
@@ -370,9 +370,9 @@ on_set_configuration_cb (GObject      *source_object,
                                                    res,
                                                    &error))
     {
-      gdu_window_show_error (data->window,
-                             _("Error setting configuration"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (data->window),
+                            _("Error setting configuration"),
+                            error);
       g_clear_error (&error);
       goto out;
     }
diff --git a/src/disks/gdufilesystemdialog.c b/src/disks/gdufilesystemdialog.c
index 8539b54..e128310 100644
--- a/src/disks/gdufilesystemdialog.c
+++ b/src/disks/gdufilesystemdialog.c
@@ -70,9 +70,9 @@ change_filesystem_label_cb (UDisksFilesystem  *filesystem,
                                                 res,
                                                 &error))
     {
-      gdu_window_show_error (window,
-                             _("Error setting label"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error setting label"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
diff --git a/src/disks/gduformatdiskdialog.c b/src/disks/gduformatdiskdialog.c
index 219add6..d46c375 100644
--- a/src/disks/gduformatdiskdialog.c
+++ b/src/disks/gduformatdiskdialog.c
@@ -339,7 +339,7 @@ format_cb (GObject      *source_object,
                                         res,
                                         &error))
     {
-      gdu_window_show_error (data->window, _("Error formatting disk"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->window), _("Error formatting disk"), error);
       g_error_free (error);
     }
   format_disk_data_free (data);
@@ -419,10 +419,10 @@ gdu_format_disk_dialog_show (GduWindow    *window,
         }
 
       gtk_widget_hide (data->dialog);
-      if (!gdu_window_show_confirmation (window,
-                                         primary_message,
-                                         str->str,
-                                         _("_Format")))
+      if (!gdu_utils_show_confirmation (GTK_WINDOW (window),
+                                        primary_message,
+                                        str->str,
+                                        _("_Format")))
         {
           g_string_free (str, TRUE);
           goto out;
diff --git a/src/disks/gduformatvolumedialog.c b/src/disks/gduformatvolumedialog.c
index 32eb4c1..0cd8c76 100644
--- a/src/disks/gduformatvolumedialog.c
+++ b/src/disks/gduformatvolumedialog.c
@@ -97,7 +97,7 @@ format_cb (GObject      *source_object,
                                         res,
                                         &error))
     {
-      gdu_window_show_error (data->window, _("Error formatting volume"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->window), _("Error formatting volume"), error);
       g_error_free (error);
     }
   format_volume_data_free (data);
@@ -172,10 +172,10 @@ gdu_format_volume_dialog_show (GduWindow    *window,
           str = g_string_new (_("All data on the volume will be overwritten and will likely not be recoverable by data recovery services"));
         }
 
-      if (!gdu_window_show_confirmation (window,
-                                         primary_message,
-                                         str->str,
-                                         _("_Format")))
+      if (!gdu_utils_show_confirmation (GTK_WINDOW (window),
+                                        primary_message,
+                                        str->str,
+                                        _("_Format")))
         {
           g_string_free (str, TRUE);
           goto out;
diff --git a/src/disks/gdufstabdialog.c b/src/disks/gdufstabdialog.c
index 3faa90c..2aaf600 100644
--- a/src/disks/gdufstabdialog.c
+++ b/src/disks/gdufstabdialog.c
@@ -528,9 +528,9 @@ gdu_fstab_dialog_show (GduWindow    *window,
                   goto again;
                 }
               gtk_widget_hide (dialog);
-              gdu_window_show_error (window,
-                                     _("Error removing old /etc/fstab entry"),
-                                     error);
+              gdu_utils_show_error (GTK_WINDOW (window),
+                                    _("Error removing old /etc/fstab entry"),
+                                    error);
               g_error_free (error);
               goto out;
             }
@@ -584,9 +584,9 @@ gdu_fstab_dialog_show (GduWindow    *window,
                       goto again;
                     }
                   gtk_widget_hide (dialog);
-                  gdu_window_show_error (window,
-                                         _("Error adding new /etc/fstab entry"),
-                                         error);
+                  gdu_utils_show_error (GTK_WINDOW (window),
+                                        _("Error adding new /etc/fstab entry"),
+                                        error);
                   g_error_free (error);
                   g_free (ui_fsname);
                   goto out;
@@ -608,9 +608,9 @@ gdu_fstab_dialog_show (GduWindow    *window,
                       goto again;
                     }
                   gtk_widget_hide (dialog);
-                  gdu_window_show_error (window,
-                                         _("Error updating /etc/fstab entry"),
-                                         error);
+                  gdu_utils_show_error (GTK_WINDOW (window),
+                                        _("Error updating /etc/fstab entry"),
+                                        error);
                   g_error_free (error);
                   g_free (ui_fsname);
                   goto out;
diff --git a/src/disks/gdupartitiondialog.c b/src/disks/gdupartitiondialog.c
index d53cf66..22daf05 100644
--- a/src/disks/gdupartitiondialog.c
+++ b/src/disks/gdupartitiondialog.c
@@ -366,7 +366,7 @@ gdu_partition_dialog_show (GduWindow    *window,
                                                     NULL, /* GCancellable */
                                                     &error))
             {
-              gdu_window_show_error (window, _("Error setting partition type"), error);
+              gdu_utils_show_error (GTK_WINDOW (window), _("Error setting partition type"), error);
               g_error_free (error);
               goto set_out;
             }
@@ -380,7 +380,7 @@ gdu_partition_dialog_show (GduWindow    *window,
                                                     NULL, /* GCancellable */
                                                     &error))
             {
-              gdu_window_show_error (window, _("Error setting partition name"), error);
+              gdu_utils_show_error (GTK_WINDOW (window), _("Error setting partition name"), error);
               g_error_free (error);
               goto set_out;
             }
@@ -394,7 +394,7 @@ gdu_partition_dialog_show (GduWindow    *window,
                                                      NULL, /* GCancellable */
                                                      &error))
             {
-              gdu_window_show_error (window, _("Error setting partition flags"), error);
+              gdu_utils_show_error (GTK_WINDOW (window), _("Error setting partition flags"), error);
               g_error_free (error);
               goto set_out;
             }
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index c298d48..0f0d212 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -46,8 +46,6 @@ typedef struct
 {
   volatile gint ref_count;
 
-  gboolean destroying;
-
   GduWindow *window;
   UDisksObject *object;
   UDisksBlock *block;
@@ -83,6 +81,9 @@ typedef struct
   guint64 buffer_bytes_to_write;
 
   GduEstimator *estimator;
+
+  gulong response_signal_handler_id;
+  gboolean completed;
 } RestoreDiskImageData;
 
 static RestoreDiskImageData *
@@ -97,11 +98,16 @@ restore_disk_image_data_unref (RestoreDiskImageData *data)
 {
   if (g_atomic_int_dec_and_test (&data->ref_count))
     {
-      data->destroying = TRUE;
+      /* hide the dialog */
       if (data->dialog != NULL)
         {
-          gtk_widget_hide (data->dialog);
-          gtk_widget_destroy (data->dialog);
+          GtkWidget *dialog;
+          if (data->response_signal_handler_id != 0)
+            g_signal_handler_disconnect (data->dialog, data->response_signal_handler_id);
+          dialog = data->dialog;
+          data->dialog = NULL;
+          gtk_widget_hide (dialog);
+          gtk_widget_destroy (dialog);
         }
       g_clear_object (&data->cancellable);
       g_clear_object (&data->input_file_stream);
@@ -131,8 +137,7 @@ rescan_cb (UDisksBlock   *block,
                                         res,
                                         &error))
     {
-      if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window, _("Error rescanning device"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error rescanning device"), error);
       g_clear_error (&error);
     }
   restore_disk_image_data_unref (data);
@@ -141,15 +146,18 @@ rescan_cb (UDisksBlock   *block,
 static void
 restore_disk_image_data_complete (RestoreDiskImageData *data)
 {
-  /* request that the core OS / kernel rescans the device */
-  udisks_block_call_rescan (data->block,
-                            g_variant_new ("a{sv}", NULL), /* options */
-                            NULL, /* cancellable */
-                            (GAsyncReadyCallback) rescan_cb,
-                            restore_disk_image_data_ref (data));
-  g_cancellable_cancel (data->cancellable);
-  if (data->dialog != NULL)
-    gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_CANCEL);
+  if (!data->completed)
+    {
+      data->completed = TRUE;
+      /* request that the core OS / kernel rescans the device */
+      udisks_block_call_rescan (data->block,
+                                g_variant_new ("a{sv}", NULL), /* options */
+                                NULL, /* cancellable */
+                                (GAsyncReadyCallback) rescan_cb,
+                                restore_disk_image_data_ref (data));
+      g_cancellable_cancel (data->cancellable);
+      restore_disk_image_data_unref (data);
+    }
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -162,7 +170,7 @@ restore_disk_image_update (RestoreDiskImageData *data)
   gchar *restore_error = NULL;
   GFile *restore_file = NULL;
 
-  if (data->destroying)
+  if (data->dialog == NULL)
     goto out;
 
   /* don't update if we're already copying */
@@ -294,8 +302,8 @@ write_cb (GOutputStream  *output_stream,
   if (error != NULL)
     {
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window,
-                               _("Error writing to backup image"), error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog),
+                               _("Error writing to device"), error);
       g_error_free (error);
       restore_disk_image_data_complete (data);
       goto out;
@@ -386,7 +394,7 @@ read_cb (GInputStream  *input_stream,
       s = g_strdup_printf (_("Error reading from offset %" G_GUINT64_FORMAT " of file"),
                            (guint64) data->total_bytes_read);
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window, s, error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog), s, error);
       g_free (s);
       g_error_free (error);
       restore_disk_image_data_complete (data);
@@ -446,7 +454,7 @@ start_copying (RestoreDiskImageData *data)
   if (data->input_file_stream == NULL)
     {
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window, _("Error opening file for reading"), error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error opening file for reading"), error);
       g_error_free (error);
       restore_disk_image_data_complete (data);
       goto out;
@@ -460,8 +468,9 @@ start_copying (RestoreDiskImageData *data)
                             &error);
   if (info == NULL)
     {
-      gdu_window_show_error (data->window, _("Error determing size of file"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error determing size of file"), error);
       g_error_free (error);
+      restore_disk_image_data_complete (data);
       goto out;
     }
   data->file_size = g_file_info_get_size (info);
@@ -481,9 +490,45 @@ start_copying (RestoreDiskImageData *data)
 }
 
 static void
+on_dialog_response (GtkDialog     *dialog,
+                    gint           response,
+                    gpointer       user_data)
+{
+  RestoreDiskImageData *data = user_data;
+  if (response == GTK_RESPONSE_OK)
+    {
+      if (!gdu_utils_show_confirmation (GTK_WINDOW (data->dialog),
+                                        _("Are you sure you want to write the disk image to the device?"),
+                                        _("All existing data will be lost"),
+                                        _("_Restore")))
+        {
+          restore_disk_image_data_complete (data);
+          goto out;
+        }
+
+      /* now that we know the user picked a folder, update file chooser settings */
+      gdu_utils_file_chooser_for_disk_images_update_settings (GTK_FILE_CHOOSER (data->source_file_fcbutton));
+
+      gtk_label_set_markup (GTK_LABEL (data->copying_label), _("Copying data to device..."));
+
+      /* Advance to the progress page and hide infobars, if any */
+      gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), 1);
+      gtk_widget_hide (data->start_copying_button);
+      gtk_widget_hide (data->infobar_vbox);
+
+      start_copying (data);
+    }
+  else
+    {
+      restore_disk_image_data_complete (data);
+    }
+ out:
+  ;
+}
+
+static void
 gdu_restore_disk_image_dialog_show2 (RestoreDiskImageData *data)
 {
-  gint response;
   gchar *s;
 
   data->dialog = GTK_WIDGET (gdu_application_new_widget (gdu_window_get_application (data->window),
@@ -515,42 +560,19 @@ gdu_restore_disk_image_dialog_show2 (RestoreDiskImageData *data)
   g_signal_connect (data->source_file_fcbutton, "notify",
                     G_CALLBACK (on_notify), data);
 
-  /* Make sure we attach to parent */
-  gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (data->window));
-  gtk_dialog_set_default_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK);
-  gtk_widget_show_all (data->dialog);
-  response = gtk_dialog_run (GTK_DIALOG (data->dialog));
-
-  if (response != GTK_RESPONSE_OK)
-    goto out;
-
-  if (!gdu_window_show_confirmation (data->window,
-                                     _("Are you sure you want to write the disk image to the device?"),
-                                     _("All existing data will be lost"),
-                                     _("_Restore")))
-    goto out;
-
-  /* now that we know the user picked a folder, update file chooser settings */
-  gdu_utils_file_chooser_for_disk_images_update_settings (GTK_FILE_CHOOSER (data->source_file_fcbutton));
 
-  s = g_strdup_printf (_("Copying data to device <i>%s</i>..."),
+  /* Translators: This is the window title for the non-modal "Restore Disk Image" dialog. The %s is the device. */
+  s = g_strdup_printf (_("Restore Disk Image (%s)"),
                        udisks_block_get_preferred_device (data->block));
-  gtk_label_set_markup (GTK_LABEL (data->copying_label), s);
+  gtk_window_set_title (GTK_WINDOW (data->dialog), s);
   g_free (s);
 
-  /* Advance to the progress page and hide infobars, if any */
-  gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), 1);
-  gtk_widget_hide (data->start_copying_button);
-  gtk_widget_hide (data->infobar_vbox);
-
-  if (!start_copying (data))
-    goto out;
-
-  gtk_dialog_run (GTK_DIALOG (data->dialog));
-  restore_disk_image_data_complete (data);
-
- out:
-  restore_disk_image_data_unref (data);
+  data->response_signal_handler_id = g_signal_connect (data->dialog,
+                                                       "response",
+                                                       G_CALLBACK (on_dialog_response),
+                                                       data);
+  gtk_widget_show_all (data->dialog);
+  gtk_window_present (GTK_WINDOW (data->dialog));
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -574,10 +596,9 @@ open_cb (UDisksBlock  *block,
                                                   &error))
     {
       if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
-        gdu_window_show_error (data->window, _("Error opening device"), error);
+        gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error opening device"), error);
       g_error_free (error);
       restore_disk_image_data_complete (data);
-      restore_disk_image_data_unref (data);
       goto out;
     }
 
@@ -590,10 +611,9 @@ open_cb (UDisksBlock  *block,
   if (ioctl (fd, BLKGETSIZE64, &data->block_size) != 0)
     {
       error = g_error_new (G_IO_ERROR, g_io_error_from_errno (errno), "%s", strerror (errno));
-      gdu_window_show_error (data->window, _("Error determining size of device"), error);
+      gdu_utils_show_error (GTK_WINDOW (data->dialog), _("Error determining size of device"), error);
       g_error_free (error);
       restore_disk_image_data_complete (data);
-      restore_disk_image_data_unref (data);
       goto out;
     }
   data->block_stream = g_unix_output_stream_new (fd, TRUE);
diff --git a/src/disks/gduunlockdialog.c b/src/disks/gduunlockdialog.c
index 040e014..ab8363b 100644
--- a/src/disks/gduunlockdialog.c
+++ b/src/disks/gduunlockdialog.c
@@ -96,9 +96,9 @@ unlock_cb (UDisksEncrypted *encrypted,
                                             res,
                                             &error))
     {
-      gdu_window_show_error (data->window,
-                             _("Error unlocking encrypted device"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (data->window),
+                            _("Error unlocking encrypted device"),
+                            error);
       g_error_free (error);
     }
   dialog_data_free (data);
diff --git a/src/disks/gduutils.c b/src/disks/gduutils.c
index 961da3c..0336e19 100644
--- a/src/disks/gduutils.c
+++ b/src/disks/gduutils.c
@@ -576,3 +576,82 @@ gdu_utils_format_duration_usec (guint64                usec,
 
   return ret;
 }
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+void
+gdu_utils_show_error (GtkWindow   *parent_window,
+                      const gchar *message,
+                      GError      *error)
+{
+  GtkWidget *dialog;
+  GError *fixed_up_error;
+
+  /* Never show an error if it's because the user dismissed the
+   * authentication dialog himself
+   *
+   * ... or if the user cancelled the operation
+   */
+  if ((error->domain == UDISKS_ERROR && error->code == UDISKS_ERROR_NOT_AUTHORIZED_DISMISSED) ||
+      (error->domain == UDISKS_ERROR && error->code == UDISKS_ERROR_CANCELLED))
+    goto no_dialog;
+
+  fixed_up_error = g_error_copy (error);
+  if (g_dbus_error_is_remote_error (fixed_up_error))
+    g_dbus_error_strip_remote_error (fixed_up_error);
+
+  /* TODO: probably provide the error-domain / error-code / D-Bus error name
+   * in a GtkExpander.
+   */
+  dialog = gtk_message_dialog_new_with_markup (parent_window,
+                                               GTK_DIALOG_MODAL,
+                                               GTK_MESSAGE_ERROR,
+                                               GTK_BUTTONS_CLOSE,
+                                               "<big><b>%s</b></big>",
+                                               message);
+  gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
+                                              "%s (%s, %d)",
+                                              fixed_up_error->message,
+                                              g_quark_to_string (error->domain),
+                                              error->code);
+  g_error_free (fixed_up_error);
+  gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_widget_destroy (dialog);
+
+ no_dialog:
+  ;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+gboolean
+gdu_utils_show_confirmation (GtkWindow   *parent_window,
+                             const gchar *message,
+                             const gchar *secondary_message,
+                             const gchar *affirmative_verb)
+{
+  GtkWidget *dialog;
+  gint response;
+
+  dialog = gtk_message_dialog_new_with_markup (parent_window,
+                                               GTK_DIALOG_MODAL,
+                                               GTK_MESSAGE_INFO,
+                                               GTK_BUTTONS_CANCEL,
+                                               "<big><b>%s</b></big>",
+                                               message);
+  gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
+                                              "%s",
+                                              secondary_message);
+
+  gtk_dialog_add_button (GTK_DIALOG (dialog),
+                         affirmative_verb,
+                         GTK_RESPONSE_OK);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_destroy (dialog);
+
+  return response == GTK_RESPONSE_OK;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gduutils.h b/src/disks/gduutils.h
index 5f7c744..ee49686 100644
--- a/src/disks/gduutils.h
+++ b/src/disks/gduutils.h
@@ -60,6 +60,15 @@ const gchar *gdu_utils_get_seat (void);
 gchar *gdu_utils_format_duration_usec (guint64                usec,
                                        GduFormatDurationFlags flags);
 
+void            gdu_utils_show_error      (GtkWindow      *parent_window,
+                                           const gchar    *message,
+                                           GError         *error);
+
+gboolean        gdu_utils_show_confirmation (GtkWindow   *parent_window,
+                                             const gchar *message,
+                                             const gchar *secondary_message,
+                                             const gchar *affirmative_verb);
+
 G_END_DECLS
 
 #endif /* __GDU_UTILS_H__ */
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 4991b37..e12ba10 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -622,9 +622,9 @@ loop_delete_cb (UDisksLoop   *loop,
   error = NULL;
   if (!udisks_loop_call_delete_finish (loop, res, &error))
     {
-      gdu_window_show_error (window,
-                             _("Error deleting loop device"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error deleting loop device"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -693,9 +693,9 @@ loop_setup_cb (UDisksManager  *manager,
   error = NULL;
   if (!udisks_manager_call_loop_setup_finish (manager, &out_loop_device_object_path, NULL, res, &error))
     {
-      gdu_window_show_error (data->window,
-                             _("Error attaching disk image"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (data->window),
+                            _("Error attaching disk image"),
+                            error);
       g_error_free (error);
     }
   else
@@ -765,9 +765,9 @@ gdu_window_show_attach_disk_image (GduWindow *window)
       error = g_error_new (G_IO_ERROR,
                            g_io_error_from_errno (errno),
                            "%s", strerror (errno));
-      gdu_window_show_error (window,
-                             _("Error attaching disk image"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error attaching disk image"),
+                            error);
       g_error_free (error);
       goto out;
     }
@@ -2592,84 +2592,6 @@ teardown_device_page (GduWindow *window)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-/* TODO: right now we show a MessageDialog but we could do things like an InfoBar etc */
-void
-gdu_window_show_error (GduWindow   *window,
-                       const gchar *message,
-                       GError      *error)
-{
-  GtkWidget *dialog;
-  GError *fixed_up_error;
-
-  /* Never show an error if it's because the user dismissed the
-   * authentication dialog himself
-   *
-   * ... or if the user cancelled the operation
-   */
-  if ((error->domain == UDISKS_ERROR && error->code == UDISKS_ERROR_NOT_AUTHORIZED_DISMISSED) ||
-      (error->domain == UDISKS_ERROR && error->code == UDISKS_ERROR_CANCELLED))
-    goto no_dialog;
-
-  fixed_up_error = g_error_copy (error);
-  if (g_dbus_error_is_remote_error (fixed_up_error))
-    g_dbus_error_strip_remote_error (fixed_up_error);
-
-  /* TODO: probably provide the error-domain / error-code / D-Bus error name
-   * in a GtkExpander.
-   */
-  dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (window),
-                                               GTK_DIALOG_MODAL,
-                                               GTK_MESSAGE_ERROR,
-                                               GTK_BUTTONS_CLOSE,
-                                               "<big><b>%s</b></big>",
-                                               message);
-  gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
-                                              "%s (%s, %d)",
-                                              fixed_up_error->message,
-                                              g_quark_to_string (error->domain),
-                                              error->code);
-  g_error_free (fixed_up_error);
-  gtk_dialog_run (GTK_DIALOG (dialog));
-  gtk_widget_destroy (dialog);
-
- no_dialog:
-  ;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-gboolean
-gdu_window_show_confirmation (GduWindow   *window,
-                              const gchar *message,
-                              const gchar *secondary_message,
-                              const gchar *affirmative_verb)
-{
-  GtkWidget *dialog;
-  gint response;
-
-  dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (window),
-                                               GTK_DIALOG_MODAL,
-                                               GTK_MESSAGE_INFO,
-                                               GTK_BUTTONS_CANCEL,
-                                               "<big><b>%s</b></big>",
-                                               message);
-  gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
-                                              "%s",
-                                              secondary_message);
-
-  gtk_dialog_add_button (GTK_DIALOG (dialog),
-                         affirmative_verb,
-                         GTK_RESPONSE_OK);
-
-  response = gtk_dialog_run (GTK_DIALOG (dialog));
-
-  gtk_widget_destroy (dialog);
-
-  return response == GTK_RESPONSE_OK;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
 static void
 on_generic_menu_item_edit_label (GtkMenuItem *menu_item,
                                  gpointer   user_data)
@@ -2853,9 +2775,9 @@ ata_pm_standby_cb (GObject      *source_object,
                                                 res,
                                                 &error))
     {
-      gdu_window_show_error (window,
-                             _("An error occurred when trying to put the drive into standby mode"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("An error occurred when trying to put the drive into standby mode"),
+                            error);
       g_clear_error (&error);
     }
 
@@ -2899,9 +2821,9 @@ ata_pm_wakeup_cb (GObject      *source_object,
                                                res,
                                                &error))
     {
-      gdu_window_show_error (window,
-                             _("An error occurred when trying to wake up the drive from standby mode"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("An error occurred when trying to wake up the drive from standby mode"),
+                            error);
       g_clear_error (&error);
     }
 
@@ -2974,9 +2896,9 @@ mount_cb (UDisksFilesystem *filesystem,
                                             res,
                                             &error))
     {
-      gdu_window_show_error (window,
-                             _("Error mounting filesystem"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error mounting filesystem"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3014,9 +2936,9 @@ unmount_cb (UDisksFilesystem *filesystem,
                                               res,
                                               &error))
     {
-      gdu_window_show_error (window,
-                             _("Error unmounting filesystem"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error unmounting filesystem"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3095,9 +3017,9 @@ partition_delete_cb (UDisksPartition *partition,
                                             res,
                                             &error))
     {
-      gdu_window_show_error (window,
-                             _("Error deleting partition"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error deleting partition"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3111,10 +3033,10 @@ on_devtab_action_partition_delete_activated (GtkAction *action,
   UDisksObject *object;
   UDisksPartition *partition;
 
-  if (!gdu_window_show_confirmation (window,
-                                     _("Are you sure you want to delete the partition?"),
-                                     _("All data on the partition will be lost"),
-                                     _("_Delete")))
+  if (!gdu_utils_show_confirmation (GTK_WINDOW (window),
+                                    _("Are you sure you want to delete the partition?"),
+                                    _("All data on the partition will be lost"),
+                                    _("_Delete")))
     goto out;
 
   object = gdu_volume_grid_get_selected_device (GDU_VOLUME_GRID (window->volume_grid));
@@ -3144,9 +3066,9 @@ eject_cb (UDisksDrive  *drive,
                                        res,
                                        &error))
     {
-      gdu_window_show_error (window,
-                             _("Error ejecting media"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error ejecting media"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3196,9 +3118,9 @@ lock_cb (UDisksEncrypted *encrypted,
                                           res,
                                           &error))
     {
-      gdu_window_show_error (window,
-                             _("Error locking encrypted device"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error locking encrypted device"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3237,9 +3159,9 @@ swapspace_start_cb (UDisksSwapspace  *swapspace,
                                            res,
                                            &error))
     {
-      gdu_window_show_error (window,
-                             _("Error starting swap"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error starting swap"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3274,9 +3196,9 @@ swapspace_stop_cb (UDisksSwapspace  *swapspace,
                                           res,
                                           &error))
     {
-      gdu_window_show_error (window,
-                             _("Error stopping swap"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error stopping swap"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3316,9 +3238,9 @@ loop_set_autoclear_cb (UDisksLoop      *loop,
                                               res,
                                               &error))
     {
-      gdu_window_show_error (window,
-                             _("Error setting autoclear flag"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error setting autoclear flag"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3369,9 +3291,9 @@ drive_job_cancel_cb (UDisksJob       *job,
 
   if (!udisks_job_call_cancel_finish (job, res, &error))
     {
-      gdu_window_show_error (window,
-                             _("Error canceling job"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error canceling job"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
@@ -3424,9 +3346,9 @@ job_cancel_cb (UDisksJob       *job,
 
   if (!udisks_job_call_cancel_finish (job, res, &error))
     {
-      gdu_window_show_error (window,
-                             _("Error canceling job"),
-                             error);
+      gdu_utils_show_error (GTK_WINDOW (window),
+                            _("Error canceling job"),
+                            error);
       g_error_free (error);
     }
   g_object_unref (window);
diff --git a/src/disks/gduwindow.h b/src/disks/gduwindow.h
index 29e1b52..88ef429 100644
--- a/src/disks/gduwindow.h
+++ b/src/disks/gduwindow.h
@@ -38,15 +38,6 @@ GduWindow      *gdu_window_new             (GduApplication *application,
 GduApplication *gdu_window_get_application (GduWindow      *window);
 UDisksClient   *gdu_window_get_client      (GduWindow      *window);
 
-void            gdu_window_show_error      (GduWindow      *window,
-                                            const gchar    *message,
-                                            GError         *error);
-
-gboolean        gdu_window_show_confirmation (GduWindow   *window,
-                                              const gchar *message,
-                                              const gchar *secondary_message,
-                                              const gchar *affirmative_verb);
-
 gboolean        gdu_window_select_object     (GduWindow    *window,
                                               UDisksObject *object);
 



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