2 from gnome import gconf
4 class ApplicationSettings():
6 def __init__(self, gconf_client, gconf_root_dir):
7 self._gc = gconf_client
8 self._gconfRootDir = gconf_root_dir
9 self._gconfPopupKey = gconf_root_dir + '/daemon'
12 # ---- public API __________________________________________________________
14 def registerUsePopupListener(self, callback):
15 """Registers a listener/callback to changes on Use Daemon setting"""
17 if len(self._listeners) == 0:
18 self._gc.add_dir(self._gconfRootDir, gconf.CLIENT_PRELOAD_NONE)
19 ref_id = self._gc.notify_add(self._gconfPopupKey, callback)
20 self._listeners[callback] = ref_id
23 def unregisterUsePopupListener(self, callback):
24 """Unregisters the listener/callback"""
26 if (self._listeners.has_key(callback)):
27 ref_id = self._listeners.pop(callback)
28 self._gc.notify_remove(ref_id)
30 if len(self._listeners) == 0:
31 self._gc.remove_dir(self._gconfRootDir)
34 def getUsePopup(self):
35 """Tells whether to use the daemon or not."""
37 value = self._gc.get_without_default(self._gconfPopupKey)
39 self.setUsePopup(True)
41 return value.get_bool() is not False
44 def setUsePopup(self, mode):
45 """mode is either True or False."""
47 self._gc.set_bool(self._gconfPopupKey, mode)