diff --git a/ChangeLog b/ChangeLog index 1c2f8077a..2c8806b49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2005-09-16 Martin Hawlisch * Makefile.am: Disable install, show warning instead. + * src/PageView.py (button_press): Catch problem with no loaded database + * src/PersonView.py (button_press): Catch problem with no loaded database + * src/GrampsDbBase.py (_get_from_handle): Catch problem with no loaded database + * src/MapView.py: Updates + * src/EditPerson.py: Change complete flag into marker combo + * src/GrampsDbBase.py: Add map for custom marker values + * src/PeopleModel.py: Add support for colored markers + * src/PersonView.py: Add support for colored markers + * src/RelLib.py: Change complete flag into marker combo + * src/Utils.py: Add marker types + * src/edit_person.glade: Change complete flag into marker combo 2005-09-15 Don Allingham * src/EditPlace.py: fix windowing history diff --git a/src/EditPerson.py b/src/EditPerson.py index 9eedcc6cf..7864e34c6 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -158,8 +158,19 @@ class EditPerson(DisplayState.ManagedWindow): self.build_gallery(self.get_widget('iconbox')) - self.complete = self.get_widget('complete') - self.complete.set_sensitive(mod) + self.marker = self.get_widget('marker') + self.marker.set_sensitive(mod) + if person: + try: + defval = person.get_marker()[0] + except: + defval = (RelLib.PrimaryObject.MARKER_NONE,"") + else: + defval = None + self.marker_type_selector = AutoComp.StandardCustomSelector( + Utils.marker_types, self.marker, + RelLib.PrimaryObject.MARKER_CUSTOM, defval) + self.gender = self.get_widget('gender') self.gender.set_sensitive(mod) self.private = self.get_widget('private') @@ -335,7 +346,6 @@ class EditPerson(DisplayState.ManagedWindow): self.top.get_widget('add_src'), self.top.get_widget('edit_src'), self.top.get_widget('del_src'), self.db.readonly) - self.complete.set_active(self.person.get_complete_flag()) self.private.set_active(self.person.get_privacy()) self.eventbox.connect('button-press-event',self.image_button_press) @@ -722,8 +732,9 @@ class EditPerson(DisplayState.ManagedWindow): changed = False name = self.person.get_primary_name() - if self.complete.get_active() != self.person.get_complete_flag(): - changed = True + + #TODO#if self.complete.get_active() != self.person.get_complete_flag(): + # changed = True if self.private.get_active() != self.person.get_privacy(): changed = True @@ -992,7 +1003,7 @@ class EditPerson(DisplayState.ManagedWindow): if format != self.person.get_note_format(): self.person.set_note_format(format) - self.person.set_complete_flag(self.complete.get_active()) + self.person.set_marker(self.marker_type_selector.get_values()) self.person.set_privacy(self.private.get_active()) if not self.lds_not_loaded: diff --git a/src/GrampsDbBase.py b/src/GrampsDbBase.py index 87bb72f6c..dbadbeca4 100644 --- a/src/GrampsDbBase.py +++ b/src/GrampsDbBase.py @@ -179,6 +179,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): self.individual_event_names = sets.Set() self.individual_attributes = sets.Set() self.family_attributes = sets.Set() + self.marker_names = sets.Set() self.set_person_id_prefix(GrampsKeys.get_person_id_prefix()) self.set_object_id_prefix(GrampsKeys.get_object_id_prefix()) @@ -342,6 +343,8 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): for attr in person.attribute_list: self.individual_attributes.add(attr.type) + self.marker_names.add(person.marker[1]) + def commit_media_object(self,obj,transaction,change_time=None): """ Commits the specified MediaObject to the database, storing the changes @@ -1201,6 +1204,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): instances in the database""" return list(self.family_event_names) + def get_marker_types(): + """return a list of all marker types available in the database""" + return list(self.marker_names) + def get_media_attribute_types(self): """returns a list of all Attribute types assocated with Media instances in the database""" diff --git a/src/PeopleModel.py b/src/PeopleModel.py index 39383d5b2..4521bc2dd 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -31,6 +31,7 @@ import locale import cgi import sets import sys +import traceback #------------------------------------------------------------------------- # @@ -72,7 +73,8 @@ _DEATH_COL = 6 _BIRTH_COL = 7 _EVENT_COL = 8 _FAMILY_COL= 9 -_CHANGE_COL= 21 +_CHANGE_COL= 20 +_MARKER_COL=21 #------------------------------------------------------------------------- # @@ -108,7 +110,8 @@ class PeopleModel(gtk.GenericTreeModel): self.top_visible = {} self.invert_result = invert_result self.sortnames = {} - self.tooltip_column = 10 + self.marker_color_column = 11 + self.tooltip_column = 12 self.rebuild_data(data_filter) def rebuild_data(self,data_filter=None,skip=None): @@ -219,6 +222,9 @@ class PeopleModel(gtk.GenericTreeModel): def on_get_value(self,node,col): # test for header or data row-type if self.sname_sub.has_key(node): + # Header rows dont get the background color set + if col==self.marker_color_column: + return None # test for 'header' column being empty (most are) if not COLUMN_DEFS[col][COLUMN_DEF_HEADER]: return u'' @@ -232,6 +238,7 @@ class PeopleModel(gtk.GenericTreeModel): try: return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.db.person_map[str(node)],node) except: + print "".join(traceback.format_exception(*sys.exc_info())) return u'error' def reset_visible(self): @@ -409,6 +416,30 @@ class PeopleModel(gtk.GenericTreeModel): return u"" + def column_marker_text(self,data,node): + try: + if data[_MARKER_COL]: + if data[_MARKER_COL][0] == PrimaryObject.MARKER_CUSTOM: + return data[_MARKER_COL][1] + elif data[_MARKER_COL][0] in Utils.marker_types: + return Utils.marker_types[data[_MARKER_COL][0]] + except IndexError: + return "" + return "" + + def column_marker_color(self,data,node): + try: + if data[_MARKER_COL]: + if data[_MARKER_COL][0] == PrimaryObject.MARKER_COMPLETE: + return u"#46a046" # green + if data[_MARKER_COL][0] == PrimaryObject.MARKER_TODO: + return u"#df421e" # red + if data[_MARKER_COL][0] == PrimaryObject.MARKER_CUSTOM: + return u"#eed680" # blue + except IndexError: + pass + return None + def column_tooltip(self,data,node): return ToolTips.TipFromFunction(self.db, lambda: self.db.get_person_from_handle(data[0])) @@ -438,6 +469,8 @@ COLUMN_DEFS = [ (PeopleModel.column_spouse, None, str), (PeopleModel.column_change, None, str), (PeopleModel.column_cause_of_death, None, str), + (PeopleModel.column_marker_text, None, str), + (PeopleModel.column_marker_color, None, str), # the order of the above columns must match PeopleView.column_names # these columns are hidden, and must always be last in the list diff --git a/src/PersonView.py b/src/PersonView.py index e2ea2bc86..916be2199 100644 --- a/src/PersonView.py +++ b/src/PersonView.py @@ -437,6 +437,7 @@ class PersonView(PageView.PersonNavView): if self.model.tooltip_column != None: self.tooltips = TreeTips.TreeTips(self.tree,self.model.tooltip_column,True) + self.build_columns() def filter_toggle(self,obj): @@ -527,8 +528,10 @@ class PersonView(PageView.PersonNavView): def build_columns(self): for column in self.columns: self.tree.remove_column(column) - - column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0) + try: + column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0,background=self.model.marker_color_column) + except AttributeError: + column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0) column.set_resizable(True) #column.set_clickable(True) #column.connect('clicked',self.sort_clicked) @@ -541,7 +544,10 @@ class PersonView(PageView.PersonNavView): if not pair[0]: continue name = column_names[pair[1]] - column = gtk.TreeViewColumn(name, self.renderer, markup=pair[1]) + try: + column = gtk.TreeViewColumn(name, self.renderer, markup=pair[1],background=self.model.marker_color_column) + except AttributeError: + column = gtk.TreeViewColumn(name, self.renderer, markup=pair[1]) column.set_resizable(True) column.set_min_width(60) column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) @@ -736,4 +742,3 @@ class PersonView(PageView.PersonNavView): menu.popup(None,None,None,event.button,event.time) return True return False - diff --git a/src/RelLib.py b/src/RelLib.py index 30f5d8758..d16744c12 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -196,6 +196,11 @@ class PrimaryObject(BaseObject): handle is used as the record number for the database, and the GRAMPS ID is the user visible version. """ + + MARKER_NONE = -1 + MARKER_CUSTOM = 0 + MARKER_COMPLETE = 1 + MARKER_TODO = 2 def __init__(self,source=None): """ @@ -211,10 +216,12 @@ class PrimaryObject(BaseObject): self.gramps_id = source.gramps_id self.handle = source.handle self.change = source.change + self.marker = source.marker else: self.gramps_id = None self.handle = None self.change = 0 + self.marker = (PrimaryObject.MARKER_NONE,"") def get_change_time(self): """ @@ -340,6 +347,12 @@ class PrimaryObject(BaseObject): def _replace_handle_reference(self,classname,old_handle,new_handle): pass + def set_marker(self,marker): + self.marker = marker + + def get_marker(self): + return self.marker + class NoteBase: """ Base class for storing notes. @@ -929,7 +942,6 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): self.lds_bapt = None self.lds_endow = None self.lds_seal = None - self.complete = False # We hold a reference to the GrampsDB so that we can maintain # its genderStats. It doesn't get set here, but from @@ -957,7 +969,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): self.event_ref_list, self.family_list, self.parent_family_list, self.media_list, self.address_list, self.attribute_list, self.urls, self.lds_bapt, self.lds_endow, self.lds_seal, - self.complete, self.source_list, self.note, self.change, + self.source_list, self.note, self.change, self.marker, self.private) def unserialize(self,data): @@ -974,8 +986,8 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): self.birth_ref, self.event_ref_list, self.family_list, self.parent_family_list, self.media_list, self.address_list, self.attribute_list, self.urls, self.lds_bapt, self.lds_endow, - self.lds_seal, self.complete, self.source_list, self.note, - self.change,self.private) = (data + (False,))[0:23] + self.lds_seal, self.source_list, self.note, self.change, + self.marker, self.private) = (data + (False,))[0:23] def _has_handle_reference(self,classname,handle): if classname == 'Event': @@ -1100,26 +1112,19 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): + self.event_ref_list def set_complete_flag(self,val): - """ - Sets or clears the complete flag, which is used to indicate that the - Person's data is considered to be complete. - - @param val: True indicates the Person object is considered to be - complete - @type val: bool - """ - self.complete = val + warn( "Use set_marker instead of set_complete_flag", DeprecationWarning, 2) + # Wrapper for old API + # remove when transitition done. + if val: + self.marker = (PrimaryObject.MARKER_COMPLETE, "") + else: + self.marker = (PrimaryObject.MARKER_NONE, "") def get_complete_flag(self): - """ - Returns the complete flag, which is used to indicate that the - Person's data is considered to be complete. - - @return: True indicates that the Person's record is considered to - be complete. - @rtype: bool - """ - return self.complete + warn( "Use get_marker instead of get_complete_flag", DeprecationWarning, 2) + # Wrapper for old API + # remove when transitition done. + return self.marker[0] == PrimaryObject.MARKER_COMPLETE def set_primary_name(self,name): """ @@ -1799,7 +1804,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): self.child_list, self.type, self.event_ref_list, self.media_list, self.attribute_list, self.lds_seal, self.complete, self.source_list, self.note, - self.change) + self.change, self.marker) def unserialize(self, data): """ @@ -1809,7 +1814,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): (self.handle, self.gramps_id, self.father_handle, self.mother_handle, self.child_list, self.type, self.event_ref_list, self.media_list, self.attribute_list, self.lds_seal, - self.complete, self.source_list, self.note, self.change) = data + self.complete, self.source_list, self.note, self.change, self.marker) = data def _has_handle_reference(self,classname,handle): if classname == 'Event': @@ -2252,7 +2257,8 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): """ return (self.handle, self.gramps_id, self.type, self.date, self.description, self.place, self.cause, self.private, - self.source_list, self.note, self.media_list, self.change) + self.source_list, self.note, self.media_list, self.change, + self.marker) def unserialize(self,data): """ @@ -2265,7 +2271,8 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): """ (self.handle, self.gramps_id, self.type, self.date, self.description, self.place, self.cause, self.private, - self.source_list, self.note, self.media_list, self.change) = data + self.source_list, self.note, self.media_list, self.change, + self.marker) = data def _has_handle_reference(self,classname,handle): if classname == 'Place': @@ -2531,7 +2538,7 @@ class Place(PrimaryObject,SourceNote,MediaBase): """ return (self.handle, self.gramps_id, self.title, self.long, self.lat, self.main_loc, self.alt_loc, self.urls, self.media_list, - self.source_list, self.note, self.change) + self.source_list, self.note, self.change, self.marker) def unserialize(self,data): """ @@ -2544,7 +2551,7 @@ class Place(PrimaryObject,SourceNote,MediaBase): """ (self.handle, self.gramps_id, self.title, self.long, self.lat, self.main_loc, self.alt_loc, self.urls, self.media_list, - self.source_list, self.note, self.change) = data + self.source_list, self.note, self.change, self.marker) = data def get_text_data_list(self): """ @@ -2791,7 +2798,7 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase): """ return (self.handle, self.gramps_id, self.path, self.mime, self.desc, self.attribute_list, self.source_list, self.note, - self.change, self.date) + self.change, self.date, self.marker) def unserialize(self,data): """ @@ -2803,7 +2810,7 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase): """ (self.handle, self.gramps_id, self.path, self.mime, self.desc, self.attribute_list, self.source_list, self.note, self.change, - self.date) = data + self.date, self.marker) = data def get_text_data_list(self): """ @@ -2900,7 +2907,7 @@ class Source(PrimaryObject,MediaBase,NoteBase): return (self.handle, self.gramps_id, unicode(self.title), unicode(self.author), unicode(self.pubinfo), self.note, self.media_list, unicode(self.abbrev), - self.change,self.datamap,self.reporef_list) + self.change,self.datamap,self.reporef_list, self.marker) def unserialize(self,data): """ @@ -2909,7 +2916,8 @@ class Source(PrimaryObject,MediaBase,NoteBase): """ (self.handle, self.gramps_id, self.title, self.author, self.pubinfo, self.note, self.media_list, - self.abbrev, self.change, self.datamap, self.reporef_list) = data + self.abbrev, self.change, self.datamap, self.reporef_list, + self.marker) = data def get_text_data_list(self): """ diff --git a/src/Utils.py b/src/Utils.py index 6d71bbfbd..872b77c73 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -234,6 +234,14 @@ repository_types = { RelLib.Repository.COLLECTION : _("Collection"), RelLib.Repository.SAFE : _("Safe"), } + + +marker_types = { + RelLib.PrimaryObject.MARKER_NONE : "", + RelLib.PrimaryObject.MARKER_CUSTOM : _("Custom"), + RelLib.PrimaryObject.MARKER_COMPLETE : _("Information is complete"), + RelLib.PrimaryObject.MARKER_TODO : _("TODO"), +} #------------------------------------------------------------------------- # # Integer to GEDCOM tag mappings for constants diff --git a/src/edit_person.glade b/src/edit_person.glade index 032da62d3..1378fb24d 100644 --- a/src/edit_person.glade +++ b/src/edit_person.glade @@ -17,6 +17,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True False @@ -108,6 +109,10 @@ 0 0 surname + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -133,6 +138,10 @@ 0 0 givenName + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -158,6 +167,10 @@ 0 0 prefix + PANGO_ELLIPSIZE_NONE + -1 + False + 0 5 @@ -183,6 +196,10 @@ 0 0 title + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -230,6 +247,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -247,6 +268,8 @@ Female Male Unknown + False + True 2 @@ -293,6 +316,10 @@ Unknown 0 0 suffix + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -317,6 +344,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -341,6 +372,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 5 @@ -400,6 +435,9 @@ Unknown True + False + True + True 6 @@ -434,29 +472,6 @@ Unknown - - - 6 - True - True - Complete - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 6 - 7 - 5 - 6 - fill - - - - True @@ -470,6 +485,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -559,6 +578,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -611,6 +634,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 label_item @@ -648,6 +675,51 @@ Unknown + + + + True + Marker: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 6 + 5 + 6 + fill + + + + + + + True + False + True + True + + + 6 + 7 + 5 + 6 + fill + fill + + 10 @@ -692,6 +764,9 @@ Unknown False False True + False + False + False @@ -868,6 +943,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -906,6 +985,9 @@ Unknown False False True + False + False + False @@ -1058,6 +1140,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1107,6 +1193,9 @@ Unknown False False True + False + False + False @@ -1273,6 +1362,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1310,6 +1403,9 @@ Unknown False False True + False + False + False @@ -1462,6 +1558,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1542,6 +1642,10 @@ Unknown 0 0 flowed + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1647,6 +1751,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1683,6 +1791,9 @@ Unknown False False True + False + False + False @@ -1830,6 +1941,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2062,6 +2177,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2105,6 +2224,9 @@ Unknown False False True + False + False + False @@ -2292,6 +2414,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2329,6 +2455,10 @@ Unknown 0 0 ldsbapdate + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -2374,6 +2504,10 @@ Unknown 0 0 endowdate + PANGO_ELLIPSIZE_NONE + -1 + False + 0 Date: @@ -2422,6 +2556,10 @@ Unknown 0 0 sealdate + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -2646,6 +2784,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -2660,6 +2802,8 @@ Unknown True + False + True 4 @@ -2684,6 +2828,10 @@ Unknown 0 0 lds_bap_place + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -2721,6 +2869,8 @@ Unknown True + False + True 4 @@ -2745,6 +2895,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -2759,6 +2913,8 @@ Unknown True + False + True 4 @@ -2783,6 +2939,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -2808,6 +2968,10 @@ Unknown 0 0 lds_end_place + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -2856,6 +3020,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -2870,6 +3038,8 @@ Unknown True + False + True 4 @@ -2904,6 +3074,8 @@ Unknown True + False + True 4 @@ -2928,6 +3100,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -2953,6 +3129,10 @@ Unknown 0 0 lds_seal_place + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3001,6 +3181,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 3 @@ -3015,6 +3199,8 @@ Unknown True + False + True 4 @@ -3059,6 +3245,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3083,6 +3273,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3107,6 +3301,10 @@ Unknown 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3132,6 +3330,10 @@ Unknown 0 0 sealparents + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -3146,6 +3348,8 @@ Unknown True + False + True 2 @@ -3218,6 +3422,10 @@ Unknown 0.5 6 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0