[gnome-games/wip/aplazas/konami-code: 14/15] ui: Show message when Konami Code is performed



commit 2a94152109d5c21f5e773ab5b950ffd988052ce6
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sat Jul 23 08:43:51 2016 +0200

    ui: Show message when Konami Code is performed
    
    Show a message in the info box when the Konami Code is performed on the
    collection view.

 src/ui/application-window.vala |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 4c157ef..c5743b3 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -34,6 +34,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
                                break;
                        }
+
+                       konami_code.reset ();
                }
                get { return _ui_state; }
        }
@@ -90,6 +92,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        private uint inhibit_cookie;
        private Gtk.ApplicationInhibitFlags inhibit_flags;
 
+       private KonamiCode konami_code;
+
        public ApplicationWindow (ListModel collection) {
                collection_box.collection = collection;
        }
@@ -121,6 +125,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                header_bar_fullscreen_binding = bind_property ("is-fullscreen", display_header_bar, 
"is-fullscreen",
                                                               BindingFlags.BIDIRECTIONAL);
 
+               konami_code = new KonamiCode (this);
+               konami_code.code_performed.connect (on_konami_code_performed);
+
                window_size_update_timeout = -1;
                focus_out_timeout_id = -1;
                inhibit_cookie = 0;
@@ -554,4 +561,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                display_header_bar.media_set = null;
                display_box.header_bar.media_set = null;
        }
+       private void on_konami_code_performed () {
+               if (ui_state != UiState.COLLECTION)
+                       return;
+
+               message (KonamiCode.CODE_STRING);
+       }
 }


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