[gnome-boxes/selection-mode-keyboard-shortcuts: 2/4] icon-view: Connect Flowbox signals from UI file



commit 6657d383c1a4a1f594a4f9ba0db7c7f7c2c91fdd
Author: Felipe Borges <felipeborges gnome org>
Date:   Sun Jan 14 18:31:35 2018 +0100

    icon-view: Connect Flowbox signals from UI file

 data/ui/icon-view.ui |  3 +++
 src/icon-view.vala   | 32 ++++++++++++++++----------------
 2 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/data/ui/icon-view.ui b/data/ui/icon-view.ui
index baf5a171..11556693 100644
--- a/data/ui/icon-view.ui
+++ b/data/ui/icon-view.ui
@@ -22,6 +22,9 @@
             <property name="column-spacing">20</property>
             <property name="row-spacing">6</property>
             <property name="valign">start</property>
+            <signal name="button-release-event" handler="on_button_press_event"/>
+            <signal name="child-activated" handler="on_child_activated"/>
+            <signal name="key-press-event" handler="on_key_press_event"/>
             <style>
               <class name="boxes-list-box"/>
               <class name="view"/>
diff --git a/src/icon-view.vala b/src/icon-view.vala
index 28cbf356..12ba3626 100644
--- a/src/icon-view.vala
+++ b/src/icon-view.vala
@@ -123,23 +123,7 @@ private void setup_flowbox () {
             return child;
         });
 
-        flowbox.button_release_event.connect (on_button_press_event);
-        flowbox.key_press_event.connect (on_key_press_event);
-
         flowbox.set_filter_func (model_filter);
-
-        flowbox.child_activated.connect ((child) => {
-            if (window.selection_mode)
-                return;
-
-            var item = get_item_for_child (child);
-            if (item is LibvirtMachine && (item as LibvirtMachine).importing)
-                return;
-
-            window.select_item (item);
-        });
-
-        update_selection_mode ();
     }
 
     private CollectionItem? get_item_for_child (Gtk.FlowBoxChild child) {
@@ -176,6 +160,21 @@ private void ui_state_changed () {
             flowbox.unselect_all ();
     }
 
+    [GtkCallback]
+    private void on_child_activated (Gtk.FlowBoxChild child) {
+        if (window.selection_mode)
+            return;
+
+        var item = get_item_for_child (child);
+        if (item is LibvirtMachine && (item as LibvirtMachine).importing)
+            return;
+
+        window.select_item (item);
+
+        update_selection_mode ();
+    }
+
+    [GtkCallback]
     private bool on_button_press_event (Gdk.EventButton event) {
         if (event.type != Gdk.EventType.BUTTON_RELEASE || event.button != 3)
             return false;
@@ -185,6 +184,7 @@ private bool on_button_press_event (Gdk.EventButton event) {
         return launch_context_popover_for_child (child);
     }
 
+    [GtkCallback]
     private bool on_key_press_event (Gdk.EventKey event) {
         if (event.keyval != Gdk.Key.Menu)
             return false;


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