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:
Brian Matherly 2008-05-19 04:14:11 +00:00
parent 3afbd461c0
commit 007ba8dd49
6 changed files with 54 additions and 48 deletions

View File

@ -335,7 +335,7 @@ src/PluginUtils/__init__.py
src/PluginUtils/_GuiOptions.py src/PluginUtils/_GuiOptions.py
src/PluginUtils/_Options.py src/PluginUtils/_Options.py
src/PluginUtils/_PluginMgr.py src/PluginUtils/_PluginMgr.py
src/PluginUtils/_Plugins.py src/PluginUtils/_PluginDialogs.py
src/PluginUtils/_Tool.py src/PluginUtils/_Tool.py
src/PluginUtils/_PluginWindows.py src/PluginUtils/_PluginWindows.py
src/PluginUtils/_MenuOptions.py src/PluginUtils/_MenuOptions.py

View File

@ -13,7 +13,7 @@ pkgdata_PYTHON = \
_Tool.py\ _Tool.py\
_PluginMgr.py\ _PluginMgr.py\
_PluginWindows.py\ _PluginWindows.py\
_Plugins.py _PluginDialogs.py
pkgpyexecdir = @pkgpyexecdir@/PluginUtils pkgpyexecdir = @pkgpyexecdir@/PluginUtils
pkgpythondir = @pkgpythondir@/PluginUtils pkgpythondir = @pkgpythondir@/PluginUtils

View File

@ -20,15 +20,6 @@
# #
# $Id$ # $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 # GTK libraries
@ -60,9 +51,9 @@ import ManagedWindow
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
REPORTS = 0 _REPORTS = 0
TOOLS = 1 _TOOLS = 1
UNSUPPORTED = _("Unsupported") _UNSUPPORTED = _("Unsupported")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -70,21 +61,26 @@ UNSUPPORTED = _("Unsupported")
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PluginDialog(ManagedWindow.ManagedWindow): 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, def __init__(self, state, uistate, track, item_list, categories, msg,
label=None, button_label=None, tool_tip=None, content=REPORTS): label=None, button_label=None, tool_tip=None,
"""Display the dialog box, and build up the list of available 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 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.active = state.active
self.imap = {} self.imap = {}
self.msg = msg self.msg = msg
self.content = content self.content = content
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__) ManagedWindow.ManagedWindow.__init__(self, uistate, track,
self.__class__)
self.state = state self.state = state
self.uistate = uistate self.uistate = uistate
@ -146,7 +142,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
try: try:
(item_class, options_class, title, category, (item_class, options_class, title, category,
name, require_active) = self.item name, require_active) = self.item
if self.content == REPORTS: if self.content == _REPORTS:
report(self.state, self.uistate, self.state.active, report(self.state, self.uistate, self.state.active,
item_class, options_class, title, name, item_class, options_class, title, name,
category, require_active) category, require_active)
@ -172,7 +168,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
doc,status,author,email,unsupported,require_active) = data doc,status,author,email,unsupported,require_active) = data
self.description.set_text(doc) self.description.set_text(doc)
if unsupported: if unsupported:
status = UNSUPPORTED status = _UNSUPPORTED
self.status.set_text(status) self.status.set_text(status)
self.title.set_text('<span weight="bold" size="larger">%s</span>' \ self.title.set_text('<span weight="bold" size="larger">%s</span>' \
% title) % title)
@ -201,7 +197,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
item_hash = {} item_hash = {}
for plugin in item_list: for plugin in item_list:
if plugin[9]: if plugin[9]:
category = UNSUPPORTED category = _UNSUPPORTED
else: else:
category = categories[plugin[3]] category = categories[plugin[3]]
if item_hash.has_key(category): 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 # add a submenu for each category, and populate it with the
# GtkTreeItems that are associated with it. # 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.sort()
key_list.reverse() key_list.reverse()
prev = None prev = None
if item_hash.has_key(UNSUPPORTED): if item_hash.has_key(_UNSUPPORTED):
key = UNSUPPORTED key = _UNSUPPORTED
data = item_hash[key] data = item_hash[key]
node = self.store.insert_after(None, prev) node = self.store.insert_after(None, prev)
self.store.set(node, 0, key) self.store.set(node, 0, key)
@ -243,12 +239,14 @@ class PluginDialog(ManagedWindow.ManagedWindow):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# ReportPlugins interface class # ReportPluginDialog
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ReportPlugins(PluginDialog): class ReportPluginDialog(PluginDialog):
"""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
report that is desired.
"""
def __init__(self, dbstate, uistate, track): def __init__(self, dbstate, uistate, track):
"""Display the dialog box, and build up the list of available """Display the dialog box, and build up the list of available
@ -266,7 +264,7 @@ class ReportPlugins(PluginDialog):
_("Report Selection"), _("Report Selection"),
_("Select a report from those available on the left."), _("Select a report from those available on the left."),
_("_Generate"), _("Generate selected report"), _("_Generate"), _("Generate selected report"),
REPORTS) _REPORTS)
self.__pmgr.connect('plugins-reloaded', self.rebuild) 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 """Displays the dialog box that allows the user to select the tool
that is desired.""" that is desired."""
@ -300,7 +298,7 @@ class ToolPlugins(PluginDialog):
_("Select a tool from those available on the left."), _("Select a tool from those available on the left."),
_("_Run"), _("_Run"),
_("Run selected tool"), _("Run selected tool"),
TOOLS) _TOOLS)
def rebuild(self): def rebuild(self):
tool_list = self.__pmgr.get_tool_list() tool_list = self.__pmgr.get_tool_list()

View File

@ -31,7 +31,7 @@ from _Options import Options, OptionListCollection, OptionList, OptionHandler
from _PluginMgr import PluginManager from _PluginMgr import PluginManager
import _Tool as Tool import _Tool as Tool
import _Plugins as Plugins from _PluginDialogs import ReportPluginDialog, ToolPluginDialog
import _PluginWindows as PluginWindows import _PluginWindows as PluginWindows
# This needs to go above Tool and MenuOption as it needs both # This needs to go above Tool and MenuOption as it needs both

View File

@ -55,8 +55,8 @@ import gtk
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from PluginUtils import Plugins, Tool, PluginWindows, PluginManager from PluginUtils import Tool, PluginWindows, PluginManager, \
ReportPluginDialog, ToolPluginDialog
import ReportBase import ReportBase
import DisplayState import DisplayState
import const import const
@ -82,6 +82,7 @@ import ProgressDialog
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_UNSUPPORTED = _("Unsupported")
UIDEFAULT = '''<ui> UIDEFAULT = '''<ui>
<menubar name="MenuBar"> <menubar name="MenuBar">
@ -1251,7 +1252,7 @@ class ViewManager:
Displays the Reports dialog Displays the Reports dialog
""" """
try: try:
Plugins.ReportPlugins(self.state, self.uistate, []) ReportPluginDialog(self.state, self.uistate, [])
except Errors.WindowActiveError: except Errors.WindowActiveError:
return return
@ -1260,7 +1261,7 @@ class ViewManager:
Displays the Tools dialog Displays the Tools dialog
""" """
try: try:
Plugins.ToolPlugins(self.state, self.uistate, []) ToolPluginDialog(self.state, self.uistate, [])
except Errors.WindowActiveError: except Errors.WindowActiveError:
return return
@ -1361,7 +1362,7 @@ class ViewManager:
hash_data = {} hash_data = {}
for item in item_list: for item in item_list:
if item[9]: if item[9]:
category = Plugins.UNSUPPORTED category = _UNSUPPORTED
else: else:
category = categories[item[3]] category = categories[item[3]]
if hash_data.has_key(category): if hash_data.has_key(category):
@ -1373,7 +1374,7 @@ class ViewManager:
# Sort categories, skipping the unsupported # Sort categories, skipping the unsupported
catlist = [item for item in hash_data.keys() catlist = [item for item in hash_data.keys()
if item != Plugins.UNSUPPORTED] if item != _UNSUPPORTED]
catlist.sort() catlist.sort()
for key in catlist: for key in catlist:
new_key = key.replace(' ', '-') new_key = key.replace(' ', '-')
@ -1391,11 +1392,11 @@ class ViewManager:
# If there are any unsupported items we add separator # If there are any unsupported items we add separator
# and the unsupported category at the end of the menu # 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('<separator/>')
ofile.write('<menu action="%s">' % Plugins.UNSUPPORTED) ofile.write('<menu action="%s">' % _UNSUPPORTED)
actions.append((Plugins.UNSUPPORTED, None, Plugins.UNSUPPORTED)) actions.append((_UNSUPPORTED, None, _UNSUPPORTED))
lst = hash_data[Plugins.UNSUPPORTED] lst = hash_data[_UNSUPPORTED]
lst.sort(by_menu_name) lst.sort(by_menu_name)
for name in lst: for name in lst:
new_key = name[3].replace(' ', '-') new_key = name[3].replace(' ', '-')

View File

@ -86,6 +86,13 @@ from ReportBase._ReportOptions import ReportOptions
from BasicUtils import name_displayer as _nd from BasicUtils import name_displayer as _nd
#------------------------------------------------------------------------
#
# Private Constants
#
#------------------------------------------------------------------------
_UNSUPPORTED = _("Unsupported")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Private Functions # Private Functions
@ -195,7 +202,7 @@ class BookItem:
if item[4] == name: if item[4] == name:
self.translated_name = item[0] self.translated_name = item[0]
if item[5]: if item[5]:
self.category = Plugins.UNSUPPORTED self.category = _UNSUPPORTED
else: else:
self.category = item[1] self.category = item[1]
self.write_item = item[2] self.write_item = item[2]
@ -748,7 +755,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
for book_item in pmgr.get_book_item_list(): for book_item in pmgr.get_book_item_list():
if book_item[5]: if book_item[5]:
category = Plugins.UNSUPPORTED category = _UNSUPPORTED
else: else:
category = book_item[1] category = book_item[1]