** Sets the proper parent to a dialog. This could cause apparent "freezes" when chang...
authorSergio Villar Senin <svillar@igalia.com>
Mon, 1 Jun 2009 10:00:03 +0000 (12:00 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 1 Jun 2009 10:00:36 +0000 (12:00 +0200)
* Fixes NB#119715, set the proper parent to the "replace file" confirmation dialog when saving attachments

src/hildon2/modest-msg-view-window.c
src/maemo/modest-msg-view-window.c

index 48836f0..b901177 100644 (file)
@@ -2660,7 +2660,7 @@ typedef struct
 static void save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct);
 static gboolean idle_save_mime_part_show_result (SaveMimePartInfo *info);
 static gpointer save_mime_part_to_file (SaveMimePartInfo *info);
-static void save_mime_parts_to_file_with_checks (SaveMimePartInfo *info);
+static void save_mime_parts_to_file_with_checks (GtkWindow *parent, SaveMimePartInfo *info);
 
 static void
 save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct)
@@ -2742,7 +2742,8 @@ save_mime_part_to_file (SaveMimePartInfo *info)
 }
 
 static void
-save_mime_parts_to_file_with_checks (SaveMimePartInfo *info)
+save_mime_parts_to_file_with_checks (GtkWindow *parent,
+                                    SaveMimePartInfo *info)
 {
        gboolean is_ok = TRUE;
         gint replaced_files = 0;
@@ -2756,7 +2757,7 @@ save_mime_parts_to_file_with_checks (SaveMimePartInfo *info)
                 }
         }
        if (replaced_files) {
-               GtkWidget *confirm_overwrite_dialog;
+               gint response;
 
                if (replaced_files == 1) {
                        SaveMimePartPair *pair = files->data;
@@ -2767,17 +2768,15 @@ save_mime_parts_to_file_with_checks (SaveMimePartInfo *info)
                        message = g_strdup_printf ("%s\n%s",
                                                   _FM("docm_nc_replace_file"),
                                                   (escaped_basename) ? escaped_basename : "");
-                       confirm_overwrite_dialog = hildon_note_new_confirmation (NULL, message);
+                       response = modest_platform_run_confirmation_dialog (parent, message);
                        g_free (message);
                        g_free (escaped_basename);
                } else {
-                       confirm_overwrite_dialog = hildon_note_new_confirmation (NULL,
-                                                                                _FM("docm_nc_replace_multiple"));
+                       response = modest_platform_run_confirmation_dialog (parent,
+                                                                           _FM("docm_nc_replace_multiple"));
                }
-               if (gtk_dialog_run (GTK_DIALOG (confirm_overwrite_dialog)) != GTK_RESPONSE_OK)
+               if (response != GTK_RESPONSE_OK)
                        is_ok = FALSE;
-
-               gtk_widget_destroy (confirm_overwrite_dialog);
        }
 
        if (!is_ok) {
@@ -2854,7 +2853,7 @@ save_attachments_response (GtkDialog *dialog,
                SaveMimePartInfo *info = g_slice_new0 (SaveMimePartInfo);
                info->pairs = files_to_save;
                info->result = TRUE;
-               save_mime_parts_to_file_with_checks (info);
+               save_mime_parts_to_file_with_checks ((GtkWindow *) dialog, info);
        }
 
  end:
index 907159b..5cdcf2c 100644 (file)
@@ -2759,7 +2759,7 @@ typedef struct
 static void save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct);
 static gboolean idle_save_mime_part_show_result (SaveMimePartInfo *info);
 static gpointer save_mime_part_to_file (SaveMimePartInfo *info);
-static void save_mime_parts_to_file_with_checks (SaveMimePartInfo *info);
+static void save_mime_parts_to_file_with_checks (GtkWindow *parent, SaveMimePartInfo *info);
 
 static void 
 save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct)
@@ -2836,7 +2836,7 @@ save_mime_part_to_file (SaveMimePartInfo *info)
 }
 
 static void
-save_mime_parts_to_file_with_checks (SaveMimePartInfo *info)
+save_mime_parts_to_file_with_checks (GtkWindow *parent, SaveMimePartInfo *info)
 {
        gboolean is_ok = TRUE;
         gint replaced_files = 0;
@@ -2850,14 +2850,12 @@ save_mime_parts_to_file_with_checks (SaveMimePartInfo *info)
                 }
         }
        if (replaced_files) {
-               GtkWidget *confirm_overwrite_dialog;
+               gint response;
                 const gchar *message = (replaced_files == 1) ?
                         _FM("docm_nc_replace_file") : _FM("docm_nc_replace_multiple");
-                confirm_overwrite_dialog = hildon_note_new_confirmation (NULL, message);
-               if (gtk_dialog_run (GTK_DIALOG (confirm_overwrite_dialog)) != GTK_RESPONSE_OK) {
+                response = modest_platform_run_confirmation_dialog (parent, message);
+               if (response != GTK_RESPONSE_OK)
                        is_ok = FALSE;
-               }
-               gtk_widget_destroy (confirm_overwrite_dialog);
        }
 
        if (!is_ok) {
@@ -2925,7 +2923,7 @@ save_attachments_response (GtkDialog *dialog,
                SaveMimePartInfo *info = g_slice_new0 (SaveMimePartInfo);
                info->pairs = files_to_save;
                info->result = TRUE;
-               save_mime_parts_to_file_with_checks (info);
+               save_mime_parts_to_file_with_checks ((GtkWindow*) dialog, info);
        }
 
  end: