Skip to content

Commit

Permalink
Shut down gui on service upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
lack committed Feb 20, 2020
1 parent 1eb8870 commit 110039c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions soundcraft/gui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .dbus import Client, DbusInitializationError
from .dbus import Client, DbusInitializationError, VersionIncompatibilityError
import sys
import traceback
import gi
@@ -23,12 +23,25 @@ def __init__(self):
traceback.print_exc()
self._startupFailure(f"Unexpected exception {e.__class__.__name__}", str(e))
raise e
self.dbus.serviceDisconnected.connect(self.dbusDisconnect)
self.dbus.serviceConnected.connect(self.dbusReconnect)

def _startupFailure(self, title, message):
dialog = Gtk.MessageDialog(parent=self, message_type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK, text=title)
dialog.format_secondary_text(message)
dialog.run()

def dbusDisconnect(self):
self.setNoDevice()

def dbusReconnect(self):
try:
self.dbus.ensureServiceVersion()
except VersionIncompatibilityError as e:
self._startupFailure("Dbus service version incompatibility", "Restart of this gui application is required")
Gtk.main_quit()
# Todo: Can we relaunch ourselves?

def setDevice(self, dev):
if self.dev is not None:
if self.dev._path == dev._path:
@@ -57,6 +70,7 @@ def setDevice(self, dev):
self.show_all()

def setNoDevice(self):
self.dev = None
if self.grid is not None:
self.remove(self.grid)
self.grid = Gtk.Grid()
@@ -75,7 +89,6 @@ def deviceRemoved(self, path):
if self.dev._path != path:
# Not our device
return
self.dev = None
self.setNoDevice()

def addHeading(self, text):

0 comments on commit 110039c

Please sign in to comment.