[gnome-games] application-window: Handle delete_event()



commit 0d256abafb978ac8d6f0cb0c9a4f1d3ecb5ec53e
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Mon Mar 7 20:26:24 2016 +0100

    application-window: Handle delete_event()
    
    Propagate delete event only if quitting the game is successful.

 data/ui/application-window.ui  |    1 +
 src/ui/application-window.vala |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 7f85e56..2e4f9bd 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -7,6 +7,7 @@
     <property name="default_width">800</property>
     <property name="default_height">600</property>
     <property name="show_menubar">False</property>
+    <signal name="delete-event" after="yes" handler="on_delete_event"/>
     <signal name="key-press-event" after="yes" handler="on_key_pressed"/>
     <child>
       <object class="GamesContentBox" id="content_box">
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 9e7ab62..4626082 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -87,6 +87,11 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        }
 
        [GtkCallback]
+       public bool on_delete_event () {
+               return !quit_game ();
+       }
+
+       [GtkCallback]
        public bool on_key_pressed (Gdk.EventKey event) {
                var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
 


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