Below is the file 'dprobe.py' from this revision. You can also download the file.
#!/usr/bin/python # # dprobe; a python program that displays an interface which # displays information on the desktop bus. # import dbus import pygtk pygtk.require("2.0") import gnome import gtk import gtk.glade class DBusInfo: def __init__(self): self.bus = dbus.Bus.get_system() self.dbus_object = self.bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus') def get_bus_names(self): iface = dbus.Interface(self.dbus_object, 'org.freedesktop.DBus') return iface.ListNames() def ping(self, named_service, object_path): obj = self.bus.get_object(named_service, object_path) iface = dbus.Interface(obj, 'org.freedesktop.DBus.Peer') print iface.Ping() def get_introspection_xml(self, named_service, object_path): obj = self.bus.get_object(named_service, object_path) iface = dbus.Interface(obj, 'org.freedesktop.DBus.Introspectable') return iface.Introspect() class NameInfo: def __init__(self, bus, store): self.bus, self.store = bus, store self.dbus_obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus') self.dbus_interface = dbus.Interface(self.dbus_obj, 'org.freedesktop.DBus') self.refresh() def refresh(self): self.store.clear() for name in self.dbus_interface.ListNames(): self.store.append([name]) class DProbe: def __init__(self): xml = open('dprobe.glade').read() self.glade = gtk.glade.xml_new_from_buffer(xml, len(xml)) # connect to the desktop bus self.bus = dbus.Bus.get_system() # window and other stuff self.window = self.glade.get_widget("main_window") # set up the tree of interfaces and methods self.interface_tree = self.glade.get_widget("interface_tree") self.interface_store = gtk.TreeStore(str) self.interface_tree.set_model(self.interface_store) # interface name column name_column = gtk.TreeViewColumn("Interface") self.interface_tree.append_column(name_column) name_cell = gtk.CellRendererText() name_column.pack_start(name_cell, True) name_column.set_attributes(name_cell, text=0) # set up the list of names on the bus self.name_list = self.glade.get_widget("name_list") self.name_list_store = gtk.ListStore(str) self.name_list.set_model(self.name_list_store) # filename column name_column = gtk.TreeViewColumn("Name") self.name_list.append_column(name_column) name_cell = gtk.CellRendererText() name_column.pack_start(name_cell, True) name_column.set_attributes(name_cell, text=0) # sorting.. self.name_list_store.set_sort_func(1, lambda model, iter1, iter2: cmp(self.name_list_store.get_value(iter1, 0), self.name_list_store.get_value(iter2, 0))) self.name_list_store.set_sort_column_id(1, gtk.SORT_ASCENDING) # propogate (and update) that List... self.name_info = NameInfo(self.bus, self.name_list_store) # hook up signals sel = self.name_list.get_selection() sel.connect("changed", self.name_list_select) quit_menu = self.glade.get_widget("quit1") quit_menu.connect("activate", self.window_destroy) about_menu = self.glade.get_widget("about1") about_menu.connect("activate", self.about) self.window.connect("destroy", self.window_destroy) # go... self.window.show_all() def name_list_select(self, sel): (model, iter) = sel.get_selected() if not iter: # in which case, no interface to show self.interface_tree.clear() else: name = self.name_list_store.get_value(iter, 0) print name def window_destroy(self, widget, user=None): gtk.main_quit() def about(self, widget, user=None): about = gtk.AboutDialog() about.set_name("Desktop Bus Probe") about.set_version("0.1") about.set_copyright("Copyright 2005 Grahame Bowland") about.set_website("http://grahame.angrygoats.net/") about.set_authors(["Grahame Bowland"]) about.set_license("""\ Desktop Bus Probe Copyright (C) 2005 Grahame Bowland This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """) about.run() about.destroy() if __name__ == '__main__': gnome.init('dprobe', '0.1') dprobe = DProbe() gtk.main() # i = DBusInfo() # for name in i.get_bus_names(): # if name.startswith(':'): continue # print name # print i.get_introspection_xml(name, '/org/freedesktop/DBus')