From 556eb3aa7573b7d8901b50f62969103081efbbd2 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 12 May 2006 18:20:18 +0000 Subject: [PATCH] * src/GrampsCfg.py: update for selectable colors * src/PeopleModel.py: update for selectable colors * data/gramps.schemas.in: update for selectable colors svn: r6629 --- gramps2/ChangeLog | 3 +++ gramps2/data/gramps.schemas.in | 4 ++-- gramps2/src/GrampsCfg.py | 29 +++++++++++++++++++++++++++++ gramps2/src/PeopleModel.py | 27 ++++++++++++++++++++++++--- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index eb0452a83..ee942e188 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,6 +1,9 @@ 2006-05-12 Don Allingham * src/GrampsWidgets.py: fix MonitoredDataType initialization * plugins/BookReport.py: append "file://" properly + * src/GrampsCfg.py: update for selectable colors + * src/PeopleModel.py: update for selectable colors + * data/gramps.schemas.in: update for selectable colors 2006-05-12 Alex Roitman * src/Filters/Makefile.am (pkgdata_PYTHON): Add new files. diff --git a/gramps2/data/gramps.schemas.in b/gramps2/data/gramps.schemas.in index 998db7020..1b8931bf6 100644 --- a/gramps2/data/gramps.schemas.in +++ b/gramps2/data/gramps.schemas.in @@ -32,7 +32,7 @@ /apps/gramps/preferences/todo-color gramps string - #FF0000 + #00FF00 Color used to highlight TODO items in a list Color used to highlight TODO items in a list @@ -44,7 +44,7 @@ /apps/gramps/preferences/custom-marker-color gramps string - #00FF00 + #0000FF Color used to highlight custom marker items in a list Color used to highlight custom marker items in a list diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index 1d645868f..ddb8c26c8 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -112,6 +112,8 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): MarkupLabel("%s" % _('Warnings'))) panel.append_page(self.add_researcher_panel(), MarkupLabel("%s" % _('Researcher'))) + panel.append_page(self.add_color_panel(), + MarkupLabel("%s" % _('Marker Colors'))) self.window.show_all() self.show() @@ -164,6 +166,17 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): return table + def add_color_panel(self): + table = gtk.Table(3,8) + table.set_border_width(12) + table.set_col_spacings(6) + table.set_row_spacings(6) + + self.add_color(table, _("Complete"), 0, Config.COMPLETE_COLOR) + self.add_color(table, _("ToDo"), 1, Config.TODO_COLOR) + self.add_color(table, _("Custom"), 2, Config.CUSTOM_MARKER_COLOR) + return table + def add_formats_panel(self): table = gtk.Table(3,8) table.set_border_width(12) @@ -250,9 +263,25 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): table.attach(lwidget, 0, 1, index, index+1, yoptions=0) table.attach(entry, 1, 3, index, index+1, yoptions=0) + def add_color(self, table, label, index, constant): + lwidget = BasicLabel("%s: " % label) + hexval = Config.get(constant) + color = gtk.gdk.color_parse(hexval) + entry = gtk.ColorButton(color=color) + entry.connect('color-set', self.update_color, constant) + table.attach(lwidget, 0, 1, index, index+1, yoptions=0) + table.attach(entry, 1, 3, index, index+1, yoptions=0) + def update_entry(self, obj, constant): Config.set(constant, unicode(obj.get_text())) + def update_color(self, obj, constant): + color = obj.get_color() + hexval = "#%02x%02x%02x" % (color.red/256, + color.green/256, + color.blue/256) + Config.set(constant, hexval) + def update_checkbox(self, obj, constant): Config.set(constant, obj.get_active()) diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index d7f28f5ee..d7787437e 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -37,6 +37,7 @@ import time import cgi import sys import locale +import Config try: set() @@ -139,6 +140,17 @@ class PeopleModel(gtk.GenericTreeModel): self.db = db + Config.client.notify_add("/apps/gramps/preferences/todo-color", + self.update_todo) + Config.client.notify_add("/apps/gramps/preferences/custom-marker-color", + self.update_custom) + Config.client.notify_add("/apps/gramps/preferences/complete-color", + self.update_complete) + + self.complete_color = Config.get(Config.COMPLETE_COLOR) + self.todo_color = Config.get(Config.TODO_COLOR) + self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + self.sortnames = {} self.marker_color_column = 11 self.tooltip_column = 12 @@ -159,6 +171,15 @@ class PeopleModel(gtk.GenericTreeModel): self._build_data = self._build_filter_sub self.rebuild_data(data_filter, skip) + def update_todo(self,client,cnxn_id,entry,data): + self.todo_color = Config.get(Config.TODO_COLOR) + + def update_custom(self,client,cnxn_id,entry,data): + self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + + def update_complete(self,client,cnxn_id,entry,data): + self.complete_color = Config.get(Config.COMPLETE_COLOR) + def rebuild_data(self, data_filter=None, skip=[]): """ Convience function that calculates the new data and assigns it. @@ -512,11 +533,11 @@ class PeopleModel(gtk.GenericTreeModel): try: if data[_MARKER_COL]: if data[_MARKER_COL][0] == MarkerType.COMPLETE: - return u"#46a046" # green + return self.complete_color if data[_MARKER_COL][0] == MarkerType.TODO: - return u"#df421e" # red + return self.todo_color if data[_MARKER_COL][0] == MarkerType.CUSTOM: - return u"#eed680" # ligh brown + return self.custom_color except IndexError: pass return None