2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Copyright (C) 2003 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
|
|
|
|
#
|
|
|
|
|
2003-06-12 04:03:01 +05:30
|
|
|
#
|
|
|
|
# Written by Alex Roitman,
|
2003-08-26 09:37:00 +05:30
|
|
|
# largely based on the BaseDoc classes by Don Allingham
|
2003-06-12 04:03:01 +05:30
|
|
|
#
|
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
|
|
|
import string
|
|
|
|
|
2003-06-10 10:19:39 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SAX interface
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
try:
|
|
|
|
from xml.sax import make_parser,handler,SAXParseException
|
|
|
|
except:
|
|
|
|
from _xmlplus.sax import make_parser,handler,SAXParseException
|
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from RelLib import Person
|
|
|
|
|
|
|
|
import const
|
|
|
|
import Utils
|
|
|
|
import ListModel
|
|
|
|
import GrampsCfg
|
|
|
|
import Plugins
|
|
|
|
import Report
|
2003-08-26 09:37:00 +05:30
|
|
|
import BaseDoc
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2003-06-12 04:03:01 +05:30
|
|
|
from QuestionDialog import WarningDialog
|
2003-06-11 10:09:53 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Book Item class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class BookItem:
|
|
|
|
"""
|
|
|
|
Interface into the book item -- a smallest element of the book.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,name=None):
|
|
|
|
"""
|
|
|
|
Creates a new empty BookItem.
|
2003-06-16 21:59:35 +05:30
|
|
|
|
|
|
|
name: if not None then the book item is retreived
|
|
|
|
from the book item registry using name for lookup
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
if name:
|
|
|
|
self.get_registered_item(name)
|
2003-07-07 01:25:45 +05:30
|
|
|
else:
|
|
|
|
self.clear()
|
2003-06-11 10:09:53 +05:30
|
|
|
|
|
|
|
def clear(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Clear the contents of the book item.
|
|
|
|
|
|
|
|
Everything gets set to empty values except for the style_name"""
|
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
self.name = ""
|
|
|
|
self.category = ""
|
|
|
|
self.dialog = None
|
|
|
|
self.write_item = None
|
|
|
|
self.options = []
|
|
|
|
self.style_file = ""
|
|
|
|
self.style_name = "default"
|
|
|
|
self.make_default_style = None
|
|
|
|
|
|
|
|
def get_registered_item(self,name):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Retrieve the item from the book item registry.
|
|
|
|
|
|
|
|
name: a name used for lookup.
|
|
|
|
"""
|
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
self.clear()
|
|
|
|
for item in Plugins._bkitems:
|
|
|
|
if item[0] == name:
|
|
|
|
self.name = item[0]
|
|
|
|
self.category = item[1]
|
|
|
|
self.dialog = item[2]
|
|
|
|
self.write_item = item[3]
|
2003-07-07 01:25:45 +05:30
|
|
|
self.options = list(item[4])
|
2003-06-11 10:09:53 +05:30
|
|
|
self.style_name = item[5]
|
|
|
|
self.style_file = item[6]
|
|
|
|
self.make_default_style = item[7]
|
|
|
|
|
|
|
|
def get_name(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the name of the item.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.name
|
|
|
|
|
|
|
|
def get_category(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the category of the item.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.category
|
|
|
|
|
|
|
|
def get_dialog(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the callable cofigurator dialog.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.dialog
|
|
|
|
|
|
|
|
def get_write_item(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the report-writing function of the item.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.write_item
|
|
|
|
|
|
|
|
def set_options(self,options):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Sets the options for the item.
|
|
|
|
|
|
|
|
options: list of options to set.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.options = options
|
|
|
|
|
|
|
|
def get_options(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the list of options for the item.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.options
|
|
|
|
|
|
|
|
def set_style_name(self,style_name):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Sets the style name for the item.
|
|
|
|
|
|
|
|
style_name: name of the style to set.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.style_name = style_name
|
|
|
|
|
|
|
|
def get_style_name(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the style name of the item.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.style_name
|
|
|
|
|
|
|
|
def get_style_file(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the style file name for the item.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.style_file
|
|
|
|
|
|
|
|
def get_make_default_style(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the function to make default style for the item.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.make_default_style
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Book class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class Book:
|
|
|
|
"""
|
2003-06-16 21:59:35 +05:30
|
|
|
Interface into the user-defined book -- a collection of book items.
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,obj=None):
|
|
|
|
"""
|
|
|
|
Creates a new empty Book.
|
|
|
|
|
2003-06-16 21:59:35 +05:30
|
|
|
obj: if not None, creates the Book from the values in
|
|
|
|
obj, instead of creating an empty Book.
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
self.name = ""
|
|
|
|
self.dbname = ""
|
|
|
|
if obj:
|
|
|
|
self.item_list = obj.item_list
|
|
|
|
else:
|
|
|
|
self.item_list = []
|
|
|
|
|
|
|
|
def set_name(self,name):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Sets the name of the book.
|
|
|
|
|
|
|
|
name: the name to set.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.name = name
|
|
|
|
|
|
|
|
def get_name(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the name of the book.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.name
|
|
|
|
|
|
|
|
def get_dbname(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns the name of the database file used for the book.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.dbname
|
|
|
|
|
|
|
|
def set_dbname(self,name):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Sets the name of the database file used for the book.
|
|
|
|
|
|
|
|
name: a filename to set.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.dbname = name
|
|
|
|
|
|
|
|
def clear(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Clears the contents of the book.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.item_list = []
|
|
|
|
|
|
|
|
def append_item(self,item):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Adds an item to the book.
|
|
|
|
|
|
|
|
item: an item to append.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.item_list.append(item)
|
|
|
|
|
|
|
|
def insert_item(self,index,item):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Inserts an item into the given position in the book.
|
|
|
|
|
|
|
|
index: a position index.
|
|
|
|
item: an item to append.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.item_list.insert(index,item)
|
|
|
|
|
|
|
|
def pop_item(self,index):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Pop an item from given position in the book.
|
|
|
|
|
|
|
|
index: a position index.
|
|
|
|
"""
|
2003-06-12 04:03:01 +05:30
|
|
|
return self.item_list.pop(index)
|
2003-06-11 10:09:53 +05:30
|
|
|
|
|
|
|
def get_item(self,index):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns an item at a given position in the book.
|
|
|
|
|
|
|
|
index: a position index.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.item_list[index]
|
|
|
|
|
|
|
|
def set_item(self,index,item):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Sets an item at a given position in the book.
|
|
|
|
|
|
|
|
index: a position index.
|
|
|
|
item: an item to set.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.item_list[index] = item
|
|
|
|
|
|
|
|
def get_item_list(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Returns list of items in the current book.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
return self.item_list
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# BookList class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class BookList:
|
|
|
|
"""
|
2003-06-16 21:59:35 +05:30
|
|
|
Interface into the user-defined list of books.
|
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
BookList is loaded from a specified XML file if it exists.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,file):
|
|
|
|
"""
|
|
|
|
Creates a new BookList from the books that may be defined in the
|
|
|
|
specified file.
|
|
|
|
|
2003-06-16 21:59:35 +05:30
|
|
|
file: XML file that contains book items definitions
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
self.bookmap = {}
|
|
|
|
self.file = os.path.expanduser("~/.gramps/" + file)
|
|
|
|
self.parse()
|
|
|
|
|
|
|
|
def delete_book(self,name):
|
|
|
|
"""
|
|
|
|
Removes a book from the list. Since each book must have a
|
|
|
|
unique name, the name is used to delete the book.
|
|
|
|
|
2003-06-16 21:59:35 +05:30
|
|
|
name: name of the book to delete
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
del self.bookmap[name]
|
|
|
|
|
|
|
|
def get_book_map(self):
|
|
|
|
"""
|
|
|
|
Returns the map of names to books.
|
|
|
|
"""
|
|
|
|
return self.bookmap
|
|
|
|
|
|
|
|
def get_book(self,name):
|
|
|
|
"""
|
|
|
|
Returns the Book associated with the name
|
|
|
|
|
2003-06-16 21:59:35 +05:30
|
|
|
name: name associated with the desired Book.
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
return self.bookmap[name]
|
|
|
|
|
|
|
|
def get_book_names(self):
|
|
|
|
"Returns a list of all the book names in the BookList"
|
|
|
|
return self.bookmap.keys()
|
|
|
|
|
|
|
|
def set_book(self,name,book):
|
|
|
|
"""
|
|
|
|
Adds or replaces a Book in the BookList.
|
|
|
|
|
2003-06-16 21:59:35 +05:30
|
|
|
name: name assocated with the Book to add or replace.
|
|
|
|
book: definition of the Book
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
self.bookmap[name] = book
|
|
|
|
|
|
|
|
def save(self):
|
|
|
|
"""
|
|
|
|
Saves the current BookList to the associated file.
|
|
|
|
"""
|
|
|
|
f = open(self.file,"w")
|
|
|
|
f.write("<?xml version=\"1.0\"?>\n")
|
|
|
|
f.write('<booklist>\n')
|
|
|
|
|
|
|
|
for name in self.bookmap.keys():
|
|
|
|
book = self.get_book(name)
|
|
|
|
dbname = book.get_dbname()
|
|
|
|
f.write('<book name="%s" database="%s">\n' % (name,dbname) )
|
|
|
|
for item in book.get_item_list():
|
|
|
|
f.write(' <item name="%s">\n' % item.get_name() )
|
|
|
|
options = item.get_options()
|
|
|
|
for opt_index in range(len(options)):
|
|
|
|
f.write(' <option number="%d" value="%s"/>\n' % (
|
|
|
|
opt_index,options[opt_index]) )
|
|
|
|
f.write(' <style name="%s"/>\n' % item.get_style_name() )
|
|
|
|
f.write(' </item>\n')
|
|
|
|
f.write('</book>\n')
|
|
|
|
|
|
|
|
f.write('</booklist>\n')
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
def parse(self):
|
|
|
|
"""
|
|
|
|
Loads the BookList from the associated file, if it exists.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
p = make_parser()
|
|
|
|
p.setContentHandler(BookParser(self))
|
|
|
|
p.parse('file://' + self.file)
|
|
|
|
except (IOError,OSError,SAXParseException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# BookParser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class BookParser(handler.ContentHandler):
|
|
|
|
"""
|
|
|
|
SAX parsing class for the Books XML file.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,booklist):
|
|
|
|
"""
|
|
|
|
Creates a BookParser class that populates the passed booklist.
|
|
|
|
|
2003-06-16 21:59:35 +05:30
|
|
|
booklist: BookList to be loaded from the file.
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
handler.ContentHandler.__init__(self)
|
|
|
|
self.booklist = booklist
|
|
|
|
self.b = None
|
|
|
|
self.i = None
|
|
|
|
self.o = None
|
|
|
|
self.s = None
|
|
|
|
self.bname = None
|
|
|
|
self.iname = None
|
|
|
|
|
|
|
|
def startElement(self,tag,attrs):
|
|
|
|
"""
|
|
|
|
Overridden class that handles the start of a XML element
|
|
|
|
"""
|
|
|
|
if tag == "book":
|
|
|
|
self.b = Book()
|
|
|
|
self.bname = attrs['name']
|
|
|
|
self.b.set_name(self.bname)
|
|
|
|
self.dbname = attrs['database']
|
|
|
|
self.b.set_dbname(self.dbname)
|
|
|
|
elif tag == "item":
|
|
|
|
self.i = BookItem(attrs['name'])
|
|
|
|
self.o = []
|
|
|
|
elif tag == "option":
|
|
|
|
self.o.append(attrs['value'])
|
|
|
|
elif tag == "style":
|
|
|
|
self.s = attrs['name']
|
|
|
|
|
|
|
|
def endElement(self,tag):
|
2003-06-16 21:59:35 +05:30
|
|
|
"Overridden class that handles the end of a XML element"
|
2003-06-11 10:09:53 +05:30
|
|
|
if tag == "item":
|
|
|
|
self.i.set_options(self.o)
|
|
|
|
self.i.set_style_name(self.s)
|
|
|
|
self.b.append_item(self.i)
|
|
|
|
elif tag == "book":
|
|
|
|
self.booklist.set_book(self.bname,self.b)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# BookList Display class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class BookListDisplay:
|
|
|
|
"""
|
2003-06-16 21:59:35 +05:30
|
|
|
Interface into a dialog with the list of available books.
|
|
|
|
|
|
|
|
Allows the user to select and/or delete a book from the list.
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,booklist,nodelete=0):
|
|
|
|
"""
|
|
|
|
Creates a BookListDisplay object that displays the books in BookList.
|
|
|
|
|
2003-06-16 21:59:35 +05:30
|
|
|
booklist: books that are displayed
|
|
|
|
nodelete: if not 0 then the Delete button is hidden
|
2003-06-11 10:09:53 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
self.booklist = booklist
|
|
|
|
base = os.path.dirname(__file__)
|
|
|
|
glade_file = os.path.join(base,"book.glade")
|
2003-08-17 07:44:33 +05:30
|
|
|
self.xml = gtk.glade.XML(glade_file,"booklist","gramps")
|
2003-06-11 10:09:53 +05:30
|
|
|
self.top = self.xml.get_widget('booklist')
|
|
|
|
|
|
|
|
Utils.set_titles(self.top,
|
|
|
|
self.xml.get_widget('title'),_('Available Books'))
|
|
|
|
|
|
|
|
if nodelete:
|
|
|
|
delete_button = self.xml.get_widget("delete_button")
|
|
|
|
delete_button.hide()
|
|
|
|
|
|
|
|
self.xml.signal_autoconnect({
|
|
|
|
"on_booklist_cancel_clicked" : self.on_booklist_cancel_clicked,
|
|
|
|
"on_booklist_ok_clicked" : self.on_booklist_ok_clicked,
|
|
|
|
"on_booklist_delete_clicked" : self.on_booklist_delete_clicked
|
|
|
|
})
|
|
|
|
|
|
|
|
title_label = self.xml.get_widget('title')
|
|
|
|
title_label.set_text(Utils.title(_('Book List')))
|
|
|
|
title_label.set_use_markup(gtk.TRUE)
|
|
|
|
|
|
|
|
self.blist = ListModel.ListModel(self.xml.get_widget("list"),
|
|
|
|
[('Name',-1,10)],)
|
|
|
|
self.redraw()
|
|
|
|
self.selection = None
|
|
|
|
self.top.run()
|
|
|
|
|
|
|
|
def redraw(self):
|
2003-06-12 04:03:01 +05:30
|
|
|
"""Redraws the list of currently available books"""
|
2003-06-11 10:09:53 +05:30
|
|
|
|
|
|
|
self.blist.model.clear()
|
|
|
|
names = self.booklist.get_book_names()
|
|
|
|
if not len(names):
|
|
|
|
return
|
|
|
|
for name in names:
|
|
|
|
iter = self.blist.add([name])
|
|
|
|
if iter:
|
|
|
|
self.blist.selection.select_iter(iter)
|
|
|
|
path = self.blist.model.get_path(iter)
|
|
|
|
|
|
|
|
def on_booklist_ok_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""Returns selected book. Saves the current list into xml file."""
|
2003-06-11 10:09:53 +05:30
|
|
|
store,iter = self.blist.get_selected()
|
|
|
|
if iter:
|
|
|
|
data = self.blist.get_data(iter,[0])
|
|
|
|
self.selection = self.booklist.get_book(data[0])
|
|
|
|
self.booklist.save()
|
|
|
|
|
|
|
|
def on_booklist_delete_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Deletes selected book from the list.
|
|
|
|
|
|
|
|
This change is not final. OK button has to be clicked to save the list.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
store,iter = self.blist.get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
data = self.blist.get_data(iter,[0])
|
|
|
|
self.booklist.delete_book(data[0])
|
|
|
|
self.blist.remove(iter)
|
|
|
|
self.top.run()
|
|
|
|
|
|
|
|
def on_booklist_cancel_clicked(self,obj):
|
|
|
|
pass
|
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2003-06-11 10:09:53 +05:30
|
|
|
# Book creation dialog
|
2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class BookReportSelector:
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Interface into a dialog setting up the book.
|
|
|
|
|
|
|
|
Allows the user to add/remove/reorder/setup items for the current book
|
|
|
|
and to clear/load/save/edit whole books.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def __init__(self,db,person):
|
|
|
|
self.db = db
|
|
|
|
self.person = person
|
2003-06-11 10:09:53 +05:30
|
|
|
self.file = "books.xml"
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
base = os.path.dirname(__file__)
|
|
|
|
glade_file = os.path.join(base,"book.glade")
|
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
self.xml = gtk.glade.XML(glade_file,"top","gramps")
|
2003-06-02 19:04:18 +05:30
|
|
|
self.top = self.xml.get_widget("top")
|
|
|
|
|
|
|
|
self.xml.signal_autoconnect({
|
|
|
|
"on_add_clicked" : self.on_add_clicked,
|
|
|
|
"on_remove_clicked" : self.on_remove_clicked,
|
|
|
|
"on_up_clicked" : self.on_up_clicked,
|
|
|
|
"on_down_clicked" : self.on_down_clicked,
|
|
|
|
"on_setup_clicked" : self.on_setup_clicked,
|
|
|
|
"on_clear_clicked" : self.on_clear_clicked,
|
2003-06-09 05:37:31 +05:30
|
|
|
"on_save_clicked" : self.on_save_clicked,
|
|
|
|
"on_open_clicked" : self.on_open_clicked,
|
2003-06-11 10:09:53 +05:30
|
|
|
"on_edit_clicked" : self.on_edit_clicked,
|
2003-06-02 19:04:18 +05:30
|
|
|
"on_book_ok_clicked" : self.on_book_ok_clicked,
|
|
|
|
"destroy_passed_object" : self.close
|
|
|
|
})
|
|
|
|
|
|
|
|
self.avail_tree = self.xml.get_widget("avail_tree")
|
|
|
|
self.book_tree = self.xml.get_widget("book_tree")
|
2003-08-29 08:38:02 +05:30
|
|
|
self.avail_tree.connect('button-press-event',self.av_button_press)
|
|
|
|
self.book_tree.connect('button-press-event',self.bk_button_press)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
title_label = self.xml.get_widget('title')
|
|
|
|
Utils.set_titles(self.top,title_label,_('Book Report'))
|
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
self.name_entry = self.xml.get_widget("name_entry")
|
2003-07-05 23:55:25 +05:30
|
|
|
self.name_entry.set_text(_('New Book'))
|
2003-06-11 10:09:53 +05:30
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
avail_label = self.xml.get_widget('avail_label')
|
2003-07-05 23:55:25 +05:30
|
|
|
avail_label.set_text("<b>%s</b>" % _("Available items"))
|
2003-06-02 19:04:18 +05:30
|
|
|
avail_label.set_use_markup(gtk.TRUE)
|
|
|
|
book_label = self.xml.get_widget('book_label')
|
2003-07-05 23:55:25 +05:30
|
|
|
book_label.set_text("<b>%s</b>" % _("Current book"))
|
2003-06-02 19:04:18 +05:30
|
|
|
book_label.set_use_markup(gtk.TRUE)
|
|
|
|
|
2003-06-09 05:37:31 +05:30
|
|
|
av_titles = [(_('Name'),0,150),(_('Type'),1,50)]
|
|
|
|
bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),
|
2003-06-11 10:09:53 +05:30
|
|
|
(_('Center person'),-1,50)]
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
self.av_ncols = len(av_titles)
|
|
|
|
self.bk_ncols = len(bk_titles)
|
|
|
|
|
|
|
|
self.av_model = ListModel.ListModel(self.avail_tree,av_titles)
|
|
|
|
self.bk_model = ListModel.ListModel(self.book_tree,bk_titles)
|
|
|
|
self.draw_avail_list()
|
2003-06-11 10:09:53 +05:30
|
|
|
|
|
|
|
self.book = Book()
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def close(self,obj):
|
|
|
|
self.top.destroy()
|
|
|
|
|
|
|
|
def draw_avail_list(self):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Draw the list with the selections available for the book.
|
|
|
|
|
|
|
|
The selections are read from the book item registry.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2003-06-08 05:08:13 +05:30
|
|
|
if not Plugins._bkitems:
|
|
|
|
return
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2003-06-08 05:08:13 +05:30
|
|
|
for book_item in Plugins._bkitems:
|
|
|
|
data = [ book_item[0], book_item[1] ]
|
|
|
|
new_iter = self.av_model.add(data)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
self.av_model.connect_model()
|
|
|
|
|
2003-06-08 05:08:13 +05:30
|
|
|
if new_iter:
|
|
|
|
self.av_model.selection.select_iter(new_iter)
|
|
|
|
path = self.av_model.model.get_path(new_iter)
|
2003-06-02 19:04:18 +05:30
|
|
|
col = self.avail_tree.get_column(0)
|
|
|
|
self.avail_tree.scroll_to_cell(path,col,1,1,0.0)
|
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
def open_book(self,book):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Open the book: set the current set of selections to this book's items.
|
|
|
|
|
|
|
|
book: the book object to load.
|
|
|
|
"""
|
2003-06-12 04:03:01 +05:30
|
|
|
if book.get_dbname() == self.db.getSavePath():
|
|
|
|
same_db = 1
|
|
|
|
else:
|
|
|
|
same_db = 0
|
|
|
|
WarningDialog(_('Different database'), _(
|
2003-06-16 21:59:35 +05:30
|
|
|
'This book was created with the references to database %s.\n\n'
|
2003-06-12 04:03:01 +05:30
|
|
|
'This makes references to the central person saved in the book invalid.\n\n'
|
|
|
|
'Therefore, the central person for each item is being set '
|
2003-06-16 21:59:35 +05:30
|
|
|
'to the active person of the currently opened database.' )
|
2003-06-12 04:03:01 +05:30
|
|
|
% book.get_dbname() )
|
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
self.book.clear()
|
|
|
|
self.bk_model.clear()
|
|
|
|
for saved_item in book.get_item_list():
|
|
|
|
name = saved_item.get_name()
|
|
|
|
item = BookItem(name)
|
|
|
|
options = saved_item.get_options()
|
2003-06-12 04:03:01 +05:30
|
|
|
if not same_db or not options[0]:
|
2003-06-11 10:09:53 +05:30
|
|
|
options[0] = self.person.getId()
|
|
|
|
item.set_options(options)
|
|
|
|
item.set_style_name(saved_item.get_style_name())
|
|
|
|
self.book.append_item(item)
|
|
|
|
|
|
|
|
data = [ item.get_name(), item.get_category() ]
|
|
|
|
pname = self.db.getPerson(options[0])
|
|
|
|
data.append(pname.getPrimaryName().getRegularName())
|
|
|
|
self.bk_model.add(data)
|
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
def on_add_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Add an item to the current selections.
|
|
|
|
|
|
|
|
Use the selected available item to get the item's name in the registry.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
store,iter = self.av_model.get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
data = self.av_model.get_data(iter,range(self.av_ncols))
|
2003-07-06 03:20:23 +05:30
|
|
|
if data[1] == _("Title"):
|
|
|
|
data.append(_("Not Applicable"))
|
|
|
|
else:
|
|
|
|
data.append(self.person.getPrimaryName().getRegularName())
|
2003-06-02 19:04:18 +05:30
|
|
|
self.bk_model.add(data)
|
2003-06-11 10:09:53 +05:30
|
|
|
item = BookItem(data[0])
|
|
|
|
options = item.get_options()
|
|
|
|
if not options[0]:
|
|
|
|
options[0] = self.person.getId()
|
|
|
|
item.set_options(options)
|
|
|
|
self.book.append_item(item)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def on_remove_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Remove the item from the current list of selections.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
store,iter = self.bk_model.get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2003-06-11 10:09:53 +05:30
|
|
|
row = self.bk_model.get_selected_row()
|
|
|
|
self.book.pop_item(row)
|
2003-06-02 19:04:18 +05:30
|
|
|
self.bk_model.remove(iter)
|
|
|
|
|
|
|
|
def on_clear_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Clear the whole current book.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
self.bk_model.clear()
|
2003-06-11 10:09:53 +05:30
|
|
|
self.book.clear()
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def on_up_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Move the currently selected item one row up in the selection list.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
row = self.bk_model.get_selected_row()
|
|
|
|
if not row or row == -1:
|
|
|
|
return
|
|
|
|
store,iter = self.bk_model.get_selected()
|
|
|
|
data = self.bk_model.get_data(iter,range(self.bk_ncols))
|
|
|
|
self.bk_model.remove(iter)
|
|
|
|
self.bk_model.insert(row-1,data,None,1)
|
2003-06-11 10:09:53 +05:30
|
|
|
item = self.book.pop_item(row)
|
|
|
|
self.book.insert_item(row-1,item)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def on_down_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Move the currently selected item one row down in the selection list.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
row = self.bk_model.get_selected_row()
|
|
|
|
if row + 1 >= self.bk_model.count or row == -1:
|
|
|
|
return
|
|
|
|
store,iter = self.bk_model.get_selected()
|
|
|
|
data = self.bk_model.get_data(iter,range(self.bk_ncols))
|
|
|
|
self.bk_model.remove(iter)
|
|
|
|
self.bk_model.insert(row+1,data,None,1)
|
2003-06-11 10:09:53 +05:30
|
|
|
item = self.book.pop_item(row)
|
|
|
|
self.book.insert_item(row+1,item)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def on_setup_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Configure currently selected item.
|
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
store,iter = self.bk_model.get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
|
|
|
data = self.bk_model.get_data(iter,range(self.bk_ncols))
|
2003-06-11 10:09:53 +05:30
|
|
|
row = self.bk_model.get_selected_row()
|
|
|
|
item = self.book.get_item(row)
|
2003-06-12 04:03:01 +05:30
|
|
|
options_dialog = item.get_dialog()
|
2003-06-11 10:09:53 +05:30
|
|
|
options = item.get_options()
|
|
|
|
style_name = item.get_style_name()
|
|
|
|
opt_dlg = options_dialog(self.db,self.person,options,style_name)
|
2003-06-10 04:09:56 +05:30
|
|
|
opt_dlg.window.destroy()
|
2003-07-06 03:20:23 +05:30
|
|
|
if opt_dlg.person and data[1] != _("Title"):
|
2003-06-09 02:02:17 +05:30
|
|
|
self.bk_model.model.set_value(iter,2,
|
|
|
|
opt_dlg.person.getPrimaryName().getRegularName())
|
2003-06-11 10:09:53 +05:30
|
|
|
item.set_options(opt_dlg.options)
|
|
|
|
item.set_style_name(opt_dlg.style_name)
|
|
|
|
self.book.set_item(row,item)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2003-08-29 08:38:02 +05:30
|
|
|
def bk_button_press(self,obj,event):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Double-click on the current book selection is the same as setup.
|
2003-08-29 08:38:02 +05:30
|
|
|
Right click evokes the context menu.
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
self.on_setup_clicked(obj)
|
2003-08-29 08:38:02 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
|
|
self.build_bk_context_menu()
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2003-08-29 08:38:02 +05:30
|
|
|
def av_button_press(self,obj,event):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Double-click on the available selection is the same as add.
|
2003-08-29 08:38:02 +05:30
|
|
|
Right click evokes the context menu.
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
2003-06-02 19:04:18 +05:30
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
self.on_add_clicked(obj)
|
2003-08-29 08:38:02 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
|
|
self.build_av_context_menu()
|
|
|
|
|
|
|
|
def build_bk_context_menu(self):
|
|
|
|
"""Builds the menu with item-centered and book-centered options."""
|
|
|
|
|
|
|
|
store,iter = self.bk_model.get_selected()
|
|
|
|
if iter:
|
|
|
|
sensitivity = 1
|
|
|
|
else:
|
|
|
|
sensitivity = 0
|
|
|
|
entries = [
|
|
|
|
(gtk.STOCK_GO_UP, self.on_up_clicked, sensitivity),
|
|
|
|
(gtk.STOCK_GO_DOWN, self.on_down_clicked, sensitivity),
|
|
|
|
(_("Setup"), self.on_setup_clicked, sensitivity),
|
|
|
|
(gtk.STOCK_REMOVE, self.on_remove_clicked, sensitivity),
|
|
|
|
(None,None,0),
|
|
|
|
(gtk.STOCK_CLEAR, self.on_clear_clicked, 1),
|
|
|
|
(gtk.STOCK_SAVE, self.on_save_clicked, 1),
|
|
|
|
(gtk.STOCK_OPEN, self.on_open_clicked, 1),
|
|
|
|
(_("Edit"), self.on_edit_clicked,1 ),
|
|
|
|
]
|
|
|
|
|
|
|
|
menu = gtk.Menu()
|
|
|
|
menu.set_title(_('Book Menu'))
|
|
|
|
for stock_id,callback,sensitivity in entries:
|
|
|
|
item = gtk.ImageMenuItem(stock_id)
|
|
|
|
if callback:
|
|
|
|
item.connect("activate",callback)
|
|
|
|
item.set_sensitive(sensitivity)
|
|
|
|
item.show()
|
|
|
|
menu.append(item)
|
|
|
|
menu.popup(None,None,None,0,0)
|
|
|
|
|
|
|
|
def build_av_context_menu(self):
|
|
|
|
"""Builds the menu with the single Add option."""
|
|
|
|
|
|
|
|
store,iter = self.av_model.get_selected()
|
|
|
|
if iter:
|
|
|
|
sensitivity = 1
|
|
|
|
else:
|
|
|
|
sensitivity = 0
|
|
|
|
entries = [
|
|
|
|
(gtk.STOCK_ADD, self.on_add_clicked, sensitivity),
|
|
|
|
]
|
|
|
|
|
|
|
|
menu = gtk.Menu()
|
|
|
|
menu.set_title(_('Available Items Menu'))
|
|
|
|
for stock_id,callback,sensitivity in entries:
|
|
|
|
item = gtk.ImageMenuItem(stock_id)
|
|
|
|
if callback:
|
|
|
|
item.connect("activate",callback)
|
|
|
|
item.set_sensitive(sensitivity)
|
|
|
|
item.show()
|
|
|
|
menu.append(item)
|
|
|
|
menu.popup(None,None,None,0,0)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2003-06-08 05:08:13 +05:30
|
|
|
def on_book_ok_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Run final BookReportDialog with the current book.
|
|
|
|
"""
|
|
|
|
if self.book.item_list:
|
2003-06-11 10:09:53 +05:30
|
|
|
BookReportDialog(self.db,self.person,self.book)
|
2003-06-10 10:19:39 +05:30
|
|
|
self.top.destroy()
|
|
|
|
|
2003-06-09 05:37:31 +05:30
|
|
|
def on_save_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Save the current book in the xml booklist file.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.book_list = BookList(self.file)
|
|
|
|
name = self.name_entry.get_text()
|
|
|
|
self.book.set_name(name)
|
|
|
|
self.book.set_dbname(self.db.getSavePath())
|
|
|
|
self.book_list.set_book(name,self.book)
|
|
|
|
self.book_list.save()
|
2003-06-09 05:37:31 +05:30
|
|
|
|
|
|
|
def on_open_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Run the BookListDisplay dialog to present the choice of books to open.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.book_list = BookList(self.file)
|
|
|
|
booklistdisplay = BookListDisplay(self.book_list,1)
|
|
|
|
booklistdisplay.top.destroy()
|
|
|
|
book = booklistdisplay.selection
|
|
|
|
if book:
|
|
|
|
self.open_book(book)
|
|
|
|
|
|
|
|
def on_edit_clicked(self,obj):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
Run the BookListDisplay dialog to present the choice of books to delete.
|
|
|
|
"""
|
2003-06-11 10:09:53 +05:30
|
|
|
self.book_list = BookList(self.file)
|
|
|
|
booklistdisplay = BookListDisplay(self.book_list)
|
|
|
|
booklistdisplay.top.destroy()
|
2003-06-10 10:19:39 +05:30
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-06-08 05:08:13 +05:30
|
|
|
# The final dialog - paper, format, target, etc.
|
2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-06-08 05:08:13 +05:30
|
|
|
class BookReportDialog(Report.ReportDialog):
|
2003-06-16 21:59:35 +05:30
|
|
|
"""
|
|
|
|
A usual Report.Dialog subclass.
|
|
|
|
|
|
|
|
Creates a dialog selecting target, format, and paper/HTML options.
|
|
|
|
"""
|
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
def __init__(self,database,person,book):
|
2003-08-26 09:37:00 +05:30
|
|
|
import BaseDoc
|
2003-06-04 10:42:08 +05:30
|
|
|
Report.BareReportDialog.__init__(self,database,person)
|
2003-06-11 10:09:53 +05:30
|
|
|
self.book = book
|
2003-06-08 05:08:13 +05:30
|
|
|
self.database = database
|
|
|
|
self.person = person
|
2003-08-26 09:37:00 +05:30
|
|
|
self.selected_style = BaseDoc.StyleSheet()
|
2003-07-11 08:22:59 +05:30
|
|
|
|
2003-06-11 10:09:53 +05:30
|
|
|
for item in self.book.get_item_list():
|
2003-07-18 11:47:28 +05:30
|
|
|
# Set up default style
|
2003-08-26 09:37:00 +05:30
|
|
|
default_style = BaseDoc.StyleSheet()
|
2003-06-11 10:09:53 +05:30
|
|
|
make_default_style = item.get_make_default_style()
|
2003-07-18 11:47:28 +05:30
|
|
|
make_default_style(default_style)
|
|
|
|
|
|
|
|
# Read all style sheets available for this item
|
|
|
|
style_file = item.get_style_file()
|
2003-08-26 09:37:00 +05:30
|
|
|
style_list = BaseDoc.StyleSheetList(style_file,default_style)
|
2003-07-18 11:47:28 +05:30
|
|
|
|
|
|
|
# Get the selected stylesheet
|
2003-06-11 10:09:53 +05:30
|
|
|
style_name = item.get_style_name()
|
2003-07-18 11:47:28 +05:30
|
|
|
style_sheet = style_list.get_style_sheet(style_name)
|
|
|
|
|
|
|
|
for this_style_name in style_sheet.get_names():
|
|
|
|
self.selected_style.add_style(
|
|
|
|
this_style_name,style_sheet.get_style(this_style_name))
|
2003-06-08 05:08:13 +05:30
|
|
|
|
|
|
|
def setup_style_frame(self): pass
|
|
|
|
def setup_report_options_frame(self): pass
|
|
|
|
def setup_other_frames(self): pass
|
|
|
|
def parse_style_frame(self): pass
|
|
|
|
def parse_report_options_frame(self): pass
|
|
|
|
def parse_other_frames(self): pass
|
|
|
|
|
|
|
|
def doc_uses_tables(self):
|
|
|
|
return 1
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def get_title(self):
|
2003-06-08 05:08:13 +05:30
|
|
|
return _("Book Report")
|
|
|
|
|
|
|
|
def get_header(self,name):
|
2003-06-12 04:03:01 +05:30
|
|
|
return _("GRAMPS Book")
|
2003-06-08 05:08:13 +05:30
|
|
|
|
2003-07-05 23:55:25 +05:30
|
|
|
def get_stylesheet_savefile(self):
|
|
|
|
"""Needed solely for forming sane filename for the output."""
|
|
|
|
return "book.xml"
|
|
|
|
|
2003-06-08 05:08:13 +05:30
|
|
|
def make_doc_menu(self):
|
|
|
|
"""Build a menu of document types that are appropriate for
|
|
|
|
this text report. This menu will be generated based upon
|
|
|
|
whether the document requires table support, etc."""
|
2003-06-30 08:42:22 +05:30
|
|
|
Plugins.get_book_menu(self.format_menu, self.doc_uses_tables(),
|
|
|
|
self.doc_type_changed)
|
2003-06-08 05:08:13 +05:30
|
|
|
|
|
|
|
def make_document(self):
|
|
|
|
"""Create a document of the type requested by the user."""
|
|
|
|
self.doc = self.format(self.selected_style,self.paper,
|
2003-06-09 05:37:31 +05:30
|
|
|
self.template_name,self.orien)
|
2003-06-08 05:08:13 +05:30
|
|
|
|
2003-07-13 05:39:29 +05:30
|
|
|
self.rptlist = []
|
2003-06-25 09:05:44 +05:30
|
|
|
newpage = 0
|
2003-06-11 10:09:53 +05:30
|
|
|
for item in self.book.get_item_list():
|
|
|
|
write_book_item = item.get_write_item()
|
|
|
|
options = item.get_options()
|
2003-06-08 05:08:13 +05:30
|
|
|
if write_book_item:
|
2003-06-25 09:05:44 +05:30
|
|
|
obj = write_book_item(self.database,self.person,
|
2003-07-13 05:39:29 +05:30
|
|
|
self.doc,options,newpage)
|
|
|
|
self.rptlist.append(obj)
|
2003-06-25 09:05:44 +05:30
|
|
|
newpage = 1
|
2003-07-13 05:39:29 +05:30
|
|
|
self.doc.open(self.target_path)
|
|
|
|
|
|
|
|
def make_report(self):
|
|
|
|
"""The actual book report. Start it out, then go through the item list
|
|
|
|
and call each item's write_book_item method."""
|
|
|
|
|
|
|
|
for item in self.rptlist:
|
2003-06-25 09:05:44 +05:30
|
|
|
item.write_report()
|
2003-06-08 05:08:13 +05:30
|
|
|
self.doc.close()
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-06-08 05:08:13 +05:30
|
|
|
# Function to register the overall book report
|
2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def report(database,person):
|
|
|
|
BookReportSelector(database,person)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def get_xpm_image():
|
|
|
|
return [
|
|
|
|
"48 48 33 1",
|
|
|
|
" c None",
|
|
|
|
". c #1A1A1A",
|
|
|
|
"+ c #6A665E",
|
|
|
|
"@ c #A6A6A6",
|
|
|
|
"# c #BABAB6",
|
|
|
|
"$ c #D2D2D2",
|
|
|
|
"% c #EDE2D2",
|
|
|
|
"& c #7A7262",
|
|
|
|
"* c #F1EADF",
|
|
|
|
"= c #867A6E",
|
|
|
|
"- c #56524E",
|
|
|
|
"; c #868686",
|
|
|
|
"> c #E2CAA2",
|
|
|
|
", c #F2EEE2",
|
|
|
|
"' c #4E4E4E",
|
|
|
|
") c #B2966E",
|
|
|
|
"! c #FAFAFA",
|
|
|
|
"~ c #A29E96",
|
|
|
|
"{ c #BEA27A",
|
|
|
|
"] c #CECABE",
|
|
|
|
"^ c #968A76",
|
|
|
|
"/ c #DAD2C6",
|
|
|
|
"( c #423E3E",
|
|
|
|
"_ c #BA9E72",
|
|
|
|
": c #B7AC9A",
|
|
|
|
"< c #E9DAC3",
|
|
|
|
"[ c #E6E2E2",
|
|
|
|
"} c #322E2A",
|
|
|
|
"| c #9E9286",
|
|
|
|
"1 c #E6D2B6",
|
|
|
|
"2 c #F2EEE9",
|
|
|
|
"3 c #5E5A56",
|
|
|
|
"4 c #F6F2EE",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ^=^=====&&&+&++++333+& ",
|
|
|
|
" =##############:#:~;33& ",
|
|
|
|
" =#!!!!!!!!!!!!!!*[$#;;|- ",
|
|
|
|
" ;#!!!!!!!!!!!!!!!2[$@&]|( ",
|
|
|
|
" =#!!!!!!!!!!!!!!!!2[$-[];} ",
|
|
|
|
" =#!!!!@@@@@@@@!!!!![4'![];} ",
|
|
|
|
" =#!!!!!!4!!4!!!!!!!!4'!![];} ",
|
|
|
|
" =#!!!!!!!!!!!!!!!!!!!'*!![];( ",
|
|
|
|
" =#!!!!!!!!!!!!!!!!!!!'[*!![]|- ",
|
|
|
|
" &#!!!!@@~@@@~@@~@@@@@'][4!![#|+ ",
|
|
|
|
" &#!4!!!!!!!!!!!!!4!!!'..}('3&=+& ",
|
|
|
|
" =#!!!!@@@@@@@@@@@@@@@@##@~;=+3(+ ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!!![$##~;;='( ",
|
|
|
|
" &#!!!!@@@@@~@@@~@@@@~@@@@@#~~;+( ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!!!444[]#@~&} ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!4442[[$]#@=} ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!4444[[$]]:;} ",
|
|
|
|
" +#!!!!@~@@@@@@@@~@@@@@~~~|;]]];} ",
|
|
|
|
" +#!!!!!!!!!!!!!!!!!44444,[$/]:^} ",
|
|
|
|
" +#!!!!@@@~@@@@@@@@~@~~~~~~|1>$|} ",
|
|
|
|
" +#!!!!!!!!!!!!!!!44442[*%[[<$]|} ",
|
|
|
|
" +#!!!!@@@@~@@@@~~@~~~~~~~~|1/>~} ",
|
|
|
|
" +#!!!!!!!!!!!!!!44444**[%%</1])} ",
|
|
|
|
" +#!!!!!!!!!!!!!4422******%%<1/|} ",
|
|
|
|
" +#!!!!!!!!!!!!!!4,*,**2***%<1/)} ",
|
|
|
|
" 3#!!!!@@@@@~,442,*,*,2**,,[<1/)} ",
|
|
|
|
" +#!!!!!!4!!444444**[%%%%%%<<1>~} ",
|
|
|
|
" 3#!!!!@@4*@@@~~~~~~~~~~||||<11)} ",
|
|
|
|
" +#4!!4444444,24[[*[<%<%<<<<<11|} ",
|
|
|
|
" 3#!!!44,,,@~~~~~~~~~|||||||111_} ",
|
|
|
|
" 3#!!!!!44444[4[[%%%%%<<<<11111)} ",
|
|
|
|
" 3#!!!!~@,*~~~~~~~~||||||^|^1>1_} ",
|
|
|
|
" 3#!!!444442%**[%<%%%<<<<11111>_} ",
|
|
|
|
" 3#!!!4***[~~~~~~|||||||^|^^1>>{} ",
|
|
|
|
" -#!444444**[%<%%%<<<<11111>1>>_} ",
|
|
|
|
" -#4444~~[[~~~|||||||^)^^^^^>>>_} ",
|
|
|
|
" -#4444[**[%%%%%%<<<<11111>>>>>)} ",
|
|
|
|
" '#4444****%%%%%<<<111<11>>>>>>_} ",
|
|
|
|
" ':44****%%%%%<<<1<1<1>>1>>>>>>)} ",
|
|
|
|
" -@4******%%%<%<1<<1111>>>>>>>>)} ",
|
|
|
|
" '#****%%%%<%<<<<1<11>1>>>>>>>>)} ",
|
|
|
|
" ':##:::::::{{{{{{__{___))^)))))} ",
|
|
|
|
" }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" "]
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
from Plugins import register_report
|
|
|
|
|
|
|
|
register_report(
|
|
|
|
report,
|
|
|
|
_("Book Report"),
|
2003-06-25 09:05:44 +05:30
|
|
|
category=_("Books"),
|
2003-06-04 10:42:08 +05:30
|
|
|
status=(_("Unstable")),
|
2003-08-07 14:23:22 +05:30
|
|
|
description=_("Creates a book containing several reports."),
|
2003-06-04 10:42:08 +05:30
|
|
|
xpm=get_xpm_image(),
|
|
|
|
author_name="Alex Roitman",
|
|
|
|
author_email="shura@alex.neuro.umn.edu"
|
2003-06-02 19:04:18 +05:30
|
|
|
)
|