Rename "_Plugins.py" to a more appropriate name: "_PluginDialogs.py". Same goes for the classes in the file.
svn: r10742
This commit is contained in:
parent
3afbd461c0
commit
007ba8dd49
@ -335,7 +335,7 @@ src/PluginUtils/__init__.py
|
||||
src/PluginUtils/_GuiOptions.py
|
||||
src/PluginUtils/_Options.py
|
||||
src/PluginUtils/_PluginMgr.py
|
||||
src/PluginUtils/_Plugins.py
|
||||
src/PluginUtils/_PluginDialogs.py
|
||||
src/PluginUtils/_Tool.py
|
||||
src/PluginUtils/_PluginWindows.py
|
||||
src/PluginUtils/_MenuOptions.py
|
||||
|
@ -13,7 +13,7 @@ pkgdata_PYTHON = \
|
||||
_Tool.py\
|
||||
_PluginMgr.py\
|
||||
_PluginWindows.py\
|
||||
_Plugins.py
|
||||
_PluginDialogs.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/PluginUtils
|
||||
pkgpythondir = @pkgpythondir@/PluginUtils
|
||||
|
@ -20,15 +20,6 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
The core of the GRAMPS plugin system. This module provides tasks to load
|
||||
plugins from specfied directories, build menus for the different categories,
|
||||
and provide dialog to select and execute plugins.
|
||||
|
||||
Plugins are divided into several categories. This are: reports, tools,
|
||||
importers, exporters, and document generators.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK libraries
|
||||
@ -60,9 +51,9 @@ import ManagedWindow
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
REPORTS = 0
|
||||
TOOLS = 1
|
||||
UNSUPPORTED = _("Unsupported")
|
||||
_REPORTS = 0
|
||||
_TOOLS = 1
|
||||
_UNSUPPORTED = _("Unsupported")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -70,21 +61,26 @@ UNSUPPORTED = _("Unsupported")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class PluginDialog(ManagedWindow.ManagedWindow):
|
||||
"""Displays the dialog box that allows the user to select the
|
||||
report that is desired."""
|
||||
|
||||
"""
|
||||
Displays the dialog box that allows the user to select the
|
||||
plugin that is desired.
|
||||
"""
|
||||
def __init__(self, state, uistate, track, item_list, categories, msg,
|
||||
label=None, button_label=None, tool_tip=None, content=REPORTS):
|
||||
"""Display the dialog box, and build up the list of available
|
||||
label=None, button_label=None, tool_tip=None,
|
||||
content=_REPORTS):
|
||||
"""
|
||||
Display the dialog box, and build up the list of available
|
||||
reports. This is used to build the selection tree on the left
|
||||
hand side of the dailog box."""
|
||||
hand side of the dialog box.
|
||||
"""
|
||||
|
||||
self.active = state.active
|
||||
self.imap = {}
|
||||
self.msg = msg
|
||||
self.content = content
|
||||
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track,
|
||||
self.__class__)
|
||||
|
||||
self.state = state
|
||||
self.uistate = uistate
|
||||
@ -146,7 +142,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
|
||||
try:
|
||||
(item_class, options_class, title, category,
|
||||
name, require_active) = self.item
|
||||
if self.content == REPORTS:
|
||||
if self.content == _REPORTS:
|
||||
report(self.state, self.uistate, self.state.active,
|
||||
item_class, options_class, title, name,
|
||||
category, require_active)
|
||||
@ -172,7 +168,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
|
||||
doc,status,author,email,unsupported,require_active) = data
|
||||
self.description.set_text(doc)
|
||||
if unsupported:
|
||||
status = UNSUPPORTED
|
||||
status = _UNSUPPORTED
|
||||
self.status.set_text(status)
|
||||
self.title.set_text('<span weight="bold" size="larger">%s</span>' \
|
||||
% title)
|
||||
@ -201,7 +197,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
|
||||
item_hash = {}
|
||||
for plugin in item_list:
|
||||
if plugin[9]:
|
||||
category = UNSUPPORTED
|
||||
category = _UNSUPPORTED
|
||||
else:
|
||||
category = categories[plugin[3]]
|
||||
if item_hash.has_key(category):
|
||||
@ -211,13 +207,13 @@ class PluginDialog(ManagedWindow.ManagedWindow):
|
||||
|
||||
# add a submenu for each category, and populate it with the
|
||||
# GtkTreeItems that are associated with it.
|
||||
key_list = [ item for item in item_hash.keys() if item != UNSUPPORTED]
|
||||
key_list = [ item for item in item_hash.keys() if item != _UNSUPPORTED]
|
||||
key_list.sort()
|
||||
key_list.reverse()
|
||||
|
||||
prev = None
|
||||
if item_hash.has_key(UNSUPPORTED):
|
||||
key = UNSUPPORTED
|
||||
if item_hash.has_key(_UNSUPPORTED):
|
||||
key = _UNSUPPORTED
|
||||
data = item_hash[key]
|
||||
node = self.store.insert_after(None, prev)
|
||||
self.store.set(node, 0, key)
|
||||
@ -243,12 +239,14 @@ class PluginDialog(ManagedWindow.ManagedWindow):
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# ReportPlugins interface class
|
||||
# ReportPluginDialog
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ReportPlugins(PluginDialog):
|
||||
"""Displays the dialog box that allows the user to select the
|
||||
report that is desired."""
|
||||
class ReportPluginDialog(PluginDialog):
|
||||
"""
|
||||
Displays the dialog box that allows the user to select the
|
||||
report that is desired.
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, uistate, track):
|
||||
"""Display the dialog box, and build up the list of available
|
||||
@ -266,7 +264,7 @@ class ReportPlugins(PluginDialog):
|
||||
_("Report Selection"),
|
||||
_("Select a report from those available on the left."),
|
||||
_("_Generate"), _("Generate selected report"),
|
||||
REPORTS)
|
||||
_REPORTS)
|
||||
|
||||
self.__pmgr.connect('plugins-reloaded', self.rebuild)
|
||||
|
||||
@ -276,10 +274,10 @@ class ReportPlugins(PluginDialog):
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# ToolPlugins interface class
|
||||
# ToolPluginDialog
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ToolPlugins(PluginDialog):
|
||||
class ToolPluginDialog(PluginDialog):
|
||||
"""Displays the dialog box that allows the user to select the tool
|
||||
that is desired."""
|
||||
|
||||
@ -300,7 +298,7 @@ class ToolPlugins(PluginDialog):
|
||||
_("Select a tool from those available on the left."),
|
||||
_("_Run"),
|
||||
_("Run selected tool"),
|
||||
TOOLS)
|
||||
_TOOLS)
|
||||
|
||||
def rebuild(self):
|
||||
tool_list = self.__pmgr.get_tool_list()
|
@ -31,7 +31,7 @@ from _Options import Options, OptionListCollection, OptionList, OptionHandler
|
||||
from _PluginMgr import PluginManager
|
||||
|
||||
import _Tool as Tool
|
||||
import _Plugins as Plugins
|
||||
from _PluginDialogs import ReportPluginDialog, ToolPluginDialog
|
||||
import _PluginWindows as PluginWindows
|
||||
|
||||
# This needs to go above Tool and MenuOption as it needs both
|
||||
|
@ -55,8 +55,8 @@ import gtk
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from PluginUtils import Plugins, Tool, PluginWindows, PluginManager
|
||||
|
||||
from PluginUtils import Tool, PluginWindows, PluginManager, \
|
||||
ReportPluginDialog, ToolPluginDialog
|
||||
import ReportBase
|
||||
import DisplayState
|
||||
import const
|
||||
@ -82,6 +82,7 @@ import ProgressDialog
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_UNSUPPORTED = _("Unsupported")
|
||||
|
||||
UIDEFAULT = '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
@ -1251,7 +1252,7 @@ class ViewManager:
|
||||
Displays the Reports dialog
|
||||
"""
|
||||
try:
|
||||
Plugins.ReportPlugins(self.state, self.uistate, [])
|
||||
ReportPluginDialog(self.state, self.uistate, [])
|
||||
except Errors.WindowActiveError:
|
||||
return
|
||||
|
||||
@ -1260,7 +1261,7 @@ class ViewManager:
|
||||
Displays the Tools dialog
|
||||
"""
|
||||
try:
|
||||
Plugins.ToolPlugins(self.state, self.uistate, [])
|
||||
ToolPluginDialog(self.state, self.uistate, [])
|
||||
except Errors.WindowActiveError:
|
||||
return
|
||||
|
||||
@ -1361,7 +1362,7 @@ class ViewManager:
|
||||
hash_data = {}
|
||||
for item in item_list:
|
||||
if item[9]:
|
||||
category = Plugins.UNSUPPORTED
|
||||
category = _UNSUPPORTED
|
||||
else:
|
||||
category = categories[item[3]]
|
||||
if hash_data.has_key(category):
|
||||
@ -1373,7 +1374,7 @@ class ViewManager:
|
||||
|
||||
# Sort categories, skipping the unsupported
|
||||
catlist = [item for item in hash_data.keys()
|
||||
if item != Plugins.UNSUPPORTED]
|
||||
if item != _UNSUPPORTED]
|
||||
catlist.sort()
|
||||
for key in catlist:
|
||||
new_key = key.replace(' ', '-')
|
||||
@ -1391,11 +1392,11 @@ class ViewManager:
|
||||
|
||||
# If there are any unsupported items we add separator
|
||||
# and the unsupported category at the end of the menu
|
||||
if hash_data.has_key(Plugins.UNSUPPORTED):
|
||||
if hash_data.has_key(_UNSUPPORTED):
|
||||
ofile.write('<separator/>')
|
||||
ofile.write('<menu action="%s">' % Plugins.UNSUPPORTED)
|
||||
actions.append((Plugins.UNSUPPORTED, None, Plugins.UNSUPPORTED))
|
||||
lst = hash_data[Plugins.UNSUPPORTED]
|
||||
ofile.write('<menu action="%s">' % _UNSUPPORTED)
|
||||
actions.append((_UNSUPPORTED, None, _UNSUPPORTED))
|
||||
lst = hash_data[_UNSUPPORTED]
|
||||
lst.sort(by_menu_name)
|
||||
for name in lst:
|
||||
new_key = name[3].replace(' ', '-')
|
||||
|
@ -86,6 +86,13 @@ from ReportBase._ReportOptions import ReportOptions
|
||||
|
||||
from BasicUtils import name_displayer as _nd
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Private Constants
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_UNSUPPORTED = _("Unsupported")
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Private Functions
|
||||
@ -195,7 +202,7 @@ class BookItem:
|
||||
if item[4] == name:
|
||||
self.translated_name = item[0]
|
||||
if item[5]:
|
||||
self.category = Plugins.UNSUPPORTED
|
||||
self.category = _UNSUPPORTED
|
||||
else:
|
||||
self.category = item[1]
|
||||
self.write_item = item[2]
|
||||
@ -748,7 +755,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
|
||||
|
||||
for book_item in pmgr.get_book_item_list():
|
||||
if book_item[5]:
|
||||
category = Plugins.UNSUPPORTED
|
||||
category = _UNSUPPORTED
|
||||
else:
|
||||
category = book_item[1]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user