[gnome-music] view: show No Music view if XDG user dirs are not set
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] view: show No Music view if XDG user dirs are not set
- Date: Tue, 6 Jan 2015 11:11:16 +0000 (UTC)
commit 0444ce2f79534729f126ac83de53506a3320f67a
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Tue Jan 6 12:10:39 2015 +0100
view: show No Music view if XDG user dirs are not set
https://bugzilla.gnome.org/show_bug.cgi?id=731613
gnomemusic/query.py | 28 +++++++++++++++++-----------
gnomemusic/window.py | 29 +++++++++++++++++------------
2 files changed, 34 insertions(+), 23 deletions(-)
---
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index a208a41..dd7f4fa 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -33,18 +33,24 @@ logger = logging.getLogger(__name__)
class Query():
- music_folder = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
- MUSIC_URI = Tracker.sparql_escape_string(GLib.filename_to_uri(music_folder))
- download_folder = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOWNLOAD)
- DOWNLOAD_URI = Tracker.sparql_escape_string(GLib.filename_to_uri(download_folder))
-
- for folder in [music_folder, download_folder]:
- if os.path.islink(folder):
- logger.warn("%s is a symlink, this folder will be omitted" % folder)
- else:
- i = len(next(os.walk(folder))[2])
- logger.debug("Found %d files in %s" % (i, folder))
+ music_folder = None
+ MUSIC_URI = None
+ download_folder = None
+ DOWNLOAD_URI = None
+ try:
+ music_folder = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
+ MUSIC_URI = Tracker.sparql_escape_string(GLib.filename_to_uri(music_folder))
+ download_folder = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOWNLOAD)
+ DOWNLOAD_URI = Tracker.sparql_escape_string(GLib.filename_to_uri(download_folder))
+ for folder in [music_folder, download_folder]:
+ if os.path.islink(folder):
+ logger.warn("%s is a symlink, this folder will be omitted" % folder)
+ else:
+ i = len(next(os.walk(folder))[2])
+ logger.debug("Found %d files in %s" % (i, folder))
+ except TypeError:
+ logger.warn("XDG user dirs are not set")
@staticmethod
def order_by_statement(attr):
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 6edbe97..b98b341 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -197,20 +197,25 @@ class Window(Gtk.ApplicationWindow):
self.add(self._box)
count = 1
cursor = None
- try:
- cursor = tracker.query(Query.all_songs_count(), None)
- except Exception as e:
- logger.error("Tracker query crashed: %s" % e)
- count = 0
- if cursor is not None and cursor.next(None):
- count = cursor.get_integer(0)
- if count > 0:
- self._switch_to_player_view()
- # To revert to the No Music View when no songs are found
+ if Query.music_folder and Query.download_folder:
+ try:
+ cursor = tracker.query(Query.all_songs_count(), None)
+ except Exception as e:
+ logger.error("Tracker query crashed: %s" % e)
+ count = 0
+
+ if cursor is not None and cursor.next(None):
+ count = cursor.get_integer(0)
+ if count > 0:
+ self._switch_to_player_view()
+ # To revert to the No Music View when no songs are found
+ else:
+ if self.toolbar._selectionMode is False:
+ self._switch_to_empty_view()
else:
- if self.toolbar._selectionMode is False:
- self._switch_to_empty_view()
+ # Revert to No Music view if XDG dirs are not set
+ self._switch_to_empty_view()
self.toolbar._search_button.connect('toggled', self._on_search_toggled)
self.toolbar.connect('selection-mode-changed', self._on_selection_mode_changed)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]