Commit 41bb970e authored by Rafaël Carré's avatar Rafaël Carré

mpris: make sure only one gobject timer is running

parent b81ff26d
...@@ -58,7 +58,6 @@ def player_change(newname, a, b): ...@@ -58,7 +58,6 @@ def player_change(newname, a, b):
Connect(newname) Connect(newname)
def itemchange_handler(item): def itemchange_handler(item):
gobject.timeout_add( 2000, timeset)
try: try:
a = item["artist"] a = item["artist"]
except: except:
...@@ -89,7 +88,6 @@ def Connect(name): ...@@ -89,7 +88,6 @@ def Connect(name):
player = dbus.Interface(player_o, "org.freedesktop.MediaPlayer") player = dbus.Interface(player_o, "org.freedesktop.MediaPlayer")
player_o.connect_to_signal("TrackChange", itemchange_handler, dbus_interface="org.freedesktop.MediaPlayer") player_o.connect_to_signal("TrackChange", itemchange_handler, dbus_interface="org.freedesktop.MediaPlayer")
if player.GetStatus() == 0: if player.GetStatus() == 0:
gobject.timeout_add( 2000, timeset)
playing = True playing = True
window.set_title(root.Identity()) window.set_title(root.Identity())
...@@ -157,7 +155,6 @@ def Pause(widget): ...@@ -157,7 +155,6 @@ def Pause(widget):
status = player.GetStatus() status = player.GetStatus()
if status == 0: if status == 0:
img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_SMALL_TOOLBAR) img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
gobject.timeout_add( 2000, timeset)
else: else:
img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR) img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR)
update(0) update(0)
...@@ -188,8 +185,9 @@ def timechange(widget, x=None, y=None): ...@@ -188,8 +185,9 @@ def timechange(widget, x=None, y=None):
#refresh position #refresh position
def timeset(): def timeset():
global playing global playing
if playing == True:
time_s.set_value(player.PositionGet()) time_s.set_value(player.PositionGet())
return playing return True
#simple/full display #simple/full display
def expander(widget): def expander(widget):
...@@ -306,6 +304,9 @@ if name != "": ...@@ -306,6 +304,9 @@ if name != "":
window.set_title(root.Identity()) window.set_title(root.Identity())
vol.set_value(player.VolumeGet()) vol.set_value(player.VolumeGet())
#runs timer to update position
gobject.timeout_add( 1000, timeset)
window.set_icon_name('audio-x-generic') window.set_icon_name('audio-x-generic')
window.show() window.show()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment