From 34fc21e621c7d881e62e30ffe8dc058ee89740b7 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 10 Jun 2003 04:49:39 +0000 Subject: [PATCH] * src/plugins/BookReport.py, src/plugins/FtmStyleDescendants.py, src/plugins/FtmStyleAncestors.py: Further work on option handling. Start parse/save cycle. svn: r1681 --- ChangeLog | 5 + src/plugins/BookReport.py | 141 ++++++++++++++++++++++++++--- src/plugins/FtmStyleAncestors.py | 10 +- src/plugins/FtmStyleDescendants.py | 14 +-- 4 files changed, 147 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb6912459..7537586b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-06-09 Alex Roitman + * src/plugins/BookReport.py, src/plugins/FtmStyleDescendants.py, + src/plugins/FtmStyleAncestors.py: Further work on option handling. + Start parse/save cycle. + 2003-06-09 Alex Roitman * src/ReadXML.py, src/plugins/Check.py, src/plugins/WriteCD.py, src/plugins/WritePkg.py: Proper use of dialog.run() in file diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index cc9e5e77d..db0833347 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -27,6 +27,16 @@ import os import string +#------------------------------------------------------------------------- +# +# SAX interface +# +#------------------------------------------------------------------------- +try: + from xml.sax import make_parser,handler,SAXParseException +except: + from _xmlplus.sax import make_parser,handler,SAXParseException + #------------------------------------------------------------------------- # # internationalization @@ -65,6 +75,7 @@ class BookReportSelector: def __init__(self,db,person): self.db = db self.person = person + self.file = os.path.expanduser("~/.gramps/books.xml") base = os.path.dirname(__file__) glade_file = os.path.join(base,"book.glade") @@ -72,11 +83,6 @@ class BookReportSelector: self.xml = gtk.glade.XML(glade_file,"top") self.top = self.xml.get_widget("top") - if person: - self.default_name = person.getPrimaryName().getSurname().upper() - else: - self.default_name = "" - self.xml.signal_autoconnect({ "on_add_clicked" : self.on_add_clicked, "on_remove_clicked" : self.on_remove_clicked, @@ -118,6 +124,8 @@ class BookReportSelector: self.av_model = ListModel.ListModel(self.avail_tree,av_titles) self.bk_model = ListModel.ListModel(self.book_tree,bk_titles) self.draw_avail_list() + self.bookmap = {} + self.parse() def close(self,obj): self.top.destroy() @@ -152,10 +160,6 @@ class BookReportSelector: self.bk_model.add(data) for book_item in Plugins._bkitems: if book_item[0] == data[0]: - #get_options = book_item[4] - #get_style = book_item[5] - #store_item = list(book_item) - #[ book_item[0], book_item[1], book_item[2], book_item[3], get_options(), get_style() ] self.item_storage[newkey] = list(book_item) def on_remove_clicked(self,obj): @@ -217,8 +221,14 @@ class BookReportSelector: self.on_add_clicked(obj) def on_book_ok_clicked(self,obj): + item_list = self.build_item_list() + if item_list: + BookReportDialog(self.db,self.person,item_list) + self.top.destroy() + + def build_item_list(self): + item_list = [] if self.bk_model.count: - item_list = [] for row in range(self.bk_model.count): self.bk_model.select_row(row) store,iter = self.bk_model.get_selected() @@ -226,15 +236,120 @@ class BookReportSelector: key = data[self.bk_ncols-1] book_item = self.item_storage[key] item_list.append(book_item) - BookReportDialog(self.db,self.person,item_list) - self.top.destroy() + return item_list + + + def save(self): + """ + Saves the current BookReportSelector selections to the associated file. + """ + f = open(self.file,"w") + f.write("\n") + f.write('\n') + + # Write old entries first + for name in self.bookmap.keys(): + f.write('\n' % + (name,self.db.getSavePath())) + item_list = self.bookmap[name] + for book_item in item_list: + f.write(' \n' % book_item[0]) + options = book_item[4] + for opt_index in range(len(options)): + f.write('