mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
commit
86caa2ccb0
32
bin/mpdevil
32
bin/mpdevil
@ -559,7 +559,7 @@ class EventEmitter(GObject.Object):
|
||||
"single": (GObject.SignalFlags.RUN_FIRST, None, (str,)),
|
||||
"consume": (GObject.SignalFlags.RUN_FIRST, None, (bool,)),
|
||||
"audio": (GObject.SignalFlags.RUN_FIRST, None, (str,)),
|
||||
"bitrate": (GObject.SignalFlags.RUN_FIRST, None, (float,)),
|
||||
"bitrate": (GObject.SignalFlags.RUN_FIRST, None, (str,)),
|
||||
"add_to_playlist": (GObject.SignalFlags.RUN_FIRST, None, (str,)),
|
||||
"show_info": (GObject.SignalFlags.RUN_FIRST, None, ())
|
||||
}
|
||||
@ -851,7 +851,10 @@ class Client(MPDClient):
|
||||
else:
|
||||
self.emitter.emit("elapsed_changed", 0.0, 0.0)
|
||||
elif key == "bitrate":
|
||||
self.emitter.emit("bitrate", float(val))
|
||||
if val == "0":
|
||||
self.emitter.emit("bitrate", None)
|
||||
else:
|
||||
self.emitter.emit("bitrate", val)
|
||||
elif key == "songid":
|
||||
self.emitter.emit("current_song_changed")
|
||||
elif key in ("state", "single", "audio"):
|
||||
@ -874,7 +877,7 @@ class Client(MPDClient):
|
||||
elif "updating_db" == key:
|
||||
self.emitter.emit("update")
|
||||
elif "bitrate" == key:
|
||||
self.emitter.emit("bitrate", 0.0)
|
||||
self.emitter.emit("bitrate", None)
|
||||
elif "audio" == key:
|
||||
self.emitter.emit("audio", None)
|
||||
self._last_status=status
|
||||
@ -3359,7 +3362,8 @@ class AudioFormat(Gtk.Box):
|
||||
super().__init__(spacing=6)
|
||||
self._client=client
|
||||
self._settings=settings
|
||||
self._top_label=Gtk.Label(xalign=1)
|
||||
self._file_type_label=Gtk.Label(xalign=1)
|
||||
self._separator_label=Gtk.Label(xalign=1)
|
||||
self._brate_label=Gtk.Label(xalign=1, width_chars=5)
|
||||
self._format_label=Gtk.Label()
|
||||
self.set_property("no-show-all", not(self._settings.get_boolean("show-audio-format")))
|
||||
@ -3376,7 +3380,8 @@ class AudioFormat(Gtk.Box):
|
||||
# packing
|
||||
hbox=Gtk.Box(halign=Gtk.Align.END)
|
||||
hbox.pack_start(self._brate_label, False, False, 0)
|
||||
hbox.pack_start(self._top_label, False, False, 0)
|
||||
hbox.pack_start(self._separator_label, False, False, 0)
|
||||
hbox.pack_start(self._file_type_label, False, False, 0)
|
||||
vbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL, valign=Gtk.Align.CENTER)
|
||||
vbox.pack_start(hbox, False, False, 0)
|
||||
vbox.pack_start(self._format_label, False, False, 0)
|
||||
@ -3391,16 +3396,22 @@ class AudioFormat(Gtk.Box):
|
||||
self._format_label.set_markup("<small>"+ClientHelper.convert_audio_format(audio_format)+"</small>")
|
||||
|
||||
def _on_bitrate(self, emitter, brate):
|
||||
self._brate_label.set_text(locale.str(brate))
|
||||
# handle unknown bitrates: https://github.com/MusicPlayerDaemon/MPD/issues/428#issuecomment-442430365
|
||||
if brate is None:
|
||||
self._brate_label.set_text("–")
|
||||
else:
|
||||
self._brate_label.set_text(brate)
|
||||
|
||||
def _on_song_changed(self, *args):
|
||||
current_song=self._client.currentsong()
|
||||
if current_song == {}:
|
||||
self._top_label.set_text(" kb/s")
|
||||
self._file_type_label.set_text("")
|
||||
self._separator_label.set_text(" kb/s")
|
||||
self._format_label.set_markup("<small> </small>")
|
||||
else:
|
||||
file_type=current_song["file"].split(".")[-1].split("/")[0].upper()
|
||||
self._top_label.set_text(" kb/s • "+file_type)
|
||||
self._separator_label.set_text(" kb/s • ")
|
||||
self._file_type_label.set_text(file_type)
|
||||
|
||||
def _on_mini_player(self, obj, typestring):
|
||||
self._on_show_audio_format_changed()
|
||||
@ -3415,8 +3426,9 @@ class AudioFormat(Gtk.Box):
|
||||
|
||||
def _on_disconnected(self, *args):
|
||||
self.set_sensitive(False)
|
||||
self._brate_label.set_text(locale.str(0.0))
|
||||
self._top_label.set_text(" kb/s")
|
||||
self._brate_label.set_text("–")
|
||||
self._separator_label.set_text(" kb/s")
|
||||
self._file_type_label.set_text("")
|
||||
self._format_label.set_markup("<small> </small>")
|
||||
|
||||
def _on_reconnected(self, *args):
|
||||
|
Loading…
Reference in New Issue
Block a user