Cache gconf values, and handle them changing
This commit is contained in:
parent
f186d242b9
commit
07a142c6a0
|
@ -227,6 +227,8 @@ class Config(object):
|
||||||
base = None
|
base = None
|
||||||
profile = None
|
profile = None
|
||||||
gconf = None
|
gconf = None
|
||||||
|
system_font = None
|
||||||
|
system_focus = None
|
||||||
|
|
||||||
def __init__(self, profile='default'):
|
def __init__(self, profile='default'):
|
||||||
self.base = ConfigBase()
|
self.base = ConfigBase()
|
||||||
|
@ -297,25 +299,41 @@ class Config(object):
|
||||||
|
|
||||||
def get_system_font(self):
|
def get_system_font(self):
|
||||||
"""Look up the system font"""
|
"""Look up the system font"""
|
||||||
if 'gconf' not in globals():
|
if self.system_font is not None:
|
||||||
|
return(self.system_font)
|
||||||
|
elif 'gconf' not in globals():
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
if self.gconf is None:
|
if self.gconf is None:
|
||||||
self.gconf = gconf.client_get_default()
|
self.gconf = gconf.client_get_default()
|
||||||
|
|
||||||
value = self.gconf.get('/desktop/gnome/interface/monospace_font_name')
|
value = self.gconf.get('/desktop/gnome/interface/monospace_font_name')
|
||||||
return(value.get_string())
|
self.system_font = value.get_string()
|
||||||
|
self.gconf.notify_add('/desktop/gnome/interface/monospace_font_name',
|
||||||
|
self.on_gconf_notify)
|
||||||
|
return(self.system_font)
|
||||||
|
|
||||||
def get_system_focus(self):
|
def get_system_focus(self):
|
||||||
"""Look up the system focus setting"""
|
"""Look up the system focus setting"""
|
||||||
if 'gconf' not in globals():
|
if self.system_focus is not None:
|
||||||
|
return(self.system_focus)
|
||||||
|
elif 'gconf' not in globals():
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
if self.gconf is None:
|
if self.gconf is None:
|
||||||
self.gconf = gconf.client_get_default()
|
self.gconf = gconf.client_get_default()
|
||||||
|
|
||||||
value = self.gconf.get('/apps/metacity/general/focus_mode')
|
value = self.gconf.get('/apps/metacity/general/focus_mode')
|
||||||
return(value.get_string())
|
self.system_focus = value.get_string()
|
||||||
|
self.gconf.notify_add('/apps/metacity/general/focus_mode',
|
||||||
|
self.on_gconf_notify)
|
||||||
|
return(self.system_focus)
|
||||||
|
|
||||||
|
def on_gconf_notify(self, client, cnxn_id, entry, what):
|
||||||
|
"""Handle a gconf watch changing"""
|
||||||
|
dbg('GConf notification received. Invalidating caches')
|
||||||
|
self.system_focus = None
|
||||||
|
self.system_font = None
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Cause ConfigBase to save our config to file"""
|
"""Cause ConfigBase to save our config to file"""
|
||||||
|
|
Loading…
Reference in New Issue