let the GUI module directly return a ScreenSetup instance
authorRalf Jung <post@ralfj.de>
Sun, 7 Oct 2012 13:41:08 +0000 (15:41 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 7 Oct 2012 13:41:08 +0000 (15:41 +0200)
dsl.py
gui.py

diff --git a/dsl.py b/dsl.py
index f9c58fa641bb4969c081ded41256f93f2b0f104f..52bcd08bcccf9b8c89e3b7650509b098841a586b 100755 (executable)
--- a/dsl.py
+++ b/dsl.py
@@ -46,7 +46,7 @@ class ScreenSetup:
                return args
        
        def getExternalArgs(self, intName):
                return args
        
        def getExternalArgs(self, intName):
-               args = ["--mode", res2xrandr(self.extResolution)]
+               args = ["--mode", res2xrandr(self.extResolution)] # set external screen to desired resolution
                if self.extIsPrimary:
                        args.append('--primary')
                if self.relPosition == RelativeScreenPosition.LEFT:
                if self.extIsPrimary:
                        args.append('--primary')
                if self.relPosition == RelativeScreenPosition.LEFT:
@@ -187,8 +187,7 @@ if __name__ == "__main__":
                usedExternalConnector = findAvailableConnector(externalConnectors, connectors) # *the* external connector which is actually used
                if usedExternalConnector is not None: # there's an external screen connected, we need to ask what to do
                        # get setup
                usedExternalConnector = findAvailableConnector(externalConnectors, connectors) # *the* external connector which is actually used
                if usedExternalConnector is not None: # there's an external screen connected, we need to ask what to do
                        # get setup
-                       dialogue = gui.getDialogue(connectors[internalConnector], connectors[usedExternalConnector])
-                       setup = dialogue.run()
+                       setup = gui.setup(connectors[internalConnector], connectors[usedExternalConnector])
                        if setup is None: sys.exit(1) # the user canceled
                        # apply it
                        connectorArgs[internalConnector] = setup.getInternalArgs()
                        if setup is None: sys.exit(1) # the user canceled
                        # apply it
                        connectorArgs[internalConnector] = setup.getInternalArgs()
diff --git a/gui.py b/gui.py
index 84e0da39943cb1bd4f865b89d587208eedf9f4b3..2e5d47673f05397e46788dcf2c67d7869f7a5a61 100644 (file)
--- a/gui.py
+++ b/gui.py
@@ -25,6 +25,6 @@ def error(message):
        '''Displays a fatal error to the user'''
        QtGui.QMessageBox.critical(None, 'Fatal error', message)
 
        '''Displays a fatal error to the user'''
        QtGui.QMessageBox.critical(None, 'Fatal error', message)
 
-def getDialogue(internalResolutions, externalResolutions):
-       '''Returns a class implementing a function run() which returns a ScreenSetup instance, or None if the user canceled'''
-       return PositionSelection(internalResolutions, externalResolutions)
+def setup(internalResolutions, externalResolutions):
+       '''Returns a ScreenSetup instance, or None if the user canceled'''
+       return PositionSelection(internalResolutions, externalResolutions).run()