diff --git a/ChangeLog b/ChangeLog index b36fb96e6..9fae7a3ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2006-04-19 Don Allingham + * src/DataViews/_EventView.py: more GrampsTypes changes + * src/DataViews/_PedigreeView.py: more GrampsTypes changes + * src/RelLib/_ChildRef.py: more GrampsTypes changes + * src/RelLib/_Family.py: more GrampsTypes changes + * src/RelLib/_Repository.py: more GrampsTypes changes + * src/RelLib/_Event.py: more GrampsTypes changes + * src/Editors/_EditPerson.py: more GrampsTypes changes + * src/Editors/_EditEventRef.py: more GrampsTypes changes + * src/Editors/_EditEvent.py: more GrampsTypes changes + * src/PeopleModel.py: more GrampsTypes changes + * src/DisplayTabs.py: more GrampsTypes changes + * src/GrampsWidgets.py: more GrampsTypes changes + * src/Utils.py: more GrampsTypes changes + * src/PageView.py: more GrampsTypes changes + 2006-04-19 Alex Roitman * src/Utils.py: Remove obsolete code. * src/DisplayTabs.py (EventRefModel.column_role): Adapt to new types. diff --git a/src/DataViews/_EventView.py b/src/DataViews/_EventView.py index 6086e3d3b..e92e3dd09 100644 --- a/src/DataViews/_EventView.py +++ b/src/DataViews/_EventView.py @@ -37,6 +37,8 @@ import PageView import DisplayModels import const import Utils +import Errors + from DdTargets import DdTargets from QuestionDialog import QuestionDialog, ErrorDialog from Editors import EditEvent, DelEventQuery diff --git a/src/DataViews/_PedigreeView.py b/src/DataViews/_PedigreeView.py index 0e6baf7b6..218503e5f 100644 --- a/src/DataViews/_PedigreeView.py +++ b/src/DataViews/_PedigreeView.py @@ -33,7 +33,6 @@ from cgi import escape # GTK/Gnome modules # #------------------------------------------------------------------------- -import gobject import gtk import gtk.gdk try: @@ -49,7 +48,6 @@ except: #------------------------------------------------------------------------- import RelLib import PageView -import Relationship import NameDisplay import Utils import DateHandler @@ -361,9 +359,7 @@ class FormattingHelper: if event and int(event.get_type()) == RelLib.EventType.MARRIAGE: if line_count < 3: return DateHandler.get_date(event) - i = int(event.get_type()) - s = str(even.get_type()) - name = Utils.family_events.get(i) + name = str(event.get_type()) text += name text += "\n" text += DateHandler.get_date(event) @@ -732,9 +728,6 @@ class PedigreeView(PageView.PersonNavView): self.rebuild( self.table_4, pos_4, person) self.rebuild( self.table_5, pos_5, person) - #gobject.idle_add(self.request_resize) - - def rebuild( self, table_widget, positions, active_person): # Build ancestor tree lst = [None]*31 diff --git a/src/DisplayTabs.py b/src/DisplayTabs.py index a80efea66..a319f9322 100644 --- a/src/DisplayTabs.py +++ b/src/DisplayTabs.py @@ -672,7 +672,7 @@ class EventEmbedList(EmbeddedList): return RelLib.EventType(RelLib.EventType.MARRIAGE) def default_role(self): - return (RelLib.EventRoleType.FAMILY, '') + return RelLib.EventRoleType(RelLib.EventRoleType.FAMILY) def add_button_clicked(self, obj): try: @@ -735,7 +735,7 @@ class PersonEventEmbedList(EventEmbedList): return self.orig_data def default_role(self): - return (RelLib.EventRoleType.PRIMARY, '') + return RelLib.EventRoleType(RelLib.EventRoleType.PRIMARY) def default_type(self): type_list = [] diff --git a/src/Editors/_EditEvent.py b/src/Editors/_EditEvent.py index f8a6a4c0c..65b2d3957 100644 --- a/src/Editors/_EditEvent.py +++ b/src/Editors/_EditEvent.py @@ -82,14 +82,6 @@ class EditEvent(EditPrimary): def empty_object(self): return RelLib.Event() - def get_base_events(self): - new_batch = {} - for key in Utils.personal_events: - new_batch[key] = Utils.personal_events[key] - for key in Utils.family_events: - new_batch[key] = Utils.family_events[key] - return new_batch - def get_custom_events(self): return self.dbstate.db.get_person_event_type_list() + \ self.dbstate.db.get_family_event_types() @@ -240,9 +232,6 @@ class EditPersonEvent(EditEvent): def _init_event(self): self.commit_event = self.db.commit_personal_event - def get_base_events(self): - return Utils.personal_events - def get_custom_events(self): return self.dbstate.db.get_person_event_type_list() @@ -255,9 +244,6 @@ class EditFamilyEvent(EditEvent): def _init_event(self): self.commit_event = self.db.commit_family_event - def get_base_events(self): - return Utils.family_events - def get_custom_events(self): return self.dbstate.db.get_family_event_types() diff --git a/src/Editors/_EditEventRef.py b/src/Editors/_EditEventRef.py index 4e9512497..51b6127f4 100644 --- a/src/Editors/_EditEventRef.py +++ b/src/Editors/_EditEventRef.py @@ -48,7 +48,6 @@ import gtk.glade import const import Utils import RelLib -import DisplayState from DisplayTabs import * from GrampsWidgets import * @@ -84,12 +83,6 @@ class EditEventRef(EditReference): self.commit_event = self.db.commit_personal_event self.add_event = self.db.add_person_event - def get_roles(self): - return Utils.event_roles - - def get_event_types(self): - return Utils.personal_events - def get_custom_events(self): return [ (RelLib.EventType.CUSTOM,val) \ for val in self.dbstate.db.get_person_event_types()] @@ -126,12 +119,11 @@ class EditEventRef(EditReference): self.top.get_widget("eer_ev_priv"), self.source) - self.role_selector = MonitoredType( + self.role_selector = MonitoredDataType( self.top.get_widget('eer_role_combo'), self.source_ref.set_role, self.source_ref.get_role, - self.get_roles(), - RelLib.EventRef.CUSTOM) + ) self.event_menu = MonitoredDataType( self.top.get_widget("eer_type_combo"), @@ -174,7 +166,7 @@ class EditEventRef(EditReference): notebook, GalleryTab(self.dbstate, self.uistate, self.track, self.source.get_media_list())) - + self.backref_tab = self._add_tab( notebook, EventBackRefList(self.dbstate, self.uistate, self.track, @@ -231,11 +223,9 @@ class EditFamilyEventRef(EditEventRef): def get_roles(self): return Utils.event_roles - def get_event_types(self): - return Utils.family_events - def get_custom_events(self): - return [ RelLib.EventType((RelLib.EventType.CUSTOM,val)) for val in self.dbstate.db.get_family_event_types()] + return [ RelLib.EventType((RelLib.EventType.CUSTOM,val)) \ + for val in self.dbstate.db.get_family_event_types()] #------------------------------------------------------------------------- diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index a65ae73a8..53d7d3993 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -175,12 +175,10 @@ class EditPerson(EditPrimary): self.pname.get_type, self.db.readonly) - self.marker = GrampsWidgets.MonitoredType( + self.marker = GrampsWidgets.MonitoredDataType( self.top.get_widget('marker'), self.obj.set_marker, self.obj.get_marker, - dict(Utils.marker_types), - RelLib.MarkerType.CUSTOM, self.db.readonly) if self.use_patronymic: diff --git a/src/GrampsWidgets.py b/src/GrampsWidgets.py index 1b87fcec9..fc679a9e4 100644 --- a/src/GrampsWidgets.py +++ b/src/GrampsWidgets.py @@ -354,9 +354,9 @@ class MonitoredDataType: self.obj = obj val = get_val() + if val: default = int(val) - print val, default else: default = None @@ -369,6 +369,10 @@ class MonitoredDataType: value = self.sel.get_values() self.set_val(self.fix_value(value)) + + if val.is_custom(): + obj.child.set_text(str(val)) + self.obj.set_sensitive(not readonly) self.obj.connect('changed', self.on_change) diff --git a/src/PageView.py b/src/PageView.py index 01978ea96..e7cfca2f2 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -150,6 +150,15 @@ class PageView: def change_page(self): pass + def edit(self,obj): + pass + + def remove(self,obj): + pass + + def add(self,obj): + pass + def key_press(self,obj,event): ret_key = gtk.gdk.keyval_from_name("Return") if event.keyval == ret_key and not event.state: diff --git a/src/PeopleModel.py b/src/PeopleModel.py index 32f2bcfdf..9251b637b 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -68,7 +68,6 @@ import NameDisplay import DateHandler import ToolTips import GrampsLocale -import Utils import const #------------------------------------------------------------------------- @@ -268,10 +267,7 @@ class PeopleModel(gtk.GenericTreeModel): return COLUMN_DEFS[col][COLUMN_DEF_LIST](self, self.prev_data, node) except: - if col == _MARKER_COL: - return None - else: - return u'error' + return None def on_iter_next(self, node): '''returns the next node at this level of the tree''' @@ -378,7 +374,7 @@ class PeopleModel(gtk.GenericTreeModel): event = self.db.get_event_from_handle(er.ref) etype = event.get_type()[0] date_str = DateHandler.get_date(event) - if (etype in [Event.BAPTISM, Event.CHRISTEN] + if (etype in [EventType.BAPTISM, EventType.CHRISTEN] and date_str != ""): return "" + cgi.escape(date_str) + "" @@ -399,7 +395,7 @@ class PeopleModel(gtk.GenericTreeModel): event = self.db.get_event_from_handle(er.ref) etype = event.get_type()[0] date_str = DateHandler.get_date(event) - if (etype in [Event.BURIAL, Event.CREMATION] + if (etype in [EventType.BURIAL, EventType.CREMATION] and date_str != ""): return "" + cgi.escape(date_str) + "" @@ -431,7 +427,7 @@ class PeopleModel(gtk.GenericTreeModel): er.unserialize(event_ref) event = self.db.get_event_from_handle(er.ref) etype = event.get_type()[0] - if etype in [Event.BAPTISM, Event.CHRISTEN]: + if etype in [EventType.BAPTISM, EventType.CHRISTEN]: place_handle = event.get_place_handle() if place_handle: place = self.db.get_place_from_handle(place_handle) @@ -459,7 +455,7 @@ class PeopleModel(gtk.GenericTreeModel): er.unserialize(event_ref) event = self.db.get_event_from_handle(er.ref) etype = event.get_type()[0] - if etype in [Event.BURIAL, Event.CREMATION]: + if etype in [EventType.BURIAL, EventType.CREMATION]: place_handle = event.get_place_handle() if place_handle: place = self.db.get_place_from_handle(place_handle) diff --git a/src/RelLib/_ChildRef.py b/src/RelLib/_ChildRef.py index 613137b79..52f74acc7 100644 --- a/src/RelLib/_ChildRef.py +++ b/src/RelLib/_ChildRef.py @@ -88,7 +88,7 @@ class ChildRef(BaseObject,PrivacyBase,SourceBase,NoteBase,RefBase): @return: Returns the list of all textual attributes of the object. @rtype: list """ - return [self.rel, str(self.frel), str(mrel)] + return [str(self.frel), str(self.mrel)] def get_text_data_child_list(self): """ diff --git a/src/RelLib/_Event.py b/src/RelLib/_Event.py index b443fd18d..6c9326f6e 100644 --- a/src/RelLib/_Event.py +++ b/src/RelLib/_Event.py @@ -206,7 +206,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase): description = self.description cause = self.cause the_type = self.type - return (the_type == Event.CUSTOM and date.is_empty() + return (the_type == EventType.CUSTOM and date.is_empty() and not place and not description and not cause) def are_equal(self,other): @@ -238,23 +238,6 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase): return True - def set_name(self,name): - warn( "Use set_type instead of set_name", DeprecationWarning, 2) - # INCOMPLETE Wrapper for old API - # remove when transitition done. - if name in range(-1,45): - the_type = (name,'') - else: - the_type = (Event.CUSTOM,name) - self.set_type(the_type) - - def get_name(self): - warn( "Use get_type instead of get_name", DeprecationWarning, 2) - # INCOMPLETE Wrapper for old API - # remove when transitition done. - type = self.get_type() - return type[1] - def set_type(self,the_type): """ Sets the type of the Event to the passed (int,str) tuple. diff --git a/src/RelLib/_Family.py b/src/RelLib/_Family.py index 3c09c0a72..885983d26 100644 --- a/src/RelLib/_Family.py +++ b/src/RelLib/_Family.py @@ -92,7 +92,6 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase, self.child_ref_list = [] self.type = FamilyRelType() self.event_ref_list = [] - self.lds_seal = None self.complete = 0 def serialize(self): @@ -111,10 +110,6 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase, be considered persistent. @rtype: tuple """ - if self.lds_seal == None: - lds_seal = None - else: - lds_seal = self.lds_seal.serialize() return (self.handle, self.gramps_id, self.father_handle, self.mother_handle, [cr.serialize() for cr in self.child_ref_list], @@ -153,7 +148,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase, if classname == 'Event': return handle in [ref.ref for ref in self.event_ref_list] elif classname == 'Person': - return handle in ([ref.ref for ref in self.child_list] + return handle in ([ref.ref for ref in self.child_ref_list] + [self.father_handle,self.mother_handle]) elif classname == 'Place': return handle in [ x.place for x in self.lds_ord_list ] @@ -381,7 +376,7 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase, in the list. @rtype: bool """ - if not isinstance(childref,ChildRef): + if not isinstance(child_ref,ChildRef): raise ValueError("expecting ChildRef instance") new_list = [ref for ref in self.child_ref_list if ref.ref != child_ref.ref ] diff --git a/src/RelLib/_Repository.py b/src/RelLib/_Repository.py index b7fe84d79..af64f2d05 100644 --- a/src/RelLib/_Repository.py +++ b/src/RelLib/_Repository.py @@ -141,7 +141,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase): @type type: str """ if type(the_type) == tuple: - self.type = NameType(the_type) + self.type = RepositoryType(the_type) else: self.type = the_type diff --git a/src/Utils.py b/src/Utils.py index 822cc9053..5a37ae389 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -81,76 +81,6 @@ confidence = { def format_confidence( type): return confidence.get(type[0],_("Invalid id %d ('%s')")%type) -# family_events = { -# RelLib.Event.UNKNOWN : _("Unknown"), -# RelLib.Event.CUSTOM : _("Custom"), -# RelLib.Event.MARRIAGE : _("Marriage"), -# RelLib.Event.MARR_SETTL : _("Marriage Settlement"), -# RelLib.Event.MARR_LIC : _("Marriage License"), -# RelLib.Event.MARR_CONTR : _("Marriage Contract"), -# RelLib.Event.MARR_BANNS : _("Marriage Banns"), -# RelLib.Event.ENGAGEMENT : _("Engagement"), -# RelLib.Event.DIVORCE : _("Divorce"), -# RelLib.Event.DIV_FILING : _("Divorce Filing"), -# RelLib.Event.ANNULMENT : _("Annulment"), -# RelLib.Event.MARR_ALT : _("Alternate Marriage"), -# } -# def format_family_event( type): -# if type[0] == RelLib.Event.CUSTOM: -# return type[1] -# return family_events.get(type[0],_("Invalid id %d ('%s')")%type) - -# personal_events = { -# RelLib.Event.UNKNOWN : _("Unknown"), -# RelLib.Event.CUSTOM : _("Custom"), -# RelLib.Event.ADOPT : _("Adopted"), -# RelLib.Event.BIRTH : _("Birth"), -# RelLib.Event.DEATH : _("Death"), -# RelLib.Event.ADULT_CHRISTEN : _("Adult Christening"), -# RelLib.Event.BAPTISM : _("Baptism"), -# RelLib.Event.BAR_MITZVAH : _("Bar Mitzvah"), -# RelLib.Event.BAS_MITZVAH : _("Bas Mitzvah"), -# RelLib.Event.BLESS : _("Blessing"), -# RelLib.Event.BURIAL : _("Burial"), -# RelLib.Event.CAUSE_DEATH : _("Cause Of Death"), -# RelLib.Event.CENSUS : _("Census"), -# RelLib.Event.CHRISTEN : _("Christening"), -# RelLib.Event.CONFIRMATION : _("Confirmation"), -# RelLib.Event.CREMATION : _("Cremation"), -# RelLib.Event.DEGREE : _("Degree"), -# RelLib.Event.DIV_FILING : _("Divorce Filing"), -# RelLib.Event.EDUCATION : _("Education"), -# RelLib.Event.ELECTED : _("Elected"), -# RelLib.Event.EMIGRATION : _("Emigration"), -# RelLib.Event.FIRST_COMMUN : _("First Communion"), -# RelLib.Event.IMMIGRATION : _("Immigration"), -# RelLib.Event.GRADUATION : _("Graduation"), -# RelLib.Event.MED_INFO : _("Medical Information"), -# RelLib.Event.MILITARY_SERV : _("Military Service"), -# RelLib.Event.NATURALIZATION : _("Naturalization"), -# RelLib.Event.NOB_TITLE : _("Nobility Title"), -# RelLib.Event.NUM_MARRIAGES : _("Number of Marriages"), -# RelLib.Event.OCCUPATION : _("Occupation"), -# RelLib.Event.ORDINATION : _("Ordination"), -# RelLib.Event.PROBATE : _("Probate"), -# RelLib.Event.PROPERTY : _("Property"), -# RelLib.Event.RELIGION : _("Religion"), -# RelLib.Event.RESIDENCE : _("Residence"), -# RelLib.Event.RETIREMENT : _("Retirement"), -# RelLib.Event.WILL : _("Will") -# } -# def format_personal_event( type): -# if type[0] == RelLib.Event.CUSTOM: -# return type[1] -# return personal_events.get(type[0],_("Invalid id %d ('%s')")%type) - -# def format_event( type): -# if type[0] == RelLib.Event.CUSTOM: -# return type[1] -# val = personal_events.get(type[0]) -# if not val: -# val = family_events.get(type[0],_("Invalid id %d ('%s')")%type) -# return val personal_attributes = { RelLib.Attribute.UNKNOWN : _("Unknown"), @@ -185,18 +115,6 @@ def format_attribute( type): val = family_attributes.get(type[0],_("Invalid id %d ('%s')")%type) return val -## family_relations = { -## RelLib.Family.MARRIED : _("Married"), -## RelLib.Family.UNMARRIED : _("Unmarried"), -## RelLib.Family.CIVIL_UNION : _("Civil Union"), -## RelLib.Family.UNKNOWN : _("Unknown"), -## RelLib.Family.CUSTOM : _("Other"), -## } -## def format_family_relation( type): -## if type[0] == RelLib.Family.CUSTOM: -## return type[1] -## return family_relations.get(type[0],_("Invalid id %d ('%s')")%type) - family_rel_descriptions = { RelLib.FamilyRelType.MARRIED : _("A legal or common-law relationship " "between a husband and wife"), @@ -210,91 +128,6 @@ family_rel_descriptions = { "a man and woman"), } -## source_media_types = { -## RelLib.RepoRef.UNKNOWN : _("Unknown"), -## RelLib.RepoRef.CUSTOM : _("Custom"), -## RelLib.RepoRef.AUDIO : _("Audio"), -## RelLib.RepoRef.BOOK : _("Book"), -## RelLib.RepoRef.CARD : _("Card"), -## RelLib.RepoRef.ELECTRONIC : _("Electronic"), -## RelLib.RepoRef.FICHE : _("Fiche"), -## RelLib.RepoRef.FILM : _("Film"), -## RelLib.RepoRef.MAGAZINE : _("Magazine"), -## RelLib.RepoRef.MANUSCRIPT : _("Manuscript"), -## RelLib.RepoRef.MAP : _("Map"), -## RelLib.RepoRef.NEWSPAPER : _("Newspaper"), -## RelLib.RepoRef.PHOTO : _("Photo"), -## RelLib.RepoRef.TOMBSTONE : _("Tombstone"), -## RelLib.RepoRef.VIDEO : _("Video"), -## } -## def format_source_media_type( type): -## if type[0] == RelLib.RepoRef.CUSTOM: -## return type[1] -## return source_media_types.get(type[0],_("Invalid id %d ('%s')")%type) - -## event_roles = { -## RelLib.EventRef.UNKNOWN : _("Unknown"), -## RelLib.EventRef.CUSTOM : _("Custom"), -## RelLib.EventRef.PRIMARY : _("Primary"), -## RelLib.EventRef.CLERGY : _("Clergy"), -## RelLib.EventRef.CELEBRANT : _("Celebrant"), -## RelLib.EventRef.AIDE : _("Aide"), -## RelLib.EventRef.BRIDE : _("Bride"), -## RelLib.EventRef.GROOM : _("Groom"), -## RelLib.EventRef.WITNESS : _("Witness"), -## } -## def format_personal_event_role( type): -## if type[0] == RelLib.EventRef.CUSTOM: -## return type[1] -## return event_roles.get(type[0],_("Invalid id %d ('%s')")%type) - -## family_event_roles = { -## RelLib.EventRef.UNKNOWN : _("Unknown"), -## RelLib.EventRef.CUSTOM : _("Custom"), -## RelLib.EventRef.FAMILY : _("Family"), -## } -## def format_family_event_role( type): -## if type[0] == RelLib.EventRef.CUSTOM: -## return type[1] -## return family_event_roles.get(type[0],_("Invalid id %d ('%s')")%type) - -## def format_event_role( type): -## if type[0] == RelLib.EventRef.CUSTOM: -## return type[1] -## val = event_roles.get(type[0]) -## if not val: -## val = family_event_roles.get(type[0],_("Invalid id %d ('%s')")%type) -## return val - -# repository_types = { -# RelLib.Repository.UNKNOWN : _("Unknown"), -# RelLib.Repository.CUSTOM : _("Custom"), -# RelLib.Repository.LIBRARY : _("Library"), -# RelLib.Repository.CEMETERY : _("Cemetery"), -# RelLib.Repository.CHURCH : _("Church"), -# RelLib.Repository.ARCHIVE : _("Archive"), -# RelLib.Repository.ALBUM : _("Album"), -# RelLib.Repository.WEBSITE : _("Web site"), -# RelLib.Repository.BOOKSTORE : _("Bookstore"), -# RelLib.Repository.COLLECTION : _("Collection"), -# RelLib.Repository.SAFE : _("Safe"), -# } -# def format_repository_type( type): -# if type[0] == RelLib.Repository.CUSTOM: -# return type[1] -# return repository_types.get(type[0],_("Invalid id %d ('%s')")%type) - - -## marker_types = { -## RelLib.PrimaryObject.MARKER_NONE : "", -## RelLib.PrimaryObject.MARKER_CUSTOM : _("Custom"), -## RelLib.PrimaryObject.MARKER_COMPLETE : _("Information is complete"), -## RelLib.PrimaryObject.MARKER_TODO : _("TODO"), -## } -## def format_marker_type( type): -## if type[0] == RelLib.PrimaryObject.MARKER_CUSTOM: -## return type[1] -## return marker_types.get(type[0],_("Invalid id %d ('%s')")%type) #------------------------------------------------------------------------- #