Resolves #54 fixes the explosions when no server is configured
This commit is contained in:
@@ -153,8 +153,9 @@ class SublimeMusicApp(Gtk.Application):
|
|||||||
if (self.state.config.current_server is None
|
if (self.state.config.current_server is None
|
||||||
or self.state.config.current_server < 0):
|
or self.state.config.current_server < 0):
|
||||||
self.show_configure_servers_dialog()
|
self.show_configure_servers_dialog()
|
||||||
if self.state.config.current_server is None:
|
if self.current_server is None:
|
||||||
self.window.close()
|
self.window.close()
|
||||||
|
return
|
||||||
|
|
||||||
self.update_window()
|
self.update_window()
|
||||||
|
|
||||||
@@ -230,11 +231,14 @@ class SublimeMusicApp(Gtk.Application):
|
|||||||
|
|
||||||
# ########## DBUS MANAGMENT ########## #
|
# ########## DBUS MANAGMENT ########## #
|
||||||
def do_dbus_register(self, connection, path):
|
def do_dbus_register(self, connection, path):
|
||||||
|
def get_state_and_player():
|
||||||
|
return (self.state, getattr(self, 'player', None))
|
||||||
|
|
||||||
self.dbus_manager = DBusManager(
|
self.dbus_manager = DBusManager(
|
||||||
connection,
|
connection,
|
||||||
self.on_dbus_method_call,
|
self.on_dbus_method_call,
|
||||||
self.on_dbus_set_property,
|
self.on_dbus_set_property,
|
||||||
lambda: (self.state, self.player),
|
get_state_and_player,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -650,6 +654,10 @@ class SublimeMusicApp(Gtk.Application):
|
|||||||
|
|
||||||
def on_app_shutdown(self, app):
|
def on_app_shutdown(self, app):
|
||||||
Notify.uninit()
|
Notify.uninit()
|
||||||
|
|
||||||
|
if self.current_server is None:
|
||||||
|
return
|
||||||
|
|
||||||
self.player.pause()
|
self.player.pause()
|
||||||
self.chromecast_player.shutdown()
|
self.chromecast_player.shutdown()
|
||||||
self.mpv_player.shutdown()
|
self.mpv_player.shutdown()
|
||||||
@@ -662,6 +670,8 @@ class SublimeMusicApp(Gtk.Application):
|
|||||||
# ########## PROPERTIES ########## #
|
# ########## PROPERTIES ########## #
|
||||||
@property
|
@property
|
||||||
def current_server(self):
|
def current_server(self):
|
||||||
|
if len(self.state.config.servers) < 1:
|
||||||
|
return None
|
||||||
return self.state.config.servers[self.state.config.current_server]
|
return self.state.config.servers[self.state.config.current_server]
|
||||||
|
|
||||||
# ########## HELPER METHODS ########## #
|
# ########## HELPER METHODS ########## #
|
||||||
|
@@ -72,6 +72,10 @@ class CacheManager(metaclass=Singleton):
|
|||||||
executor: ThreadPoolExecutor = ThreadPoolExecutor(max_workers=50)
|
executor: ThreadPoolExecutor = ThreadPoolExecutor(max_workers=50)
|
||||||
should_exit: bool = False
|
should_exit: bool = False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def ready():
|
||||||
|
return CacheManager._instance is not None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def shutdown():
|
def shutdown():
|
||||||
# TODO fix this shutdown
|
# TODO fix this shutdown
|
||||||
|
@@ -208,7 +208,7 @@ class DBusManager:
|
|||||||
(False, True): 'Stopped',
|
(False, True): 'Stopped',
|
||||||
(True, False): 'Paused',
|
(True, False): 'Paused',
|
||||||
(True, True): 'Playing',
|
(True, True): 'Playing',
|
||||||
}[player.song_loaded, state.playing],
|
}[player is not None and player.song_loaded, state.playing],
|
||||||
'LoopStatus':
|
'LoopStatus':
|
||||||
state.repeat_type.as_mpris_loop_status(),
|
state.repeat_type.as_mpris_loop_status(),
|
||||||
'Rate':
|
'Rate':
|
||||||
@@ -250,7 +250,9 @@ class DBusManager:
|
|||||||
'org.mpris.MediaPlayer2.Playlists': {
|
'org.mpris.MediaPlayer2.Playlists': {
|
||||||
# TODO this may do a network request. This really is a case for
|
# TODO this may do a network request. This really is a case for
|
||||||
# doing the whole thing with caching some data beforehand.
|
# doing the whole thing with caching some data beforehand.
|
||||||
'PlaylistCount': len(CacheManager.get_playlists().result()),
|
'PlaylistCount': (
|
||||||
|
0 if not CacheManager.ready() else len(
|
||||||
|
CacheManager.get_playlists().result())),
|
||||||
'Orderings': ['Alphabetical', 'Created', 'Modified'],
|
'Orderings': ['Alphabetical', 'Created', 'Modified'],
|
||||||
'ActivePlaylist': ('(b(oss))', active_playlist),
|
'ActivePlaylist': ('(b(oss))', active_playlist),
|
||||||
},
|
},
|
||||||
|
@@ -115,6 +115,9 @@ class AlbumsPanel(Gtk.Box):
|
|||||||
state: ApplicationState,
|
state: ApplicationState,
|
||||||
force: bool = False,
|
force: bool = False,
|
||||||
):
|
):
|
||||||
|
if not CacheManager.ready():
|
||||||
|
return
|
||||||
|
|
||||||
def get_genres_done(f):
|
def get_genres_done(f):
|
||||||
new_store = [
|
new_store = [
|
||||||
(genre.value, genre.value) for genre in (f.result() or [])
|
(genre.value, genre.value) for genre in (f.result() or [])
|
||||||
@@ -404,6 +407,11 @@ class AlbumsGrid(Gtk.ScrolledWindow):
|
|||||||
children[0].update(force=force)
|
children[0].update(force=force)
|
||||||
|
|
||||||
def update_grid(self, force=False, selected_id=None):
|
def update_grid(self, force=False, selected_id=None):
|
||||||
|
if not CacheManager.ready():
|
||||||
|
self.spinner.hide()
|
||||||
|
self.continuation_spinner.hide()
|
||||||
|
return
|
||||||
|
|
||||||
def reflow_grid(force_reload, selected_index):
|
def reflow_grid(force_reload, selected_index):
|
||||||
selection_changed = (selected_index != self.current_selection)
|
selection_changed = (selected_index != self.current_selection)
|
||||||
self.current_selection = selected_index
|
self.current_selection = selected_index
|
||||||
|
Reference in New Issue
Block a user