[gnome-games/wip/exalm/gtk4: 41/62] ui: Stop using 'button-press-event' signal



commit 36e781c5d88762226095e70c32edddb3cc4b0308
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sat Jul 28 20:04:38 2018 +0500

    ui: Stop using 'button-press-event' signal
    
    Replace it with GtkGestureMultiPress and its 'pressed' signal.

 data/ui/application-window.ui  |  8 +++++++-
 src/ui/application-window.vala | 12 ++----------
 2 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index a40d4a44..bb64ec9c 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -8,9 +8,15 @@
     <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"/>
-    <signal name="button-press-event" after="yes" handler="on_button_pressed"/>
     <signal name="window-state-event" after="yes" handler="on_window_state_event"/>
     <signal name="notify::is-active" after="yes" handler="on_active_changed"/>
+    <child>
+      <object class="GtkGestureMultiPress">
+        <!-- Mouse button 8 is the navigation previous button -->
+        <property name="button">8</property>
+        <signal name="pressed" handler="on_button_pressed" swapped="no"/>
+      </object>
+    </child>
     <child>
       <object class="GtkStack" id="content_box">
         <property name="visible">True</property>
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 7082d393..c2b3d7f3 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -232,17 +232,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        }
 
        [GtkCallback]
-       public bool on_button_pressed (Gdk.EventButton event) {
-               // Mouse button 8 is the navigation previous button
-               if (event.button == 8) {
-                       if (ui_state != UiState.DISPLAY)
-                               return false;
-
+       public void on_button_pressed (Gtk.GestureMultiPress gesture, int n_press, double x, double y) {
+               if (ui_state == UiState.DISPLAY)
                        on_display_back ();
-                       return true;
-               }
-
-               return false;
        }
 
        [GtkCallback]


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