Proper behaviour on configuration window close
This commit is contained in:
parent
965b7109a2
commit
a92d307486
@ -527,9 +527,10 @@ class SyncplayClientManager(object):
|
|||||||
|
|
||||||
from syncplay import ui
|
from syncplay import ui
|
||||||
from syncplay.ConfigurationGetter import ConfigurationGetter
|
from syncplay.ConfigurationGetter import ConfigurationGetter
|
||||||
|
from syncplay.ConfigurationGetter import InvalidConfigValue
|
||||||
from syncplay.ui.GuiConfiguration import GuiConfiguration
|
from syncplay.ui.GuiConfiguration import GuiConfiguration
|
||||||
|
import sys
|
||||||
|
|
||||||
class SyncplayClient(object):
|
class SyncplayClient(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._prepareArguments()
|
self._prepareArguments()
|
||||||
@ -540,9 +541,11 @@ class SyncplayClient(object):
|
|||||||
try:
|
try:
|
||||||
self._promptForMissingArguments()
|
self._promptForMissingArguments()
|
||||||
self.argsGetter.saveValuesIntoConfigFile()
|
self.argsGetter.saveValuesIntoConfigFile()
|
||||||
except:
|
except InvalidConfigValue:
|
||||||
self._checkAndSaveConfiguration()
|
self._checkAndSaveConfiguration()
|
||||||
|
except GuiConfiguration.WindowClosed:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def _prepareArguments(self):
|
def _prepareArguments(self):
|
||||||
self.argsGetter = ConfigurationGetter()
|
self.argsGetter = ConfigurationGetter()
|
||||||
self.args = self.argsGetter.getConfiguration()
|
self.args = self.argsGetter.getConfiguration()
|
||||||
|
|||||||
@ -8,10 +8,11 @@ import cairo, gio, pango, atk, pangocairo, gobject #@UnusedImport
|
|||||||
class GuiConfiguration:
|
class GuiConfiguration:
|
||||||
def __init__(self, args, force = False):
|
def __init__(self, args, force = False):
|
||||||
self.args = args
|
self.args = args
|
||||||
|
self.closedAndNotSaved = False
|
||||||
if(args.host == None or args.name == None or force):
|
if(args.host == None or args.name == None or force):
|
||||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||||
self.window.set_title("Syncplay Configuration")
|
self.window.set_title("Syncplay Configuration")
|
||||||
self.window.connect("delete_event", lambda w, e: gtk.main_quit())
|
self.window.connect("delete_event", lambda w, e: self._windowClosed())
|
||||||
vbox = gtk.VBox(False, 0)
|
vbox = gtk.VBox(False, 0)
|
||||||
self.window.add(vbox)
|
self.window.add(vbox)
|
||||||
vbox.show()
|
vbox.show()
|
||||||
@ -26,6 +27,11 @@ class GuiConfiguration:
|
|||||||
button.show()
|
button.show()
|
||||||
self.window.show()
|
self.window.show()
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
||||||
|
def _windowClosed(self):
|
||||||
|
self.window.destroy()
|
||||||
|
gtk.main_quit()
|
||||||
|
self.closedAndNotSaved = True
|
||||||
|
|
||||||
def _addLabeledEntries(self, args, vbox):
|
def _addLabeledEntries(self, args, vbox):
|
||||||
self.hostEntry = self._addLabeledEntryToVbox('Host: ', args.host, vbox, self._focusNext)
|
self.hostEntry = self._addLabeledEntryToVbox('Host: ', args.host, vbox, self._focusNext)
|
||||||
@ -34,6 +40,8 @@ class GuiConfiguration:
|
|||||||
self.passEntry = self._addLabeledEntryToVbox('Server password (optional): ', args.password, vbox, self._focusNext)
|
self.passEntry = self._addLabeledEntryToVbox('Server password (optional): ', args.password, vbox, self._focusNext)
|
||||||
|
|
||||||
def getProcessedConfiguration(self):
|
def getProcessedConfiguration(self):
|
||||||
|
if(self.closedAndNotSaved):
|
||||||
|
raise self.WindowClosed
|
||||||
return self.args
|
return self.args
|
||||||
|
|
||||||
def _saveDataAndLeave(self):
|
def _saveDataAndLeave(self):
|
||||||
@ -70,6 +78,10 @@ class GuiConfiguration:
|
|||||||
hbox.show()
|
hbox.show()
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
class WindowClosed(Exception):
|
||||||
|
def __init__(self):
|
||||||
|
Exception.__init__(self)
|
||||||
|
|
||||||
class GuiConfigurationForMPC(GuiConfiguration):
|
class GuiConfigurationForMPC(GuiConfiguration):
|
||||||
def __init__(self, args, force = False):
|
def __init__(self, args, force = False):
|
||||||
force = (args.mpc_path == None) or force
|
force = (args.mpc_path == None) or force
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user