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



commit 5812aab1a8f8a015769a5c682c7e1426c13d16bf
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 22b75634..e12823cc 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 e0ac74ec..d4e4a0eb 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -236,17 +236,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]