Hello planet GNOME, glad to be in this planet after so many years reading it. Probably you were able to skip my Tracker presentations in different conferences… so now I try via blog. And my first post brings good news.

From now on (it has just landed in master), Tracker libraries are accessible via gobject-introspection. You can manipulate the information via libtracker-sparql or write new miners using libtracker-miner in any language with gobject-introspection support (E.G. python). A snipped of code is worth a thousand words:

#!/usr/bin/env python
import gi
from gi.repository import Tracker

conn = Tracker.SparqlConnection.get (None)
cursor = conn.query ("SELECT ?u WHERE { ?u a nie:InformationElement. }", None)

while (cursor.next (None)):
      print cursor.get_string (0)

This is a synchronous query to the store. Note that you have a cursor to access the results: they will be retrieved from the DB only when needed. Using this while building a model for the UI should show quite a performance improvement compared with the old DBus API. And if you fancy more the asynchronous way of coding, the code looks like this. You can open the connection, run the query and retrieve the results all asynchronously.

When it comes to miners (processes retrieving information), here is a skeleton of an implementation: a subclass of Miner overriding few methods. Install with the usual dbus files and you have a miner that can be started/stoped/monitored with the Tracker tools.

libtracker-sparql is our recommended way to use tracker, the DBus API can be considered internal, and now with gobject-introspection it is available from different languages than C or vala. Combine this with libpeas (also using GI) and then we can easily write plugins showing information from Tracker into applications like EOG or totem… Interesting!

About these ads