Fixed launching issues

This commit is contained in:
Maxim Stewart 2020-10-28 18:26:28 -05:00
parent 5f783ac320
commit d1a587b026
2 changed files with 12 additions and 4 deletions

View File

@ -23,29 +23,34 @@ class Main(Context):
super().__init__(args) super().__init__(args)
HOME_APPS = os.path.expanduser('~') + "/.local/share/applications/" HOME_APPS = os.path.expanduser('~') + "/.local/share/applications/"
paths = ["/opt/", "/usr/share/applications/", HOME_APPS] paths = ["/opt/", "/usr/share/applications/", HOME_APPS]
baseOptions = ["[ TO MAIN MENU ]", "Favorites"]
self.menuData = self.getDesktopFilesInfo(paths) self.menuData = self.getDesktopFilesInfo(paths)
baseOptions = ["[ TO MAIN MENU ]", "[ Favorites ]"]
query = "" query = ""
while True: while True:
try: try:
self.clear() self.clear()
group = self.call_method("mainMenu")["group"] group = self.call_method("mainMenu")["group"]
self.clear()
if "Search..." in group: if "Search..." in group:
query = self.call_method("searchMenu")["query"] query = self.call_method("searchMenu")["query"]
if "Favorites" in group: if "Favorites" in group:
query = self.call_method("favoritesMenu")["faves"] query = self.call_method("favoritesMenu")["faves"]
continue
if "[ Exit ]" in group: if "[ Exit ]" in group:
break break
self.clear()
progsList = ["[ TO MAIN MENU ]"] progsList = ["[ TO MAIN MENU ]"]
progsList += self.getSubgroup(group, query) progsList += self.getSubgroup(group, query)
entry = self.call_method("subMenu", [group, progsList])["prog"] entry = self.call_method("subMenu", [group, progsList])["prog"]
self.logger.debug(entry)
if entry not in baseOptions: if entry not in baseOptions:
self.logger.info("[Executing Program] Group: {} Entry: {}".format(group, entry))
self.executeProgram(group, entry) self.executeProgram(group, entry)
except Exception as e: except Exception as e:
pass self.logger.error(e)
def call_method(self, method_name, data = None): def call_method(self, method_name, data = None):
@ -155,7 +160,7 @@ class Main(Context):
program = parts[0].strip() program = parts[0].strip()
comment = parts[1].strip() comment = parts[1].strip()
if "[ Search ]" in group: if "Search..." in group:
gkeys = self.menuData.keys() gkeys = self.menuData.keys()
for gkey in gkeys: for gkey in gkeys:
self.pre_execute(self.menuData[gkey], program, comment) self.pre_execute(self.menuData[gkey], program, comment)

View File

@ -54,6 +54,7 @@ class Context(StylesMixin):
def favoritesMenu(self, _grouplist = None): def favoritesMenu(self, _grouplist = None):
GROUPS = ["[ TO MAIN MENU ]", "This is a stub method for Favorites..."]
grouplist = GROUPS if not _grouplist else _grouplist grouplist = GROUPS if not _grouplist else _grouplist
menu = { menu = {
'type': 'list', 'type': 'list',
@ -62,6 +63,8 @@ class Context(StylesMixin):
'choices': grouplist 'choices': grouplist
} }
return prompt(menu, style=self.theme)
def subMenu(self, data = ["NO GROUP NAME", "NO PROGRAMS PASSED IN"]): def subMenu(self, data = ["NO GROUP NAME", "NO PROGRAMS PASSED IN"]):
group = data[0] group = data[0]