fixed AudioType

This commit is contained in:
Martin Wagner 2020-05-13 19:05:24 +02:00
parent 2cf05fc308
commit 16bcc74b15

View File

@ -2652,19 +2652,21 @@ class AudioType(Gtk.Button):
self.treeview.append_column(self.column_value)
#timeouts
GLib.timeout_add(1000, self.refresh)
self.timeout_id=None
#connect
self.connect("clicked", self.on_clicked)
self.client.emitter.connect("disconnected", self.on_disconnected)
self.client.emitter.connect("reconnected", self.on_reconnected)
self.client.emitter.connect("player", self.on_player)
#packing
self.popover.add(self.treeview)
self.add(self.label)
def refresh(self):
if self.client.connected():
status=self.client.status()
try:
status=self.client.status()
file_type=self.client.playlistinfo(status["song"])[0]["file"].split('.')[-1]
freq, res, chan=status["audio"].split(':')
freq=str(float(freq)/1000)
@ -2673,12 +2675,9 @@ class AudioType(Gtk.Button):
self.label.set_text(string)
except:
self.label.set_text("-")
else:
self.label.set_text("-")
return True
def on_clicked(self, *args):
try:
self.store.clear()
song=self.client.song_to_str_dict(self.client.currentsong())
for tag, value in song.items():
@ -2688,8 +2687,40 @@ class AudioType(Gtk.Button):
self.store.append([tag, value])
self.popover.show_all()
self.treeview.queue_resize()
except:
pass
def enable(self):
self.set_sensitive(True)
def disable(self):
self.label.set_text("-")
self.set_sensitive(False)
def on_reconnected(self, *args):
self.timeout_id=GLib.timeout_add(1000, self.refresh)
self.enable()
def on_disconnected(self, *args):
if not self.timeout_id == None:
GLib.source_remove(self.timeout_id)
self.timeout_id=None
self.disable()
def on_player(self, *args):
status=self.client.status()
if status['state'] == "stop":
if not self.timeout_id == None:
GLib.source_remove(self.timeout_id)
self.timeout_id=None
self.disable()
elif status['state'] == "pause":
if not self.timeout_id == None:
GLib.source_remove(self.timeout_id)
self.timeout_id=None
self.refresh()
else:
if self.timeout_id == None:
self.timeout_id=GLib.timeout_add(1000, self.refresh)
self.enable()
class ProfileSelect(Gtk.ComboBoxText):
def __init__(self, client, settings):