[gnome-games] ui: Prevent display of multiple preferences window



commit 6bdd9034c5685a69e0c9883331ab7079b3e0509a
Author: 1PunMan <saurabhsingh412 gmail com>
Date:   Sat Apr 7 18:42:32 2018 +0530

    ui: Prevent display of multiple preferences window
    
    Make a new preferences window if it doesn't exist, else show existing.
    
    https://gitlab.gnome.org/GNOME/gnome-games/issues/12

 src/ui/application.vala | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 502bde7..5f562d4 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -5,6 +5,7 @@ private extern const string VERSION;
 public class Games.Application : Gtk.Application {
        private Database database;
 
+       private PreferencesWindow preferences_window;
        private ApplicationWindow window;
        private bool game_list_loaded;
 
@@ -298,7 +299,15 @@ public class Games.Application : Gtk.Application {
        }
 
        private void preferences () {
-               new PreferencesWindow ();
+               if (preferences_window != null) {
+                       preferences_window.present ();
+
+                       return;
+               }
+               preferences_window = new PreferencesWindow ();
+               preferences_window.destroy.connect (() => {
+                       preferences_window = null;
+               });
        }
 
        private void about () {


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