* src/plugins/BookReport.py: Switch to saving/restoring/registering

items by the non-localized name.
* src/plugins/GraphViz.py: Many various fixes.


svn: r3911
This commit is contained in:
Alex Roitman 2005-01-14 05:02:20 +00:00
parent 173c687ec7
commit 0c525c8e3b
3 changed files with 81 additions and 56 deletions

View File

@ -2,6 +2,10 @@
* src/Report.py: Typos.
* src/plugins/WebPage.py: Typos.
* src/plugins/BookReport.py: Switch to saving/restoring/registering
items by the non-localized name.
* src/plugins/GraphViz.py: Many various fixes.
2005-01-13 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/Check.py: Typos.

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2004 Donald N. Allingham
# Copyright (C) 2003-2005 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
@ -94,14 +94,14 @@ class BookItem:
Everything gets set to empty values except for the style_name"""
self.name = ""
self.translated_name = ""
self.category = ""
self.write_item = None
self.option_class = None
self.style_file = ""
self.style_name = "default"
self.make_default_style = None
self.item_name = ""
self.name = ""
def get_registered_item(self,name):
"""
@ -112,12 +112,12 @@ class BookItem:
self.clear()
for item in PluginMgr.bkitems_list:
if item[0] == name:
self.name = item[0]
if item[4] == name:
self.translated_name = item[0]
self.category = item[1]
self.write_item = item[2]
self.item_name = item[4]
self.option_class = item[3](self.item_name)
self.name = item[4]
self.option_class = item[3](self.name)
def get_name(self):
"""
@ -125,6 +125,12 @@ class BookItem:
"""
return self.name
def get_translated_name(self):
"""
Returns the translated name of the item.
"""
return self.translated_name
def get_category(self):
"""
Returns the category of the item.
@ -343,7 +349,8 @@ class BookList:
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() )
f.write(' <item name="%s" trans_name="%s">\n' %
(item.get_name(),item.get_translated_name() ) )
option_handler = item.option_class.handler
for option_name in option_handler.options_dict.keys():
option_value = option_handler.options_dict[option_name]
@ -507,15 +514,15 @@ class BookListDisplay:
if not len(names):
return
for name in names:
iter = self.blist.add([name])
if iter:
self.blist.selection.select_iter(iter)
the_iter = self.blist.add([name])
if the_iter:
self.blist.selection.select_iter(the_iter)
def on_booklist_ok_clicked(self,obj):
"""Returns selected book. Saves the current list into xml file."""
store,iter = self.blist.get_selected()
if iter:
data = self.blist.get_data(iter,[0])
store,the_iter = self.blist.get_selected()
if the_iter:
data = self.blist.get_data(the_iter,[0])
self.selection = self.booklist.get_book(data[0])
if self.dosave:
self.booklist.save()
@ -526,12 +533,12 @@ class BookListDisplay:
This change is not final. OK button has to be clicked to save the list.
"""
store,iter = self.blist.get_selected()
if not iter:
store,the_iter = self.blist.get_selected()
if not the_iter:
return
data = self.blist.get_data(iter,[0])
data = self.blist.get_data(the_iter,[0])
self.booklist.delete_book(data[0])
self.blist.remove(iter)
self.blist.remove(the_iter)
self.top.run()
def on_booklist_cancel_clicked(self,obj):
@ -620,8 +627,8 @@ class BookReportSelector:
book_label.set_use_underline(gtk.TRUE)
book_label.set_use_markup(gtk.TRUE)
av_titles = [(_('Name'),0,150),(_('Type'),1,50)]
bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),
av_titles = [(_('Name'),0,150),(_('Type'),1,50),('',-1,0)]
bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),('',-1,0),
(_('Center person'),-1,50)]
self.av_ncols = len(av_titles)
@ -647,7 +654,7 @@ class BookReportSelector:
return
for book_item in PluginMgr.bkitems_list:
data = [ book_item[0], book_item[1] ]
data = [ book_item[0], book_item[1], book_item[4] ]
new_iter = self.av_model.add(data)
self.av_model.connect_model()
@ -688,8 +695,8 @@ class BookReportSelector:
item.set_style_name(saved_item.get_style_name())
self.book.append_item(item)
data = [ item.get_name(), item.get_category() ]
if data[1] == _("Title"):
data = [ item.get_translated_name(), item.get_category(), item.get_name() ]
if data[2] == 'simple_book_title':
data.append(_("Not Applicable"))
else:
pname = self.db.get_person_from_gramps_id(person_id)
@ -702,16 +709,16 @@ class BookReportSelector:
Use the selected available item to get the item's name in the registry.
"""
store,iter = self.av_model.get_selected()
if not iter:
store,the_iter = self.av_model.get_selected()
if not the_iter:
return
data = self.av_model.get_data(iter,range(self.av_ncols))
if data[1] == _("Title"):
data = self.av_model.get_data(the_iter,range(self.av_ncols))
if data[2] == 'simple_book_title':
data.append(_("Not Applicable"))
else:
data.append(self.person.get_primary_name().get_regular_name())
self.bk_model.add(data)
item = BookItem(data[0])
item = BookItem(data[2])
person_id = item.option_class.handler.get_person_id()
if not person_id:
person_id = self.person.get_gramps_id()
@ -722,12 +729,12 @@ class BookReportSelector:
"""
Remove the item from the current list of selections.
"""
store,iter = self.bk_model.get_selected()
if not iter:
store,the_iter = self.bk_model.get_selected()
if not the_iter:
return
row = self.bk_model.get_selected_row()
self.book.pop_item(row)
self.bk_model.remove(iter)
self.bk_model.remove(the_iter)
def on_clear_clicked(self,obj):
"""
@ -743,9 +750,9 @@ class BookReportSelector:
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)
store,the_iter = self.bk_model.get_selected()
data = self.bk_model.get_data(the_iter,range(self.bk_ncols))
self.bk_model.remove(the_iter)
self.bk_model.insert(row-1,data,None,1)
item = self.book.pop_item(row)
self.book.insert_item(row-1,item)
@ -757,9 +764,9 @@ class BookReportSelector:
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)
store,the_iter = self.bk_model.get_selected()
data = self.bk_model.get_data(the_iter,range(self.bk_ncols))
self.bk_model.remove(the_iter)
self.bk_model.insert(row+1,data,None,1)
item = self.book.pop_item(row)
self.book.insert_item(row+1,item)
@ -768,17 +775,18 @@ class BookReportSelector:
"""
Configure currently selected item.
"""
store,iter = self.bk_model.get_selected()
if not iter:
store,the_iter = self.bk_model.get_selected()
if not the_iter:
return
data = self.bk_model.get_data(iter,range(self.bk_ncols))
data = self.bk_model.get_data(the_iter,range(self.bk_ncols))
row = self.bk_model.get_selected_row()
item = self.book.get_item(row)
option_class = item.option_class
item_dialog = BookItemDialog(self.db,option_class,item.item_name,data[0])
item_dialog = BookItemDialog(self.db,option_class,item.get_name(),
item.get_translated_name())
response = item_dialog.window.run()
if response == True and item_dialog.person and data[1] != _("Title"):
self.bk_model.model.set_value(iter,2,
self.bk_model.model.set_value(the_iter,2,
item_dialog.person.get_primary_name().get_regular_name())
self.book.set_item(row,item)
item_dialog.window.destroy()
@ -806,8 +814,8 @@ class BookReportSelector:
def build_bk_context_menu(self,event):
"""Builds the menu with item-centered and book-centered options."""
store,iter = self.bk_model.get_selected()
if iter:
store,the_iter = self.bk_model.get_selected()
if the_iter:
sensitivity = 1
else:
sensitivity = 0
@ -837,8 +845,8 @@ class BookReportSelector:
def build_av_context_menu(self,event):
"""Builds the menu with the single Add option."""
store,iter = self.av_model.get_selected()
if iter:
store,the_iter = self.av_model.get_selected()
if the_iter:
sensitivity = 1
else:
sensitivity = 0

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2004 Donald N. Allingham
# Copyright (C) 2000-2005 Donald N. Allingham
# Contributions by Lorenzo Cappelletti <lorenzo.cappelletti@email.it>
#
# This program is free software; you can redistribute it and/or modify
@ -381,6 +381,7 @@ class GraphVizOptions(ReportOptions.ReportOptions):
'marglr' : 0.5,
'pagesh' : 1,
'pagesv' : 1,
'gvof' : 'png',
}
self.options_help = {
@ -426,6 +427,9 @@ class GraphVizOptions(ReportOptions.ReportOptions):
"Integer values"),
'pagesv' : ("=num","Number of pages in vertical direction.",
"Integer values"),
'gvof' : ("=str","Output format to convert dot file into.",
[ "%s\t%s" % (item[1],item[0]) for item in _formats ],
False),
}
def enable_options(self):
@ -461,14 +465,13 @@ class GraphVizOptions(ReportOptions.ReportOptions):
return [all,des,ans,com]
def make_doc_menu(self,dialog,active=None):
pass
def make_doc_menu(self,dialog,active=None): pass
def add_user_options(self,dialog):
if dot_found:
if self.handler.report_name == "rel_graph2":
dialog.make_doc_menu = self.make_doc_menu
dialog.format_menu = GraphicsFormatComboBox()
dialog.format_menu.set()
dialog.format_menu.set(self.options_dict['gvof'])
self.arrowstyles = (
(_("Descendants <- Ancestors"), 'd'),
@ -573,7 +576,7 @@ class GraphVizOptions(ReportOptions.ReportOptions):
_("Families will show up as ellipses, linked "
"to parents and children."))
self.includeid_cb = gtk.CheckButton(msg)
self.includeid_cb = gtk.CheckButton(_("Include IDs"))
self.includeid_cb.set_active(self.options_dict['incid'])
dialog.add_frame_option(_("GraphViz Options"), '',
self.includeid_cb,
@ -636,8 +639,8 @@ class GraphVizOptions(ReportOptions.ReportOptions):
self.options_dict['incid'] = int(self.includeid_cb.get_active())
self.options_dict['font'] = \
self.font_options[self.font_box.get_active()][1]
if dot_found:
self.handler.dot_format_str = dialog.format_menu.get_format_str()
if self.handler.report_name == "rel_graph2":
self.options_dict['gvof'] = dialog.format_menu.get_format_str()
#------------------------------------------------------------------------
#
@ -726,6 +729,8 @@ class FormatComboBox(gtk.ComboBox):
def get_printable(self):
return _("Generate print output")
def get_clname(self):
return 'dot'
class GraphicsFormatComboBox(gtk.ComboBox):
"""
@ -738,9 +743,14 @@ class GraphicsFormatComboBox(gtk.ComboBox):
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
active_index = 0
index = 0
for item in _formats:
self.store.append(row=[item[0]])
self.set_active(0)
if active == item[1]:
active_index = index
index = index + 1
self.set_active(active_index)
def get_label(self):
return _formats[self.get_active()][0]
@ -763,6 +773,9 @@ class GraphicsFormatComboBox(gtk.ComboBox):
def get_printable(self):
return _("Generate print output")
def get_clname(self):
return 'print'
#------------------------------------------------------------------------
#
# Empty class to keep the BaseDoc-targeted format happy
@ -804,7 +817,7 @@ class GraphVizGraphics(Report.Report):
self.user_output = options_class.get_output()
self.junk_output = os.path.expanduser("~/.gramps/junk")
self.the_format = options_class.handler.dot_format_str
self.the_format = self.options_class.handler.options_dict['gvof']
self.the_font = self.options_class.handler.options_dict['font']
def begin_report(self):