[gimp] app: use the GimpDisplay as progress object when exporting.



commit 73a64a4ee820de159d7f1682b6aafbc5fd5a3922
Author: Jehan <jehan girinstud io>
Date:   Sat Jan 30 10:44:36 2021 +0100

    app: use the GimpDisplay as progress object when exporting.
    
    Since we now hide the file dialog when exporting, progression ends up
    invisible, which is especially a problem with big files. Therefore use
    the image display as a GimpProgress to show progression.

 app/actions/file-commands.c    | 19 +++++++++++--------
 app/dialogs/file-save-dialog.c | 20 ++++++++++++--------
 app/widgets/gimpexportdialog.c |  4 +++-
 app/widgets/gimpexportdialog.h |  5 ++++-
 4 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index ec1d244108..e3f87637b5 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -83,7 +83,8 @@ static GtkWidget * file_save_dialog_show        (Gimp         *gimp,
                                                  GimpDisplay  *display);
 static GtkWidget * file_export_dialog_show      (Gimp         *gimp,
                                                  GimpImage    *image,
-                                                 GtkWidget    *parent);
+                                                 GtkWidget    *parent,
+                                                 GimpDisplay  *display);
 static void        file_save_dialog_response    (GtkWidget    *dialog,
                                                  gint          response_id,
                                                  gpointer      data);
@@ -303,7 +304,7 @@ file_save_cmd_callback (GimpAction *action,
       break;
 
     case GIMP_SAVE_MODE_EXPORT_AS:
-      file_export_dialog_show (gimp, image, widget);
+      file_export_dialog_show (gimp, image, widget, display);
       break;
 
     case GIMP_SAVE_MODE_EXPORT:
@@ -321,7 +322,7 @@ file_save_cmd_callback (GimpAction *action,
             if (! file)
               {
                 /* Behave as if Export As... was invoked */
-                file_export_dialog_show (gimp, image, widget);
+                file_export_dialog_show (gimp, image, widget, display);
                 break;
               }
 
@@ -687,7 +688,7 @@ file_save_dialog_response (GtkWidget *dialog,
 
       other = file_export_dialog_show (GIMP_FILE_DIALOG (file_dialog)->image->gimp,
                                        GIMP_FILE_DIALOG (file_dialog)->image,
-                                       GTK_WIDGET (parent));
+                                       GTK_WIDGET (parent), NULL);
 
       gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (other), folder);
       gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), basename);
@@ -698,9 +699,10 @@ file_save_dialog_response (GtkWidget *dialog,
 }
 
 static GtkWidget *
-file_export_dialog_show (Gimp      *gimp,
-                         GimpImage *image,
-                         GtkWidget *parent)
+file_export_dialog_show (Gimp        *gimp,
+                         GimpImage   *image,
+                         GtkWidget   *parent,
+                         GimpDisplay *display)
 {
   GtkWidget *dialog;
 
@@ -735,7 +737,8 @@ file_export_dialog_show (Gimp      *gimp,
 
   if (dialog)
     {
-      gimp_export_dialog_set_image (GIMP_EXPORT_DIALOG (dialog), image);
+      gimp_export_dialog_set_image (GIMP_EXPORT_DIALOG (dialog), image,
+                                    GIMP_OBJECT (display));
 
       gtk_window_present (GTK_WINDOW (dialog));
     }
diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c
index 30d94138bb..3886de897a 100644
--- a/app/dialogs/file-save-dialog.c
+++ b/app/dialogs/file-save-dialog.c
@@ -179,12 +179,13 @@ file_save_dialog_response (GtkWidget *dialog,
 
     case CHECK_URI_OK:
       {
-        GimpImage   *image              = file_dialog->image;
-        GimpDisplay *display_to_close   = NULL;
-        gboolean     xcf_compression    = FALSE;
-        gboolean     is_save_dialog     = GIMP_IS_SAVE_DIALOG (dialog);
-        gboolean     close_after_saving = FALSE;
-        gboolean     save_a_copy        = FALSE;
+        GimpImage    *image              = file_dialog->image;
+        GimpProgress *progress           = GIMP_PROGRESS (dialog);
+        GimpDisplay  *display_to_close   = NULL;
+        gboolean      xcf_compression    = FALSE;
+        gboolean      is_save_dialog     = GIMP_IS_SAVE_DIALOG (dialog);
+        gboolean      close_after_saving = FALSE;
+        gboolean      save_a_copy        = FALSE;
 
         if (is_save_dialog)
           {
@@ -205,13 +206,16 @@ file_save_dialog_response (GtkWidget *dialog,
          * file dialog is just blocking the view.
          */
         if  (GIMP_IS_EXPORT_DIALOG (dialog))
-          gtk_widget_hide (dialog);
+          {
+            gtk_widget_hide (dialog);
+            progress = GIMP_PROGRESS (GIMP_EXPORT_DIALOG (dialog)->display);
+          }
 
         g_signal_connect (dialog, "destroy",
                           G_CALLBACK (gtk_widget_destroyed),
                           &dialog);
 
-        if (file_save_dialog_save_image (GIMP_PROGRESS (dialog),
+        if (file_save_dialog_save_image (progress,
                                          gimp,
                                          image,
                                          file,
diff --git a/app/widgets/gimpexportdialog.c b/app/widgets/gimpexportdialog.c
index eebf98e66f..02ccad0c30 100644
--- a/app/widgets/gimpexportdialog.c
+++ b/app/widgets/gimpexportdialog.c
@@ -85,7 +85,8 @@ gimp_export_dialog_new (Gimp *gimp)
 
 void
 gimp_export_dialog_set_image (GimpExportDialog *dialog,
-                              GimpImage        *image)
+                              GimpImage        *image,
+                              GimpObject       *display)
 {
   GimpFileDialog *file_dialog;
   GFile          *dir_file  = NULL;
@@ -99,6 +100,7 @@ gimp_export_dialog_set_image (GimpExportDialog *dialog,
   file_dialog = GIMP_FILE_DIALOG (dialog);
 
   file_dialog->image = image;
+  dialog->display    = display;
 
   gimp_file_dialog_set_file_proc (file_dialog, NULL);
 
diff --git a/app/widgets/gimpexportdialog.h b/app/widgets/gimpexportdialog.h
index 7e1c368b4c..f9791c29ea 100644
--- a/app/widgets/gimpexportdialog.h
+++ b/app/widgets/gimpexportdialog.h
@@ -38,6 +38,8 @@ typedef struct _GimpExportDialogClass GimpExportDialogClass;
 struct _GimpExportDialog
 {
   GimpFileDialog       parent_instance;
+
+  GimpObject          *display;
 };
 
 struct _GimpExportDialogClass
@@ -51,7 +53,8 @@ GType       gimp_export_dialog_get_type  (void) G_GNUC_CONST;
 GtkWidget * gimp_export_dialog_new       (Gimp             *gimp);
 
 void        gimp_export_dialog_set_image (GimpExportDialog *dialog,
-                                          GimpImage        *image);
+                                          GimpImage        *image,
+                                          GimpObject       *display);
 
 G_END_DECLS
 


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