~fontanon/hamster-applet/hamster-plugins

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
# -*- coding: utf-8 -*-
####################################################################
# hamster-dbus-tracker
# Author: J. Félix Ontañón 2008 <fontanon at emergya dot es>
# Comment: Simple development tool for tracking hamter event changes
# License: Distributed under the GPLv2
####################################################################

import dbus
import gobject
from dbus.mainloop.glib import DBusGMainLoop

def print_activity(message):
    print "Activity", message

def print_fact(message):
    print "Fact", message

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

bus = dbus.SessionBus()
bus.add_signal_receiver(print_activity, dbus_interface="org.gnome.hamster", signal_name="update_activity")
bus.add_signal_receiver(print_fact, dbus_interface="org.gnome.hamster", signal_name="update_fact")

obj = bus.get_object("org.gnome.hamster", "/org/gnome/hamster")
get_hamster_activity = obj.get_dbus_method("get_activity")
get_hamster_fact = obj.get_dbus_method("get_fact")

print_activity(get_hamster_activity())
print_fact(get_hamster_fact())

gobject.MainLoop().run()
exit(0)