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



commit dad1205e85b9d6755f1b75671b160c1bfd4bb957
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 |  5 +++--
 src/ui/collection-view.vala    |  4 ----
 src/ui/display-view.vala       | 10 ----------
 src/ui/ui-view.vala            |  2 --
 5 files changed, 10 insertions(+), 19 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 7d198791..6e9bfc3b 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_back_mouse_button_pressed"/>
+      </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 f2dc7952..f125f204 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -165,8 +165,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        }
 
        [GtkCallback]
-       public bool on_button_pressed (Gdk.EventButton event) {
-               return current_view.on_button_pressed (event);
+       public void on_back_mouse_button_pressed () {
+               if (current_view == display_view)
+                       display_view.back ();
        }
 
        [GtkCallback]
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 95c8cb5a..d375bb0f 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -99,10 +99,6 @@ private class Games.CollectionView : Object, UiView {
                box.show_error (error_message);
        }
 
-       public bool on_button_pressed (Gdk.EventButton event) {
-               return false;
-       }
-
        public bool on_key_pressed (Gdk.EventKey event) {
                var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
 
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index d4859feb..c4c342d4 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -76,16 +76,6 @@ private class Games.DisplayView : Object, UiView {
                focus_out_timeout_id = -1;
        }
 
-       public bool on_button_pressed (Gdk.EventButton event) {
-               // Mouse button 8 is the navigation previous button
-               if (event.button == 8) {
-                       back ();
-                       return true;
-               }
-
-               return false;
-       }
-
        public bool on_key_pressed (Gdk.EventKey event) {
                var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
 
diff --git a/src/ui/ui-view.vala b/src/ui/ui-view.vala
index f5e19ab0..7feb66c4 100644
--- a/src/ui/ui-view.vala
+++ b/src/ui/ui-view.vala
@@ -7,8 +7,6 @@ private interface Games.UiView : Object {
 
        public abstract bool is_view_active { get; set; }
 
-       public abstract bool on_button_pressed (Gdk.EventButton event);
-
        public abstract bool on_key_pressed (Gdk.EventKey event);
 
        public abstract bool gamepad_button_press_event (Manette.Event event);


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