diff --git a/NetworkPrinterOutputDevicePlugin.py b/NetworkPrinterOutputDevicePlugin.py index ec367d96d9..9e8a43b187 100644 --- a/NetworkPrinterOutputDevicePlugin.py +++ b/NetworkPrinterOutputDevicePlugin.py @@ -18,7 +18,7 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter): # Because the model needs to be created in the same thread as the QMLEngine, we use a signal. self.addPrinterSignal.connect(self.addPrinter) - Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onActiveMachineInstanceChanged) + Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged) addPrinterSignal = Signal() @@ -30,12 +30,13 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter): def stop(self): self._zero_conf.close() - def _onActiveMachineInstanceChanged(self): + def _onGlobalContainerStackChanged(self): try: - active_machine_key = Application.getInstance().getMachineManager().getActiveMachineInstance().getKey() + active_machine_key = Application.getInstance().getGlobalContainerStack().getId() except AttributeError: ## Active machine instance changed to None. This can happen upon clean start. Simply ignore. return + for key in self._printers: if key == active_machine_key: self._printers[key].connect() @@ -47,8 +48,8 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter): def addPrinter(self, name, address, properties): printer = NetworkPrinterOutputDevice.NetworkPrinterOutputDevice(name, address, properties) self._printers[printer.getKey()] = printer - active_machine_instance = Application.getInstance().getMachineManager().getActiveMachineInstance() - if active_machine_instance and printer.getKey() == active_machine_instance.getKey(): + stack = Application.getInstance().getGlobalContainerStack() + if stack and printer.getKey() == stack.getKey(): self._printers[printer.getKey()].connect() printer.connectionStateChanged.connect(self._onPrinterConnectionStateChanged) @@ -71,4 +72,4 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter): elif state_change == ServiceStateChange.Removed: pass # TODO; This isn't testable right now. We need to also decide how to handle - # \ No newline at end of file + # diff --git a/__init__.py b/__init__.py index b5aaa03513..76d4094709 100644 --- a/__init__.py +++ b/__init__.py @@ -11,7 +11,7 @@ def getMetaData(): "name": "Wifi connection", "author": "Ultimaker", "description": catalog.i18nc("Wifi connection", "Wifi connection"), - "api": 2 + "api": 3 } }