diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2008-10-24 14:01:23 (GMT) |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2008-10-29 09:40:40 (GMT) |
commit | 8ca2e81ac1b8aa431af927c684dadf9d97e8586c (patch) | |
tree | 1c944af36ea58beb2eb3d715eadf10703f974921 /src | |
parent | 7b19bc93b3e6f9df748e5f4cdd2c6a570e8d2902 (diff) |
watch /desktop/sugar/collaboration/publish_gadget gconf key and call Publish according the new value
Diffstat (limited to 'src')
-rw-r--r-- | src/jarabe/model/neighborhood.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py index 7aada26..9aba2b1 100644 --- a/src/jarabe/model/neighborhood.py +++ b/src/jarabe/model/neighborhood.py @@ -98,6 +98,11 @@ class Neighborhood(gobject.GObject): for conn in self._conn_watcher.get_connections(): self.__conn_addded_cb(self._conn_watcher, conn) + self.gconf_client = gconf.client_get_default() + self.gconf_client.add_dir('/desktop/sugar/user', gconf.CLIENT_PRELOAD_NONE) + self.gconf_client.notify_add('/desktop/sugar/collaboration/publish_gadget', + self.__publish_gadget_changed_cb) + def __conn_addded_cb(self, watcher, conn): if CONN_INTERFACE_GADGET not in conn: return @@ -111,9 +116,7 @@ class Neighborhood(gobject.GObject): self._gadget_discovered(conn) def _gadget_discovered(self, conn): - # FIXME: watch change of the gconf key - client = gconf.client_get_default() - publish = client.get_bool('/desktop/sugar/collaboration/publish_gadget') + publish = self.gconf_client.get_bool('/desktop/sugar/collaboration/publish_gadget') logging.debug("Gadget discovered on connection %s." " Publish our status: %r" % (conn.service_name.split('.')[-1], publish)) @@ -140,6 +143,22 @@ class Neighborhood(gobject.GObject): 'org.laptop.Telepathy.Channel.Interface.View.MaxSize': nb }) + def __publish_gadget_changed_cb(self, client_, cnxn_id_, entry, user_data=None): + if entry.value.type == gconf.VALUE_BOOL: + publish = entry.value.get_bool() + + for conn in self._conn_watcher.get_connections(): + if CONN_INTERFACE_GADGET not in conn: + continue + + gadget_discovered = conn[PROPERTIES_IFACE].Get(CONN_INTERFACE_GADGET, + 'GadgetAvailable') + if gadget_discovered: + logging.debug("publish_gadget gconf key changed." + " Publish our status: %r" % + (conn.service_name.split('.')[-1], publish)) + conn[CONN_INTERFACE_GADGET].Publish(publish) + def _get_buddies_cb(self, buddy_list): for buddy in buddy_list: self._buddy_appeared_cb(self._pservice, buddy) |