diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 1c5281549..0eae450bf 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,12 @@ +2005-10-17 Don Allingham + * src/AddSpouse.py: remove signal_autoconnect + * src/DisplayTrace.py: remove signal_autoconnect + * src/EditSource.py: remove signal_autoconnect + * src/ReadGedcom.py: two pass approach for handling forward + refererencing notes + * src/gramps.glade: remove signal mappings + * src/plugins.glade: remove signal mappings + 2005-10-18 Julio Sanchez * src/WriteGedcom.py: Add description and notes for media objects diff --git a/gramps2/src/AddSpouse.py b/gramps2/src/AddSpouse.py index c50367624..cab6fcaf4 100644 --- a/gramps2/src/AddSpouse.py +++ b/gramps2/src/AddSpouse.py @@ -60,6 +60,7 @@ import Marriage import NameDisplay import GenericFilter from QuestionDialog import ErrorDialog, QuestionDialog2 +from WindowUtils import GladeIf #------------------------------------------------------------------------- # @@ -94,6 +95,7 @@ class AddSpouse: # the same gender as the current person. self.glade = gtk.glade.XML(const.gladeFile, "spouseDialog","gramps") + self.gladeif = GladeIf(self.glade) self.relation_def = self.glade.get_widget("reldef") self.rel_combo = self.glade.get_widget("rel_combo") @@ -118,19 +120,25 @@ class AddSpouse: Utils.set_titles(self.window, self.glade.get_widget('title'),title, _('Choose Spouse/Partner')) - - self.glade.signal_autoconnect({ - "on_select_spouse_clicked" : self.select_spouse_clicked, - "on_spouse_help_clicked" : self.on_spouse_help_clicked, - "on_show_toggled" : self.on_show_toggled, - "on_new_spouse_clicked" : self.new_spouse_clicked, - "destroy_passed_object" : Utils.destroy_passed_object - }) + self.gladeif.connect('button117','clicked',self.close) + self.gladeif.connect('spouseDialog','delete_event',self.delete_event) + self.gladeif.connect('spouse_ok','clicked',self.select_spouse_clicked) + self.gladeif.connect('spouse_help','clicked',self.on_spouse_help_clicked) + self.gladeif.connect('spouseNewPerson','clicked',self.new_spouse_clicked) + self.gladeif.connect('show_all','clicked',self.on_show_toggled) + self.rel_combo.set_active(RelLib.Family.MARRIED) self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) gobject.idle_add(self.update_data) + def delete_event(self,obj): + self.gladeif.close() + + def close(self,obj): + self.gladeif.close() + self.window.close() + def build_all(self): return None diff --git a/gramps2/src/DisplayTrace.py b/gramps2/src/DisplayTrace.py index a8e2b2338..c8024afc7 100644 --- a/gramps2/src/DisplayTrace.py +++ b/gramps2/src/DisplayTrace.py @@ -107,7 +107,9 @@ class DisplayTrace: window.get_buffer().set_text(msg.getvalue()) print msg.getvalue() - self.glade.signal_autoconnect({'on_close_clicked':self.close}) + + window.connect('delete_event',self.close) + self.glade.get_widget('button107').connect('clicked',self.close) def close(self,obj): self.top.destroy() diff --git a/gramps2/src/EditSource.py b/gramps2/src/EditSource.py index 4c5ff032e..09f21a94e 100644 --- a/gramps2/src/EditSource.py +++ b/gramps2/src/EditSource.py @@ -49,6 +49,7 @@ import RelLib import NameDisplay import Spell import GrampsDisplay +from WindowUtils import GladeIf #------------------------------------------------------------------------- # @@ -87,6 +88,7 @@ class EditSource: self.top_window = gtk.glade.XML(const.gladeFile,"sourceEditor","gramps") self.top = self.top_window.get_widget("sourceEditor") + self.gladeif = GladeIf(self.top_window) Utils.set_titles(self.top,self.top_window.get_widget('title'), _('Source Editor')) @@ -138,20 +140,17 @@ class EditSource: if self.source.get_media_list(): Utils.bold_label(self.gallery_label) - self.top_window.signal_autoconnect({ - "on_switch_page" : self.on_switch_page, - "on_addphoto_clicked" : self.gallery.on_add_media_clicked, - "on_selectphoto_clicked" : self.gallery.on_select_media_clicked, - "on_deletephoto_clicked" : self.gallery.on_delete_media_clicked, - "on_editphoto_clicked" : self.gallery.on_edit_media_clicked, - "on_edit_properties_clicked": self.gallery.popup_change_description, - "on_sourceEditor_help_clicked" : self.on_help_clicked, - "on_sourceEditor_ok_clicked" : self.on_source_apply_clicked, - "on_sourceEditor_cancel_clicked" : self.close, - "on_sourceEditor_delete_event" : self.on_delete_event, - "on_delete_data_clicked" : self.on_delete_data_clicked, - "on_add_data_clicked" : self.on_add_data_clicked, - }) + self.gladeif.connect('sourceEditor','delete_event',self.on_delete_event) + self.gladeif.connect('button90','clicked',self.close) + self.gladeif.connect('ok','clicked',self.on_source_apply_clicked) + self.gladeif.connect('button166','clicked',self.on_help_clicked) + self.gladeif.connect('notebook2','switch_page',self.on_switch_page) + self.gladeif.connect('add_data','clicked',self.on_add_data_clicked) + self.gladeif.connect('del_data','clicked',self.on_delete_data_clicked) + self.gladeif.connect('add_photo','clicked',self.gallery.on_add_media_clicked) + self.gladeif.connect('sel_photo','clicked',self.gallery.on_select_media_clicked) + self.gladeif.connect('edit_photo','clicked',self.gallery.on_edit_media_clicked) + self.gladeif.connect('delete_photo','clicked',self.gallery.on_delete_media_clicked) if self.source.get_handle() == None or self.db.readonly: self.top_window.get_widget("edit_photo").set_sensitive(False) @@ -219,6 +218,7 @@ class EditSource: def on_delete_event(self,obj,b): self.close_child_windows() self.remove_itself_from_menu() + self.gladeif.close() gc.collect() def on_help_clicked(self,obj): @@ -229,6 +229,7 @@ class EditSource: self.gallery.close() self.close_child_windows() self.remove_itself_from_menu() + self.gladeif.close() self.top.destroy() gc.collect() diff --git a/gramps2/src/ReadGedcom.py b/gramps2/src/ReadGedcom.py index 02eb19aeb..7f7526cd9 100644 --- a/gramps2/src/ReadGedcom.py +++ b/gramps2/src/ReadGedcom.py @@ -197,7 +197,8 @@ def import2(database, filename, cb, codeset, use_trans): }) try: - g = GedcomParser(database,filename,statusTop, codeset) + np = NoteParser(filename, False) + g = GedcomParser(database,filename,statusTop, codeset, np.get_map()) except IOError,msg: Utils.destroy_passed_object(statusWindow) ErrorDialog(_("%s could not be opened\n") % filename,str(msg)) @@ -263,6 +264,52 @@ class GedcomDateParser(DateParser.DateParser): 'sep' : 9, 'oct' : 10, 'nov' : 11, 'dec' : 12, } +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- + +noteRE = re.compile(r"\s*\d+\s+\@(\S+)\@\s+NOTE(.*)$") +contRE = re.compile(r"\s*\d+\s+CONT\s(.*)$") +concRE = re.compile(r"\s*\d+\s+CONC\s(.*)$") + + +class NoteParser: + def __init__(self, filename,broken): + self.nmap = {} + + f = open(filename,"rU") + innote = False + + for line in f.xreadlines(): + + if innote: + match = contRE.match(line) + if match: + noteobj.append("\n" + match.groups()[0]) + + match = concRE.match(line) + if match: + if broken: + noteobj.append(" " + match.groups()[0]) + else: + noteobj.append(match.groups()[0]) + continue + innote = False + else: + match = noteRE.match(line) + if match: + data = match.groups()[0] + noteobj = RelLib.Note() + self.nmap["@%s@" % data] = noteobj + noteobj.append(match.groups()[1]) + innote = True + f.close() + + def get_map(self): + return self.nmap + #------------------------------------------------------------------------- # # @@ -273,7 +320,7 @@ class GedcomParser: SyntaxError = "Syntax Error" BadFile = "Not a GEDCOM file" - def __init__(self, dbase, filename, window, codeset): + def __init__(self, dbase, filename, window, codeset, smap): self.dp = GedcomDateParser() self.db = dbase self.person = None @@ -281,8 +328,7 @@ class GedcomParser: self.media_map = {} self.fmap = {} self.smap = {} - self.nmap = {} - self.share_note = {} + self.nmap = smap self.refn = {} self.added = {} self.gedmap = GedcomInfoDB() @@ -537,7 +583,6 @@ class GedcomParser: src.set_note(note) self.db.add_source(src,self.trans) - self.break_note_links() t = time.time() - t msg = _('Import Complete: %d seconds') % t @@ -554,14 +599,6 @@ class GedcomParser: print "Individuals: %d" % self.indi_count return None - def break_note_links(self): - for handle in self.share_note.keys(): - p = self.db.get_person_from_handle(handle) - if p: - note_id = self.share_note[handle] - p.set_note_object(self.nmap[note_id]) - self.db.commit_person(p,self.trans) - def parse_trailer(self): matches = self.get_next() if matches[0] >= 0 and matches[1] != "TRLR": @@ -697,11 +734,7 @@ class GedcomParser: source.set_title( matches[2][5:]) self.db.commit_source(source, self.trans) elif matches[2][0:4] == "NOTE": - noteobj = RelLib.Note() - self.nmap[matches[1]] = noteobj - text = matches[2][4:] - noteobj.append(text + self.parse_note_continue(1)) - self.parse_note_data(1) + self.ignore_sub_junk(1) elif matches[2] == "_LOC": # TODO: Add support for extended Locations. # See: http://en.wiki.genealogy.net/index.php/Gedcom_5.5EL @@ -945,7 +978,11 @@ class GedcomParser: def parse_note_base(self,matches,obj,level,old_note,task): note = old_note if matches[2] and matches[2][0] == "@": # reference to a named note defined elsewhere - self.share_note[obj.get_handle()] = matches[2] + nobj = self.nmap.get(matches[2]) + if nobj: + return nobj.get() + else: + return u"" else: if old_note: note = "%s\n%s%s" % (old_note,matches[2],self.parse_continue_data(level)) @@ -969,6 +1006,8 @@ class GedcomParser: if int(matches[0]) < 1: self.backup() + if note: + self.person.set_note(note) return elif matches[1] == "NAME": name = RelLib.Name() @@ -2090,3 +2129,9 @@ def extract_temple(matches): def create_id(): return Utils.create_id() + + +if __name__ == "__main__": + import sys + + a = NoteParser(sys.argv[1],False) diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index cdd6d9ced..302a111f4 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -3650,7 +3650,6 @@ GTK_RELIEF_NORMAL True -5 - @@ -3664,7 +3663,6 @@ GTK_RELIEF_NORMAL True -11 - @@ -3751,7 +3749,6 @@ True GTK_RELIEF_NORMAL True - @@ -3784,7 +3781,6 @@ False False True - 0 @@ -4739,7 +4735,6 @@ Other GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST False - @@ -4763,7 +4758,6 @@ Other GTK_RELIEF_NORMAL True -6 - @@ -4779,7 +4773,6 @@ Other GTK_RELIEF_NORMAL True -5 - @@ -4793,7 +4786,6 @@ Other GTK_RELIEF_NORMAL True -11 - @@ -4842,7 +4834,6 @@ Other GTK_POS_TOP False False - @@ -5269,7 +5260,6 @@ Other True GTK_RELIEF_NORMAL True - @@ -5297,7 +5287,6 @@ Other True GTK_RELIEF_NORMAL True - @@ -5406,7 +5395,6 @@ Other True GTK_RELIEF_NORMAL True - @@ -5434,7 +5422,6 @@ Other True GTK_RELIEF_NORMAL True - @@ -5462,7 +5449,6 @@ Other True GTK_RELIEF_NORMAL True - @@ -5490,7 +5476,6 @@ Other True GTK_RELIEF_NORMAL True - diff --git a/gramps2/src/plugins.glade b/gramps2/src/plugins.glade index 3af6053f8..ca333b6b8 100644 --- a/gramps2/src/plugins.glade +++ b/gramps2/src/plugins.glade @@ -18,7 +18,6 @@ GDK_WINDOW_TYPE_HINT_NORMAL GDK_GRAVITY_NORTH_WEST False -