* src/Plugins.py: Use category to register cl report.

* src/Report.py: Handle showing options centrally.
* src/gramps_main.py: Remove name and category from options.
* src/plugins/BookReport.py: Handle showing options centrally.


svn: r3828
This commit is contained in:
Alex Roitman 2004-12-22 04:55:12 +00:00
parent a4f9849e8f
commit 09a8a4640b
5 changed files with 35 additions and 25 deletions

View File

@ -10,6 +10,11 @@
* various: Merge REP_OPT branch with HEAD. * various: Merge REP_OPT branch with HEAD.
* src/Plugins.py: Use category to register cl report.
* src/Report.py: Handle showing options centrally.
* src/gramps_main.py: Remove name and category from options.
* src/plugins/BookReport.py: Handle showing options centrally.
2004-12-20 Alex Roitman <shura@alex.neuro.umn.edu> 2004-12-20 Alex Roitman <shura@alex.neuro.umn.edu>
* src/ArgHandler.py: Single out Book by category. * src/ArgHandler.py: Single out Book by category.
* src/Plugins.py: Use category to register cl report. * src/Plugins.py: Use category to register cl report.

View File

@ -574,7 +574,7 @@ def register_report(
(junk,standalone_task) = divmod(modes,2**Report.MODE_GUI) (junk,standalone_task) = divmod(modes,2**Report.MODE_GUI)
if standalone_task: if standalone_task:
_register_standalone(report_class,options_class,translated_name, _register_standalone(report_class,options_class,translated_name,
category,description, name,category,description,
status,author_name,author_email) status,author_name,author_email)
(junk,book_item_task) = divmod(modes-standalone_task,2**Report.MODE_BKI) (junk,book_item_task) = divmod(modes-standalone_task,2**Report.MODE_BKI)
@ -588,8 +588,8 @@ def register_report(
if command_line_task: if command_line_task:
_register_cl_report(name,category,report_class,options_class) _register_cl_report(name,category,report_class,options_class)
def _register_standalone(report_class, options_class, name, def _register_standalone(report_class, options_class, translated_name,
category=_("Uncategorized"), name, category,
description=_unavailable, description=_unavailable,
status=_("Unknown"), status=_("Unknown"),
author_name=_("Unknown"), author_name=_("Unknown"),
@ -604,7 +604,7 @@ def _register_standalone(report_class, options_class, name,
del_index = i del_index = i
if del_index != -1: if del_index != -1:
del _reports[del_index] del _reports[del_index]
_reports.append((report_class, options_class, _reports.append((report_class, options_class, translated_name,
category, name, description, status, author_name, author_email)) category, name, description, status, author_name, author_email))
def _register_book_item(translated_name,category,report_class,option_class,name): def _register_book_item(translated_name,category,report_class,option_class,name):
@ -744,13 +744,16 @@ def build_report_menu(top_menu,callback):
hash_data = {} hash_data = {}
for report in _reports: for report in _reports:
standalone_category = const.standalone_categories[report[2]] standalone_category = const.standalone_categories[report[3]]
if hash_data.has_key(standalone_category): if hash_data.has_key(standalone_category):
hash_data[standalone_category].append( hash_data[standalone_category].append(
(report[3],report[0],report[1],report[2])) (report[0],report[1],report[2],report[4],report[3]))
else: else:
hash_data[standalone_category] = [ hash_data[standalone_category] = [
(report[3],report[0],report[1],report[2])] (report[0],report[1],report[2],report[4],report[3])]
# 0 1 2 3 4
#report_class, options_class, translated_name, name, category,
catlist = hash_data.keys() catlist = hash_data.keys()
catlist.sort() catlist.sort()
@ -764,9 +767,9 @@ def build_report_menu(top_menu,callback):
lst = hash_data[key] lst = hash_data[key]
lst.sort() lst.sort()
for name in lst: for name in lst:
subentry = gtk.MenuItem("%s..." % name[0]) subentry = gtk.MenuItem("%s..." % name[2])
subentry.show() subentry.show()
subentry.connect("activate",callback,Report.report,name[1],name[2],name[3],name[0]) subentry.connect("activate",callback,Report.report,name[0],name[1],name[2],name[3],name[4])
submenu.append(subentry) submenu.append(subentry)
top_menu.set_submenu(report_menu) top_menu.set_submenu(report_menu)

View File

@ -199,7 +199,7 @@ class BareReportDialog:
frame_pad = 5 frame_pad = 5
border_pad = 6 border_pad = 6
def __init__(self,database,person,option_class,name): def __init__(self,database,person,option_class,name,translated_name):
"""Initialize a dialog to request that the user select options """Initialize a dialog to request that the user select options
for a basic *bare* report.""" for a basic *bare* report."""
@ -209,7 +209,7 @@ class BareReportDialog:
self.options = option_class(name) self.options = option_class(name)
elif type(option_class) == InstanceType: elif type(option_class) == InstanceType:
self.options = option_class self.options = option_class
self.report_name = name self.report_name = translated_name
self.init_interface() self.init_interface()
def init_interface(self): def init_interface(self):
@ -813,12 +813,12 @@ class ReportDialog(BareReportDialog):
dialog for a stand-alone report. dialog for a stand-alone report.
""" """
def __init__(self,database,person,option_class,name=''): def __init__(self,database,person,option_class,name,translated_name):
"""Initialize a dialog to request that the user select options """Initialize a dialog to request that the user select options
for a basic *stand-alone* report.""" for a basic *stand-alone* report."""
self.style_name = "default" self.style_name = "default"
BareReportDialog.__init__(self,database,person,option_class,name) BareReportDialog.__init__(self,database,person,option_class,name,translated_name)
# Allow for post processing of the format frame, since the # Allow for post processing of the format frame, since the
# show_all task calls events that may reset values # show_all task calls events that may reset values
@ -1333,12 +1333,12 @@ class ReportDialog(BareReportDialog):
class TextReportDialog(ReportDialog): class TextReportDialog(ReportDialog):
"""A class of ReportDialog customized for text based reports.""" """A class of ReportDialog customized for text based reports."""
def __init__(self,database,person,options,name=''): def __init__(self,database,person,options,name,translated_name):
"""Initialize a dialog to request that the user select options """Initialize a dialog to request that the user select options
for a basic text report. See the ReportDialog class for more for a basic text report. See the ReportDialog class for more
information.""" information."""
self.category = const.CATEGORY_TEXT self.category = const.CATEGORY_TEXT
ReportDialog.__init__(self,database,person,options,name) ReportDialog.__init__(self,database,person,options,name,translated_name)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -1379,12 +1379,12 @@ class TextReportDialog(ReportDialog):
class DrawReportDialog(ReportDialog): class DrawReportDialog(ReportDialog):
"""A class of ReportDialog customized for drawing based reports.""" """A class of ReportDialog customized for drawing based reports."""
def __init__(self,database,person,opt,name=''): def __init__(self,database,person,opt,name,translated_name):
"""Initialize a dialog to request that the user select options """Initialize a dialog to request that the user select options
for a basic drawing report. See the ReportDialog class for for a basic drawing report. See the ReportDialog class for
more information.""" more information."""
self.category = const.CATEGORY_DRAW self.category = const.CATEGORY_DRAW
ReportDialog.__init__(self,database,person,opt,name) ReportDialog.__init__(self,database,person,opt,name,translated_name)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -1635,7 +1635,7 @@ class CommandLineReport:
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# Standalone GUI report generic task # Standalone GUI report generic task
def report(database,person,report_class,options_class,category,name): def report(database,person,report_class,options_class,translated_name,name,category):
""" """
report - task starts the report. The plugin system requires that the report - task starts the report. The plugin system requires that the
task be in the format of task that takes a database and a person as task be in the format of task that takes a database and a person as
@ -1652,7 +1652,7 @@ def report(database,person,report_class,options_class,category,name):
else: else:
dialog_class = ReportDialog dialog_class = ReportDialog
dialog = dialog_class(database,person,options_class,name) dialog = dialog_class(database,person,options_class,name,translated_name)
response = dialog.window.run() response = dialog.window.run()
if response == True: if response == True:
try: try:

View File

@ -1691,10 +1691,10 @@ class Gramps:
def on_preferences_activate(self,obj): def on_preferences_activate(self,obj):
GrampsCfg.display_preferences_box(self.db) GrampsCfg.display_preferences_box(self.db)
def menu_report(self,obj,task,report_class,options_class,category,name): def menu_report(self,obj,task,report_class,options_class,translated_name,name,category):
"""Call the report plugin selected from the menus""" """Call the report plugin selected from the menus"""
if self.active_person: if self.active_person:
task(self.db,self.active_person,report_class,options_class,category,name) task(self.db,self.active_person,report_class,options_class,translated_name,name,category)
def menu_tools(self,obj,task): def menu_tools(self,obj,task):
"""Call the tool plugin selected from the menus""" """Call the tool plugin selected from the menus"""

View File

@ -100,6 +100,7 @@ class BookItem:
self.style_file = "" self.style_file = ""
self.style_name = "default" self.style_name = "default"
self.make_default_style = None self.make_default_style = None
self.item_name = ""
def get_registered_item(self,name): def get_registered_item(self,name):
""" """
@ -773,7 +774,7 @@ class BookReportSelector:
row = self.bk_model.get_selected_row() row = self.bk_model.get_selected_row()
item = self.book.get_item(row) item = self.book.get_item(row)
option_class = item.option_class option_class = item.option_class
item_dialog = BookItemDialog(self.db,option_class,data[0]) item_dialog = BookItemDialog(self.db,option_class,item.item_name,data[0])
response = item_dialog.window.run() response = item_dialog.window.run()
if response == True and item_dialog.person and data[1] != _("Title"): 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(iter,2,
@ -906,13 +907,13 @@ class BookItemDialog(Report.BareReportDialog):
in a way specific for this report. This is a book item dialog. in a way specific for this report. This is a book item dialog.
""" """
def __init__(self,database,option_class,name=''): def __init__(self,database,option_class,name,translated_name):
self.database = database self.database = database
self.option_class = option_class self.option_class = option_class
self.person = self.database.get_person_from_gramps_id(self.option_class.handler.get_person_id()) self.person = self.database.get_person_from_gramps_id(self.option_class.handler.get_person_id())
self.new_person = None self.new_person = None
Report.BareReportDialog.__init__(self,database,self.person,option_class,name) Report.BareReportDialog.__init__(self,database,self.person,option_class,name,translated_name)
def on_ok_clicked(self, obj): def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Parse all options """The user is satisfied with the dialog choices. Parse all options
@ -943,7 +944,8 @@ class BookReportDialog(Report.ReportDialog):
def __init__(self,database,person,book,options): def __init__(self,database,person,book,options):
self.options = options self.options = options
Report.BareReportDialog.__init__(self,database,person,options,'book') Report.BareReportDialog.__init__(self,database,person,options,
'book',_("Book Report"))
self.book = book self.book = book
self.database = database self.database = database
self.person = person self.person = person