1 from Screens.Screen import Screen
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger, ConfigSlider
4 from Components.ActionMap import ActionMap
5 from Screens.MessageBox import MessageBox
6 from Components.Sources.StaticText import StaticText
7 from Plugins.Plugin import PluginDescriptor
8 from Tools.Directories import fileExists
9 from enigma import eTimer
10 from Plugins.Plugin import PluginDescriptor
12 config.plugins.UIPositionSetup = ConfigSubsection()
13 config.plugins.UIPositionSetup.dst_left = ConfigInteger(default = 0)
14 config.plugins.UIPositionSetup.dst_width = ConfigInteger(default = 720)
15 config.plugins.UIPositionSetup.dst_top = ConfigInteger(default = 0)
16 config.plugins.UIPositionSetup.dst_height = ConfigInteger(default = 576)
18 class UIPositionSetupInit:
20 self.setPosition(int(config.plugins.UIPositionSetup.dst_left.value), int(config.plugins.UIPositionSetup.dst_width.value), int(config.plugins.UIPositionSetup.dst_top.value), int(config.plugins.UIPositionSetup.dst_height.value))
22 def setPosition(self,dst_left, dst_width, dst_top, dst_height):
23 if dst_left + dst_width > 720 or dst_top + dst_height > 576 :
26 print "[UIPositionSetup] write dst_left : ",dst_left
27 print "[UIPositionSetup] write dst_width : ",dst_width
28 print "[UIPositionSetup] write dst_top : ",dst_top
29 print "[UIPositionSetup] write dst_height : ",dst_height
31 file = open("/proc/stb/fb/dst_left", "w")
32 file.write('%X' % dst_left)
34 file = open("/proc/stb/fb/dst_width", "w")
35 file.write('%X' % dst_width)
37 file = open("/proc/stb/fb/dst_top", "w")
38 file.write('%X' % dst_top)
40 file = open("/proc/stb/fb/dst_height", "w")
41 file.write('%X' % dst_height)
46 uipositionsetupinit = UIPositionSetupInit()
48 class UIPositionSetup(Screen, ConfigListScreen, UIPositionSetupInit):
50 <screen position="0,0" size="%d,%d" title="Screen Position Setup" backgroundColor="#27d8dee2" >
51 <ePixmap pixmap="skin_default/buttons/red.png" position="%d,%d" size="140,40" alphatest="on" />
52 <ePixmap pixmap="skin_default/buttons/green.png" position="%d,%d" size="140,40" alphatest="on" />"
54 <widget source="key_red" render="Label" position="%d,%d" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
55 <widget source="key_green" render="Label" position="%d,%d" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
57 <widget name="config" zPosition="2" position="%d,%d" size="500,200" scrollbarMode="showOnDemand" foregroundColor="#1c1c1c" transparent="1" />
60 def __init__(self,session):
61 w,h = session.desktop.size().width(), session.desktop.size().height()
63 # btn_red btn_green lb_red lb_green config
64 self.skin = self.skin % (w,h, cw-190,ch-110, cw+50,ch-110, cw-190,ch-110, cw+50,ch-110, cw-250,ch-50)
66 Screen.__init__(self,session)
67 self.session = session
68 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
71 "cancel": self.keyCancel,
72 "red": self.keyCancel,
76 ConfigListScreen.__init__(self, self.list,session = self.session)
78 self["key_red"] = StaticText(_("Cancel"))
79 self["key_green"] = StaticText(_("Save"))
80 self["current"] = StaticText(_(" "))
83 def createSetup(self):
86 left = config.plugins.UIPositionSetup.dst_left.value
87 width = config.plugins.UIPositionSetup.dst_width.value
88 top = config.plugins.UIPositionSetup.dst_top.value
89 height = config.plugins.UIPositionSetup.dst_height.value
91 self.dst_left = ConfigSlider(default = left, increment = 5, limits = (0, 720))
92 self.dst_width = ConfigSlider(default = width, increment = 5, limits = (0, 720))
93 self.dst_top = ConfigSlider(default = top, increment = 5, limits = (0, 576))
94 self.dst_height = ConfigSlider(default = height, increment = 5, limits = (0, 576))
96 self.dst_left_entry = getConfigListEntry(_("left"), self.dst_left)
97 self.dst_width_entry = getConfigListEntry(_("width"), self.dst_width)
98 self.dst_top_entry = getConfigListEntry(_("top"), self.dst_top)
99 self.dst_height_entry = getConfigListEntry(_("height"), self.dst_height)
101 self.list.append(self.dst_left_entry)
102 self.list.append(self.dst_width_entry)
103 self.list.append(self.dst_top_entry)
104 self.list.append(self.dst_height_entry)
106 self["config"].list = self.list
107 self["config"].l.setList(self.list)
109 def resetDisplay(self):
110 for entry in self["config"].getList():
111 self["config"].l.invalidateEntry(self["config"].getList().index(entry))
113 def adjustBorder(self):
114 if self["config"].getCurrent() == self.dst_left_entry:
115 if self.dst_left.value + self.dst_width.value >720:
116 self.dst_width.setValue(720-self.dst_left.value)
118 elif self["config"].getCurrent() == self.dst_width_entry:
119 if self.dst_left.value + self.dst_width.value >720:
120 self.dst_left.setValue(720-self.dst_width.value)
122 elif self["config"].getCurrent() == self.dst_top_entry:
123 if self.dst_top.value + self.dst_height.value >576:
124 self.dst_height.setValue(576-self.dst_top.value)
126 elif self["config"].getCurrent() == self.dst_height_entry:
127 if self.dst_top.value + self.dst_height.value >576:
128 self.dst_top.setValue(576-self.dst_height.value)
132 ConfigListScreen.keyLeft(self)
134 self.setPosition(int(self.dst_left.value), int(self.dst_width.value), int(self.dst_top.value), int(self.dst_height.value))
137 ConfigListScreen.keyRight(self)
139 self.setPosition(int(self.dst_left.value), int(self.dst_width.value), int(self.dst_top.value), int(self.dst_height.value))
142 config.plugins.UIPositionSetup.dst_left.value = self.dst_left.value
143 config.plugins.UIPositionSetup.dst_width.value = self.dst_width.value
144 config.plugins.UIPositionSetup.dst_top.value = self.dst_top.value
145 config.plugins.UIPositionSetup.dst_height.value = self.dst_height.value
146 config.plugins.UIPositionSetup.save()
150 if self["config"].isChanged():
151 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
155 def cancelConfirm(self,ret):
157 self.setPosition(int(config.plugins.UIPositionSetup.dst_left.value), int(config.plugins.UIPositionSetup.dst_width.value), int(config.plugins.UIPositionSetup.dst_top.value), int(config.plugins.UIPositionSetup.dst_height.value))
160 def main(session, **kwargs):
161 session.open(UIPositionSetup)
163 def Plugins(**kwargs):
164 if fileExists("/proc/stb/fb/dst_left"):
165 return [PluginDescriptor(name = "UI position setup", description = "Adjust screen position", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main)]