* src/GrampsDb/_ReadXML.py: new types

* src/GrampsDb/_ConstXML.py: new types
	* src/GrampsDb/_WriteXML.py: new types
	* src/Editors/_EditUrl.py: new types
	* src/Editors/_EditPerson.py: new types
	* src/Editors/_EditRepository.py: new types
	* src/Editors/_EditName.py: new types
	* src/Editors/_EditChildRef.py: new types
	* src/RelLib/__init__.py: new types
	* src/RelLib/_Url.py: new types
	* src/RelLib/_RepositoryType.py: new types
	* src/RelLib/_GrampsType.py: new types
	* src/RelLib/_UrlType.py: new types
	* src/RelLib/_Repository.py: new types
	* src/RelLib/_NameType.py: new types
	* src/RelLib/_ChildRefType.py: new types
	* src/DisplayTabs.py: new types
	* src/GrampsWidgets.py: new types
	* src/Utils.py: new types


svn: r6360
This commit is contained in:
Don Allingham 2006-04-19 03:57:10 +00:00
parent 481b71447d
commit 2fa0eabb07
20 changed files with 302 additions and 198 deletions

View File

@ -1,4 +1,23 @@
2006-04-18 Don Allingham <don@gramps-project.org> 2006-04-18 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_ReadXML.py: new types
* src/GrampsDb/_ConstXML.py: new types
* src/GrampsDb/_WriteXML.py: new types
* src/Editors/_EditUrl.py: new types
* src/Editors/_EditPerson.py: new types
* src/Editors/_EditRepository.py: new types
* src/Editors/_EditName.py: new types
* src/Editors/_EditChildRef.py: new types
* src/RelLib/__init__.py: new types
* src/RelLib/_Url.py: new types
* src/RelLib/_RepositoryType.py: new types
* src/RelLib/_GrampsType.py: new types
* src/RelLib/_UrlType.py: new types
* src/RelLib/_Repository.py: new types
* src/RelLib/_NameType.py: new types
* src/RelLib/_ChildRefType.py: new types
* src/DisplayTabs.py: new types
* src/GrampsWidgets.py: new types
* src/Utils.py: new types
* src/Editors/_EditFamily.py: button messages * src/Editors/_EditFamily.py: button messages
* src/DisplayTabs.py: remove property button stuff * src/DisplayTabs.py: remove property button stuff

View File

@ -2125,11 +2125,7 @@ class WebModel(gtk.ListStore):
gtk.ListStore.__init__(self, str, str, str, object) gtk.ListStore.__init__(self, str, str, str, object)
self.db = db self.db = db
for obj in obj_list: for obj in obj_list:
self.append(row=[self.show_type(obj.type), self.append(row=[str(obj.type), obj.path, obj.desc, obj])
obj.path, obj.desc, obj])
def show_type(self, rtype):
return Utils.format_web_type(rtype)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -45,6 +45,7 @@ import gtk.glade
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
import RelLib
from _EditSecondary import EditSecondary from _EditSecondary import EditSecondary
from DisplayTabs import * from DisplayTabs import *
@ -81,12 +82,14 @@ class EditChildRef(EditSecondary):
self.top.get_widget('frel'), self.top.get_widget('frel'),
self.obj.set_father_relation, self.obj.set_father_relation,
self.obj.get_father_relation, self.obj.get_father_relation,
RelLib.ChildRefType,
) )
self.mrel = MonitoredDataType( self.mrel = MonitoredDataType(
self.top.get_widget('mrel'), self.top.get_widget('mrel'),
self.obj.set_mother_relation, self.obj.set_mother_relation,
self.obj.get_mother_relation, self.obj.get_mother_relation,
RelLib.ChildRefType,
) )
self.priv = PrivacyButton( self.priv = PrivacyButton(

View File

@ -140,14 +140,18 @@ class EditName(EditSecondary):
self.top.get_widget("alt_prefix"), self.obj.set_surname_prefix, self.top.get_widget("alt_prefix"), self.obj.set_surname_prefix,
self.obj.get_surname_prefix, self.db.readonly) self.obj.get_surname_prefix, self.db.readonly)
self.date = MonitoredDate(self.top.get_widget("date"), self.date = MonitoredDate(
self.top.get_widget("date"),
self.top.get_widget("date_stat"), self.top.get_widget("date_stat"),
self.obj.get_date_object(),self.window) self.obj.get_date_object(),
self.window)
self.obj_combo = MonitoredDataType( self.obj_combo = MonitoredDataType(
self.top.get_widget("name_type"), self.top.get_widget("name_type"),
self.obj.set_type, self.obj.set_type,
self.obj.get_type) self.obj.get_type,
RelLib.Name,
)
self.privacy = PrivacyButton( self.privacy = PrivacyButton(
self.top.get_widget("priv"), self.obj) self.top.get_widget("priv"), self.obj)

View File

@ -72,12 +72,11 @@ class EditRepository(EditPrimary):
self.obj.get_name, self.obj.get_name,
self.db.readonly) self.db.readonly)
self.type = MonitoredType( self.type = MonitoredDataType(
self.glade.get_widget("repository_type"), self.glade.get_widget("repository_type"),
self.obj.set_type, self.obj.set_type,
self.obj.get_type, self.obj.get_type
dict(Utils.repository_types), )
RelLib.Repository.CUSTOM)
self.call_number = MonitoredEntry( self.call_number = MonitoredEntry(
self.glade.get_widget('gid'), self.glade.get_widget('gid'),

View File

@ -73,19 +73,25 @@ class EditUrl(EditSecondary):
def _setup_fields(self): def _setup_fields(self):
self.des = MonitoredEntry( self.des = MonitoredEntry(
self.top.get_widget("url_des"), self.obj.set_description, self.top.get_widget("url_des"),
self.obj.get_description, self.db.readonly) self.obj.set_description,
self.obj.get_description,
self.db.readonly)
self.addr = MonitoredEntry( self.addr = MonitoredEntry(
self.top.get_widget("url_addr"), self.obj.set_path, self.top.get_widget("url_addr"),
self.obj.get_path, self.db.readonly) self.obj.set_path,
self.obj.get_path,
self.db.readonly)
self.priv = PrivacyButton(self.top.get_widget("priv"), self.priv = PrivacyButton(self.top.get_widget("priv"),
self.obj, self.db.readonly) self.obj, self.db.readonly)
self.type_sel = MonitoredType( self.type_sel = MonitoredDataType(
self.top.get_widget("type"), self.obj.set_type, self.top.get_widget("type"),
self.obj.get_type, dict(Utils.web_types), RelLib.Url.CUSTOM) self.obj.set_type,
self.obj.get_type,
)
def build_menu_names(self,obj): def build_menu_names(self,obj):
etitle =_('Internet Address Editor') etitle =_('Internet Address Editor')

View File

@ -101,12 +101,12 @@ family_relations = (
(RelLib.Family.UNKNOWN , "Unknown"), (RelLib.Family.UNKNOWN , "Unknown"),
) )
name_types = ( # name_types = (
(RelLib.NameType.UNKNOWN , "Unknown"), # (RelLib.NameType.UNKNOWN , "Unknown"),
(RelLib.NameType.AKA , "Also Known As"), # (RelLib.NameType.AKA , "Also Known As"),
(RelLib.NameType.BIRTH , "Birth Name"), # (RelLib.NameType.BIRTH , "Birth Name"),
(RelLib.NameType.MARRIED , "Married Name"), # (RelLib.NameType.MARRIED , "Married Name"),
) # )
source_media_types = ( source_media_types = (
(RelLib.RepoRef.UNKNOWN , "Unknown"), (RelLib.RepoRef.UNKNOWN , "Unknown"),
@ -137,18 +137,18 @@ event_roles = (
(RelLib.EventRef.FAMILY , "Family"), (RelLib.EventRef.FAMILY , "Family"),
) )
repository_types = ( # repository_types = (
(RelLib.Repository.UNKNOWN , "Unknown"), # (RelLib.Repository.UNKNOWN , "Unknown"),
(RelLib.Repository.LIBRARY , "Library"), # (RelLib.Repository.LIBRARY , "Library"),
(RelLib.Repository.CEMETERY , "Cemetery"), # (RelLib.Repository.CEMETERY , "Cemetery"),
(RelLib.Repository.CHURCH , "Church"), # (RelLib.Repository.CHURCH , "Church"),
(RelLib.Repository.ARCHIVE , "Archive"), # (RelLib.Repository.ARCHIVE , "Archive"),
(RelLib.Repository.ALBUM , "Album"), # (RelLib.Repository.ALBUM , "Album"),
(RelLib.Repository.WEBSITE , "Web site"), # (RelLib.Repository.WEBSITE , "Web site"),
(RelLib.Repository.BOOKSTORE , "Bookstore"), # (RelLib.Repository.BOOKSTORE , "Bookstore"),
(RelLib.Repository.COLLECTION , "Collection"), # (RelLib.Repository.COLLECTION , "Collection"),
(RelLib.Repository.SAFE , "Safe"), # (RelLib.Repository.SAFE , "Safe"),
) # )
marker_types = ( marker_types = (
(RelLib.PrimaryObject.MARKER_NONE , ""), (RelLib.PrimaryObject.MARKER_NONE , ""),
@ -156,25 +156,25 @@ marker_types = (
(RelLib.PrimaryObject.MARKER_TODO , "todo"), (RelLib.PrimaryObject.MARKER_TODO , "todo"),
) )
url_types = ( # url_types = (
(RelLib.Url.UNKNOWN , "Unknown"), # (RelLib.Url.UNKNOWN , "Unknown"),
(RelLib.Url.EMAIL , "Email"), # (RelLib.Url.EMAIL , "Email"),
(RelLib.Url.WEB_HOME , "Home"), # (RelLib.Url.WEB_HOME , "Home"),
(RelLib.Url.WEB_SEARCH , "Search"), # (RelLib.Url.WEB_SEARCH , "Search"),
(RelLib.Url.WEB_FTP , "FTP"), # (RelLib.Url.WEB_FTP , "FTP"),
) # )
# mapping from the tuple collection to the appropriate CUSTOM integer # mapping from the tuple collection to the appropriate CUSTOM integer
custom_types = { custom_types = {
events : RelLib.Event.CUSTOM, events : RelLib.Event.CUSTOM,
attributes : RelLib.Attribute.CUSTOM, attributes : RelLib.Attribute.CUSTOM,
family_relations : RelLib.Family.CUSTOM, family_relations : RelLib.Family.CUSTOM,
name_types : RelLib.NameType.CUSTOM, # name_types : RelLib.NameType.CUSTOM,
source_media_types : RelLib.RepoRef.CUSTOM, source_media_types : RelLib.RepoRef.CUSTOM,
event_roles : RelLib.EventRef.CUSTOM, event_roles : RelLib.EventRef.CUSTOM,
repository_types : RelLib.Repository.CUSTOM, # repository_types : RelLib.Repository.CUSTOM,
marker_types : RelLib.PrimaryObject.MARKER_CUSTOM, marker_types : RelLib.PrimaryObject.MARKER_CUSTOM,
url_types : RelLib.Url.CUSTOM, # url_types : RelLib.Url.CUSTOM,
} }
def str_for_xml(tuples,the_tuple): def str_for_xml(tuples,the_tuple):

View File

@ -882,7 +882,7 @@ class GrampsParser:
if not mrel.is_default(): if not mrel.is_default():
self.childref.set_mother_relation(mrel) self.childref.set_mother_relation(mrel)
if not frel.is_default() ): if not frel.is_default():
self.childref.set_father_relation(frel) self.childref.set_father_relation(frel)
self.family.add_child_reference(self.childref) self.family.add_child_reference(self.childref)
@ -1386,8 +1386,8 @@ class GrampsParser:
self.event.type = _ConstXML.tuple_from_xml(_ConstXML.events,tag) self.event.type = _ConstXML.tuple_from_xml(_ConstXML.events,tag)
elif self.repo: elif self.repo:
# Repository type # Repository type
self.repo.type = _ConstXML.tuple_from_xml( self.repo.type = RelLib.RepositoryType()
_ConstXML.repository_types,tag) self.repo.type.set_from_xml_str(tag)
def stop_childref(self,tag): def stop_childref(self,tag):
self.childref = None self.childref = None

View File

@ -470,7 +470,7 @@ class XmlWriter:
self.write_primary_tag("repository",repo,index) self.write_primary_tag("repository",repo,index)
#name #name
self.write_line('rname',repo.name,index+1) self.write_line('rname',repo.name,index+1)
rtype = _ConstXML.str_for_xml(_ConstXML.repository_types,repo.type) rtype = repo.type.xml_str()
if rtype: if rtype:
self.write_line('type',rtype,index+1) self.write_line('type',rtype,index+1)
#address list #address list

View File

@ -37,7 +37,6 @@ import AutoComp
import DateHandler import DateHandler
import DateEdit import DateEdit
import const import const
from RelLib import ChildRefType
_lock_path = os.path.join(const.image_dir, 'stock_lock.png') _lock_path = os.path.join(const.image_dir, 'stock_lock.png')
_lock_open_path = os.path.join(const.image_dir, 'stock_lock-open.png') _lock_open_path = os.path.join(const.image_dir, 'stock_lock-open.png')
@ -346,7 +345,8 @@ class MonitoredType:
class MonitoredDataType: class MonitoredDataType:
def __init__(self, obj, set_val, get_val, readonly=False, custom_values=None): def __init__(self, obj, set_val, get_val, readonly=False,
custom_values=None):
self.set_val = set_val self.set_val = set_val
self.get_val = get_val self.get_val = get_val
@ -373,9 +373,9 @@ class MonitoredDataType:
def fix_value(self, value): def fix_value(self, value):
if value[0] == self.get_val().get_custom(): if value[0] == self.get_val().get_custom():
return ChildRefType(value) return value
else: else:
return ChildRefType((value[0],'')) return (value[0],'')
def update(self): def update(self):
if self.get_val(): if self.get_val():

View File

@ -37,20 +37,24 @@ class ChildRefType(GrampsType):
_CUSTOM = CUSTOM _CUSTOM = CUSTOM
_DEFAULT = BIRTH _DEFAULT = BIRTH
_I2SMAP = { _DATAMAP = [
NONE : _("None"), (NONE, _("None"), "None"),
BIRTH : _("Birth"), (BIRTH, _("Birth"), "Birth"),
ADOPTED : _("Adopted"), (ADOPTED, _("Adopted"), "Adopted"),
STEPCHILD : _("Stepchild"), (STEPCHILD, _("Stepchild"), "Stepchild"),
SPONSORED : _("Sponsored"), (SPONSORED, _("Sponsored"), "Sponsored"),
FOSTER : _("Foster"), (FOSTER, _("Foster"), "Foster"),
UNKNOWN : _("Unknown"), (UNKNOWN, _("Unknown"), "Unknown"),
CUSTOM : _("Custom"), (CUSTOM, _("Custom"), "Custom"),
} ]
_S2IMAP = init_map(_I2SMAP) _I2SMAP = init_map(_DATAMAP, 0, 1)
_S2IMAP = init_map(_DATAMAP, 1, 0)
_I2EMAP = init_map(_DATAMAP, 0, 2)
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None): def __init__(self, value=None):
GrampsType.__init__(self, value) GrampsType.__init__(self, value)

View File

@ -22,19 +22,23 @@
from gettext import gettext as _ from gettext import gettext as _
def init_map(data): def init_map(data, key_col, data_col):
new_data = {} new_data = {}
for i in data.keys(): for item in data:
new_data[data[i]] = i new_data[item[key_col]] = item[data_col]
return new_data return new_data
class GrampsType: class GrampsType:
_CUSTOM = 0 _CUSTOM = 0
_DEFAULT = 0 _DEFAULT = 0
_I2SMAP = {}
_S2IMAP = init_map(_I2SMAP) _DATAMAP = []
_I2SMAP = init_map(_DATAMAP, 0, 1)
_S2IMAP = init_map(_DATAMAP, 1, 0)
_I2EMAP = init_map(_DATAMAP, 0, 2)
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None): def __init__(self, value=None):
self.set(value) self.set(value)
@ -59,6 +63,24 @@ class GrampsType:
self.val = self._DEFAULT self.val = self._DEFAULT
self.string = '' self.string = ''
def set_from_xml_str(self, value):
"""
This method sets the type instance based on the untranslated
string (obtained e.g. from XML).
"""
if self._E2IMAP.has_key(value):
self.val = self._E2IMAP[value]
self.string = ''
else:
self.val = self._CUSTOM
self.string = value
def xml_str(self):
if self.val == self._CUSTOM:
return self.string
else:
return self._I2EMAP[self.val]
def serialize(self): def serialize(self):
return (self.val, self.string) return (self.val, self.string)
@ -69,21 +91,9 @@ class GrampsType:
if self.val == self._CUSTOM: if self.val == self._CUSTOM:
return self.string return self.string
else: else:
return self._I2SMAP.get(self.val,_('UNKNOWN')) return self._I2SMAP.get(self.val,_('Unknown'))
def xml_str(self):
"""
This method returns an untranslated string for non-custom values,
or the value, if it is custom.
"""
# FIXME: this needs to be fixed.
return self.string
def set_from_xml_str(self,the_str): def set_from_xml_str(self,the_str):
"""
This method sets the type instance based on the untranslated
string (obtained e.g. from XML).
"""
return self return self
def __int__(self): def __int__(self):

View File

@ -20,7 +20,7 @@
# $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $ # $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $
from _GrampsType import GrampsType from _GrampsType import GrampsType, init_map
from gettext import gettext as _ from gettext import gettext as _
class NameType(GrampsType): class NameType(GrampsType):
@ -34,15 +34,19 @@ class NameType(GrampsType):
_CUSTOM = CUSTOM _CUSTOM = CUSTOM
_DEFAULT = BIRTH _DEFAULT = BIRTH
_I2SMAP = { _DATAMAP = [
UNKNOWN : _("Unknown"), (UNKNOWN, _("Unknown"), "Unknown"),
CUSTOM : _("Custom"), (CUSTOM, _("Custom"), "Custom"),
AKA : _("Also Known As"), (AKA, _("Also Known As"), "Also Known As"),
BIRTH : _("Birth Name"), (BIRTH, _("Birth Name"), "Birth Name"),
MARRIED : _("Married Name"), (MARRIED, _("Married Name"), "Married Name"),
} ]
_I2SMAP = init_map(_DATAMAP, 0, 1)
_S2IMAP = init_map(_DATAMAP, 1, 0)
_I2EMAP = init_map(_DATAMAP, 0, 2)
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None): def __init__(self, value=None):
GrampsType.__init__(self, value) GrampsType.__init__(self, value)

View File

@ -40,6 +40,7 @@ from _PrimaryObject import PrimaryObject
from _NoteBase import NoteBase from _NoteBase import NoteBase
from _AddressBase import AddressBase from _AddressBase import AddressBase
from _UrlBase import UrlBase from _UrlBase import UrlBase
from _RepositoryType import RepositoryType
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -49,29 +50,18 @@ from _UrlBase import UrlBase
class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase): class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
"""A location where collections of Sources are found""" """A location where collections of Sources are found"""
UNKNOWN = -1
CUSTOM = 0
LIBRARY = 1
CEMETERY = 2
CHURCH = 3
ARCHIVE = 4
ALBUM = 5
WEBSITE = 6
BOOKSTORE = 7
COLLECTION = 8
SAFE = 9
def __init__(self): def __init__(self):
"""creates a new Repository instance""" """creates a new Repository instance"""
PrimaryObject.__init__(self) PrimaryObject.__init__(self)
NoteBase.__init__(self) NoteBase.__init__(self)
AddressBase.__init__(self) AddressBase.__init__(self)
UrlBase.__init__(self) UrlBase.__init__(self)
self.type = (Repository.LIBRARY,"") self.type = RepositoryType()
self.name = "" self.name = ""
def serialize(self): def serialize(self):
return (self.handle, self.gramps_id, self.type, unicode(self.name), return (self.handle, self.gramps_id, self.type.serialize(),
unicode(self.name),
NoteBase.serialize(self), NoteBase.serialize(self),
AddressBase.serialize(self), AddressBase.serialize(self),
UrlBase.serialize(self), UrlBase.serialize(self),
@ -82,9 +72,10 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
Converts the data held in a tuple created by the serialize method Converts the data held in a tuple created by the serialize method
back into the data in an Repository structure. back into the data in an Repository structure.
""" """
(self.handle, self.gramps_id, self.type, self.name, note, (self.handle, self.gramps_id, the_type, self.name, note,
address_list, urls ,self.marker, self.private) = data address_list, urls ,self.marker, self.private) = data
self.type = RepositoryType(the_type)
NoteBase.unserialize(self,note) NoteBase.unserialize(self,note)
AddressBase.unserialize(self,address_list) AddressBase.unserialize(self,address_list)
UrlBase.unserialize(self,urls) UrlBase.unserialize(self,urls)
@ -96,7 +87,7 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
@return: Returns the list of all textual attributes of the object. @return: Returns the list of all textual attributes of the object.
@rtype: list @rtype: list
""" """
return [self.name,self.type[1]] return [self.name,str(self.type)]
def get_text_data_child_list(self): def get_text_data_child_list(self):
""" """
@ -149,14 +140,9 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
@param type: descriptive type of the Repository @param type: descriptive type of the Repository
@type type: str @type type: str
""" """
if not type(the_type) == tuple: if type(the_type) == tuple:
warn( "set_type now takes a tuple", DeprecationWarning, 2) self.type = NameType(the_type)
# Wrapper for old API
# remove when transitition done.
if the_type in range(-1,10):
the_type = (the_type,'')
else: else:
the_type = (Repository.CUSTOM,the_type)
self.type = the_type self.type = the_type
def get_type(self): def get_type(self):

View File

@ -0,0 +1,64 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $
from _GrampsType import GrampsType, init_map
from gettext import gettext as _
class RepositoryType(GrampsType):
UNKNOWN = -1
CUSTOM = 0
LIBRARY = 1
CEMETERY = 2
CHURCH = 3
ARCHIVE = 4
ALBUM = 5
WEBSITE = 6
BOOKSTORE = 7
COLLECTION = 8
SAFE = 9
_CUSTOM = CUSTOM
_DEFAULT = LIBRARY
_DATAMAP = [
(UNKNOWN, _("Unknown"), "Unknown"),
(CUSTOM, _("Custom"), "Custom"),
(LIBRARY, _("Library"), "Library"),
(CEMETERY, _("Cemetery"), "Cemetery"),
(CHURCH, _("Church"), "Church"),
(ARCHIVE, _("Archive"), "Archive"),
(ALBUM, _("Album"), "Album"),
(WEBSITE, _("Web site"), "Web site"),
(BOOKSTORE, _("Bookstore"), "Bookstore"),
(COLLECTION, _("Collection"), "Collection"),
(SAFE, _("Safe"), "Safe"),
]
_I2SMAP = init_map(_DATAMAP, 0, 1)
_S2IMAP = init_map(_DATAMAP, 1, 0)
_I2EMAP = init_map(_DATAMAP, 0, 2)
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None):
GrampsType.__init__(self, value)

View File

@ -38,6 +38,7 @@ from warnings import warn
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from _BaseObject import BaseObject from _BaseObject import BaseObject
from _PrivacyBase import PrivacyBase from _PrivacyBase import PrivacyBase
from _UrlType import UrlType
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -48,13 +49,6 @@ class Url(BaseObject,PrivacyBase):
"""Contains information related to internet Uniform Resource Locators, """Contains information related to internet Uniform Resource Locators,
allowing gramps to store information about internet resources""" allowing gramps to store information about internet resources"""
UNKNOWN = -1
CUSTOM = 0
EMAIL = 1
WEB_HOME = 2
WEB_SEARCH = 3
WEB_FTP = 4
def __init__(self,source=None): def __init__(self,source=None):
"""creates a new URL instance, copying from the source if present""" """creates a new URL instance, copying from the source if present"""
BaseObject.__init__(self) BaseObject.__init__(self)
@ -66,13 +60,14 @@ class Url(BaseObject,PrivacyBase):
else: else:
self.path = "" self.path = ""
self.desc = "" self.desc = ""
self.type = (Url.CUSTOM,"") self.type = UrlType()
def serialize(self): def serialize(self):
return (self.private,self.path,self.desc,self.type) return (self.private,self.path,self.desc,self.type.serialize())
def unserialize(self,data): def unserialize(self,data):
(self.private,self.path,self.desc,self.type) = data (self.private,self.path,self.desc,type_value) = data
self.type.unserialize(type_value)
return self return self
def get_text_data_list(self): def get_text_data_list(self):
@ -105,14 +100,11 @@ class Url(BaseObject,PrivacyBase):
@param type: descriptive type of the Url @param type: descriptive type of the Url
@type type: str @type type: str
""" """
if not type(the_type) == tuple: if type(the_type) == tuple:
warn( "set_type now takes a tuple", DeprecationWarning, 2) self.type = UrlType(the_type)
# Wrapper for old API
# remove when transitition done.
if the_type in range(-1,5):
the_type = (the_type,'')
else: else:
the_type = (Url.CUSTOM,the_type) print the_type
assert(isinstance(the_type,UrlType))
self.type = the_type self.type = the_type
def get_type(self): def get_type(self):

View File

@ -0,0 +1,56 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $
from _GrampsType import GrampsType, init_map
from gettext import gettext as _
class UrlType(GrampsType):
UNKNOWN = -1
CUSTOM = 0
EMAIL = 1
WEB_HOME = 2
WEB_SEARCH = 3
WEB_FTP = 4
_CUSTOM = CUSTOM
_DEFAULT = UNKNOWN
_DATAMAP = [
(UNKNOWN, _("Unknown"), "Unknown"),
(CUSTOM, _("Custom"), "Custom"),
(EMAIL, _("E-mail"), "E-mail"),
(WEB_HOME, _("Web Home"), "Web Home"),
(WEB_SEARCH, _("Web Search"), "Web Search"),
(WEB_FTP, _("FTP"), "FTP"),
]
_I2SMAP = init_map(_DATAMAP, 0, 1)
_S2IMAP = init_map(_DATAMAP, 1, 0)
_I2EMAP = init_map(_DATAMAP, 0, 2)
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None):
GrampsType.__init__(self, value)

View File

@ -61,5 +61,7 @@ from _Researcher import Researcher
# Type classes # Type classes
from _GrampsType import GrampsType from _GrampsType import GrampsType
from _NameType import NameType from _NameType import NameType
from _UrlType import UrlType
from _ChildRefType import ChildRefType from _ChildRefType import ChildRefType
from _RepositoryType import RepositoryType

View File

@ -71,21 +71,6 @@ gender = {
def format_gender( type): def format_gender( type):
return gender.get(type[0],_("Invalid")) return gender.get(type[0],_("Invalid"))
# child_relations = {
# RelLib.ChildRef.CHILD_NONE : _("None"),
# RelLib.ChildRef.CHILD_BIRTH : _("Birth"),
# RelLib.ChildRef.CHILD_ADOPTED : _("Adopted"),
# RelLib.ChildRef.CHILD_STEPCHILD : _("Stepchild"),
# RelLib.ChildRef.CHILD_SPONSORED : _("Sponsored"),
# RelLib.ChildRef.CHILD_FOSTER : _("Foster"),
# RelLib.ChildRef.CHILD_UNKNOWN : _("Unknown"),
# RelLib.ChildRef.CHILD_CUSTOM : _("Custom"),
# }
# def format_child_relation( type):
# if type[0] == RelLib.ChildRef.CHILD_CUSTOM:
# return type[1]
# return child_relations.get(type[0],_("Invalid id %d ('%s')")%type)
confidence = { confidence = {
RelLib.SourceRef.CONF_VERY_HIGH : _("Very High"), RelLib.SourceRef.CONF_VERY_HIGH : _("Very High"),
RelLib.SourceRef.CONF_HIGH : _("High"), RelLib.SourceRef.CONF_HIGH : _("High"),
@ -225,32 +210,6 @@ family_rel_descriptions = {
"a man and woman"), "a man and woman"),
} }
# name_types = {
# RelLib.NameType.UNKNOWN : _("Unknown"),
# RelLib.NameType.CUSTOM : _("Custom"),
# RelLib.NameType.AKA : _("Also Known As"),
# RelLib.NameType.BIRTH : _("Birth Name"),
# RelLib.NameType.MARRIED : _("Married Name"),
# }
# def format_name_type( type):
# assert(False)
# if type[0] == RelLib.Name.CUSTOM:
# return type[1]
# return name_types.get(type[0],_("Invalid id %d ('%s')")%type)
web_types = {
RelLib.Url.UNKNOWN : _("Unknown"),
RelLib.Url.CUSTOM : _("Custom"),
RelLib.Url.EMAIL : _("E-mail"),
RelLib.Url.WEB_HOME : _("Web Home"),
RelLib.Url.WEB_SEARCH : _("Web Search"),
RelLib.Url.WEB_FTP : _("FTP"),
}
def format_web_type( type):
if type[0] == RelLib.Url.CUSTOM:
return type[1]
return web_types.get(type[0],_("Invalid id %d ('%s')")%type)
source_media_types = { source_media_types = {
RelLib.RepoRef.UNKNOWN : _("Unknown"), RelLib.RepoRef.UNKNOWN : _("Unknown"),
RelLib.RepoRef.CUSTOM : _("Custom"), RelLib.RepoRef.CUSTOM : _("Custom"),
@ -307,23 +266,23 @@ def format_event_role( type):
val = family_event_roles.get(type[0],_("Invalid id %d ('%s')")%type) val = family_event_roles.get(type[0],_("Invalid id %d ('%s')")%type)
return val return val
repository_types = { # repository_types = {
RelLib.Repository.UNKNOWN : _("Unknown"), # RelLib.Repository.UNKNOWN : _("Unknown"),
RelLib.Repository.CUSTOM : _("Custom"), # RelLib.Repository.CUSTOM : _("Custom"),
RelLib.Repository.LIBRARY : _("Library"), # RelLib.Repository.LIBRARY : _("Library"),
RelLib.Repository.CEMETERY : _("Cemetery"), # RelLib.Repository.CEMETERY : _("Cemetery"),
RelLib.Repository.CHURCH : _("Church"), # RelLib.Repository.CHURCH : _("Church"),
RelLib.Repository.ARCHIVE : _("Archive"), # RelLib.Repository.ARCHIVE : _("Archive"),
RelLib.Repository.ALBUM : _("Album"), # RelLib.Repository.ALBUM : _("Album"),
RelLib.Repository.WEBSITE : _("Web site"), # RelLib.Repository.WEBSITE : _("Web site"),
RelLib.Repository.BOOKSTORE : _("Bookstore"), # RelLib.Repository.BOOKSTORE : _("Bookstore"),
RelLib.Repository.COLLECTION : _("Collection"), # RelLib.Repository.COLLECTION : _("Collection"),
RelLib.Repository.SAFE : _("Safe"), # RelLib.Repository.SAFE : _("Safe"),
} # }
def format_repository_type( type): # def format_repository_type( type):
if type[0] == RelLib.Repository.CUSTOM: # if type[0] == RelLib.Repository.CUSTOM:
return type[1] # return type[1]
return repository_types.get(type[0],_("Invalid id %d ('%s')")%type) # return repository_types.get(type[0],_("Invalid id %d ('%s')")%type)
marker_types = { marker_types = {