Init progress bar on Library panel (close #49)
Introduce two new callbacks for this: one when initializing the loading of albums and another one on handling the loading of each album. Use the first one to initialize and the second one to pulse the progress bar on the Library panel. Additionally use the text of the progress as status label instead of a separate label widget.
This commit is contained in:
parent
14d56452b6
commit
477f89cc0b
7 changed files with 137 additions and 111 deletions
|
|
@ -110,6 +110,10 @@ class Client(Base):
|
|||
SIGNAL_STATUS = 'status'
|
||||
# Signal: stats
|
||||
SIGNAL_STATS = 'stats'
|
||||
# Signal: init loading of albums
|
||||
SIGNAL_INIT_ALBUMS = 'init-albums'
|
||||
# Signal: pulse loading of albums
|
||||
SIGNAL_PULSE_ALBUMS = 'pulse-albums'
|
||||
# Signal: load albums
|
||||
SIGNAL_LOAD_ALBUMS = 'load-albums'
|
||||
# Signal: load playlist
|
||||
|
|
@ -498,9 +502,12 @@ class Client(Base):
|
|||
|
||||
def _load_albums(self):
|
||||
"""Action: Perform the real update."""
|
||||
self._callback(Client.SIGNAL_INIT_ALBUMS)
|
||||
self._albums = {}
|
||||
# Albums
|
||||
for album in self._parse_list(self._call('list album'), ['album']):
|
||||
self._callback(Client.SIGNAL_PULSE_ALBUMS)
|
||||
|
||||
# Album
|
||||
album = self._extract_album(album)
|
||||
self._logger.debug("album: %r", album)
|
||||
|
|
|
|||
|
|
@ -179,6 +179,8 @@ class Window():
|
|||
self._mcg.connect_signal(client.Client.SIGNAL_STATS, self.on_mcg_stats)
|
||||
self._mcg.connect_signal(client.Client.SIGNAL_LOAD_OUTPUT_DEVICES, self.on_mcg_load_output_devices)
|
||||
self._mcg.connect_signal(client.Client.SIGNAL_LOAD_PLAYLIST, self.on_mcg_load_playlist)
|
||||
self._mcg.connect_signal(client.Client.SIGNAL_PULSE_ALBUMS, self.on_mcg_pulse_albums)
|
||||
self._mcg.connect_signal(client.Client.SIGNAL_INIT_ALBUMS, self.on_mcg_init_albums)
|
||||
self._mcg.connect_signal(client.Client.SIGNAL_LOAD_ALBUMS, self.on_mcg_load_albums)
|
||||
self._mcg.connect_signal(client.Client.SIGNAL_CUSTOM, self.on_mcg_custom)
|
||||
self._mcg.connect_signal(client.Client.SIGNAL_ERROR, self.on_mcg_error)
|
||||
|
|
@ -430,6 +432,14 @@ class Window():
|
|||
self._panels[self._PANEL_INDEX_PLAYLIST].set_playlist(self._connection_panel.get_host(), playlist)
|
||||
|
||||
|
||||
def on_mcg_init_albums(self):
|
||||
GObject.idle_add(self._panels[self._PANEL_INDEX_LIBRARY].init_albums)
|
||||
|
||||
|
||||
def on_mcg_pulse_albums(self):
|
||||
GObject.idle_add(self._panels[self._PANEL_INDEX_LIBRARY].load_albums)
|
||||
|
||||
|
||||
def on_mcg_load_albums(self, albums):
|
||||
self._panels[self._PANEL_INDEX_LIBRARY].set_albums(self._connection_panel.get_host(), albums)
|
||||
|
||||
|
|
@ -1578,8 +1588,6 @@ class LibraryPanel(GObject.GObject):
|
|||
self._progress_box = builder.get_object('library-progress-box')
|
||||
self._pgross_image = builder.get_object('library-progress-image')
|
||||
self._pgross_image.set_from_pixbuf(self._get_default_image())
|
||||
self._progress_label = builder.get_object('library-progress-label')
|
||||
self._loading_text = self._progress_label.get_label()
|
||||
self._progress_bar = builder.get_object('library-progress')
|
||||
self._scroll = builder.get_object('library-scroll')
|
||||
# Toolbar menu
|
||||
|
|
@ -1859,6 +1867,14 @@ class LibraryPanel(GObject.GObject):
|
|||
return (self._sort_type != Gtk.SortType.ASCENDING)
|
||||
|
||||
|
||||
def init_albums(self):
|
||||
self._progress_bar.set_text(gettext.gettext("Loading albums"))
|
||||
|
||||
|
||||
def load_albums(self):
|
||||
self._progress_bar.pulse()
|
||||
|
||||
|
||||
def set_albums(self, host, albums):
|
||||
self._host = host
|
||||
self._library_stop.set()
|
||||
|
|
@ -1933,7 +1949,7 @@ class LibraryPanel(GObject.GObject):
|
|||
|
||||
i += 1
|
||||
GObject.idle_add(self._progress_bar.set_fraction, i/n)
|
||||
GObject.idle_add(self._progress_label.set_markup, self._loading_text.format(i, n))
|
||||
GObject.idle_add(self._progress_bar.set_text, gettext.gettext("Loading images"))
|
||||
if self._library_stop.is_set():
|
||||
self._library_lock.release()
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue