[gimp] Bug 772785 - Quit dialog should exit when all the images in the list...



commit 5e7d9d8b00f94ef90a44cfce937bf4ccdd0f3915
Author: Jehan <jehan girinstud io>
Date:   Mon Mar 27 22:43:22 2017 +0200

    Bug 772785 - Quit dialog should exit when all the images in the list...
    
    ... have been saved.
    No need to keep a list of 0 images when the creator requested a quit or
    close-all actions and manually went through the list to save all
    remaining images. Yet one can still cancel the quit/close-all action by
    hitting Esc (or Cancel button) during the last save, since it is an
    idle source action.

 app/dialogs/quit-dialog.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/app/dialogs/quit-dialog.c b/app/dialogs/quit-dialog.c
index c297024..aa7addf 100644
--- a/app/dialogs/quit-dialog.c
+++ b/app/dialogs/quit-dialog.c
@@ -113,6 +113,7 @@ static gboolean    quit_close_all_dialog_query_tooltip     (GtkWidget         *w
                                                             gboolean           keyboard_tip,
                                                             GtkTooltip        *tooltip,
                                                             QuitDialog        *private);
+static gboolean    quit_close_all_idle                     (QuitDialog        *private);
 
 
 /*  public functions  */
@@ -285,6 +286,7 @@ quit_close_all_dialog_new (Gimp     *gimp,
 static void
 quit_close_all_dialog_free (QuitDialog *private)
 {
+  g_idle_remove_by_data (private);
   g_object_unref (private->images);
   g_object_unref (private->context);
 
@@ -365,6 +367,18 @@ quit_close_all_dialog_container_changed (GimpContainer *images,
                     NULL);
 
       gtk_widget_grab_default (private->ok_button);
+
+      /* When no image requires saving anymore, there is no harm in
+       * assuming completing the original quit or close-all action is
+       * the expected end-result.
+       * I don't immediately exit though because of some unfinished
+       * actions provoking warnings. Let's just close as soon as
+       * possible with an idle source.
+       * Also the idle source has another benefit: allowing to change
+       * one's mind and not exist after the last save, for instance by
+       * hitting Esc quickly while the last save is in progress.
+       */
+      g_idle_add (quit_close_all_idle, private);
     }
   else
     {
@@ -590,3 +604,11 @@ quit_close_all_dialog_query_tooltip (GtkWidget  *widget,
 
   return show_tip;
 }
+
+static gboolean
+quit_close_all_idle (QuitDialog *private)
+{
+  gtk_dialog_response (private->dialog, GTK_RESPONSE_OK);
+
+  return FALSE;
+}


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