[gnome-music] window: Only create back button gesture once



commit 3415af5c267676c771b8b52f7baeaecc00fbdd8e
Author: Vineet Reddy <vineetreddy live com>
Date:   Sun Jun 28 16:48:57 2020 +0530

    window: Only create back button gesture once
    
    Currently a Gtk.Gesture is connected when switching to player view every
    time.
    
    Avoid connecting the gesture multiple times when the views are already
    created.
    
    Closes: #398

 gnomemusic/window.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index dfeb8fef0..99227c6a2 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -230,6 +230,11 @@ class Window(Handy.ApplicationWindow):
             'notify::visible-child', self._on_notify_mode)
         self.connect('destroy', self._notify_mode_disconnect)
 
+        # All views are created together, so if the album view is
+        # already initialized, assume the rest are as well.
+        if self.views[View.ALBUM] is not None:
+            return
+
         self._btn_ctrl = Gtk.GestureMultiPress().new(self)
         self._btn_ctrl.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
         # Mouse button 8 is the back button.
@@ -239,12 +244,6 @@ class Window(Handy.ApplicationWindow):
         self.views[View.EMPTY].props.state = EmptyView.State.SEARCH
 
         self._headerbar.props.state = HeaderBar.State.MAIN
-
-        # All views are created together, so if the album view is
-        # already initialized, assume the rest are as well.
-        if self.views[View.ALBUM] is not None:
-            return
-
         self.views[View.ALBUM] = AlbumsView(self._app)
         self.views[View.ARTIST] = ArtistsView(self._app)
         self.views[View.SONG] = SongsView(self._app)


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