diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index a1aea7efa..ad1a412c2 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -9,6 +9,9 @@ 2006-05-12 Alex Roitman * data/gramps.schemas.in: Brighter colors to use with foreground. * src/GrampsCfg.py (add_color): Update text label after color change. + * src/Config/_GrampsGconfKeys.py (get_default): Allow other types. + * src/GrampsCfg.py (reset_colors): Emit color-set signal to + trigget hex text updates. 2006-05-12 Don Allingham * src/ViewManager.py: move ScratchPad to Edit diff --git a/gramps2/src/Config/_GrampsGconfKeys.py b/gramps2/src/Config/_GrampsGconfKeys.py index 871532919..eec44d09e 100644 --- a/gramps2/src/Config/_GrampsGconfKeys.py +++ b/gramps2/src/Config/_GrampsGconfKeys.py @@ -150,6 +150,15 @@ def set_string(key,val,test_func=None): def sync(): client.suggest_sync() -def get_default(key): +def get_default(key,sample=''): token = "/apps/gramps/%s/%s" % (key[0],key[1]) - return client.get_default_from_schema(token).get_string() + value = client.get_default_from_schema(token) + if value == None: + raise Errors.GConfSchemaError("No default value for key "+key[1]) + if type(sample) in (str,unicode): + return value.get_string() + elif type(sample) == int: + return value.get_int() + elif type(sample) == bool: + return value.get_bool() + return None diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index 61aed079c..ab2b60be3 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -189,9 +189,9 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): def reset_colors(self, obj): - def_comp = Config.get_default(Config.COMPLETE_COLOR) - def_todo = Config.get_default(Config.TODO_COLOR) - def_cust = Config.get_default(Config.CUSTOM_MARKER_COLOR) + def_comp = Config.get_default(Config.COMPLETE_COLOR,'') + def_todo = Config.get_default(Config.TODO_COLOR,'') + def_cust = Config.get_default(Config.CUSTOM_MARKER_COLOR,'') Config.set(Config.COMPLETE_COLOR, def_comp) Config.set(Config.TODO_COLOR, def_todo) @@ -200,6 +200,8 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): self.comp_color.set_color(gtk.gdk.color_parse(def_comp)) self.todo_color.set_color(gtk.gdk.color_parse(def_todo)) self.custom_color.set_color(gtk.gdk.color_parse(def_cust)) + for widget in [self.comp_color,self.todo_color,self.custom_color]: + widget.emit('color-set') def add_formats_panel(self): table = gtk.Table(3,8)