[gnome-music/wip/jfelder/gtk-stack-switcher-selection-fix] window: Fix album view selection by the stack switcher on launch




commit 1357135459199ea8faa4b8a6ae9d51ba2421011a
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Mar 24 13:18:33 2021 +0100

    window: Fix album view selection by the stack switcher on launch
    
    The first view added to the stack is the EmptyView which is not
    visible on launch. Then, AlbumsView is added and becomes the
    visible_child by default because it is visible. However, it is not
    selected by the the stack switcher because the
    "notify::visible-changed" signal is received before the child is added
    to the stack switcher.
    
    This issue is fixed by adding a "visible-child" notification. This
    way, the stack switcher selected the AlbumView on launch.

 gnomemusic/window.py | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 3b5d13998..d776a43ea 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -262,7 +262,10 @@ class Window(Gtk.ApplicationWindow):
             else:
                 self._stack.add_named(i, i.props.name)
 
+        # The "visible-child" notification ensures that the AlbumView
+        # appears as selected by the stack switcher on launch.
         self._stack.props.visible_child = self.views[View.ALBUM]
+        self._stack.notify("visible-child")
 
         self.views[View.SEARCH].bind_property(
             "search-state", self._search, "state",


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