diff --git a/ChangeLog b/ChangeLog index c62ff7bd7..c344acfad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-03-05 Don Allingham + * src/ViewManager.py: support for close button on filter sidebar + * src/DisplayModels/_BaseModel.py: support for marker coloring + * src/DisplayModels/_FamilyModel.py: support for marker coloring + * src/PageView.py: support for marker coloring + * src/Filters/SideBar/_SidebarFilter.py: provide close button + * src/Filters/SideBar/_PersonSidebarFilter.py: cleanup + 2007-03-05 Brian Matherly * src/plugins/GraphViz.py: Fix doc init. diff --git a/src/DisplayModels/_BaseModel.py b/src/DisplayModels/_BaseModel.py index eb5c45425..089b6fd96 100644 --- a/src/DisplayModels/_BaseModel.py +++ b/src/DisplayModels/_BaseModel.py @@ -39,6 +39,7 @@ import gtk # #------------------------------------------------------------------------- from Filters import SearchFilter +import Config #------------------------------------------------------------------------- # @@ -174,8 +175,28 @@ class BaseModel(gtk.GenericTreeModel): self.reverse = (order == gtk.SORT_DESCENDING) self.tooltip_column = tooltip_column + + 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.rebuild_data() + 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 set_sort_column(self,col): self.sort_func = self.smap[col] @@ -277,7 +298,7 @@ class BaseModel(gtk.GenericTreeModel): except: return None - def on_get_value(self,node,col): + def on_get_value(self, node, col): try: if node != self.prev_handle: self.prev_data = self.map(str(node)) diff --git a/src/DisplayModels/_FamilyModel.py b/src/DisplayModels/_FamilyModel.py index 164488f81..8783cee30 100644 --- a/src/DisplayModels/_FamilyModel.py +++ b/src/DisplayModels/_FamilyModel.py @@ -55,6 +55,8 @@ from _BaseModel import BaseModel #------------------------------------------------------------------------- class FamilyModel(BaseModel): + _MARKER_COL = 13 + def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None, skip=set(), sort_map=None): self.gen_cursor = db.get_family_cursor @@ -66,7 +68,9 @@ class FamilyModel(BaseModel): self.column_type, self.column_change, self.column_handle, - self.column_tooltip + self.column_tooltip, + self.column_marker_text, + self.column_marker_color, ] self.smap = [ self.column_id, @@ -75,58 +79,82 @@ class FamilyModel(BaseModel): self.column_type, self.sort_change, self.column_handle, - self.column_tooltip + self.column_tooltip, + self.column_marker_text, + self.column_marker_color, ] + self.marker_color_column = 8 BaseModel.__init__(self, db, scol, order, tooltip_column=6, search=search, skip=skip, sort_map=sort_map) def on_get_n_columns(self): return len(self.fmap)+1 - def column_handle(self,data): + def column_handle(self, data): return unicode(data[0]) - def column_father(self,data): + def column_father(self, data): if data[2]: person = self.db.get_person_from_handle(data[2]) return unicode(NameDisplay.displayer.sorted_name(person.primary_name)) else: return u"" - def sort_father(self,data): + def sort_father(self, data): if data[2]: person = self.db.get_person_from_handle(data[2]) return NameDisplay.displayer.sort_string(person.primary_name) else: return u"" - def column_mother(self,data): + def column_mother(self, data): if data[3]: person = self.db.get_person_from_handle(data[3]) return unicode(NameDisplay.displayer.sorted_name(person.primary_name)) else: return u"" - def sort_mother(self,data): + def sort_mother(self, data): if data[3]: person = self.db.get_person_from_handle(data[3]) return NameDisplay.displayer.sort_string(person.primary_name) else: return u"" - def column_type(self,data): + def column_type(self, data): return str(RelLib.FamilyRelType(data[5])) - def column_id(self,data): + def column_id(self, data): return unicode(data[1]) - def sort_change(self,data): + def sort_change(self, data): return "%012x" % data[13] - def column_change(self,data): + def column_change(self, data): return unicode(time.strftime('%x %X',time.localtime(data[13])), GrampsLocale.codeset) + def column_marker_text(self, data): + try: + if data[FamilyModel._MARKER_COL]: + return str(data[FamilyModel._MARKER_COL]) + except IndexError: + return "" + return "" + + def column_marker_color(self, data): + try: + col = data[FamilyModel._MARKER_COL][0] + if col == RelLib.MarkerType.COMPLETE: + return self.complete_color + elif col == RelLib.MarkerType.TODO_TYPE: + return self.todo_color + elif col == RelLib.MarkerType.CUSTOM: + return self.custom_color + except IndexError: + pass + return None + def column_tooltip(self,data): if const.use_tips: try: diff --git a/src/Filters/SideBar/_PersonSidebarFilter.py b/src/Filters/SideBar/_PersonSidebarFilter.py index c7fb7435d..e55ab8d7c 100644 --- a/src/Filters/SideBar/_PersonSidebarFilter.py +++ b/src/Filters/SideBar/_PersonSidebarFilter.py @@ -54,8 +54,8 @@ from Filters import GenericFilter, build_filter_model, Rules #------------------------------------------------------------------------- class PersonSidebarFilter(SidebarFilter): - def __init__(self,uistate,clicked): - SidebarFilter.__init__(self,uistate) + def __init__(self, uistate, clicked): + SidebarFilter.__init__(self, uistate) self.clicked_func = clicked def create_widget(self): @@ -93,14 +93,13 @@ class PersonSidebarFilter(SidebarFilter): self.generic.add_attribute(cell, 'text', 0) self.on_filters_changed('Person') -# def set(self, quality, modifier, calendar, value, text=None): - exdate1 = RelLib.Date() exdate2 = RelLib.Date() - exdate1.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_RANGE, RelLib.Date.CAL_GREGORIAN, - (0,0,1800,False,0,0,1900,False)) - exdate2.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_BEFORE, RelLib.Date.CAL_GREGORIAN, - (0,0,1850,False)) + exdate1.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_RANGE, + RelLib.Date.CAL_GREGORIAN, (0, 0, 1800, False, + 0, 0, 1900, False)) + exdate2.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_BEFORE, + RelLib.Date.CAL_GREGORIAN, (0, 0, 1850, False)) msg1 = DateHandler.displayer.display(exdate1) msg2 = DateHandler.displayer.display(exdate2) diff --git a/src/Filters/SideBar/_SidebarFilter.py b/src/Filters/SideBar/_SidebarFilter.py index b13b3050d..032c4c3bc 100644 --- a/src/Filters/SideBar/_SidebarFilter.py +++ b/src/Filters/SideBar/_SidebarFilter.py @@ -23,15 +23,16 @@ from gettext import gettext as _ import gtk import GrampsWidgets +import Config _RETURN = gtk.gdk.keyval_from_name("Return") _KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter") class SidebarFilter: - def __init__(self,uistate): + def __init__(self, uistate): self.position = 1 - self.table = gtk.Table(3,11) + self.table = gtk.Table(4,11) self.table.set_border_width(6) self.table.set_row_spacings(6) self.table.set_col_spacing(0,6) @@ -43,7 +44,18 @@ class SidebarFilter: def _init_interface(self): self.table.attach(GrampsWidgets.MarkupLabel(_('Filter')), - 0, 3, 0, 1, xoptions=gtk.FILL, yoptions=0) + 0, 2, 0, 1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=0) + btn = gtk.Button() + img = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) + box = gtk.HBox() + btn.set_image(img) + btn.set_relief(gtk.RELIEF_NONE) + btn.set_alignment(1.0, 0.5) + box.pack_start(gtk.Label(''), expand=True, fill=True) + box.pack_end(btn, fill=False, expand=False) + box.show_all() + self.table.attach(box, 2, 4, 0, 1, yoptions=0) + btn.connect('clicked', self.btn_clicked) self.create_widget() @@ -70,9 +82,13 @@ class SidebarFilter: hbox.add(self.apply_btn) hbox.add(self.clear_btn) hbox.show() - self.table.attach(hbox, 2, 3, self.position, self.position+1, + self.table.attach(hbox, 2, 4, self.position, self.position+1, xoptions=gtk.FILL, yoptions=0) + def btn_clicked(self, obj): + Config.set(Config.FILTER, False) + Config.sync() + def get_widget(self): return self.table @@ -110,7 +126,7 @@ class SidebarFilter: self.table.attach(GrampsWidgets.BasicLabel(name), 1, 2, self.position, self.position+1, xoptions=gtk.FILL, yoptions=0) - self.table.attach(widget, 2, 3, self.position, self.position+1, + self.table.attach(widget, 2, 4, self.position, self.position+1, xoptions=gtk.FILL, yoptions=0) self.position += 1 diff --git a/src/PageView.py b/src/PageView.py index 05e089f1b..9088f00c5 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -197,7 +197,6 @@ class PageView: else: return None - class BookMarkView(PageView): def __init__(self, title, state, uistate, bookmarks, bm_type): @@ -254,7 +253,6 @@ class BookMarkView(PageView): ]) self.add_action_group(self.book_action) - #---------------------------------------------------------------- # @@ -699,7 +697,14 @@ class ListView(BookMarkView): index = 0 for pair in [pair for pair in self.column_order() if pair[0]]: name = self.colinfo[pair[1]] - column = gtk.TreeViewColumn(name, self.renderer, text=pair[1]) + + if self.model and self.model.__dict__.has_key('marker_color_column'): + mcol = self.model.marker_color_column + column = gtk.TreeViewColumn(name, self.renderer, text=pair[1], + foreground=mcol) + else: + column = gtk.TreeViewColumn(name, self.renderer, text=pair[1]) + column.connect('clicked',self.column_clicked,index) column.set_resizable(True) column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) diff --git a/src/ViewManager.py b/src/ViewManager.py index 2b882b4ef..e074b1276 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -276,6 +276,8 @@ class ViewManager: self.state.connect('database-changed', self.uistate.db_changed) toolbar = self.uimanager.get_widget('/ToolBar') + self.filter_menu = self.uimanager.get_widget('/MenuBar/ViewMenu/Filter/') + openbtn = gtk.MenuToolButton(gtk.STOCK_OPEN) openbtn.connect('clicked', self.open_activate) openbtn.set_sensitive(False) @@ -474,6 +476,8 @@ class ViewManager: self.uistate.widget.set_sensitive(True) Config.client.notify_add("/apps/gramps/interface/statusbar", self.statusbar_key_update) + Config.client.notify_add("/apps/gramps/interface/filter", + self.filter_signal) def statusbar_key_update(self, client, cnxn_id, entry, data): """ @@ -481,6 +485,13 @@ class ViewManager: """ self.uistate.modify_statusbar(self.state) + def filter_signal(self, client, cnxn_id, entry, data): + """ + Callback function for statusbar key update + """ + if self.filter_menu.get_active() != Config.get(Config.FILTER): + self.filter_menu.set_active(Config.get(Config.FILTER)) + def post_init_interface(self): # Showing the main window is deferred so that # ArgHandler can work without it always shown