Use wine paths by default even if non-existent
[carla.git] / source / frontend / carla_frontend.py
blobf741a1a6ae77435d3caf3104ca73c32f600713ee
1 #!/usr/bin/env python3
2 # SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # ------------------------------------------------------------------------------------------------------------
6 # Imports (Global)
8 # ------------------------------------------------------------------------------------------------------------
9 # Imports (ctypes)
11 from ctypes import (
12 c_bool, c_char, c_char_p, c_int, c_uint, c_uint64, c_void_p, cast,
13 cdll, Structure,
14 POINTER
17 try:
18 from sip import unwrapinstance
19 except ImportError:
20 def unwrapinstance(_):
21 return None
23 # ------------------------------------------------------------------------------------------------------------
24 # Imports (Custom)
26 from carla_backend import (
27 structToDict
30 # ---------------------------------------------------------------------------------------------------------------------
31 # Convert a ctypes struct into a python dict, or None if null
33 def structToDictOrNull(struct):
34 return structToDict(struct.contents) if struct else None
36 # ------------------------------------------------------------------------------------------------------------
37 # Carla Frontend API (C stuff)
39 class JackApplicationDialogResults(Structure):
40 _fields_ = [
41 ("command", c_char_p),
42 ("name", c_char_p),
43 ("labelSetup", c_char_p)
46 class HostSettings(Structure):
47 _fields_ = [
48 ("showPluginBridges", c_bool),
49 ("showWineBridges", c_bool),
50 ("useSystemIcons", c_bool),
51 ("wineAutoPrefix", c_bool),
52 ("wineExecutable", c_char_p),
53 ("wineFallbackPrefix", c_char_p),
56 class PluginListDialogResults(Structure):
57 _fields_ = [
58 ("build", c_uint),
59 ("type", c_uint),
60 ("hints", c_uint),
61 ("category", c_char_p),
62 ("filename", c_char_p),
63 ("name", c_char_p),
64 ("label", c_char_p),
65 ("maker", c_char_p),
66 ("uniqueId", c_uint64),
67 ("audioIns", c_uint),
68 ("audioOuts", c_uint),
69 ("cvIns", c_uint),
70 ("cvOuts", c_uint),
71 ("midiIns", c_uint),
72 ("midiOuts", c_uint),
73 ("parametersIns", c_uint),
74 ("parametersOuts", c_uint),
77 # ------------------------------------------------------------------------------------------------------------
78 # Carla Frontend object using a DLL
80 class CarlaFrontendLib():
81 def __init__(self, filename):
82 self.lib = cdll.LoadLibrary(filename)
84 self.lib.carla_frontend_createAndExecJackAppDialog.argtypes = (c_void_p, c_char_p)
85 self.lib.carla_frontend_createAndExecJackAppDialog.restype = POINTER(JackApplicationDialogResults)
87 self.lib.carla_frontend_createPluginListDialog.argtypes = (c_void_p, POINTER(HostSettings))
88 self.lib.carla_frontend_createPluginListDialog.restype = c_void_p
90 self.lib.carla_frontend_destroyPluginListDialog.argtypes = (c_void_p,)
91 self.lib.carla_frontend_destroyPluginListDialog.restype = None
93 self.lib.carla_frontend_setPluginListDialogPath.argtypes = (c_void_p, c_int, c_char_p)
94 self.lib.carla_frontend_setPluginListDialogPath.restype = None
96 self.lib.carla_frontend_execPluginListDialog.argtypes = (c_void_p,)
97 self.lib.carla_frontend_execPluginListDialog.restype = POINTER(PluginListDialogResults)
99 # --------------------------------------------------------------------------------------------------------
101 def createAndExecJackAppDialog(self, parent, projectFilename):
102 return structToDictOrNull(self.lib.carla_frontend_createAndExecJackAppDialog(unwrapinstance(parent),
103 projectFilename.encode("utf-8")))
105 def createPluginListDialog(self, parent, hostSettings):
106 hostSettingsC = HostSettings()
107 hostSettingsC.showPluginBridges = hostSettings['showPluginBridges']
108 hostSettingsC.showWineBridges = hostSettings['showWineBridges']
109 hostSettingsC.useSystemIcons = hostSettings['useSystemIcons']
110 hostSettingsC.wineAutoPrefix = hostSettings['wineAutoPrefix']
111 hostSettingsC.wineExecutable = hostSettings['wineExecutable'].encode("utf-8")
112 hostSettingsC.wineFallbackPrefix = hostSettings['wineFallbackPrefix'].encode("utf-8")
113 return self.lib.carla_frontend_createPluginListDialog(unwrapinstance(parent), hostSettingsC)
115 def destroyPluginListDialog(self, dialog):
116 self.lib.carla_frontend_destroyPluginListDialog(dialog)
118 def setPluginListDialogPath(self, dialog, ptype, path):
119 self.lib.carla_frontend_setPluginListDialogPath(dialog, ptype, path.encode("utf-8"))
121 def execPluginListDialog(self, dialog):
122 return structToDictOrNull(self.lib.carla_frontend_execPluginListDialog(dialog))
124 # ------------------------------------------------------------------------------------------------------------