[gnome-music/wip/mschraal/tracker-detection] emptyview: Add Tracker outdated state and use it
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/tracker-detection] emptyview: Add Tracker outdated state and use it
- Date: Tue, 23 Jul 2019 22:11:32 +0000 (UTC)
commit c33bea22b960c24dbc6e0e056fcc37c53bae328a
Author: Marinus Schraal <mschraal gnome org>
Date: Tue Jul 23 23:59:35 2019 +0200
emptyview: Add Tracker outdated state and use it
gnomemusic/views/emptyview.py | 16 +++++++++++++++-
gnomemusic/window.py | 24 ++++++++++++++++--------
2 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index a9ae13da..1e4c989c 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -48,6 +48,7 @@ class EmptyView(Gtk.Stack):
EMPTY = 1
SEARCH = 2
NO_TRACKER = 3
+ TRACKER_OUTDATED = 4
__gtype_name__ = "EmptyView"
@@ -84,7 +85,7 @@ class EmptyView(Gtk.Stack):
self._state = EmptyView.State.INITIAL
- @GObject.Property(type=int, default=0, minimum=0, maximum=3)
+ @GObject.Property(type=int, default=0, minimum=0, maximum=4)
def state(self):
"""Get the state of the empty view
@@ -108,6 +109,8 @@ class EmptyView(Gtk.Stack):
self._set_search_state()
elif self._state == EmptyView.State.NO_TRACKER:
self._set_no_tracker_state()
+ elif self._state == EmptyView.State.TRACKER_OUTDATED:
+ self._set_tracker_outdated_state()
self.show_all()
@log
@@ -144,6 +147,17 @@ class EmptyView(Gtk.Stack):
self._icon.props.icon_name = "dialog-error-symbolic"
+ @log
+ def _set_tracker_outdated_state(self):
+ self._main_label.props.margin_bottom = 12
+ self._main_label.props.label = _(
+ "Your system Tracker version seems outdated")
+ self._icon.props.margin_bottom = 18
+ self._information_label.props.label = _(
+ "Music needs Tracker version 2.2.0 or higher")
+
+ self._icon.props.icon_name = "dialog-error-symbolic"
+
@log
def select_all(self):
"""Cannot select songs from EmptyView."""
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index e518f9e7..69f0c0b6 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -173,6 +173,9 @@ class Window(Gtk.ApplicationWindow):
self._app.props.coremodel.connect(
"notify::songs-available", self._on_songs_available)
+ self._app.props.coremodel._grilo.connect(
+ "notify::tracker-available", self._on_tracker_available)
+
if self._app.props.coremodel.props.songs_available:
self._switch_to_player_view()
else:
@@ -182,18 +185,17 @@ class Window(Gtk.ApplicationWindow):
def _switch_to_empty_view(self):
did_initial_state = self._settings.get_boolean('did-initial-state')
- # FIXME: Tracker just checks for TrackerWrapper right now.
- # It should also check for the viability of certain queries to
- # make sure we have a recent version available.
state = self._app.props.coremodel._grilo.props.tracker_available
- if (state == TrackerState.UNAVAILABLE
- or state == TrackerState.OUTDATED):
- self.views[View.EMPTY].props.state = EmptyView.State.NO_TRACKER
+ empty_view = self.views[View.EMPTY]
+ if state == TrackerState.UNAVAILABLE:
+ empty_view.props.state = EmptyView.State.NO_TRACKER
+ elif state == TrackerState.OUTDATED:
+ empty_view.props.state = EmptyView.State.TRACKER_OUTDATED
elif did_initial_state:
- self.views[View.EMPTY].props.state = EmptyView.State.EMPTY
+ empty_view.props.state = EmptyView.State.EMPTY
else:
# FIXME: On switch back this view does not show properly.
- self.views[View.EMPTY].props.state = EmptyView.State.INITIAL
+ empty_view.props.state = EmptyView.State.INITIAL
self._headerbar.props.state = HeaderBar.State.EMPTY
@@ -203,6 +205,12 @@ class Window(Gtk.ApplicationWindow):
else:
self._switch_to_empty_view()
+ def _on_tracker_available(self, klass, value):
+ new_state = self._app.props.coremodel._grilo.props.tracker_available
+
+ if new_state != TrackerState.AVAILABLE:
+ self._switch_to_empty_view()
+
@log
def _switch_to_player_view(self):
self._settings.set_boolean('did-initial-state', True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]