Pre favorites additions
This commit is contained in:
parent
968fda6f68
commit
5f783ac320
|
@ -8,8 +8,6 @@ from os import listdir
|
||||||
# Gtk imports
|
# Gtk imports
|
||||||
from xdg.DesktopEntry import DesktopEntry
|
from xdg.DesktopEntry import DesktopEntry
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from core import Context
|
from core import Context
|
||||||
|
|
||||||
|
@ -23,27 +21,31 @@ class Main(Context):
|
||||||
Initialize it all...
|
Initialize it all...
|
||||||
"""
|
"""
|
||||||
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]
|
||||||
query = ""
|
self.menuData = self.getDesktopFilesInfo(paths)
|
||||||
|
baseOptions = ["[ TO MAIN MENU ]", "[ Favorites ]"]
|
||||||
|
query = ""
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
self.clear()
|
try:
|
||||||
if not self.menuData:
|
self.clear()
|
||||||
self.menuData = self.getDesktopFilesInfo(paths)
|
group = self.call_method("mainMenu")["group"]
|
||||||
|
if "Search..." in group:
|
||||||
|
query = self.call_method("searchMenu")["query"]
|
||||||
|
if "Favorites" in group:
|
||||||
|
query = self.call_method("favoritesMenu")["faves"]
|
||||||
|
if "[ Exit ]" in group:
|
||||||
|
break
|
||||||
|
|
||||||
group = self.call_method("mainMenu")["group"]
|
self.clear()
|
||||||
if "[ Search ]" in group:
|
progsList = ["[ TO MAIN MENU ]"]
|
||||||
query = self.call_method("searchMenu")["query"]
|
progsList += self.getSubgroup(group, query)
|
||||||
if "[ Exit ]" in group:
|
entry = self.call_method("subMenu", [group, progsList])["prog"]
|
||||||
break
|
if entry not in baseOptions:
|
||||||
|
self.executeProgram(group, entry)
|
||||||
self.clear()
|
except Exception as e:
|
||||||
progsList = ["[ TO MAIN MENU ]"]
|
pass
|
||||||
progsList += self.getSubgroup(group, query)
|
|
||||||
entry = self.call_method("subMenu", [group, progsList])["prog"]
|
|
||||||
if not "[ TO MAIN MENU ]" is entry:
|
|
||||||
self.executeProgram(group, entry)
|
|
||||||
|
|
||||||
|
|
||||||
def call_method(self, method_name, data = None):
|
def call_method(self, method_name, data = None):
|
||||||
|
@ -123,11 +125,9 @@ class Main(Context):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getSubgroup(self, group, query = ""):
|
def getSubgroup(self, group, query = ""):
|
||||||
desktopObjs = []
|
desktopObjs = []
|
||||||
if "[ Search ]" in group:
|
if "Search..." in group:
|
||||||
gkeys = self.menuData.keys()
|
gkeys = self.menuData.keys()
|
||||||
for gkey in gkeys:
|
for gkey in gkeys:
|
||||||
for opt in self.menuData[gkey]:
|
for opt in self.menuData[gkey]:
|
||||||
|
@ -135,9 +135,10 @@ class Main(Context):
|
||||||
if "comment" in keys and len(opt["comment"]) > 0 :
|
if "comment" in keys and len(opt["comment"]) > 0 :
|
||||||
if query.lower() in opt["comment"].lower():
|
if query.lower() in opt["comment"].lower():
|
||||||
desktopObjs.append( opt["title"] + " || " + opt["comment"] )
|
desktopObjs.append( opt["title"] + " || " + opt["comment"] )
|
||||||
continue
|
|
||||||
if query.lower() in opt["title"].lower() or query.lower() in opt["fileName"].lower():
|
if query.lower() in opt["title"].lower() or query.lower() in opt["fileName"].lower():
|
||||||
desktopObjs.append( opt["title"] + " || " + opt["fileName"].replace(".desktop", "") )
|
desktopObjs.append( opt["title"] + " || " + opt["fileName"].replace(".desktop", "") )
|
||||||
|
elif "Favorites" in group:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
for opt in self.menuData[group]:
|
for opt in self.menuData[group]:
|
||||||
keys = opt.keys()
|
keys = opt.keys()
|
||||||
|
|
|
@ -15,9 +15,10 @@ from .mixins import StylesMixin
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GROUPS = ["[ Search ]", "Accessories", "Multimedia", "Graphics", "Game",
|
GROUPS = [ "Favorites", "Accessories", "Multimedia", "Graphics", "Office",
|
||||||
"Office", "Development", "Internet", "Settings", "System",
|
"Development", "Internet", "Settings", "System", "Game", "Wine",
|
||||||
"Wine", "Other", "[ Exit ]"]
|
"Other", "Search...", "[ Exit ]"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Context(StylesMixin):
|
class Context(StylesMixin):
|
||||||
|
@ -51,6 +52,17 @@ class Context(StylesMixin):
|
||||||
|
|
||||||
return prompt(menu, style=self.theme)
|
return prompt(menu, style=self.theme)
|
||||||
|
|
||||||
|
|
||||||
|
def favoritesMenu(self, _grouplist = None):
|
||||||
|
grouplist = GROUPS if not _grouplist else _grouplist
|
||||||
|
menu = {
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'faves',
|
||||||
|
'message': '[ Favorites ]',
|
||||||
|
'choices': grouplist
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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]
|
||||||
progList = data[1]
|
progList = data[1]
|
||||||
|
|
Loading…
Reference in New Issue