allow forcing a view to be first in category
svn: r13590
This commit is contained in:
parent
319ca153a3
commit
47158f47ac
@ -32,7 +32,8 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
|
||||
CATEGORY_QR_DATE, PTYPE_STR,
|
||||
VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
|
||||
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
|
||||
VIEW_GEO
|
||||
VIEW_GEO, VIEW_PEDI,
|
||||
START, END
|
||||
)
|
||||
from _manager import BasePluginManager
|
||||
from _import import ImportPlugin
|
||||
@ -50,4 +51,8 @@ __all__ = [ "docbackend", "docgen", "menu", Plugin, PluginData,
|
||||
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
|
||||
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
|
||||
CATEGORY_QR_DATE, PTYPE_STR]
|
||||
CATEGORY_QR_DATE, PTYPE_STR,
|
||||
VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
|
||||
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
|
||||
VIEW_GEO, VIEW_PEDI,
|
||||
START, END]
|
||||
|
@ -107,16 +107,17 @@ VIEW_MISC = 0
|
||||
VIEW_PERSON = 1
|
||||
VIEW_REL = 2
|
||||
VIEW_FAMILY = 3
|
||||
VIEW_EVENT = 4
|
||||
VIEW_PLACE = 5
|
||||
VIEW_SOURCE = 6
|
||||
VIEW_REPO = 7
|
||||
VIEW_MEDIA = 8
|
||||
VIEW_NOTE = 9
|
||||
VIEW_GEO = 10
|
||||
VIEW_PEDI = 4
|
||||
VIEW_EVENT = 5
|
||||
VIEW_PLACE = 6
|
||||
VIEW_SOURCE = 7
|
||||
VIEW_REPO = 8
|
||||
VIEW_MEDIA = 9
|
||||
VIEW_NOTE = 10
|
||||
VIEW_GEO = 11
|
||||
VIEW_CAT = [VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
|
||||
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
|
||||
VIEW_GEO]
|
||||
VIEW_PEDI, VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA,
|
||||
VIEW_NOTE, VIEW_GEO]
|
||||
|
||||
#possible quickreport categories
|
||||
CATEGORY_QR_MISC = -1
|
||||
@ -139,6 +140,10 @@ REPORT_MODES = [REPORT_MODE_GUI, REPORT_MODE_BKI, REPORT_MODE_CLI]
|
||||
TOOL_MODE_GUI = 1 # Standard tool using GUI
|
||||
TOOL_MODE_CLI = 2 # Command line interface (CLI)
|
||||
TOOL_MODES = [TOOL_MODE_GUI, TOOL_MODE_CLI]
|
||||
|
||||
# possible view orders
|
||||
START = 1
|
||||
END = 2
|
||||
|
||||
class PluginData(object):
|
||||
"""
|
||||
@ -265,6 +270,11 @@ class PluginData(object):
|
||||
.. attribute:: viewclass
|
||||
A class of type ViewCreator that holds the needed info of the
|
||||
view to be created: icon, viewclass that derives from pageview, ...
|
||||
.. attribute:: order
|
||||
order can be START or END. Default is END. For END, on registering,
|
||||
the view is appended to the list of views. If START, then the view is
|
||||
prepended. Only set START if you want a view to be the first in the
|
||||
order of views
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@ -320,6 +330,7 @@ class PluginData(object):
|
||||
self._help_url = None
|
||||
#VIEW attr
|
||||
self._viewclass = None
|
||||
self._order = END
|
||||
|
||||
def _set_id(self, id):
|
||||
self._id = id
|
||||
@ -724,8 +735,17 @@ class PluginData(object):
|
||||
|
||||
def _get_viewclass(self):
|
||||
return self._viewclass
|
||||
|
||||
|
||||
def _set_order(self, order):
|
||||
if not self._ptype == VIEW:
|
||||
raise ValueError, 'order may only be set for VIEW plugins'
|
||||
self._order = order
|
||||
|
||||
def _get_order(self):
|
||||
return self._order
|
||||
|
||||
viewclass = property(_get_viewclass, _set_viewclass)
|
||||
order = property(_get_order, _set_order)
|
||||
|
||||
def newplugin():
|
||||
"""
|
||||
@ -849,6 +869,7 @@ class PluginRegister(object):
|
||||
'VIEW_PERSON': VIEW_PERSON,
|
||||
'VIEW_REL': VIEW_REL,
|
||||
'VIEW_FAMILY': VIEW_FAMILY,
|
||||
'VIEW_PEDI': VIEW_PEDI,
|
||||
'VIEW_EVENT': VIEW_EVENT,
|
||||
'VIEW_PLACE': VIEW_PLACE,
|
||||
'VIEW_SOURCE': VIEW_SOURCE,
|
||||
@ -871,6 +892,8 @@ class PluginRegister(object):
|
||||
'TOOL_MODE_GUI': TOOL_MODE_GUI,
|
||||
'TOOL_MODE_CLI': TOOL_MODE_CLI,
|
||||
'GRAMPSVERSION': GRAMPSVERSION,
|
||||
'START': START,
|
||||
'END': END,
|
||||
},
|
||||
{})
|
||||
except ValueError, msg:
|
||||
|
@ -64,11 +64,11 @@ import Utils
|
||||
from gui.pluginmanager import GuiPluginManager
|
||||
from gen.plug import (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
|
||||
VIEW_EVENT, VIEW_PLACE, VIEW_GEO, VIEW_SOURCE, VIEW_REPO,
|
||||
VIEW_MEDIA, VIEW_NOTE)
|
||||
VIEW_MEDIA, VIEW_PEDI, VIEW_NOTE, START, END)
|
||||
|
||||
DEFAULT_SIDEBAR_ORDER = (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
|
||||
VIEW_EVENT, VIEW_PLACE, VIEW_GEO, VIEW_SOURCE, VIEW_REPO,
|
||||
VIEW_MEDIA, VIEW_NOTE)
|
||||
VIEW_PEDI, VIEW_EVENT, VIEW_PLACE, VIEW_GEO, VIEW_SOURCE,
|
||||
VIEW_REPO, VIEW_MEDIA, VIEW_NOTE)
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Functions
|
||||
@ -258,7 +258,11 @@ def construct_view_order():
|
||||
continue
|
||||
viewclass = eval('mod.' + pdata.viewclass)
|
||||
if pdata.category in viewstoshow:
|
||||
viewstoshow[pdata.category].append((pdata.id, viewclass))
|
||||
if pdata.order == START:
|
||||
viewstoshow[pdata.category].insert(0, append((pdata.id,
|
||||
viewclass)))
|
||||
else:
|
||||
viewstoshow[pdata.category].append((pdata.id, viewclass))
|
||||
else:
|
||||
viewstoshow[pdata.category] = [(pdata.id, viewclass)]
|
||||
|
||||
|
@ -7,6 +7,6 @@ register(VIEW,
|
||||
fname = 'fanchartview.py',
|
||||
authors = [u"Douglas S. Blank"],
|
||||
authors_email = ["doug.blank@gmail.com"],
|
||||
category = VIEW_REL,
|
||||
category = VIEW_PEDI,
|
||||
viewclass = 'FanChartView',
|
||||
)
|
||||
|
@ -587,7 +587,7 @@ class FanChartView(NavigationView):
|
||||
"""
|
||||
The category stock icon
|
||||
"""
|
||||
return 'gramps-relation'
|
||||
return 'gramps-pedigree'
|
||||
|
||||
def get_viewtype_stock(self):
|
||||
"""Type of view in category
|
||||
|
@ -416,7 +416,7 @@ class PedigreeView(NavigationView):
|
||||
"""
|
||||
The category stock icon
|
||||
"""
|
||||
return 'gramps-relation'
|
||||
return 'gramps-pedigree'
|
||||
|
||||
def get_viewtype_stock(self):
|
||||
"""Type of view in category
|
||||
|
@ -38,6 +38,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_EVENT,
|
||||
viewclass = 'EventView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -51,6 +52,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_FAMILY,
|
||||
viewclass = 'FamilyView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -64,6 +66,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_MISC,
|
||||
viewclass = 'GrampletView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -77,6 +80,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_MEDIA,
|
||||
viewclass = 'MediaView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -90,6 +94,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_NOTE,
|
||||
viewclass = 'NoteView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -103,6 +108,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_REL,
|
||||
viewclass = 'RelationshipView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -114,7 +120,7 @@ status = STABLE,
|
||||
fname = 'pedigreeview.py',
|
||||
authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_REL,
|
||||
category = VIEW_PEDI,
|
||||
viewclass = 'PedigreeView',
|
||||
)
|
||||
|
||||
@ -129,6 +135,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_PERSON,
|
||||
viewclass = 'PersonView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -142,6 +149,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_PLACE,
|
||||
viewclass = 'PlaceView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -155,6 +163,7 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_REPO,
|
||||
viewclass = 'RepositoryView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
@ -168,4 +177,5 @@ authors = [u"The GRAMPS project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = VIEW_SOURCE,
|
||||
viewclass = 'SourceView',
|
||||
order = START,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user