[hamster-applet] listening if maybe dbus backend has went away - that means no awkwardness on return (yay!)
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] listening if maybe dbus backend has went away - that means no awkwardness on return (yay!)
- Date: Sun, 1 Aug 2010 20:06:03 +0000 (UTC)
commit 09d5d82fe1d7be980a650010bc580e44222b0a26
Author: Toms Bauģis <toms baugis gmail com>
Date: Sun Aug 1 20:44:04 2010 +0100
listening if maybe dbus backend has went away - that means no awkwardness on return (yay!)
src/hamster/client.py | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/hamster/client.py b/src/hamster/client.py
index 68127d6..9d7e4bd 100644
--- a/src/hamster/client.py
+++ b/src/hamster/client.py
@@ -65,21 +65,31 @@ class Storage(gobject.GObject):
gobject.GObject.__init__(self)
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SessionBus()
- hamster_conn = dbus.Interface(bus.get_object('org.gnome.Hamster',
- '/org/gnome/Hamster'),
- dbus_interface='org.gnome.Hamster')
- self.conn = hamster_conn
+ self.bus = dbus.SessionBus()
+ self._connection = None # will be initiated on demand
- bus.add_signal_receiver(self._on_tags_changed, 'TagsChanged', 'org.gnome.Hamster')
- bus.add_signal_receiver(self._on_facts_changed, 'FactsChanged', 'org.gnome.Hamster')
- bus.add_signal_receiver(self._on_activities_changed, 'ActivitiesChanged', 'org.gnome.Hamster')
- bus.add_signal_receiver(self._on_toggle_called, 'ToggleCalled', 'org.gnome.Hamster')
+ self.bus.add_signal_receiver(self._on_tags_changed, 'TagsChanged', 'org.gnome.Hamster')
+ self.bus.add_signal_receiver(self._on_facts_changed, 'FactsChanged', 'org.gnome.Hamster')
+ self.bus.add_signal_receiver(self._on_activities_changed, 'ActivitiesChanged', 'org.gnome.Hamster')
+ self.bus.add_signal_receiver(self._on_toggle_called, 'ToggleCalled', 'org.gnome.Hamster')
+ self.bus.add_signal_receiver(self._on_dbus_connection_change, 'NameOwnerChanged',
+ 'org.freedesktop.DBus', arg0='org.gnome.Hamster')
@staticmethod
def _to_dict(columns, result_list):
return [dict(zip(columns, row)) for row in result_list]
+ @property
+ def conn(self):
+ if not self._connection:
+ self._connection = dbus.Interface(self.bus.get_object('org.gnome.Hamster',
+ '/org/gnome/Hamster'),
+ dbus_interface='org.gnome.Hamster')
+ return self._connection
+
+ def _on_dbus_connection_change(self, name, old, new):
+ self._connection = None
+
def _on_tags_changed(self):
self.emit("tags-changed")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]