From 7a7d31bbbc96127fa7bd46fa4f6c7e7ea9689225 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 1 Oct 2007 19:55:48 +0000 Subject: [PATCH] 2007-10-01 Benny Malengier * src/GrampsDbUtils/_ReadXML.py: read region tag in xml * src/GrampsDb/_GrampsDbWriteXML.py: output region tag in xml (=subsection of picture) * src/GrampsDb/_GrampsDbConst.py: change env_dir in ENV_DIR * src/Editors/_EditMediaRef.py: remove bug with coord None svn: r9057 --- ChangeLog | 8 +++++++- src/Editors/_EditMediaRef.py | 4 ++-- src/GrampsDb/_GrampsDbConst.py | 2 +- src/GrampsDb/_GrampsDbWriteXML.py | 24 +++++++++++++++++++++++- src/GrampsDbUtils/_ReadXML.py | 8 ++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49deefa88..93759ba8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2007-09-28 James G. Sack +2007-10-01 Benny Malengier + * src/GrampsDbUtils/_ReadXML.py: read region tag in xml + * src/GrampsDb/_GrampsDbWriteXML.py: output region tag in xml (=subsection of picture) + * src/GrampsDb/_GrampsDbConst.py: change env_dir in ENV_DIR + * src/Editors/_EditMediaRef.py: remove bug with coord None + +2007-10-01 James G. Sack * src/gramps.py: remove wrong setting of sys.path 2007-10-01 Zsolt Foldvari diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index 88ccd67c9..685b4bc37 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -88,12 +88,12 @@ class EditMediaRef(EditReference): coord = self.source_ref.get_rectangle() #upgrade path: set invalid (from eg old db) to none - if (coord[0] == None and coord[1] == None + if coord is not None and ((coord[0] == None and coord[1] == None and coord[2] == None and coord[3] == None) or ( coord[0] == 0 and coord[1] == 0 and coord[2] == 100 and coord[3] == 100) or ( coord[0] == coord[2] and coord[1] == coord[3] - ): + )): coord = None self.rectangle = coord diff --git a/src/GrampsDb/_GrampsDbConst.py b/src/GrampsDb/_GrampsDbConst.py index 481d24774..571252ad0 100644 --- a/src/GrampsDb/_GrampsDbConst.py +++ b/src/GrampsDb/_GrampsDbConst.py @@ -40,7 +40,7 @@ else: USER_HOME = os.environ['HOME'] HOME_DIR = os.path.join(USER_HOME,'.gramps') -env_dir = os.path.join(HOME_DIR,"env") +ENV_DIR = os.path.join(HOME_DIR,"env") APP_GRAMPS = "application/x-gramps" diff --git a/src/GrampsDb/_GrampsDbWriteXML.py b/src/GrampsDb/_GrampsDbWriteXML.py index 6c8b236df..ced284eb8 100644 --- a/src/GrampsDb/_GrampsDbWriteXML.py +++ b/src/GrampsDb/_GrampsDbWriteXML.py @@ -943,10 +943,32 @@ class GrampsDbXmlWriter(UpdateCallback): proplist = photo.get_attribute_list() refslist = photo.get_source_references() nreflist = photo.get_note_list() - if (len(proplist) + len(nreflist) + len(refslist)) == 0: + rect = photo.get_rectangle() + if rect is not None : + corner1_x = rect[0] + corner1_y = rect[1] + corner2_x = rect[2] + corner2_y = rect[3] + if corner1_x==None : corner1_x = 0 + if corner1_y==None : corner1_y = 0 + if corner2_x==None : corner2_x = 100 + if corner2_y==None : corner2_y = 100 + #don't output not set rectangle + if (corner1_x == 0 and corner1_y == 0 + and corner2_x == 0 and corner2_y == 0 + ) or (corner1_x == 0 and corner1_y == 0 + and corner2_x == 100 and corner2_y == 100 + ): + rect = None + if (len(proplist) + len(nreflist) + len(refslist)) == 0 \ + and rect is None: self.g.write("/>\n") else: self.g.write(">\n") + if rect is not None : + self.g.write(' %s\n' % + (sp,corner1_x,corner1_y,corner2_x,corner2_y)) self.write_attribute_list(proplist,indent+1) for ref in refslist: self.dump_source_ref(ref,indent+1) diff --git a/src/GrampsDbUtils/_ReadXML.py b/src/GrampsDbUtils/_ReadXML.py index 25d8588a3..cc0fc34ac 100644 --- a/src/GrampsDbUtils/_ReadXML.py +++ b/src/GrampsDbUtils/_ReadXML.py @@ -382,6 +382,7 @@ class GrampsParser(UpdateCallback): "families" : (None, self.stop_families), "family" : (self.start_family, self.stop_family), "rel" : (self.start_rel, None), + "region" : (self.start_region, None), "father" : (self.start_father, None), "first" : (None, self.stop_first), "call" : (None, self.stop_call), @@ -1342,6 +1343,13 @@ class GrampsParser(UpdateCallback): elif self.placeobj: self.placeobj.add_media_reference(self.objref) + def start_region(self,attrs): + rect = (int(attrs.get('corner1_x')), + int(attrs.get('corner1_y')), + int(attrs.get('corner2_x')), + int(attrs.get('corner2_y')) ) + self.objref.set_rectangle(rect) + def start_object(self, attrs): gramps_id = self.map_oid(attrs['id']) try: