[rhythmbox] Port the rb-set-rating.py example script to PyGI/GDBus



commit c5533584b7d905dac1bd6790323e072545e84ad6
Author: Nirbheek Chauhan <nirbheek gentoo org>
Date:   Mon Jan 16 06:56:21 2012 +0530

    Port the rb-set-rating.py example script to PyGI/GDBus

 remote/dbus/rb-set-rating.py |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/remote/dbus/rb-set-rating.py b/remote/dbus/rb-set-rating.py
index 82264d5..2d74a0e 100755
--- a/remote/dbus/rb-set-rating.py
+++ b/remote/dbus/rb-set-rating.py
@@ -1,11 +1,20 @@
 #!/usr/bin/python
+# vim: set sts=2 sw=2 et :
 # Set the rating for a URI
 
-import dbus, sys
+import sys
 
-bus = dbus.SessionBus()
-rbshellobj = bus.get_object('org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Shell')
-rbshell = dbus.Interface(rbshellobj, 'org.gnome.Rhythmbox.Shell')
+from gi.repository import GLib, Gio
 
-rbshell.setSongProperty(sys.argv[1], "rating", dbus.Double(float(sys.argv[2])))
+bus_type = Gio.BusType.SESSION
+flags = 0
+iface_info = None
+proxy = Gio.DBusProxy.new_for_bus_sync(bus_type, flags, iface_info,
+                                       "org.gnome.Rhythmbox3",
+                                       "/org/gnome/Rhythmbox3/RhythmDB",
+                                       "org.gnome.Rhythmbox3.RhythmDB", None)
 
+entry_uri = sys.argv[1]
+rating = float(sys.argv[2])
+vrating = GLib.Variant("d", rating)
+proxy.SetEntryProperties("(sa{sv})", entry_uri, {"rating": vrating})



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]