improvement: add stock_category_icon support
This commit is contained in:
parent
70e62d438d
commit
c122ccbf9d
@ -373,6 +373,8 @@ class PluginData:
|
|||||||
.. 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:: stock_category_icon
|
||||||
|
The icon used for the view category if there is none
|
||||||
.. attribute:: stock_icon
|
.. attribute:: stock_icon
|
||||||
The icon in the toolbar or sidebar used to select the view
|
The icon in the toolbar or sidebar used to select the view
|
||||||
|
|
||||||
@ -482,6 +484,7 @@ class PluginData:
|
|||||||
self._orientation = None
|
self._orientation = None
|
||||||
#VIEW attr
|
#VIEW attr
|
||||||
self._viewclass = None
|
self._viewclass = None
|
||||||
|
self._stock_category_icon = None
|
||||||
self._stock_icon = None
|
self._stock_icon = None
|
||||||
#SIDEBAR attr
|
#SIDEBAR attr
|
||||||
self._sidebarclass = None
|
self._sidebarclass = None
|
||||||
@ -1016,6 +1019,14 @@ class PluginData:
|
|||||||
def _get_viewclass(self):
|
def _get_viewclass(self):
|
||||||
return self._viewclass
|
return self._viewclass
|
||||||
|
|
||||||
|
def _set_stock_category_icon(self, stock_category_icon):
|
||||||
|
if not self._ptype == VIEW:
|
||||||
|
raise ValueError('stock_category_icon may only be set for VIEW plugins')
|
||||||
|
self._stock_category_icon = stock_category_icon
|
||||||
|
|
||||||
|
def _get_stock_category_icon(self):
|
||||||
|
return self._stock_category_icon
|
||||||
|
|
||||||
def _set_stock_icon(self, stock_icon):
|
def _set_stock_icon(self, stock_icon):
|
||||||
if not self._ptype == VIEW:
|
if not self._ptype == VIEW:
|
||||||
raise ValueError('stock_icon may only be set for VIEW plugins')
|
raise ValueError('stock_icon may only be set for VIEW plugins')
|
||||||
@ -1025,6 +1036,7 @@ class PluginData:
|
|||||||
return self._stock_icon
|
return self._stock_icon
|
||||||
|
|
||||||
viewclass = property(_get_viewclass, _set_viewclass)
|
viewclass = property(_get_viewclass, _set_viewclass)
|
||||||
|
stock_category_icon = property(_get_stock_category_icon, _set_stock_category_icon)
|
||||||
stock_icon = property(_get_stock_icon, _set_stock_icon)
|
stock_icon = property(_get_stock_icon, _set_stock_icon)
|
||||||
|
|
||||||
#SIDEBAR attributes
|
#SIDEBAR attributes
|
||||||
|
@ -172,6 +172,14 @@ class Navigator:
|
|||||||
views[cat_num] = []
|
views[cat_num] = []
|
||||||
cat_name = page[0].category[1]
|
cat_name = page[0].category[1]
|
||||||
cat_icon = CATEGORY_ICON.get(page[0].category[0])
|
cat_icon = CATEGORY_ICON.get(page[0].category[0])
|
||||||
|
if cat_icon is None:
|
||||||
|
try:
|
||||||
|
cat_icon = page[0].stock_category_icon
|
||||||
|
except AttributeError:
|
||||||
|
try:
|
||||||
|
cat_icon = page[0].stock_icon
|
||||||
|
except AttributeError:
|
||||||
|
cat_icon = 'gramps-view'
|
||||||
if cat_icon is None:
|
if cat_icon is None:
|
||||||
cat_icon = 'gramps-view'
|
cat_icon = 'gramps-view'
|
||||||
categories.append([cat_num, cat_name, cat_icon])
|
categories.append([cat_num, cat_name, cat_icon])
|
||||||
|
Loading…
Reference in New Issue
Block a user