Browse Source

More robust desktop discovery

master
Nils 4 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", "luppp", "non-mixer", "non-timeline", "non-sequencer", "non-midi-mapper", "non-mixer-noui",
"OPNplug", "qmidiarp", "qtractor", "zynaddsubfx", "jack_mixer", "OPNplug", "qmidiarp", "qtractor", "zynaddsubfx", "jack_mixer",
"hydrogen", "mfp", "shuriken", "laborejo", "guitarix", "radium", "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. ) #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.userWhitelist = () #added dynamically to morePrograms. highest priority
self.userBlacklist = () #added dynamically to blacklist. 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. 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 "zynaddsubfx": "zynaddsubfx-jack.desktop", #value will later get replaced with the .desktop entry
"carla-jack-multi" : "carla.desktop", "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.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. 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. #.build needs to be called from the api/GUI.
@ -146,10 +152,10 @@ class SupportedProgramsDatabase(object):
try: try:
config.read(f) config.read(f)
entryDict = dict(config._sections["Desktop Entry"]) entryDict = dict(config._sections["Desktop Entry"])
if f.name == "zynaddsubfx-jack.desktop": #Replace simple names in our shortcut list with full data
self.knownDesktopFiles["zynaddsubfx"] = entryDict if f.name in self.knownDesktopFiles.values():
elif f.name == "carla.desktop": key = self._reverseKnownDesktopFiles[f.name]
self.knownDesktopFiles["carla-jack-multi"] = entryDict self.knownDesktopFiles[key] = entryDict
#in any case: #in any case:
allDesktopEntries.append(entryDict) #_sections 'DesktopEntry':{dictOfActualData) allDesktopEntries.append(entryDict) #_sections 'DesktopEntry':{dictOfActualData)
except: #any bad config means skip except: #any bad config means skip
@ -184,10 +190,12 @@ class SupportedProgramsDatabase(object):
def _exeToDesktopEntry(self, exe:str)->dict: def _exeToDesktopEntry(self, exe:str)->dict:
"""Assumes self.desktopEntries is up to date """Assumes self.desktopEntries is up to date
Convert one exe (not full path!) to one dict entry. """ 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] entry = self.knownDesktopFiles[exe]
return entry
else: #Reverse Search desktop files. else: #Reverse Search desktop files.
for entry in self.desktopEntries: for entry in self.desktopEntries:
self.progressHook(f"desktop: {entry}")
if "exec" in entry and exe.lower() in entry["exec"].lower(): if "exec" in entry and exe.lower() in entry["exec"].lower():
return entry return entry
#else: #Foor loop ended. Did not find any matching desktop file #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.drawPixmap(2, 2, overlayPixmap) #top left corner of icon, with some padding for the shadow
p.end() p.end()
ico = QtGui.QIcon(pixmap) ico = QtGui.QIcon(pixmap)
else: else:
ico = self.parentController.mainWindow.programIcons[self.argodejoExec] 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) self.setIcon(ico)

Loading…
Cancel
Save