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:
coderkun 2020-03-22 00:19:45 +01:00
parent 14d56452b6
commit 477f89cc0b
7 changed files with 138 additions and 112 deletions

View file

@ -1708,10 +1708,12 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="library-progress-label">
<object class="GtkProgressBar" id="library-progress">
<property name="width_request">200</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">{} of {} images loaded</property>
<property name="pulse_step">0.01</property>
<property name="show_text">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -1719,19 +1721,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="library-progress">
<property name="width_request">200</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="fraction">0.5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

Binary file not shown.

View file

@ -1,15 +1,15 @@
msgid ""
msgstr ""
"Project-Id-Version: CoverGrid (mcg)\n"
"POT-Creation-Date: 2019-02-16 23:50+0100\n"
"PO-Revision-Date: 2019-02-16 23:51+0100\n"
"POT-Creation-Date: 2020-03-22 00:15+0100\n"
"PO-Revision-Date: 2020-03-22 00:16+0100\n"
"Last-Translator: coderkun <olli@suruatoel.xyz>\n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.1\n"
"X-Generator: Poedit 2.3\n"
"X-Poedit-Basepath: ../../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
@ -42,151 +42,147 @@ msgstr "nach Titel"
msgid "sort by year"
msgstr "nach Jahr"
#: data/gtk.glade:292 data/gtk.shortcuts.ui:74
#: data/gtk.glade:293 data/gtk.shortcuts.ui:74
msgid "Connect or disconnect"
msgstr "Die Verbindung herstellen oder trennen"
#: data/gtk.glade:314 data/gtk.shortcuts.ui:81
#: data/gtk.glade:315 data/gtk.shortcuts.ui:81
msgid "Switch between play and pause"
msgstr "Zwischen Abspielen und Pause wechseln"
#: data/gtk.glade:334
#: data/gtk.glade:335
msgid "Adjust the volume"
msgstr "Die Lautstärke anpassen"
#: data/gtk.glade:378
#: data/gtk.glade:379
msgid "Connect to MPD"
msgstr "Zu MPD verbinden"
#: data/gtk.glade:420 data/gtk.shortcuts.ui:101
#: data/gtk.glade:421 data/gtk.shortcuts.ui:101
msgid "Show the cover in fullscreen mode"
msgstr "Das Cover im Vollbildmodus anzeigen"
#: data/gtk.glade:469 data/gtk.glade:548
#: data/gtk.glade:470 data/gtk.glade:549
msgid "Select multiple albums"
msgstr "Mehrere Alben auswählen"
#: data/gtk.glade:491 data/gtk.shortcuts.ui:88
#: data/gtk.glade:492 data/gtk.shortcuts.ui:88
msgid "Clear the playlist"
msgstr "Die Wiedergabeliste leeren"
#: data/gtk.glade:525 data/gtk.shortcuts.ui:114
#: data/gtk.glade:526 data/gtk.shortcuts.ui:114
msgid "Search the library"
msgstr "Die Bibliothek durchsuchen"
#: data/gtk.glade:570
#: data/gtk.glade:571
msgid "Settings and actions"
msgstr "Einstellungen und Aktionen"
#: data/gtk.glade:675
#: data/gtk.glade:676
msgid "Enter hostname or IP address"
msgstr "Hostnamen oder IP-Adresse eingeben"
#: data/gtk.glade:687
#: data/gtk.glade:688
msgid "Enter URL or local path"
msgstr "URL oder lokalen Pfad eingeben"
#: data/gtk.glade:700
#: data/gtk.glade:701
msgid "Enter password or leave blank"
msgstr "Passwort eingeben oder leer lassen"
#: data/gtk.glade:728
#: data/gtk.glade:729
msgid "Host:"
msgstr "Host:"
#: data/gtk.glade:740
#: data/gtk.glade:741
msgid "Port:"
msgstr "Port:"
#: data/gtk.glade:752
#: data/gtk.glade:753
msgid "Password:"
msgstr "Passwort:"
#: data/gtk.glade:764
#: data/gtk.glade:765
msgid "Image Directory:"
msgstr "Bildordner:"
#: data/gtk.glade:865
#: data/gtk.glade:866
msgid "File:"
msgstr "Datei:"
#: data/gtk.glade:878
#: data/gtk.glade:879
msgid "Audio:"
msgstr "Audio:"
#: data/gtk.glade:891
#: data/gtk.glade:892
msgid "Bitrate:"
msgstr "Bitrate:"
#: data/gtk.glade:904
#: data/gtk.glade:905
msgid "Error:"
msgstr "Fehler:"
#: data/gtk.glade:916 data/gtk.glade:932 data/gtk.glade:948 data/gtk.glade:964
#: data/gtk.glade:917 data/gtk.glade:933 data/gtk.glade:949 data/gtk.glade:965
msgid "<i>none</i>"
msgstr "<i>nichts</i>"
#: data/gtk.glade:999
#: data/gtk.glade:1000
msgid "Status"
msgstr "Status"
#: data/gtk.glade:1084
#: data/gtk.glade:1085
msgid "Albums"
msgstr "Alben"
#: data/gtk.glade:1096
#: data/gtk.glade:1097
msgid "Songs"
msgstr "Songs"
#: data/gtk.glade:1108
#: data/gtk.glade:1109
msgid "Artists"
msgstr "Künstler"
#: data/gtk.glade:1132
#: data/gtk.glade:1133
msgid "Seconds"
msgstr "Sekunden"
#: data/gtk.glade:1179
#: data/gtk.glade:1180
msgid "Seconds played"
msgstr "Sekunden gespielt"
#: data/gtk.glade:1190
#: data/gtk.glade:1191
msgid "Seconds running"
msgstr "Sekunden laufend"
#: data/gtk.glade:1221
#: data/gtk.glade:1222
msgid "Statistics"
msgstr "Statistiken"
#: data/gtk.glade:1291
#: data/gtk.glade:1292
msgid "Audio Devices"
msgstr "Audiogeräte"
#: data/gtk.glade:1305
#: data/gtk.glade:1306
msgid "Server"
msgstr "Server"
#: data/gtk.glade:1486 data/gtk.menu.ui:30
#: data/gtk.glade:1487 data/gtk.menu.ui:30
msgid "Cover"
msgstr "Cover"
#: data/gtk.glade:1628 data/gtk.menu.ui:36
#: data/gtk.glade:1629 data/gtk.menu.ui:36
msgid "Playlist"
msgstr "Wiedergabeliste"
#: data/gtk.glade:1655
#: data/gtk.glade:1656
msgid "search library"
msgstr "Bibliothek durchsuchen"
#: data/gtk.glade:1713
msgid "{} of {} images loaded"
msgstr "{} von {} Bildern geladen"
#: data/gtk.glade:1891 data/gtk.menu.ui:42
#: data/gtk.glade:1881 data/gtk.menu.ui:42
msgid "Library"
msgstr "Bibliothek"
#: data/gtk.glade:1974
#: data/gtk.glade:1964
msgid ""
"CoverGrid is a client for the Music Player Daemon, focusing on albums "
"instead of single tracks."
@ -270,22 +266,33 @@ msgstr "Bibliothekspaneel"
msgid "{} feat. {}"
msgstr "{} mit {}"
#: mcg/widgets.py:1267 mcg/widgets.py:1601
#: mcg/widgets.py:1281 mcg/widgets.py:1621
msgid "cancel"
msgstr "abbrechen"
#: mcg/widgets.py:1284 mcg/widgets.py:1618
#: mcg/widgets.py:1298 mcg/widgets.py:1638
msgid "play"
msgstr "abspielen"
#: mcg/widgets.py:1287
#: mcg/widgets.py:1301
msgid "remove"
msgstr "entfernen"
#: mcg/widgets.py:1604 mcg/widgets.py:1621
#: mcg/widgets.py:1624 mcg/widgets.py:1641
msgid "queue"
msgstr "einreihen"
#: mcg/widgets.py:1873
msgid "Loading albums"
msgstr "Alben werden geladen"
#: mcg/widgets.py:1954
msgid "Loading images"
msgstr "Bilder werden geladen"
#~ msgid "{} of {} images loaded"
#~ msgstr "{} von {} Bildern geladen"
#~ msgid "Tracklist"
#~ msgstr "Titelliste"

Binary file not shown.

View file

@ -1,15 +1,15 @@
msgid ""
msgstr ""
"Project-Id-Version: CoverGrid (mcg)\n"
"POT-Creation-Date: 2019-02-16 23:52+0100\n"
"PO-Revision-Date: 2019-02-16 23:52+0100\n"
"POT-Creation-Date: 2020-03-22 00:16+0100\n"
"PO-Revision-Date: 2020-03-22 00:16+0100\n"
"Last-Translator: coderkun <olli@suruatoel.xyz>\n"
"Language-Team: \n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.1\n"
"X-Generator: Poedit 2.3\n"
"X-Poedit-Basepath: ../../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: data/gtk.glade\n"
@ -41,151 +41,147 @@ msgstr "by Title"
msgid "sort by year"
msgstr "by Year"
#: data/gtk.glade:292 data/gtk.shortcuts.ui:74
#: data/gtk.glade:293 data/gtk.shortcuts.ui:74
msgid "Connect or disconnect"
msgstr "Connect or disconnect"
#: data/gtk.glade:314 data/gtk.shortcuts.ui:81
#: data/gtk.glade:315 data/gtk.shortcuts.ui:81
msgid "Switch between play and pause"
msgstr "Switch between play and pause"
#: data/gtk.glade:334
#: data/gtk.glade:335
msgid "Adjust the volume"
msgstr "Adjust the volume"
#: data/gtk.glade:378
#: data/gtk.glade:379
msgid "Connect to MPD"
msgstr "Connect to MPD"
#: data/gtk.glade:420 data/gtk.shortcuts.ui:101
#: data/gtk.glade:421 data/gtk.shortcuts.ui:101
msgid "Show the cover in fullscreen mode"
msgstr "Show the cover in fullscreen mode"
#: data/gtk.glade:469 data/gtk.glade:548
#: data/gtk.glade:470 data/gtk.glade:549
msgid "Select multiple albums"
msgstr "Select multiple albums"
#: data/gtk.glade:491 data/gtk.shortcuts.ui:88
#: data/gtk.glade:492 data/gtk.shortcuts.ui:88
msgid "Clear the playlist"
msgstr "Clear the playlist"
#: data/gtk.glade:525 data/gtk.shortcuts.ui:114
#: data/gtk.glade:526 data/gtk.shortcuts.ui:114
msgid "Search the library"
msgstr "Search the library"
#: data/gtk.glade:570
#: data/gtk.glade:571
msgid "Settings and actions"
msgstr "Settings and actions"
#: data/gtk.glade:675
#: data/gtk.glade:676
msgid "Enter hostname or IP address"
msgstr "Enter hostname or IP address"
#: data/gtk.glade:687
#: data/gtk.glade:688
msgid "Enter URL or local path"
msgstr "Enter URL or local path"
#: data/gtk.glade:700
#: data/gtk.glade:701
msgid "Enter password or leave blank"
msgstr "Enter password or leave blank"
#: data/gtk.glade:728
#: data/gtk.glade:729
msgid "Host:"
msgstr "Host:"
#: data/gtk.glade:740
#: data/gtk.glade:741
msgid "Port:"
msgstr "Port:"
#: data/gtk.glade:752
#: data/gtk.glade:753
msgid "Password:"
msgstr "Password:"
#: data/gtk.glade:764
#: data/gtk.glade:765
msgid "Image Directory:"
msgstr "Image Directory:"
#: data/gtk.glade:865
#: data/gtk.glade:866
msgid "File:"
msgstr "File:"
#: data/gtk.glade:878
#: data/gtk.glade:879
msgid "Audio:"
msgstr "Audio:"
#: data/gtk.glade:891
#: data/gtk.glade:892
msgid "Bitrate:"
msgstr "Bitrate:"
#: data/gtk.glade:904
#: data/gtk.glade:905
msgid "Error:"
msgstr "Error:"
#: data/gtk.glade:916 data/gtk.glade:932 data/gtk.glade:948 data/gtk.glade:964
#: data/gtk.glade:917 data/gtk.glade:933 data/gtk.glade:949 data/gtk.glade:965
msgid "<i>none</i>"
msgstr "<i>none</i>"
#: data/gtk.glade:999
#: data/gtk.glade:1000
msgid "Status"
msgstr "Status"
#: data/gtk.glade:1084
#: data/gtk.glade:1085
msgid "Albums"
msgstr "Albums"
#: data/gtk.glade:1096
#: data/gtk.glade:1097
msgid "Songs"
msgstr "Songs"
#: data/gtk.glade:1108
#: data/gtk.glade:1109
msgid "Artists"
msgstr "Artists"
#: data/gtk.glade:1132
#: data/gtk.glade:1133
msgid "Seconds"
msgstr "Seconds"
#: data/gtk.glade:1179
#: data/gtk.glade:1180
msgid "Seconds played"
msgstr "Seconds"
#: data/gtk.glade:1190
#: data/gtk.glade:1191
msgid "Seconds running"
msgstr "Seconds running"
#: data/gtk.glade:1221
#: data/gtk.glade:1222
msgid "Statistics"
msgstr "Statistics"
#: data/gtk.glade:1291
#: data/gtk.glade:1292
msgid "Audio Devices"
msgstr "Audio Devices"
#: data/gtk.glade:1305
#: data/gtk.glade:1306
msgid "Server"
msgstr "Server"
#: data/gtk.glade:1486 data/gtk.menu.ui:30
#: data/gtk.glade:1487 data/gtk.menu.ui:30
msgid "Cover"
msgstr "Cover"
#: data/gtk.glade:1628 data/gtk.menu.ui:36
#: data/gtk.glade:1629 data/gtk.menu.ui:36
msgid "Playlist"
msgstr "Playlist"
#: data/gtk.glade:1655
#: data/gtk.glade:1656
msgid "search library"
msgstr "search library"
#: data/gtk.glade:1713
msgid "{} of {} images loaded"
msgstr "{} of {} images loaded"
#: data/gtk.glade:1891 data/gtk.menu.ui:42
#: data/gtk.glade:1881 data/gtk.menu.ui:42
msgid "Library"
msgstr "Library"
#: data/gtk.glade:1974
#: data/gtk.glade:1964
msgid ""
"CoverGrid is a client for the Music Player Daemon, focusing on albums "
"instead of single tracks."
@ -269,22 +265,33 @@ msgstr "Library Panel"
msgid "{} feat. {}"
msgstr "{} feat. {}"
#: mcg/widgets.py:1267 mcg/widgets.py:1601
#: mcg/widgets.py:1281 mcg/widgets.py:1621
msgid "cancel"
msgstr "cancel"
#: mcg/widgets.py:1284 mcg/widgets.py:1618
#: mcg/widgets.py:1298 mcg/widgets.py:1638
msgid "play"
msgstr "play"
#: mcg/widgets.py:1287
#: mcg/widgets.py:1301
msgid "remove"
msgstr "remove"
#: mcg/widgets.py:1604 mcg/widgets.py:1621
#: mcg/widgets.py:1624 mcg/widgets.py:1641
msgid "queue"
msgstr "queue"
#: mcg/widgets.py:1873
msgid "Loading albums"
msgstr "Loading albums"
#: mcg/widgets.py:1954
msgid "Loading images"
msgstr "Loading images"
#~ msgid "{} of {} images loaded"
#~ msgstr "{} of {} images loaded"
#~ msgid "Tracklist"
#~ msgstr "Tracklist"

View file

@ -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)

View file

@ -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