Telepathy-glib is a library that provides a higher level API for interacting with the Telepathy framework than the low level D-Bus API. No languages bindings exist currently for this library so only C apps such as Empathy used it, developers using languages such as Python and JavaScript were stuck with the D-Bus API and generally each app invented a more or less complete new API on top of it.
In parallel to a push for adding more high-level APIs to telepathy-glib, we are looking at what remains to be done in the gobject-introspection stack so we don't need to write static bindings for each language. After some weeks hacking on Gjs (Danielle Madeley), Vala (Travis Reitter) and PyGI (me) things are starting to take shape.
Following Danni's post on her progress, here comes an example observer written in Python and using PyGI to call telepathy-glib:
import gobject
gobject.threads_init()
from gi.repository import TelepathyGLib
#TelepathyGLib.debug_set_flags('all')
def observe_channels(observer, account, connection, channels,
dispatch_op, requests, context, user_data):
print 'observe_channels'
print 'account = %s' % account.get_object_path()
print 'connection = %s' % connection.get_object_path()
for channel in channels:
print 'channel = %s' % channel.get_object_path()
if dispatch_op is not None:
print 'dispatch_op = %s' % dispatch_op.get_object_path()
else:
print 'dispatch_op = None'
if requests is not None:
for request in requests:
print 'request = %s' % request.get_object_path()
context.accept()
dbus = TelepathyGLib.DBusDaemon.dup()
observer = TelepathyGLib.SimpleObserver.new(dbus, True, 'PythonObserver', True,
observe_channels, None)
observer.add_observer_filter({
TelepathyGLib.PROP_CHANNEL_CHANNEL_TYPE: TelepathyGLib.IFACE_CHANNEL_TYPE_TEXT,
})
observer.register()
main_loop = gobject.MainLoop()
main_loop.run()
This needs the latest code in telepathy-glib, gobject-introspection and pygi, and also a patch to PyGI that hasn't been release yet.
2 comments:
hi, I'm doing a gtk application and I would like start porting it to python 3, can I use pygi to use gtk in python 3?
how is the status of the port?
cay you point me to some link that helps me get started?
@luismarianoguerra:
Hi, the state of the port is such that we have patches for PyGObject and PyGI that passes the tests with Python 3, see for links:
http://www.daa.com.au/pipermail/pygtk/2010-May/018545.html
We will appreciate help pushing this forward!
Post a Comment