Browse Source

More robust desktop discovery

master
Nils 3 years ago
parent
commit
84238728c7
  1. 20
      engine/findprograms.py
  2. 5
      qtgui/quickopensessioncontroller.py

20
engine/findprograms.py

@ -72,14 +72,20 @@ class SupportedProgramsDatabase(object):
"luppp", "non-mixer", "non-timeline", "non-sequencer", "non-midi-mapper", "non-mixer-noui",
"OPNplug", "qmidiarp", "qtractor", "zynaddsubfx", "jack_mixer",
"hydrogen", "mfp", "shuriken", "laborejo", "guitarix", "radium",
"ray-proxy", "ray-jackpatch",
"ray-proxy", "ray-jackpatch", "amsynth",
) #shortcut list and programs not found by buildCache_grepExecutablePaths because they are just shellscripts and do not contain /nsm/server/announce.
self.userWhitelist = () #added dynamically to morePrograms. highest priority
self.userBlacklist = () #added dynamically to blacklist. highest priority
self.knownDesktopFiles = { #shortcuts to the correct desktop files. Reverse lookup binary->desktop creates false entries, for example ZynAddSubFx and Carla.
"zynaddsubfx": "zynaddsubfx-jack.desktop", #value will later get replaced with the .desktop entry
"carla-jack-multi" : "carla.desktop",
#"carla-jack-single" : "carla.desktop", #We CANNOT add them here because both key and value must be unique and hashable. We create a reverse dict from this.
#"carla-jack-patchbay" : "carla.desktop",
#"carla-jack-rack" : "carla.desktop",
"ams" : "ams.desktop",
"amsynth" : "amsynth.desktop",
}
self._reverseKnownDesktopFiles = dict(zip(self.knownDesktopFiles.values(),self.knownDesktopFiles.keys())) #to lookup the exe by desktoip name
self.programs = [] #list of dicts. guaranteed keys: argodejoExec, name, argodejoFullPath. And probably others, like description and version.
self.nsmExecutables = set() #set of executables for fast membership, if a GUI wants to know if they are available. Needs to be build "manually" with self.programs. no auto-property for a list. at least we don't want to do the work.
#.build needs to be called from the api/GUI.
@ -146,10 +152,10 @@ class SupportedProgramsDatabase(object):
try:
config.read(f)
entryDict = dict(config._sections["Desktop Entry"])
if f.name == "zynaddsubfx-jack.desktop":
self.knownDesktopFiles["zynaddsubfx"] = entryDict
elif f.name == "carla.desktop":
self.knownDesktopFiles["carla-jack-multi"] = entryDict
#Replace simple names in our shortcut list with full data
if f.name in self.knownDesktopFiles.values():
key = self._reverseKnownDesktopFiles[f.name]
self.knownDesktopFiles[key] = entryDict
#in any case:
allDesktopEntries.append(entryDict) #_sections 'DesktopEntry':{dictOfActualData)
except: #any bad config means skip
@ -184,10 +190,12 @@ class SupportedProgramsDatabase(object):
def _exeToDesktopEntry(self, exe:str)->dict:
"""Assumes self.desktopEntries is up to date
Convert one exe (not full path!) to one dict entry. """
if exe in self.knownDesktopFiles: #Shortcut through internal database
if exe in self.knownDesktopFiles: #Shortcut through internal database
entry = self.knownDesktopFiles[exe]
return entry
else: #Reverse Search desktop files.
for entry in self.desktopEntries:
self.progressHook(f"desktop: {entry}")
if "exec" in entry and exe.lower() in entry["exec"].lower():
return entry
#else: #Foor loop ended. Did not find any matching desktop file

5
qtgui/quickopensessioncontroller.py

@ -136,8 +136,9 @@ class StarterClientItem(QtWidgets.QListWidgetItem):
p.drawPixmap(2, 2, overlayPixmap) #top left corner of icon, with some padding for the shadow
p.end()
ico = QtGui.QIcon(pixmap)
else:
ico = self.parentController.mainWindow.programIcons[self.argodejoExec]
else:
assert self.argodejoExec in self.parentController.mainWindow.programIcons, self.argodejoExec #because we created missing icons ourselves
ico = self.parentController.mainWindow.programIcons[self.argodejoExec]
self.setIcon(ico)

Loading…
Cancel
Save