Pre favorites additions
This commit is contained in:
parent
968fda6f68
commit
5f783ac320
|
@ -8,8 +8,6 @@ from os import listdir
|
|||
# Gtk imports
|
||||
from xdg.DesktopEntry import DesktopEntry
|
||||
|
||||
|
||||
|
||||
# Application imports
|
||||
from core import Context
|
||||
|
||||
|
@ -25,16 +23,18 @@ class Main(Context):
|
|||
super().__init__(args)
|
||||
HOME_APPS = os.path.expanduser('~') + "/.local/share/applications/"
|
||||
paths = ["/opt/", "/usr/share/applications/", HOME_APPS]
|
||||
self.menuData = self.getDesktopFilesInfo(paths)
|
||||
baseOptions = ["[ TO MAIN MENU ]", "[ Favorites ]"]
|
||||
query = ""
|
||||
|
||||
while True:
|
||||
try:
|
||||
self.clear()
|
||||
if not self.menuData:
|
||||
self.menuData = self.getDesktopFilesInfo(paths)
|
||||
|
||||
group = self.call_method("mainMenu")["group"]
|
||||
if "[ Search ]" in 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
|
||||
|
||||
|
@ -42,8 +42,10 @@ class Main(Context):
|
|||
progsList = ["[ TO MAIN MENU ]"]
|
||||
progsList += self.getSubgroup(group, query)
|
||||
entry = self.call_method("subMenu", [group, progsList])["prog"]
|
||||
if not "[ TO MAIN MENU ]" is entry:
|
||||
if entry not in baseOptions:
|
||||
self.executeProgram(group, entry)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
||||
def call_method(self, method_name, data = None):
|
||||
|
@ -123,11 +125,9 @@ class Main(Context):
|
|||
})
|
||||
|
||||
|
||||
|
||||
|
||||
def getSubgroup(self, group, query = ""):
|
||||
desktopObjs = []
|
||||
if "[ Search ]" in group:
|
||||
if "Search..." in group:
|
||||
gkeys = self.menuData.keys()
|
||||
for gkey in gkeys:
|
||||
for opt in self.menuData[gkey]:
|
||||
|
@ -135,9 +135,10 @@ class Main(Context):
|
|||
if "comment" in keys and len(opt["comment"]) > 0 :
|
||||
if query.lower() in opt["comment"].lower():
|
||||
desktopObjs.append( opt["title"] + " || " + opt["comment"] )
|
||||
continue
|
||||
if query.lower() in opt["title"].lower() or query.lower() in opt["fileName"].lower():
|
||||
desktopObjs.append( opt["title"] + " || " + opt["fileName"].replace(".desktop", "") )
|
||||
elif "Favorites" in group:
|
||||
pass
|
||||
else:
|
||||
for opt in self.menuData[group]:
|
||||
keys = opt.keys()
|
||||
|
|
|
@ -15,9 +15,10 @@ from .mixins import StylesMixin
|
|||
|
||||
|
||||
|
||||
GROUPS = ["[ Search ]", "Accessories", "Multimedia", "Graphics", "Game",
|
||||
"Office", "Development", "Internet", "Settings", "System",
|
||||
"Wine", "Other", "[ Exit ]"]
|
||||
GROUPS = [ "Favorites", "Accessories", "Multimedia", "Graphics", "Office",
|
||||
"Development", "Internet", "Settings", "System", "Game", "Wine",
|
||||
"Other", "Search...", "[ Exit ]"
|
||||
]
|
||||
|
||||
|
||||
class Context(StylesMixin):
|
||||
|
@ -51,6 +52,17 @@ class Context(StylesMixin):
|
|||
|
||||
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"]):
|
||||
group = data[0]
|
||||
progList = data[1]
|
||||
|
|
Loading…
Reference in New Issue