add the first plugins
This commit is contained in:
0
raven/plugins/domain/__init__.py
Normal file
0
raven/plugins/domain/__init__.py
Normal file
11
raven/plugins/domain/menucontribution.py
Normal file
11
raven/plugins/domain/menucontribution.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from raven.plugins.domain.raction import RAction
|
||||
from raven.plugins.domain.rmenu import RMenu
|
||||
|
||||
|
||||
class MenuContribution():
|
||||
def __init__(self, menu_id: str, action: RAction = None, menu: RMenu = None, action_id=None):
|
||||
super(MenuContribution, self).__init__()
|
||||
self.menu_id = menu_id
|
||||
self.action = action
|
||||
self.menu = menu
|
||||
self.action_id = action_id
|
||||
37
raven/plugins/domain/raction.py
Normal file
37
raven/plugins/domain/raction.py
Normal file
@@ -0,0 +1,37 @@
|
||||
class RAction():
|
||||
|
||||
def __init__(self,
|
||||
label: str,
|
||||
action=None,
|
||||
shortcut: str = None,
|
||||
icon_from_theme: str = None,
|
||||
icon_file: str = None,
|
||||
checkable: bool = False,
|
||||
checked: bool = False
|
||||
):
|
||||
super(RAction, self).__init__()
|
||||
self.label = label
|
||||
self.action = action
|
||||
self.shortcut = shortcut
|
||||
self.icon_from_theme = icon_from_theme
|
||||
self.icon_file = icon_file
|
||||
self.checkable = checkable
|
||||
self.checked = checked
|
||||
|
||||
def set_action(self, action):
|
||||
self.action = action
|
||||
|
||||
def set_icon_from_theme(self, icon_from_theme: str):
|
||||
self.icon_from_theme = icon_from_theme
|
||||
|
||||
def set_icon_file(self, icon_file: str):
|
||||
self.icon_file = icon_file
|
||||
|
||||
def set_shortcut(self, shortcut: str):
|
||||
self.shortcut = shortcut
|
||||
|
||||
def set_checkable(self, checkable: bool):
|
||||
self.checkable = checkable
|
||||
|
||||
def set_checked(self, checked: bool):
|
||||
self.checked = checked
|
||||
26
raven/plugins/domain/rmenu.py
Normal file
26
raven/plugins/domain/rmenu.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from typing import Callable
|
||||
|
||||
from raven.plugins.domain.raction import RAction
|
||||
|
||||
|
||||
class RMenu():
|
||||
def __init__(self, label: str):
|
||||
super(RMenu, self).__init__()
|
||||
self.label = label
|
||||
self.actions = []
|
||||
self.listeners = []
|
||||
|
||||
def add_action(self, action: RAction):
|
||||
self.actions.append(action)
|
||||
self._notify()
|
||||
|
||||
def clear(self):
|
||||
self.actions.clear()
|
||||
self._notify()
|
||||
|
||||
def _notify(self):
|
||||
for listener in self.listeners:
|
||||
listener()
|
||||
|
||||
def add_change_listener(self, listener: Callable[[], None]):
|
||||
self.listeners.append(listener)
|
||||
Reference in New Issue
Block a user