[gnome-music/wip/jfelder/tracker-not-found-view: 2/2] app: Display an empty view when tracker cannot be found
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/tracker-not-found-view: 2/2] app: Display an empty view when tracker cannot be found
- Date: Thu, 31 Jan 2019 07:45:13 +0000 (UTC)
commit 33b1617d0fb3e75862bb9edd36d557090d8aaf3c
Author: Jean Felder <jfelder src gnome org>
Date: Wed Jan 30 11:26:44 2019 +0100
app: Display an empty view when tracker cannot be found
This new empty view is displayed if Tracker is not installed on the
system.
Closes: #165
gnomemusic/__init__.py | 6 ++----
gnomemusic/grilo.py | 9 +++++++++
gnomemusic/views/emptyview.py | 15 ++++++++++++++-
gnomemusic/window.py | 4 +++-
4 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/__init__.py b/gnomemusic/__init__.py
index 6da3044c..1deeccfc 100644
--- a/gnomemusic/__init__.py
+++ b/gnomemusic/__init__.py
@@ -81,14 +81,12 @@ class TrackerWrapper(GObject.GObject):
"""Create a connection to an instance of Tracker"""
def __init__(self):
- self._tracker = None
try:
self._tracker = Tracker.SparqlConnection.get(None)
except Exception as e:
- from sys import exit
+ self._tracker = None
logger.error(
- "Cannot connect to tracker, error {}\nExiting".format(str(e)))
- exit(1)
+ "Cannot connect to tracker, error {}\n".format(str(e)))
@GObject.Property(type=object, flags=GObject.ParamFlags.READABLE)
def tracker(self):
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 5f90e41f..73716d67 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -506,8 +506,17 @@ class Grilo(GObject.GObject):
# TODO: currently just checks tracker, should work with any
# queryable supported Grilo source.
+ if not self.props.tracker_available:
+ callback(False)
+ return
+
self.sparqltracker.query_async(Query.all_songs_count(), None,
songs_query_cb, None)
+ @GObject.Property(
+ type=bool, default=False, flags=GObject.ParamFlags.READABLE)
+ def tracker_available(self):
+ return self.sparqltracker is not None
+
grilo = Grilo()
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index ff31654d..f44869e0 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -48,6 +48,7 @@ class EmptyView(Gtk.Stack):
INITIAL = 0
EMPTY = 1
SEARCH = 2
+ NO_TRACKER = 3
__gtype_name__ = "EmptyView"
@@ -72,7 +73,7 @@ class EmptyView(Gtk.Stack):
self._state = EmptyView.State.INITIAL
- @GObject.Property(type=int, default=0, minimum=0, maximum=2)
+ @GObject.Property(type=int, default=0, minimum=0, maximum=3)
def state(self):
"""Get the state of the empty view
@@ -94,6 +95,8 @@ class EmptyView(Gtk.Stack):
self._set_empty_state()
elif self._state == EmptyView.State.SEARCH:
self._set_search_state()
+ elif self._state == EmptyView.State.NO_TRACKER:
+ self._set_no_tracker_state()
self.show_all()
@log
@@ -118,3 +121,13 @@ class EmptyView(Gtk.Stack):
self._main_label.props.label = _("No music found")
self._icon.props.margin_bottom = 18
self._information_label.props.label = _("Try a different search")
+
+ @log
+ def _set_no_tracker_state(self):
+ self._main_label.props.margin_bottom = 12
+ self._main_label.props.label = _(
+ "Unable to find Tracker on your operating system")
+ self._icon.props.margin_bottom = 18
+ self._information_label.props.label = ""
+
+ self._icon.props.icon_name = "dialog-error"
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 539642a4..dd20b350 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -201,7 +201,9 @@ class Window(Gtk.ApplicationWindow):
def _switch_to_empty_view(self):
did_initial_state = self._settings.get_boolean('did-initial-state')
- if did_initial_state:
+ if not grilo.props.tracker_available:
+ self.views[View.EMPTY].props.state = EmptyView.State.NO_TRACKER
+ elif did_initial_state:
self.views[View.EMPTY].props.state = EmptyView.State.EMPTY
else:
self.views[View.EMPTY].props.state = EmptyView.State.INITIAL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]