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,
|
CATEGORY_QR_DATE, PTYPE_STR,
|
||||||
VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
|
VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
|
||||||
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
|
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
|
||||||
VIEW_GEO
|
VIEW_GEO, VIEW_PEDI,
|
||||||
|
START, END
|
||||||
)
|
)
|
||||||
from _manager import BasePluginManager
|
from _manager import BasePluginManager
|
||||||
from _import import ImportPlugin
|
from _import import ImportPlugin
|
||||||
@ -50,4 +51,8 @@ __all__ = [ "docbackend", "docgen", "menu", Plugin, PluginData,
|
|||||||
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
|
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
|
||||||
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
|
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_PERSON = 1
|
||||||
VIEW_REL = 2
|
VIEW_REL = 2
|
||||||
VIEW_FAMILY = 3
|
VIEW_FAMILY = 3
|
||||||
VIEW_EVENT = 4
|
VIEW_PEDI = 4
|
||||||
VIEW_PLACE = 5
|
VIEW_EVENT = 5
|
||||||
VIEW_SOURCE = 6
|
VIEW_PLACE = 6
|
||||||
VIEW_REPO = 7
|
VIEW_SOURCE = 7
|
||||||
VIEW_MEDIA = 8
|
VIEW_REPO = 8
|
||||||
VIEW_NOTE = 9
|
VIEW_MEDIA = 9
|
||||||
VIEW_GEO = 10
|
VIEW_NOTE = 10
|
||||||
|
VIEW_GEO = 11
|
||||||
VIEW_CAT = [VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
|
VIEW_CAT = [VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
|
||||||
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
|
VIEW_PEDI, VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA,
|
||||||
VIEW_GEO]
|
VIEW_NOTE, VIEW_GEO]
|
||||||
|
|
||||||
#possible quickreport categories
|
#possible quickreport categories
|
||||||
CATEGORY_QR_MISC = -1
|
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_GUI = 1 # Standard tool using GUI
|
||||||
TOOL_MODE_CLI = 2 # Command line interface (CLI)
|
TOOL_MODE_CLI = 2 # Command line interface (CLI)
|
||||||
TOOL_MODES = [TOOL_MODE_GUI, TOOL_MODE_CLI]
|
TOOL_MODES = [TOOL_MODE_GUI, TOOL_MODE_CLI]
|
||||||
|
|
||||||
|
# possible view orders
|
||||||
|
START = 1
|
||||||
|
END = 2
|
||||||
|
|
||||||
class PluginData(object):
|
class PluginData(object):
|
||||||
"""
|
"""
|
||||||
@ -265,6 +270,11 @@ class PluginData(object):
|
|||||||
.. attribute:: viewclass
|
.. attribute:: viewclass
|
||||||
A class of type ViewCreator that holds the needed info of the
|
A class of type ViewCreator that holds the needed info of the
|
||||||
view to be created: icon, viewclass that derives from pageview, ...
|
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):
|
def __init__(self):
|
||||||
@ -320,6 +330,7 @@ class PluginData(object):
|
|||||||
self._help_url = None
|
self._help_url = None
|
||||||
#VIEW attr
|
#VIEW attr
|
||||||
self._viewclass = None
|
self._viewclass = None
|
||||||
|
self._order = END
|
||||||
|
|
||||||
def _set_id(self, id):
|
def _set_id(self, id):
|
||||||
self._id = id
|
self._id = id
|
||||||
@ -724,8 +735,17 @@ class PluginData(object):
|
|||||||
|
|
||||||
def _get_viewclass(self):
|
def _get_viewclass(self):
|
||||||
return self._viewclass
|
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)
|
viewclass = property(_get_viewclass, _set_viewclass)
|
||||||
|
order = property(_get_order, _set_order)
|
||||||
|
|
||||||
def newplugin():
|
def newplugin():
|
||||||
"""
|
"""
|
||||||
@ -849,6 +869,7 @@ class PluginRegister(object):
|
|||||||
'VIEW_PERSON': VIEW_PERSON,
|
'VIEW_PERSON': VIEW_PERSON,
|
||||||
'VIEW_REL': VIEW_REL,
|
'VIEW_REL': VIEW_REL,
|
||||||
'VIEW_FAMILY': VIEW_FAMILY,
|
'VIEW_FAMILY': VIEW_FAMILY,
|
||||||
|
'VIEW_PEDI': VIEW_PEDI,
|
||||||
'VIEW_EVENT': VIEW_EVENT,
|
'VIEW_EVENT': VIEW_EVENT,
|
||||||
'VIEW_PLACE': VIEW_PLACE,
|
'VIEW_PLACE': VIEW_PLACE,
|
||||||
'VIEW_SOURCE': VIEW_SOURCE,
|
'VIEW_SOURCE': VIEW_SOURCE,
|
||||||
@ -871,6 +892,8 @@ class PluginRegister(object):
|
|||||||
'TOOL_MODE_GUI': TOOL_MODE_GUI,
|
'TOOL_MODE_GUI': TOOL_MODE_GUI,
|
||||||
'TOOL_MODE_CLI': TOOL_MODE_CLI,
|
'TOOL_MODE_CLI': TOOL_MODE_CLI,
|
||||||
'GRAMPSVERSION': GRAMPSVERSION,
|
'GRAMPSVERSION': GRAMPSVERSION,
|
||||||
|
'START': START,
|
||||||
|
'END': END,
|
||||||
},
|
},
|
||||||
{})
|
{})
|
||||||
except ValueError, msg:
|
except ValueError, msg:
|
||||||
|
@ -64,11 +64,11 @@ import Utils
|
|||||||
from gui.pluginmanager import GuiPluginManager
|
from gui.pluginmanager import GuiPluginManager
|
||||||
from gen.plug import (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
|
from gen.plug import (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
|
||||||
VIEW_EVENT, VIEW_PLACE, VIEW_GEO, VIEW_SOURCE, VIEW_REPO,
|
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,
|
DEFAULT_SIDEBAR_ORDER = (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
|
||||||
VIEW_EVENT, VIEW_PLACE, VIEW_GEO, VIEW_SOURCE, VIEW_REPO,
|
VIEW_PEDI, VIEW_EVENT, VIEW_PLACE, VIEW_GEO, VIEW_SOURCE,
|
||||||
VIEW_MEDIA, VIEW_NOTE)
|
VIEW_REPO, VIEW_MEDIA, VIEW_NOTE)
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Functions
|
# Functions
|
||||||
@ -258,7 +258,11 @@ def construct_view_order():
|
|||||||
continue
|
continue
|
||||||
viewclass = eval('mod.' + pdata.viewclass)
|
viewclass = eval('mod.' + pdata.viewclass)
|
||||||
if pdata.category in viewstoshow:
|
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:
|
else:
|
||||||
viewstoshow[pdata.category] = [(pdata.id, viewclass)]
|
viewstoshow[pdata.category] = [(pdata.id, viewclass)]
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ register(VIEW,
|
|||||||
fname = 'fanchartview.py',
|
fname = 'fanchartview.py',
|
||||||
authors = [u"Douglas S. Blank"],
|
authors = [u"Douglas S. Blank"],
|
||||||
authors_email = ["doug.blank@gmail.com"],
|
authors_email = ["doug.blank@gmail.com"],
|
||||||
category = VIEW_REL,
|
category = VIEW_PEDI,
|
||||||
viewclass = 'FanChartView',
|
viewclass = 'FanChartView',
|
||||||
)
|
)
|
||||||
|
@ -587,7 +587,7 @@ class FanChartView(NavigationView):
|
|||||||
"""
|
"""
|
||||||
The category stock icon
|
The category stock icon
|
||||||
"""
|
"""
|
||||||
return 'gramps-relation'
|
return 'gramps-pedigree'
|
||||||
|
|
||||||
def get_viewtype_stock(self):
|
def get_viewtype_stock(self):
|
||||||
"""Type of view in category
|
"""Type of view in category
|
||||||
|
@ -416,7 +416,7 @@ class PedigreeView(NavigationView):
|
|||||||
"""
|
"""
|
||||||
The category stock icon
|
The category stock icon
|
||||||
"""
|
"""
|
||||||
return 'gramps-relation'
|
return 'gramps-pedigree'
|
||||||
|
|
||||||
def get_viewtype_stock(self):
|
def get_viewtype_stock(self):
|
||||||
"""Type of view in category
|
"""Type of view in category
|
||||||
|
@ -38,6 +38,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_EVENT,
|
category = VIEW_EVENT,
|
||||||
viewclass = 'EventView',
|
viewclass = 'EventView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -51,6 +52,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_FAMILY,
|
category = VIEW_FAMILY,
|
||||||
viewclass = 'FamilyView',
|
viewclass = 'FamilyView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -64,6 +66,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_MISC,
|
category = VIEW_MISC,
|
||||||
viewclass = 'GrampletView',
|
viewclass = 'GrampletView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -77,6 +80,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_MEDIA,
|
category = VIEW_MEDIA,
|
||||||
viewclass = 'MediaView',
|
viewclass = 'MediaView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -90,6 +94,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_NOTE,
|
category = VIEW_NOTE,
|
||||||
viewclass = 'NoteView',
|
viewclass = 'NoteView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -103,6 +108,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_REL,
|
category = VIEW_REL,
|
||||||
viewclass = 'RelationshipView',
|
viewclass = 'RelationshipView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -114,7 +120,7 @@ status = STABLE,
|
|||||||
fname = 'pedigreeview.py',
|
fname = 'pedigreeview.py',
|
||||||
authors = [u"The GRAMPS project"],
|
authors = [u"The GRAMPS project"],
|
||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_REL,
|
category = VIEW_PEDI,
|
||||||
viewclass = 'PedigreeView',
|
viewclass = 'PedigreeView',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -129,6 +135,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_PERSON,
|
category = VIEW_PERSON,
|
||||||
viewclass = 'PersonView',
|
viewclass = 'PersonView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -142,6 +149,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_PLACE,
|
category = VIEW_PLACE,
|
||||||
viewclass = 'PlaceView',
|
viewclass = 'PlaceView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -155,6 +163,7 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_REPO,
|
category = VIEW_REPO,
|
||||||
viewclass = 'RepositoryView',
|
viewclass = 'RepositoryView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
|
||||||
register(VIEW,
|
register(VIEW,
|
||||||
@ -168,4 +177,5 @@ authors = [u"The GRAMPS project"],
|
|||||||
authors_email = ["http://gramps-project.org"],
|
authors_email = ["http://gramps-project.org"],
|
||||||
category = VIEW_SOURCE,
|
category = VIEW_SOURCE,
|
||||||
viewclass = 'SourceView',
|
viewclass = 'SourceView',
|
||||||
|
order = START,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user