_, intres, extres, mode, extprim = result
intres = Resolution.fromDatabase(intres) # this method is safe for NULLs
extres = Resolution.fromDatabase(extres)
- mode = RelativeScreenPosition(mode)
+ mode = RelativeScreenPosition(mode) if mode else None
extprim = bool(extprim) # 0 => False, 1 => True
return ScreenSetup(intres, extres, mode, extprim)
def __exit__(self, type, value, tb):
self.intEnabled.setChecked(last.intResolution is not None)
self.extEnabled.setChecked(last.extResolution is not None)
if last.relPosition:
- print("YO:",last.relPosition.value-1)
self.relPos.setCurrentIndex(last.relPosition.value-1)
# make sure we are in a correct state
return self.userChoose("Select resolution for %s"%displayname, modedescs, availablemodes, None)
def setup (self, situation):
+ if situation.lastSetup:
+ applyLast = self.userChoose("This display is known. The last setup for it was like this:\n%s.\nApply the last used configuration?" % str(situation.lastSetup), ("Apply last setup", "Enter different setup"), (True,False), None)
+ if applyLast is None:
+ return None
+ if applyLast is True:
+ return situation.lastSetup
+ assert applyLast is False
operationmodes = list(OperationMode)
operationmodedescs = list(map(lambda x: x.text, operationmodes))
operationmode = self.userChoose ("Display setup", operationmodedescs, operationmodes, None)
cls = self.__class__
self._value_ = len(cls.__members__) + 1
self.text = text
+ def __str__(self):
+ return self.text
class Resolution:
'''Represents a resolution of a screen'''
RelativeScreenPosition.MIRROR: '--same-as',
}[self.relPosition], intName]
return args
+
+ def __str__(self):
+ if self.intResolution is None:
+ return "External display only, at "+str(self.extResolution)
+ if self.extResolution is None:
+ return "Internal display only, at "+str(self.intResolution)
+ return "External display %s at %s %s internal display %s at %s" % ("(primary)" if self.extIsPrimary else "", str(self.extResolution), str(self.relPosition), "" if self.extIsPrimary else "(primary)", str(self.intResolution))
class Connector:
def __init__(self, name=None):
def userChoose (self, title, choices, returns, fallback):
assert len(choices) == len(returns)
- args = ["zenity", "--list", "--text="+title, "--column="]+choices
+ args = ["zenity", "--list", "--text="+title, "--column="]+list(choices)
switch = dict (list(zip (choices,returns)))
try:
for line in processOutputIt(*args):