Add status information to new Server panel (close #37)
This commit is contained in:
parent
ccd355d4c2
commit
fe1b60ea17
3 changed files with 184 additions and 4 deletions
137
data/gtk.glade
137
data/gtk.glade
|
|
@ -571,6 +571,143 @@
|
||||||
<object class="GtkStack" id="server-stack">
|
<object class="GtkStack" id="server-stack">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child type="center">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child type="center">
|
||||||
|
<object class="GtkGrid">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="row_spacing">2</property>
|
||||||
|
<property name="column_spacing">5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="label" translatable="yes">file:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="label" translatable="yes">audio:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="label" translatable="yes">bitrate:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="label" translatable="yes">error:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="server-status-bitrate">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="selectable">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="server-status-audio">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="selectable">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="server-status-file">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="selectable">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="server-status-error">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="selectable">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">page0</property>
|
||||||
|
<property name="title" translatable="yes">Status</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
||||||
|
|
@ -375,10 +375,14 @@ class Client(Base):
|
||||||
if 'error' in status:
|
if 'error' in status:
|
||||||
error = status['error']
|
error = status['error']
|
||||||
# Album
|
# Album
|
||||||
|
file = None
|
||||||
album = None
|
album = None
|
||||||
pos = 0
|
pos = 0
|
||||||
song = self._parse_dict(self._call("currentsong"))
|
song = self._parse_dict(self._call("currentsong"))
|
||||||
if song:
|
if song:
|
||||||
|
# File
|
||||||
|
if 'file' in song:
|
||||||
|
file = song['file']
|
||||||
# Track
|
# Track
|
||||||
track = self._extract_playlist_track(song)
|
track = self._extract_playlist_track(song)
|
||||||
if track:
|
if track:
|
||||||
|
|
@ -391,7 +395,15 @@ class Client(Base):
|
||||||
album = palbum
|
album = palbum
|
||||||
break
|
break
|
||||||
pos = pos - len(palbum.get_tracks())
|
pos = pos - len(palbum.get_tracks())
|
||||||
self._callback(Client.SIGNAL_STATUS, state, album, pos, time, volume, error)
|
# Audio
|
||||||
|
audio = None
|
||||||
|
if 'audio' in status:
|
||||||
|
audio = status['audio']
|
||||||
|
# Bitrate
|
||||||
|
bitrate = None
|
||||||
|
if 'bitrate' in status:
|
||||||
|
bitrate = status['bitrate']
|
||||||
|
self._callback(Client.SIGNAL_STATUS, state, album, pos, time, volume, file, audio, bitrate, error)
|
||||||
|
|
||||||
|
|
||||||
def _load_albums(self):
|
def _load_albums(self):
|
||||||
|
|
|
||||||
|
|
@ -361,7 +361,7 @@ class Window():
|
||||||
self._panel_action.set_enabled(False)
|
self._panel_action.set_enabled(False)
|
||||||
|
|
||||||
|
|
||||||
def on_mcg_status(self, state, album, pos, time, volume, error):
|
def on_mcg_status(self, state, album, pos, time, volume, file, audio, bitrate, error):
|
||||||
# Album
|
# Album
|
||||||
GObject.idle_add(self._panels[Window._PANEL_INDEX_COVER].set_album, album)
|
GObject.idle_add(self._panels[Window._PANEL_INDEX_COVER].set_album, album)
|
||||||
# State
|
# State
|
||||||
|
|
@ -375,6 +375,8 @@ class Window():
|
||||||
self._play_action.set_state(GLib.Variant.new_boolean(False))
|
self._play_action.set_state(GLib.Variant.new_boolean(False))
|
||||||
# Volume
|
# Volume
|
||||||
GObject.idle_add(self._header_bar.set_volume, volume)
|
GObject.idle_add(self._header_bar.set_volume, volume)
|
||||||
|
# Audio
|
||||||
|
self._panels[Window._PANEL_INDEX_SERVER].set_status(file, audio, bitrate, error)
|
||||||
# Error
|
# Error
|
||||||
if error is None:
|
if error is None:
|
||||||
self._infobar.hide()
|
self._infobar.hide()
|
||||||
|
|
@ -470,8 +472,7 @@ class Window():
|
||||||
def _save_visible_panel(self):
|
def _save_visible_panel(self):
|
||||||
panels = [panel.get() for panel in self._panels]
|
panels = [panel.get() for panel in self._panels]
|
||||||
panel_index_selected = panels.index(self._stack.get_visible_child())
|
panel_index_selected = panels.index(self._stack.get_visible_child())
|
||||||
if panel_index_selected > 0:
|
self._settings.set_int(Window.SETTING_PANEL, panel_index_selected)
|
||||||
self._settings.set_int(Window.SETTING_PANEL, panel_index_selected)
|
|
||||||
|
|
||||||
|
|
||||||
def _set_menu_visible_panel(self):
|
def _set_menu_visible_panel(self):
|
||||||
|
|
@ -803,6 +804,12 @@ class ServerPanel(GObject.GObject):
|
||||||
self._toolbar = builder.get_object('server-toolbar')
|
self._toolbar = builder.get_object('server-toolbar')
|
||||||
self._stack = builder.get_object('server-stack')
|
self._stack = builder.get_object('server-stack')
|
||||||
|
|
||||||
|
# Status widgets
|
||||||
|
self._status_file = builder.get_object('server-status-file')
|
||||||
|
self._status_audio = builder.get_object('server-status-audio')
|
||||||
|
self._status_bitrate = builder.get_object('server-status-bitrate')
|
||||||
|
self._status_error = builder.get_object('server-status-error')
|
||||||
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
return self._panel
|
return self._panel
|
||||||
|
|
@ -812,6 +819,30 @@ class ServerPanel(GObject.GObject):
|
||||||
return self._toolbar
|
return self._toolbar
|
||||||
|
|
||||||
|
|
||||||
|
def set_status(self, file, audio, bitrate, error):
|
||||||
|
if not file:
|
||||||
|
file = ""
|
||||||
|
self._status_file.set_text(file)
|
||||||
|
# Audio information
|
||||||
|
if audio:
|
||||||
|
parts = audio.split(":")
|
||||||
|
if len(parts) == 3:
|
||||||
|
audio = "{} Hz, {} bit, {} channels".format(parts[0], parts[1], parts[2])
|
||||||
|
else:
|
||||||
|
audio = ""
|
||||||
|
self._status_audio.set_text(audio)
|
||||||
|
# Bitrate
|
||||||
|
if bitrate:
|
||||||
|
bitrate = bitrate + " kb/s"
|
||||||
|
else:
|
||||||
|
bitrate = ""
|
||||||
|
self._status_bitrate.set_text(bitrate)
|
||||||
|
# Error
|
||||||
|
if not error:
|
||||||
|
error = ""
|
||||||
|
self._status_error.set_markup(error)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CoverPanel(GObject.GObject):
|
class CoverPanel(GObject.GObject):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue