[gnome-calculator] Quit warns and closes all windows (fixes #51)



commit 8c79a989364834d3e1160111bac7dfd5092b7215
Author: Robert Roth <robert roth off gmail com>
Date:   Wed Mar 27 14:01:34 2019 +0200

    Quit warns and closes all windows (fixes #51)

 src/gnome-calculator.vala | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index ac61cc17..60b072d8 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -349,13 +349,27 @@ public class Calculator : Gtk.Application
     private void quit_cb ()
     {
         save_window_position (get_active_math_window ());
-        get_active_window ().destroy ();
+
+        if (get_windows ().length () > 1)
+        {
+            var dialog = new Gtk.MessageDialog.with_markup (get_active_math_window (), Gtk.DialogFlags.MODAL,
+                                                            Gtk.MessageType.QUESTION, Gtk.ButtonsType.CANCEL,
+                                                            _("Are you sure you want to close all open 
windows?"));
+            dialog.add_buttons (_("Close _All"), Gtk.ResponseType.CLOSE);
+
+            int result = dialog.run ();
+            if (result == Gtk.ResponseType.CLOSE)
+                this.quit ();
+            dialog.destroy ();
+        } else {
+            this.quit ();
+        }
     }
 
     private void new_window_cb ()
     {
         var window = create_new_window (settings);
-        window.present ();
+        window.show ();
     }
 
     /**


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