[gnome-music/wip/jfelder/grilo-misc-cleanups: 4/7] baseview: Simplify grilo interactions



commit ce56f1a718a570e0d120795f7f005306130f5524
Author: Jean Felder <jfelder src gnome org>
Date:   Thu May 2 11:23:36 2019 +0200

    baseview: Simplify grilo interactions
    
    The views are now populated on demand: when displaying a view, it is
    populated if it is not already populated (self._init check) and if the
    tracker plugin from grilo is
    available (grilo.props.tracker_plugin_available). It means that the
    main views do not need to wait for the ready signal from grilo
    anymore.

 gnomemusic/views/baseview.py | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index b821b422..fe272f0e 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -90,7 +90,6 @@ class BaseView(Gtk.Stack):
         self._view.hide()
 
         self._init = False
-        grilo.connect('ready', self._on_grilo_ready)
         self.connect('notify::selection-mode', self._on_selection_mode_changed)
         grilo.connect('changes-pending', self._on_changes_pending)
 
@@ -98,9 +97,8 @@ class BaseView(Gtk.Stack):
             'selection-mode', self._window, 'selection-mode',
             GObject.BindingFlags.BIDIRECTIONAL)
 
-        if (grilo.props.tracker_plugin_available
-                and not self._init):
-            self._on_grilo_ready()
+        self._headerbar.props.stack.connect(
+            'notify::visible-child', self._on_headerbar_visible)
 
     @log
     def _on_changes_pending(self, data=None):
@@ -111,18 +109,10 @@ class BaseView(Gtk.Stack):
         """Instantiate and set up the view object"""
         pass
 
-    @log
-    def _on_grilo_ready(self, data=None):
-        if (self._headerbar.props.stack.props.visible_child == self
-                and not self._init):
-            self._populate()
-
-        self._headerbar.props.stack.connect(
-            'notify::visible-child', self._on_headerbar_visible)
-
     @log
     def _on_headerbar_visible(self, widget, param):
         if (self == widget.get_visible_child()
+                and grilo.props.tracker_plugin_available
                 and not self._init):
             self._populate()
 


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