Update prefs_profile to not look at the Defaults, but the current RC file

This commit is contained in:
Chris Jones 2008-11-11 11:21:18 +00:00
parent b754489c54
commit 2a852620ac
1 changed files with 33 additions and 16 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
from terminatorlib.config import dbg,err,Defaults from terminatorlib.config import dbg,err,Defaults,TerminatorConfValuestoreRC
from terminatorlib.version import APP_NAME, APP_VERSION from terminatorlib.version import APP_NAME, APP_VERSION
import gtk import gtk
@ -74,12 +74,13 @@ class ProfileEditor:
raise KeyError raise KeyError
def source_get_value (self, key): def source_get_value (self, key):
if Defaults.has_key (key): try:
return Defaults[key] return self.term.conf.__getattr__(key)
elif Defaults['keybindings'].has_key (key): except AttributeError:
return Defaults['keybindings'][key] try:
else: return self.term.conf.keybindings.__getattr(key)
raise KeyError except AttributeError:
pass
def auto_add (self, table, list): def auto_add (self, table, list):
row = 0 row = 0
@ -182,7 +183,7 @@ class ProfileEditor:
elif type == "list": elif type == "list":
continue continue
else: else:
print "Unknown type: " + type err("Unknown type: %s for key: %s" % (type, key))
continue continue
if hasattr(widget, 'set_tooltip_text') and self.data.has_key (key): if hasattr(widget, 'set_tooltip_text') and self.data.has_key (key):
@ -197,6 +198,7 @@ class ProfileEditor:
return (table) return (table)
def apply (self, data): def apply (self, data):
values = {}
for page in [self.appearance, self.behaviour, self.globals, self.colours]: for page in [self.appearance, self.behaviour, self.globals, self.colours]:
for property in page: for property in page:
widget = self.widgets[property] widget = self.widgets[property]
@ -217,7 +219,7 @@ class ProfileEditor:
elif widget.name == 'tab_position': elif widget.name == 'tab_position':
bucket = self.tab_position bucket = self.tab_position
else: else:
print "Unknown bucket type for %s" % widget.name err("Unknown bucket type for %s" % widget.name)
continue continue
value = bucket[widget.get_active()] value = bucket[widget.get_active()]
@ -227,8 +229,7 @@ class ProfileEditor:
value = widget.get_font_name() value = widget.get_font_name()
elif isinstance (widget, gtk.HScale): elif isinstance (widget, gtk.HScale):
value = widget.get_value() value = widget.get_value()
digits = widget.get_digits() if widget.get_digits() == 0:
if digits == 0:
value = int(value) value = int(value)
elif isinstance (widget, gtk.ColorButton): elif isinstance (widget, gtk.ColorButton):
value = widget.get_color().to_string() value = widget.get_color().to_string()
@ -236,16 +237,32 @@ class ProfileEditor:
value = widget.get_filename() value = widget.get_filename()
elif widget.get_name() == 'palette': elif widget.get_name() == 'palette':
value = '' value = ''
valuebits = []
children = widget.get_children() children = widget.get_children()
children.reverse() children.reverse()
for child in children: for child in children:
if value != '': valuebits.append (child.get_color().to_string())
value = value + ':' value = ':'.join (valuebits)
value = value + child.get_color().to_string()
else: else:
value = None value = None
print "skipping unknown thingy %s" % property err("skipping unknown thingy: %s" % property)
print "%s = %s" % (property, value)
values[property] = value
#print "%s = %s" % (property, value)
has_changed = False
for source in self.term.conf.sources:
if isinstance (source, TerminatorConfValuestoreRC):
for property in values:
try:
if source.values[property] != values[property]:
print "%s changed from %s to %s" % (property, source.values[property], values[property])
source.values[property] = values[property]
has_changed = True
except KeyError:
pass
if has_changed:
self.term.reconfigure_vtes()
def cancel (self, data): def cancel (self, data):
self.window.destroy() self.window.destroy()