Package gen :: Package lib :: Module mediaref
[frames] | no frames]

Source Code for Module gen.lib.mediaref

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2000-2007  Donald N. Allingham 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 19  # 
 20   
 21  # $Id: mediaref.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  Media Reference class for GRAMPS. 
 25  """ 
 26   
 27  #------------------------------------------------------------------------- 
 28  # 
 29  # GRAMPS modules 
 30  # 
 31  #------------------------------------------------------------------------- 
 32  from gen.lib.secondaryobj import SecondaryObject 
 33  from gen.lib.privacybase import PrivacyBase 
 34  from gen.lib.srcbase import SourceBase 
 35  from gen.lib.notebase import NoteBase 
 36  from gen.lib.refbase import RefBase 
 37  from gen.lib.attrbase import AttributeBase 
 38   
 39  #------------------------------------------------------------------------- 
 40  # 
 41  # MediaObject References for Person/Place/Source 
 42  # 
 43  #------------------------------------------------------------------------- 
44 -class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase, 45 AttributeBase):
46 """Media reference class."""
47 - def __init__(self, source=None):
48 PrivacyBase.__init__(self, source) 49 SourceBase.__init__(self, source) 50 NoteBase.__init__(self, source) 51 RefBase.__init__(self, source) 52 AttributeBase.__init__(self, source) 53 54 if source: 55 self.rect = source.rect 56 else: 57 self.rect = None
58
59 - def serialize(self):
60 """ 61 Convert the object to a serialized tuple of data. 62 """ 63 return (PrivacyBase.serialize(self), 64 SourceBase.serialize(self), 65 NoteBase.serialize(self), 66 AttributeBase.serialize(self), 67 RefBase.serialize(self), 68 self.rect)
69
70 - def unserialize(self, data):
71 """ 72 Convert a serialized tuple of data to an object. 73 """ 74 (privacy, source_list, note_list,attribute_list,ref,self.rect) = data 75 PrivacyBase.unserialize(self, privacy) 76 SourceBase.unserialize(self, source_list) 77 NoteBase.unserialize(self, note_list) 78 AttributeBase.unserialize(self, attribute_list) 79 RefBase.unserialize(self, ref) 80 return self
81
82 - def get_text_data_child_list(self):
83 """ 84 Return the list of child objects that may carry textual data. 85 86 @return: Returns the list of child objects that may carry textual data. 87 @rtype: list 88 """ 89 return self.attribute_list + self.source_list
90
91 - def get_sourcref_child_list(self):
92 """ 93 Return the list of child secondary objects that may refer sources. 94 95 @return: Returns the list of child secondary child objects that may 96 refer sources. 97 @rtype: list 98 """ 99 return self.attribute_list
100
101 - def get_note_child_list(self):
102 """ 103 Return the list of child secondary objects that may refer notes. 104 105 @return: Returns the list of child secondary child objects that may 106 refer notes. 107 @rtype: list 108 """ 109 return self.attribute_list + self.source_list
110
111 - def get_referenced_handles(self):
112 """ 113 Return the list of (classname, handle) tuples for all directly 114 referenced primary objects. 115 116 @return: List of (classname, handle) tuples for referenced objects. 117 @rtype: list 118 """ 119 ret = self.get_referenced_note_handles() 120 if self.ref: 121 ret += [('MediaObject', self.ref)] 122 return ret
123
124 - def get_handle_referents(self):
125 """ 126 Return the list of child objects which may, directly or through 127 their children, reference primary objects. 128 129 @return: Returns the list of objects refereincing primary objects. 130 @rtype: list 131 """ 132 return self.attribute_list + self.source_list
133
134 - def set_rectangle(self, coord):
135 """Set subection of an image.""" 136 self.rect = coord
137
138 - def get_rectangle(self):
139 """Return the subsection of an image.""" 140 return self.rect
141