fix up stuff
This commit is contained in:
parent
ff8df58334
commit
af8bf385a7
@ -17,7 +17,10 @@ class command():
|
|||||||
return _('get current v menu entry')
|
return _('get current v menu entry')
|
||||||
def run(self):
|
def run(self):
|
||||||
print('CURR MENU')
|
print('CURR MENU')
|
||||||
|
try:
|
||||||
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
||||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -17,8 +17,11 @@ class command():
|
|||||||
return _('leave v menu submenu')
|
return _('leave v menu submenu')
|
||||||
def run(self):
|
def run(self):
|
||||||
print('DEC LEVEL')
|
print('DEC LEVEL')
|
||||||
|
try:
|
||||||
self.env['runtime']['vmenuManager'].decLevel()
|
self.env['runtime']['vmenuManager'].decLevel()
|
||||||
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
||||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -17,7 +17,9 @@ class command():
|
|||||||
return _('execute v menu entry')
|
return _('execute v menu entry')
|
||||||
def run(self):
|
def run(self):
|
||||||
print('EXEC ENTRY')
|
print('EXEC ENTRY')
|
||||||
|
try:
|
||||||
self.env['runtime']['vmenuManager'].executeMenu()
|
self.env['runtime']['vmenuManager'].executeMenu()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -17,9 +17,11 @@ class command():
|
|||||||
return _('enter v menu submenu')
|
return _('enter v menu submenu')
|
||||||
def run(self):
|
def run(self):
|
||||||
print('INC LEVEL')
|
print('INC LEVEL')
|
||||||
|
try:
|
||||||
self.env['runtime']['vmenuManager'].incLevel()
|
self.env['runtime']['vmenuManager'].incLevel()
|
||||||
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
||||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -17,8 +17,11 @@ class command():
|
|||||||
return _('get next v menu entry')
|
return _('get next v menu entry')
|
||||||
def run(self):
|
def run(self):
|
||||||
print('NEXT MENU')
|
print('NEXT MENU')
|
||||||
|
try:
|
||||||
self.env['runtime']['vmenuManager'].nextIndex()
|
self.env['runtime']['vmenuManager'].nextIndex()
|
||||||
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
||||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -17,9 +17,11 @@ class command():
|
|||||||
return _('get prev v menu entry')
|
return _('get prev v menu entry')
|
||||||
def run(self):
|
def run(self):
|
||||||
print('PREV MENU')
|
print('PREV MENU')
|
||||||
|
try:
|
||||||
self.env['runtime']['vmenuManager'].prevIndex()
|
self.env['runtime']['vmenuManager'].prevIndex()
|
||||||
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
text = self.env['runtime']['vmenuManager'].getCurrentEntry()
|
||||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
|
|
||||||
from fenrirscreenreader.core import debug
|
from fenrirscreenreader.core import debug
|
||||||
from fenrirscreenreader.utils import module_utils
|
from fenrirscreenreader.utils import module_utils
|
||||||
|
import os, inspect
|
||||||
|
|
||||||
import os
|
currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe()))))
|
||||||
|
fenrirPath = os.path.dirname(currentdir)
|
||||||
|
|
||||||
class vmenuManager():
|
class vmenuManager():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -16,6 +17,7 @@ class vmenuManager():
|
|||||||
self.currIndex = None
|
self.currIndex = None
|
||||||
self.currMenu = ''
|
self.currMenu = ''
|
||||||
self.active = False
|
self.active = False
|
||||||
|
self.defaultVMenuPath = fenrirPath+ "/commands/vmenu-profiles/KEY"
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
@ -37,7 +39,6 @@ class vmenuManager():
|
|||||||
self.setActive(not self.getActive())
|
self.setActive(not self.getActive())
|
||||||
def setActive(self, active):
|
def setActive(self, active):
|
||||||
self.active = active
|
self.active = active
|
||||||
print('drin')
|
|
||||||
if self.active:
|
if self.active:
|
||||||
#try:
|
#try:
|
||||||
self.createMenuTree()
|
self.createMenuTree()
|
||||||
@ -67,11 +68,9 @@ class vmenuManager():
|
|||||||
del(self.env['bindings'][str([1, ['KEY_ENTER']])])
|
del(self.env['bindings'][str([1, ['KEY_ENTER']])])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
print(self.env['bindings'])
|
|
||||||
|
|
||||||
def createMenuTree(self):
|
def createMenuTree(self):
|
||||||
self.currIndex = None
|
self.currIndex = None
|
||||||
menu = self.fs_tree_to_dict( '/home/chrys/Projekte/fenrir/src/fenrirscreenreader/commands/vmenu-profiles/KEY')
|
menu = self.fs_tree_to_dict( self.defaultVMenuPath)
|
||||||
if menu:
|
if menu:
|
||||||
self.menuDict = menu
|
self.menuDict = menu
|
||||||
if len(self.menuDict) > 0:
|
if len(self.menuDict) > 0:
|
||||||
@ -79,6 +78,10 @@ class vmenuManager():
|
|||||||
def executeMenu(self):
|
def executeMenu(self):
|
||||||
if self.currIndex == None:
|
if self.currIndex == None:
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
self.incLevel()
|
||||||
def incLevel(self):
|
def incLevel(self):
|
||||||
if self.currIndex == None:
|
if self.currIndex == None:
|
||||||
return
|
return
|
||||||
@ -93,33 +96,51 @@ class vmenuManager():
|
|||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
self.currIndex.append(0)
|
self.currIndex.append(0)
|
||||||
|
print(self.currIndex)
|
||||||
def decLevel(self):
|
def decLevel(self):
|
||||||
if self.currIndex == None:
|
if self.currIndex == None:
|
||||||
return
|
return
|
||||||
if len(self.currIndex) == 1:
|
if len(self.currIndex) == 1:
|
||||||
return
|
return
|
||||||
self.currIndex.remove(len(self.currIndex) - 1)
|
self.currIndex.remove(len(self.currIndex) - 1)
|
||||||
|
print(self.currIndex)
|
||||||
def nextIndex(self):
|
def nextIndex(self):
|
||||||
if self.currIndex == None:
|
if self.currIndex == None:
|
||||||
return
|
return
|
||||||
self.currIndex[len(self.currIndex) - 1] += 1
|
if self.currIndex[len(self.currIndex) - 1] + 1 >= len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])):
|
||||||
if self.currIndex[len(self.currIndex) - 1] >= len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])):
|
|
||||||
self.currIndex[len(self.currIndex) - 1] = 0
|
self.currIndex[len(self.currIndex) - 1] = 0
|
||||||
|
else:
|
||||||
|
self.currIndex[len(self.currIndex) - 1] += 1
|
||||||
|
print(self.currIndex)
|
||||||
|
|
||||||
def prevIndex(self):
|
def prevIndex(self):
|
||||||
if self.currIndex == None:
|
if self.currIndex == None:
|
||||||
return
|
return
|
||||||
if len(self.currIndex) - 1 < self.currLevel:
|
if self.currIndex[len(self.currIndex) - 1] == 0:
|
||||||
return
|
|
||||||
self.currIndex[len(self.currIndex) - 1] -= 1
|
|
||||||
if self.currIndex[len(self.currIndex) - 1] < 0:
|
|
||||||
self.currIndex[len(self.currIndex) - 1] = len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])) - 1
|
self.currIndex[len(self.currIndex) - 1] = len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])) - 1
|
||||||
|
else:
|
||||||
|
self.currIndex[len(self.currIndex) - 1] -= 1
|
||||||
|
print(self.currIndex)
|
||||||
|
|
||||||
def getCurrentEntry(self):
|
def getCurrentEntry(self):
|
||||||
|
print( self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]])
|
||||||
return self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]]
|
return self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]]
|
||||||
def fs_tree_to_dict(self, path_):
|
def fs_tree_to_dict(self, path_):
|
||||||
for root, dirs, files in os.walk(path_):
|
for root, dirs, files in os.walk(path_):
|
||||||
tree = {d: self.fs_tree_to_dict(os.path.join(root, d)) for d in dirs}
|
tree = {d: self.fs_tree_to_dict(os.path.join(root, d)) for d in dirs}
|
||||||
tree.update({f: root + '/' + f for f in files})
|
tree.update({f: root + '/' + f for f in files})
|
||||||
return tree # note we discontinue iteration trough os.walk
|
return tree # note we discontinue iteration trough os.walk
|
||||||
|
def getNestedByPath(self, complete, path):
|
||||||
|
path = path.copy()
|
||||||
|
if path != []:
|
||||||
|
index = list(complete.keys())[path[0]]
|
||||||
|
print(path)
|
||||||
|
path.remove(0)
|
||||||
|
nested = self.getNestedByPath(complete[index], path)
|
||||||
|
return nested
|
||||||
|
else:
|
||||||
|
return complete
|
||||||
|
|
||||||
|
|
||||||
def getKeysByPath(self, complete, path):
|
def getKeysByPath(self, complete, path):
|
||||||
if not isinstance(complete, dict):
|
if not isinstance(complete, dict):
|
||||||
|
Loading…
Reference in New Issue
Block a user