[sabayon] Make PanelThing's subclasses use the GConf client from their PanelDelegate, not any random default c
- From: Federico Mena Quintero <federico src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [sabayon] Make PanelThing's subclasses use the GConf client from their PanelDelegate, not any random default c
- Date: Thu, 30 Jul 2009 22:39:47 +0000 (UTC)
commit a176f4b20a2516ca498ebf2437a0d4016d981917
Author: Federico Mena Quintero <federico novell com>
Date: Thu Jul 30 15:23:11 2009 -0500
Make PanelThing's subclasses use the GConf client from their PanelDelegate, not any random default client
That random default client is not reading from the correct location, so it never
reads any correct configuration values.
Signed-off-by: Federico Mena Quintero <federico novell com>
lib/sources/gconfsource.py | 40 ++++++++++----------
lib/sources/paneldelegate.py | 81 ++++++++++++++++++++++--------------------
2 files changed, 62 insertions(+), 59 deletions(-)
---
diff --git a/lib/sources/gconfsource.py b/lib/sources/gconfsource.py
index c03e99d..da41bed 100755
--- a/lib/sources/gconfsource.py
+++ b/lib/sources/gconfsource.py
@@ -125,7 +125,7 @@ class GConfSource (userprofile.ProfileSource):
self.storage = storage
self.home_dir = util.get_home_dir ()
- self.client = None
+ self.gconf_client = None
self.notify_id = 0
self.defaults_client = None
self.mandatory_client = None
@@ -213,19 +213,19 @@ class GConfSource (userprofile.ProfileSource):
self.emit_change (GConfChange (self, entry.key, value))
# Only monitor for changes in the user settings database
- (self.client, address) = get_client_and_address_for_path (os.path.join (self.home_dir, ".gconf"))
- self.client.add_dir ("/", gconf.CLIENT_PRELOAD_RECURSIVE)
- self.notify_id = self.client.notify_add ("/", handle_notify, self)
+ (self.gconf_client, address) = get_client_and_address_for_path (os.path.join (self.home_dir, ".gconf"))
+ self.gconf_client.add_dir ("/", gconf.CLIENT_PRELOAD_RECURSIVE)
+ self.notify_id = self.gconf_client.notify_add ("/", handle_notify, self)
def stop_monitoring (self):
"""Stop monitoring for GConf changes."""
if self.notify_id == 0:
return
- self.client.notify_remove (self.notify_id)
+ self.gconf_client.notify_remove (self.notify_id)
self.notify_id = 0
- self.client.remove_dir ("/")
- self.client = None
+ self.gconf_client.remove_dir ("/")
+ self.gconf_client = None
def sync_changes (self):
"""Ensure that all committed changes are saved to disk."""
@@ -324,10 +324,10 @@ class GConfSource (userprofile.ProfileSource):
subprocess.call (["gconftool-2", "--shutdown"])
def add_gconf_notify (self, key, handler, data):
- return self.client.notify_add (key, handler, data)
+ return self.gconf_client.notify_add (key, handler, data)
def remove_gconf_notify (self, id):
- return self.client.notify_remove (id)
+ return self.gconf_client.notify_remove (id)
def get_gconf_key_is_mandatory (self, key):
(client, address) = self.get_committing_client_and_address (True)
@@ -339,7 +339,7 @@ class GConfSource (userprofile.ProfileSource):
def set_value (self, key, gconf_value, mandatory):
change = GConfChange (self, key, gconf_value)
change.set_mandatory (mandatory)
- self.client.set (key, gconf_value)
+ self.gconf_client.set (key, gconf_value)
self.emit_change (change)
def set_gconf_boolean (self, key, value, mandatory):
@@ -401,7 +401,7 @@ def run_unit_tests ():
# Make sure there's no stale keys from a previous run
# FIXME: gconf_client_recursive_unset() has no wrapping
- # source.client.recursive_unset ("/tmp/test-gconfprofile")
+ # source.gconf_client.recursive_unset ("/tmp/test-gconfprofile")
subprocess.call (["gconftool-2", "--recursive-unset", "/tmp/test-gconfprofile"])
time.sleep (1)
@@ -423,17 +423,17 @@ def run_unit_tests ():
while main_loop.get_context ().pending ():
main_loop.get_context ().iteration (False)
- source.client.set_bool ("/tmp/test-gconfprofile/t1", True)
+ source.gconf_client.set_bool ("/tmp/test-gconfprofile/t1", True)
poll (main_loop)
- source.client.set_bool ("/tmp/test-gconfprofile/t1", False)
+ source.gconf_client.set_bool ("/tmp/test-gconfprofile/t1", False)
poll (main_loop)
- source.client.set_bool ("/tmp/test-gconfprofile/t2", True)
+ source.gconf_client.set_bool ("/tmp/test-gconfprofile/t2", True)
poll (main_loop)
- source.client.set_int ("/tmp/test-gconfprofile/t3", 3)
+ source.gconf_client.set_int ("/tmp/test-gconfprofile/t3", 3)
poll (main_loop)
source.stop_monitoring ()
- source.client = gconf.client_get_default ()
+ source.gconf_client = gconf.client_get_default ()
assert len (changes) == 4
assert changes[3].key == "/tmp/test-gconfprofile/t3"
@@ -445,7 +445,7 @@ def run_unit_tests ():
assert changes[1].key == "/tmp/test-gconfprofile/t1"
assert changes[0].key == "/tmp/test-gconfprofile/t1"
- # source.client.recursive_unset ("/tmp/test-gconfprofile")
+ # source.gconf_client.recursive_unset ("/tmp/test-gconfprofile")
subprocess.call (["gconftool-2", "--recursive-unset", "/tmp/test-gconfprofile"])
source.sync_changes ()
@@ -457,16 +457,16 @@ def run_unit_tests ():
# We need to clear the cache because GConfClient doesn't know
# some new sources have been added to the sources stack so it
# won't see the value we put in the mandatory source
- source.client.clear_cache ()
+ source.gconf_client.clear_cache ()
- entry = source.client.get_entry ("/tmp/test-gconfprofile/t3", "", False)
+ entry = source.gconf_client.get_entry ("/tmp/test-gconfprofile/t3", "", False)
assert entry.value
assert entry.value.type == gconf.VALUE_INT
assert entry.value.get_int () == 3
assert not entry.get_is_default ()
assert entry.get_is_writable ()
- entry = source.client.get_entry ("/tmp/test-gconfprofile/t2", "", False)
+ entry = source.gconf_client.get_entry ("/tmp/test-gconfprofile/t2", "", False)
assert entry.value
assert entry.value.type == gconf.VALUE_BOOL
assert entry.value.get_bool () == True
diff --git a/lib/sources/paneldelegate.py b/lib/sources/paneldelegate.py
index c9c8b2c..f3464b5 100755
--- a/lib/sources/paneldelegate.py
+++ b/lib/sources/paneldelegate.py
@@ -65,11 +65,11 @@ class PanelAppletAddedChange (PanelChange):
PanelChange.__init__ (self, source, delegate, id)
def get_short_description (self):
# FIXME: This only works if panel object type is bonobo-applet. Are all applets bonobo-applets ?
- panel_applet = self.delegate.PanelApplet(self.id)
+ panel_applet = self.delegate.PanelApplet(self.delegate, self.id)
toplevel_id = panel_applet.toplevel_id
name = panel_applet.name
- panel_toplevel = self.delegate.PanelToplevel(toplevel_id)
+ panel_toplevel = self.delegate.PanelToplevel(self.delegate, toplevel_id)
panel_orientation = panel_toplevel.orientation
if panel_orientation == "top":
@@ -86,11 +86,11 @@ class PanelAppletRemovedChange (PanelChange):
PanelChange.__init__ (self, source, delegate, id)
def get_short_description (self):
# FIXME: This only works if panel object type is bonobo-applet. Are all applets bonobo-applets ?
- panel_applet = self.delegate.PanelApplet(self.id)
+ panel_applet = self.delegate.PanelApplet(self.delegate, self.id)
toplevel_id = panel_applet.toplevel_id
name = panel_applet.name
- panel_toplevel = self.delegate.PanelToplevel(toplevel_id)
+ panel_toplevel = self.delegate.PanelToplevel(self.delegate, toplevel_id)
panel_orientation = panel_toplevel.orientation
if panel_orientation == "top":
@@ -106,11 +106,11 @@ class PanelObjectAddedChange (PanelChange):
def __init__ (self, source, delegate, id):
PanelChange.__init__ (self, source, delegate, id)
def get_short_description (self):
- panel_object = self.delegate.PanelObject(self.id)
+ panel_object = self.delegate.PanelObject(self.delegate, self.id)
toplevel_id = panel_object.toplevel_id
name = panel_object.name
- panel_toplevel = self.delegate.PanelToplevel(toplevel_id)
+ panel_toplevel = self.delegate.PanelToplevel(self.delegate, toplevel_id)
panel_orientation = panel_toplevel.orientation
if panel_orientation == "top":
@@ -124,7 +124,7 @@ class PanelObjectAddedChange (PanelChange):
def commit_change (self, mandatory):
# Might have to commit a launcher file
- launcher = self.delegate.client.get_string (PANEL_KEY_BASE + "/objects/" + self.id + "/launcher_location")
+ launcher = self.delegate.get_gconf_client ().get_string (PANEL_KEY_BASE + "/objects/" + self.id + "/launcher_location")
if launcher and launcher[0] != '/':
file = PANEL_LAUNCHER_DIR + "/" + launcher
self.source.storage.add (file, self.delegate.home_dir, self.delegate.name)
@@ -133,11 +133,11 @@ class PanelObjectRemovedChange (PanelChange):
def __init__ (self, source, delegate, id):
PanelChange.__init__ (self, source, delegate, id)
def get_short_description (self):
- panel_object = self.delegate.PanelObject(self.id)
+ panel_object = self.delegate.PanelObject(self.delegate, self.id)
toplevel_id = panel_object.toplevel_id
name = panel_object.name
- panel_toplevel = self.delegate.PanelToplevel(toplevel_id)
+ panel_toplevel = self.delegate.PanelToplevel(self.delegate, toplevel_id)
panel_orientation = panel_toplevel.orientation
if panel_orientation == "top":
@@ -150,38 +150,39 @@ class PanelObjectRemovedChange (PanelChange):
return _("%s removed from right panel") % name
def commit_change (self, mandatory):
- launcher = self.delegate.client.get_string (PANEL_KEY_BASE + "/objects/" + self.id + "/launcher_location")
+ launcher = self.delegate.get_gconf_client ().get_string (PANEL_KEY_BASE + "/objects/" + self.id + "/launcher_location")
if launcher and launcher[0] != '/':
file = PANEL_LAUNCHER_DIR + "/" + launcher
self.source.storage.remove (file)
class PanelDelegate (userprofile.SourceDelegate):
class PanelThing:
- def __init__ (self, id, added, removed):
- self.id = id
- self.added = added
- self.removed = removed
- self.client = gconf.client_get_default ()
+ def __init__ (self, delegate, id, added, removed):
+ self.delegate = delegate
+ self.id = id
+ self.added = added
+ self.removed = removed
+ self.gconf_client = self.delegate.get_gconf_client ()
class PanelToplevel (PanelThing):
- def __init__ (self, id, added = False, removed = False):
- PanelDelegate.PanelThing.__init__ (self, id, added, removed)
+ def __init__ (self, delegate, id, added = False, removed = False):
+ PanelDelegate.PanelThing.__init__ (self, delegate, id, added, removed)
- self.orientation = self.client.get_string (PANEL_KEY_BASE + "/toplevels/" + id + "/orientation")
+ self.orientation = self.gconf_client.get_string (PANEL_KEY_BASE + "/toplevels/" + id + "/orientation")
# FIXME: which of the following attributes do we really need?
- # self.name = self.client.get_string (PANEL_KEY_BASE + "/toplevels/" + toplevel_id + "/name")
- # self.expand = self.client.get_bool (PANEL_KEY_BASE + "/toplevels/" + toplevel_id + "/expand")
+ # self.name = self.gconf_client.get_string (PANEL_KEY_BASE + "/toplevels/" + toplevel_id + "/name")
+ # self.expand = self.gconf_client.get_bool (PANEL_KEY_BASE + "/toplevels/" + toplevel_id + "/expand")
class PanelApplet (PanelThing):
- def __init__ (self, id, added = False, removed = False):
- PanelDelegate.PanelThing.__init__ (self, id, added, removed)
+ def __init__ (self, delegate, id, added = False, removed = False):
+ PanelDelegate.PanelThing.__init__ (self, delegate, id, added, removed)
toplevel_key_name = PANEL_KEY_BASE + "/applets/" + id + "/toplevel_id"
bonobo_iid_key_name = PANEL_KEY_BASE + "/applets/" + id + "/bonobo_iid"
- self.toplevel_id = self.client.get_string (toplevel_key_name)
- self.bonobo_iid = self.client.get_string (bonobo_iid_key_name)
+ self.toplevel_id = self.gconf_client.get_string (toplevel_key_name)
+ self.bonobo_iid = self.gconf_client.get_string (bonobo_iid_key_name)
dprint ("Creating PanelApplet for '%s' (toplevel_key %s, toplevel_id %s, bonobo_key %s, bonobo_iid %s)",
id,
@@ -197,11 +198,11 @@ class PanelDelegate (userprofile.SourceDelegate):
class PanelObject (PanelThing):
- def __init__ (self, id, added = False, removed = False):
- PanelDelegate.PanelThing.__init__ (self, id, added, removed)
+ def __init__ (self, delegate, id, added = False, removed = False):
+ PanelDelegate.PanelThing.__init__ (self, delegate, id, added, removed)
- self.toplevel_id = self.client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/toplevel_id")
- self.object_type = self.client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/object_type")
+ self.toplevel_id = self.gconf_client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/toplevel_id")
+ self.object_type = self.gconf_client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/object_type")
if self.object_type == "drawer-object":
# Translators: This is a drawer in gnome-panel (where you can put applets)
@@ -209,7 +210,7 @@ class PanelDelegate (userprofile.SourceDelegate):
elif self.object_type == "menu-object":
self.name = _("Main Menu")
elif self.object_type == "launcher-object":
- launcher_location = self.client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/launcher_location")
+ launcher_location = self.gconf_client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/launcher_location")
if launcher_location[0] == '/':
desktop_file = launcher_location
elif launcher_location[0:7] == "file://": # See what happens when you drag and drop from the menu
@@ -219,7 +220,7 @@ class PanelDelegate (userprofile.SourceDelegate):
launcher = xdg.DesktopEntry.DesktopEntry(desktop_file)
self.name = _("%s launcher") % launcher.getName()
elif self.object_type == "action-applet":
- action_type = self.client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/action_type")
+ action_type = self.gconf_client.get_string (PANEL_KEY_BASE + "/objects/" + id + "/action_type")
if action_type == "lock":
self.name = _("Lock Screen button")
elif action_type == "logout":
@@ -235,33 +236,35 @@ class PanelDelegate (userprofile.SourceDelegate):
def __init__ (self, source):
userprofile.SourceDelegate.__init__ (self, _("Panel"), source, PANEL_KEY_BASE)
- self.client = gconf.client_get_default ()
self.home_dir = util.get_home_dir()
self.toplevels = {}
self.applets = {}
self.objects = {}
+ def get_gconf_client (self):
+ return self.source.gconf_client
+
def __read_panel_config (self):
dprint ("Reading initial panel config");
dprint ("Toplevels:");
- for id in self.client.get_list (PANEL_KEY_BASE + "/general/toplevel_id_list", gconf.VALUE_STRING):
+ for id in self.get_gconf_client ().get_list (PANEL_KEY_BASE + "/general/toplevel_id_list", gconf.VALUE_STRING):
if not self.toplevels.has_key (id):
dprint (" %s", id);
- self.toplevels[id] = PanelDelegate.PanelToplevel (id)
+ self.toplevels[id] = PanelDelegate.PanelToplevel (self, id)
dprint ("Applets:");
- for id in self.client.get_list (PANEL_KEY_BASE + "/general/applet_id_list", gconf.VALUE_STRING):
+ for id in self.get_gconf_client ().get_list (PANEL_KEY_BASE + "/general/applet_id_list", gconf.VALUE_STRING):
if not self.applets.has_key (id):
dprint (" %s", id);
- self.applets[id] = PanelDelegate.PanelApplet (id)
+ self.applets[id] = PanelDelegate.PanelApplet (self, id)
dprint ("Objects:");
- for id in self.client.get_list (PANEL_KEY_BASE + "/general/object_id_list", gconf.VALUE_STRING):
+ for id in self.get_gconf_client ().get_list (PANEL_KEY_BASE + "/general/object_id_list", gconf.VALUE_STRING):
if not self.objects.has_key (id):
dprint (" %s", id);
- self.objects[id] = PanelDelegate.PanelObject (id)
+ self.objects[id] = PanelDelegate.PanelObject (self, id)
def __handle_id_list_change (self, change, dict, thing_class, added_class, removed_class):
if not change.value or \
@@ -278,7 +281,7 @@ class PanelDelegate (userprofile.SourceDelegate):
if dict.has_key (id) and not dict[id].removed:
continue
if not dict.has_key (id):
- dict[id] = thing_class (id, True)
+ dict[id] = thing_class (self, id, True)
else:
dict[id].added = True
dict[id].removed = False
@@ -376,7 +379,7 @@ class PanelDelegate (userprofile.SourceDelegate):
(client, address) = self.source.get_committing_client_and_address (mandatory)
- self.__copy_dir (self.client, client, address, PANEL_KEY_BASE + "/" + dir_name + "/" + thing.id)
+ self.__copy_dir (self.get_gconf_client (), client, address, PANEL_KEY_BASE + "/" + dir_name + "/" + thing.id)
id_list = self.__get_current_list (dict)
id_list.append (thing.id)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]