* src/Witness.py (WitnessEditor.__init__): Typo.
* src/PluginMgr.py: Update all lists properly on any registration; (purge_failed): Add function. * src/Plugins.py (Reload.__init__): Purge plugins newly failed on reload; Regenerate all menus after reload. * src/gramps_main.py (build_plugin_menus): Add optional argument indicating rebuild, do not load plugins on rebuild; (load_plugins) factor out plugin loading routine. svn: r5361
This commit is contained in:
parent
b79beef27b
commit
8e67461d3b
@ -1,3 +1,13 @@
|
||||
2005-11-04 Alex Roitman <shura@gramps-project.org>
|
||||
* src/Witness.py (WitnessEditor.__init__): Typo.
|
||||
* src/PluginMgr.py: Update all lists properly on any registration;
|
||||
(purge_failed): Add function.
|
||||
* src/Plugins.py (Reload.__init__): Purge plugins newly failed on
|
||||
reload; Regenerate all menus after reload.
|
||||
* src/gramps_main.py (build_plugin_menus): Add optional argument
|
||||
indicating rebuild, do not load plugins on rebuild; (load_plugins)
|
||||
factor out plugin loading routine.
|
||||
|
||||
2005-11-04 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/ReportUtils.py (sanitize_person): Restrict Media reference list
|
||||
* src/plugins/NavWebPage.py: Add many more filtering of private data
|
||||
|
@ -147,13 +147,26 @@ def register_export(exportData,title,description='',config=None,filename=''):
|
||||
and the list of patterns for the filename matching.
|
||||
"""
|
||||
if description and filename:
|
||||
del_index = -1
|
||||
for i in range(0,len(export_list)):
|
||||
if export_list[i][1] == title:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del export_list[del_index]
|
||||
|
||||
export_list.append((exportData,title,description,config,filename))
|
||||
|
||||
def register_import(task, ffilter, mime=None, native_format=0, format_name=""):
|
||||
"""Register an import filter, taking the task and file filter"""
|
||||
if mime:
|
||||
import_list.append((task, ffilter, mime, native_format, format_name))
|
||||
del_index = -1
|
||||
for i in range(0,len(import_list)):
|
||||
if import_list[i][2] == mime:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del import_list[del_index]
|
||||
|
||||
import_list.append((task, ffilter, mime, native_format, format_name))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -202,7 +215,7 @@ def _register_gui_tool(tool_class,options_class,translated_name,
|
||||
del_index = -1
|
||||
for i in range(0,len(tool_list)):
|
||||
val = tool_list[i]
|
||||
if val[2] == name:
|
||||
if val[4] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del tool_list[del_index]
|
||||
@ -212,9 +225,13 @@ def _register_gui_tool(tool_class,options_class,translated_name,
|
||||
|
||||
def _register_cli_tool(name,category,tool_class,options_class,
|
||||
translated_name):
|
||||
for n in cli_tool_list:
|
||||
if n[0] == name:
|
||||
return
|
||||
del_index = -1
|
||||
for i in range(0,len(cli_tool_list)):
|
||||
val = cli_tool_list[i]
|
||||
if val[0] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del cli_tool_list[del_index]
|
||||
cli_tool_list.append((name,category,tool_class,options_class,
|
||||
translated_name))
|
||||
|
||||
@ -277,7 +294,7 @@ def _register_standalone(report_class, options_class, translated_name,
|
||||
del_index = -1
|
||||
for i in range(0,len(report_list)):
|
||||
val = report_list[i]
|
||||
if val[2] == name:
|
||||
if val[4] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del report_list[del_index]
|
||||
@ -288,17 +305,26 @@ def register_book_item(translated_name, category, report_class,
|
||||
option_class, name):
|
||||
"""Register a book item"""
|
||||
|
||||
for n in bkitems_list:
|
||||
if n[0] == name:
|
||||
return
|
||||
del_index = -1
|
||||
for i in range(0,len(bkitems_list)):
|
||||
val = bkitems_list[i]
|
||||
if val[4] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del bkitems_list[del_index]
|
||||
|
||||
bkitems_list.append((translated_name, category, report_class,
|
||||
option_class, name))
|
||||
|
||||
def _register_cl_report(name,category,report_class,options_class,
|
||||
translated_name):
|
||||
for n in cl_list:
|
||||
if n[0] == name:
|
||||
return
|
||||
del_index = -1
|
||||
for i in range(0,len(cl_list)):
|
||||
val = cl_list[i]
|
||||
if val[0] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del cl_list[del_index]
|
||||
cl_list.append((name,category,report_class,options_class,
|
||||
translated_name))
|
||||
|
||||
@ -310,11 +336,17 @@ def _register_cl_report(name,category,report_class,options_class,
|
||||
def register_text_doc(name,classref, table, paper, style, ext,
|
||||
print_report_label=None,clname=''):
|
||||
"""Register a text document generator"""
|
||||
for n in textdoc_list:
|
||||
if n[0] == name:
|
||||
return
|
||||
del_index = -1
|
||||
for i in range(0,len(textdoc_list)):
|
||||
val = textdoc_list[i]
|
||||
if val[0] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del textdoc_list[del_index]
|
||||
|
||||
if not clname:
|
||||
clname = ext[1:]
|
||||
|
||||
textdoc_list.append(
|
||||
(name, classref, table, paper, style,
|
||||
ext, print_report_label, clname))
|
||||
@ -326,9 +358,14 @@ def register_text_doc(name,classref, table, paper, style, ext,
|
||||
#-------------------------------------------------------------------------
|
||||
def register_book_doc(name,classref, table, paper, style, ext, clname=''):
|
||||
"""Register a text document generator"""
|
||||
for n in bookdoc_list:
|
||||
if n[0] == name:
|
||||
return
|
||||
del_index = -1
|
||||
for i in range(0,len(bookdoc_list)):
|
||||
val = bookdoc_list[i]
|
||||
if val[0] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del bookdoc_list[del_index]
|
||||
|
||||
if not clname:
|
||||
clname = ext[1:]
|
||||
bookdoc_list.append((name,classref,table,paper,style,ext,None,clname))
|
||||
@ -341,14 +378,60 @@ def register_book_doc(name,classref, table, paper, style, ext, clname=''):
|
||||
def register_draw_doc(name,classref,paper,style, ext,
|
||||
print_report_label=None,clname=''):
|
||||
"""Register a drawing document generator"""
|
||||
for n in drawdoc_list:
|
||||
if n[0] == name:
|
||||
return
|
||||
del_index = -1
|
||||
for i in range(0,len(drawdoc_list)):
|
||||
val = drawdoc_list[i]
|
||||
if val[0] == name:
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del drawdoc_list[del_index]
|
||||
if not clname:
|
||||
clname = ext[1:]
|
||||
drawdoc_list.append((name, classref, paper,style, ext,
|
||||
print_report_label, clname))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Remove plugins whose reloading failed from the already-registered lists
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def purge_failed(failed_list,export_list,import_list,tool_list,cli_tool_list,
|
||||
report_list,bkitems_list,cl_list,textdoc_list,bookdoc_list,
|
||||
drawdoc_list):
|
||||
failed_module_names = [
|
||||
os.path.splitext(os.path.basename(filename))[0]
|
||||
for filename,junk in failed_list
|
||||
]
|
||||
|
||||
export_list = [ item for item in export_list
|
||||
if item[0].__module__ not in failed_module_names ]
|
||||
import_list = [ item for item in import_list
|
||||
if item[0].__module__ not in failed_module_names ]
|
||||
tool_list = [ item for item in tool_list
|
||||
if item[0].__module__ not in failed_module_names ]
|
||||
cli_tool_list = [ item for item in cli_tool_list
|
||||
if item[2].__module__ not in failed_module_names ]
|
||||
report_list = [ item for item in report_list
|
||||
if item[0].__module__ not in failed_module_names ]
|
||||
bkitems_list = [ item for item in bkitems_list
|
||||
if item[2].__module__ not in failed_module_names ]
|
||||
cl_list = [ item for item in cl_list
|
||||
if item[2].__module__ not in failed_module_names ]
|
||||
textdoc_list = [ item for item in textdoc_list
|
||||
if item[1].__module__ not in failed_module_names ]
|
||||
bookdoc_list = [ item for item in bookdoc_list
|
||||
if item[1].__module__ not in failed_module_names ]
|
||||
drawdoc_list = [ item for item in drawdoc_list
|
||||
if item[1].__module__ not in failed_module_names ]
|
||||
|
||||
# For some funky reason this module's global variables
|
||||
# are not seen inside this function. But they are seen
|
||||
# from other modules, so we pass them back and forth.
|
||||
# Sucks, but I don't know why this happens :-(
|
||||
return (export_list,import_list,tool_list,cli_tool_list,
|
||||
report_list,bkitems_list,cl_list,textdoc_list,bookdoc_list,
|
||||
drawdoc_list)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Relationship calculator registration
|
||||
|
@ -611,8 +611,31 @@ class Reload(Tool.Tool):
|
||||
except:
|
||||
PluginMgr.failmsg_list.append((filename,sys.exc_info()))
|
||||
|
||||
# Remove previously good plugins that are now bad
|
||||
# from the registered lists
|
||||
(PluginMgr.export_list,
|
||||
PluginMgr.import_list,
|
||||
PluginMgr.tool_list,
|
||||
PluginMgr.cli_tool_list,
|
||||
PluginMgr.report_list,
|
||||
PluginMgr.bkitems_list,
|
||||
PluginMgr.cl_list,
|
||||
PluginMgr.textdoc_list,
|
||||
PluginMgr.bookdoc_list,
|
||||
PluginMgr.drawdoc_list) = PluginMgr.purge_failed(
|
||||
PluginMgr.failmsg_list,
|
||||
PluginMgr.export_list,
|
||||
PluginMgr.import_list,
|
||||
PluginMgr.tool_list,
|
||||
PluginMgr.cli_tool_list,
|
||||
PluginMgr.report_list,
|
||||
PluginMgr.bkitems_list,
|
||||
PluginMgr.cl_list,
|
||||
PluginMgr.textdoc_list,
|
||||
PluginMgr.bookdoc_list,
|
||||
PluginMgr.drawdoc_list)
|
||||
|
||||
# attempt to load the plugins that have failed in the past
|
||||
|
||||
for (filename,message) in oldfailmsg:
|
||||
name = os.path.split(filename)
|
||||
match = pymod.match(name[1])
|
||||
@ -656,6 +679,9 @@ class Reload(Tool.Tool):
|
||||
status_up.close(None)
|
||||
status_up = None
|
||||
|
||||
# Re-generate tool and report menus
|
||||
parent.build_plugin_menus(rebuild=True)
|
||||
|
||||
class ReloadOptions(Tool.ToolOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
|
@ -139,10 +139,12 @@ class WitnessEditor:
|
||||
self.win_key = self
|
||||
self.update = update
|
||||
self.ref = ref
|
||||
self.show_witness = gtk.glade.XML(const.dialogFile, "witness_edit","gramps")
|
||||
self.show_witness = gtk.glade.XML(const.dialogFile,
|
||||
"witness_edit","gramps")
|
||||
self.gladeif = GladeIf(self.show_witness)
|
||||
|
||||
self.gladeif.connect('name_edit','delete_event',self.on_delete_event)
|
||||
self.gladeif.connect('witness_edit','delete_event',
|
||||
self.on_delete_event)
|
||||
self.gladeif.connect('cancelbutton1','clicked',self.close)
|
||||
self.gladeif.connect('ok','clicked',self.ok_clicked)
|
||||
self.gladeif.connect('button132','clicked',self.on_help_clicked)
|
||||
|
@ -924,26 +924,31 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
else:
|
||||
self.toolbardock.hide()
|
||||
|
||||
def build_plugin_menus(self):
|
||||
def build_plugin_menus(self,rebuild=False):
|
||||
self.report_menu = self.gtop.get_widget("reports_menu")
|
||||
self.tools_menu = self.gtop.get_widget("tools_menu")
|
||||
|
||||
self.report_menu.set_sensitive(0)
|
||||
self.tools_menu.set_sensitive(0)
|
||||
if not rebuild:
|
||||
self.report_menu.set_sensitive(0)
|
||||
self.tools_menu.set_sensitive(0)
|
||||
error = self.load_plugins()
|
||||
if GrampsKeys.get_pop_plugin_status() and error:
|
||||
Plugins.PluginStatus(self)
|
||||
|
||||
error = PluginMgr.load_plugins(const.docgenDir)
|
||||
error |= PluginMgr.load_plugins(os.path.expanduser("~/.gramps/docgen"))
|
||||
error |= PluginMgr.load_plugins(const.pluginsDir)
|
||||
error |= PluginMgr.load_plugins(os.path.expanduser("~/.gramps/plugins"))
|
||||
|
||||
if GrampsKeys.get_pop_plugin_status() and error:
|
||||
Plugins.PluginStatus(self)
|
||||
Plugins.build_report_menu(self.report_menu,self.menu_report)
|
||||
Plugins.build_tools_menu(self.tools_menu,self.menu_tools)
|
||||
|
||||
self.RelClass = PluginMgr.relationship_class
|
||||
self.relationship = self.RelClass(self.db)
|
||||
|
||||
def load_plugins(self):
|
||||
error = PluginMgr.load_plugins(const.docgenDir)
|
||||
error |= PluginMgr.load_plugins(os.path.expanduser("~/.gramps/docgen"))
|
||||
error |= PluginMgr.load_plugins(const.pluginsDir)
|
||||
error |= PluginMgr.load_plugins(
|
||||
os.path.expanduser("~/.gramps/plugins"))
|
||||
return error
|
||||
|
||||
def init_filters(self):
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
|
Loading…
x
Reference in New Issue
Block a user