示例#1
0
    def setMode(self, port, mode, rate, force = None):
        print '[VideoMode] setMode - port: %s, mode: %s, rate: %s' % (port, mode, rate)
        self.current_mode = mode
        self.current_port = port
        modes = self.rates[mode][rate]
        mode_50 = modes.get(50)
        mode_60 = modes.get(60)
        if mode_50 is None or force == 60:
            mode_50 = mode_60
        if mode_60 is None or force == 50:
            mode_60 = mode_50
        try:
            f = open('/proc/stb/video/videomode_50hz', 'w')
            f.write(mode_50)
            f.close()
            f = open('/proc/stb/video/videomode_60hz', 'w')
            f.write(mode_60)
            f.close()
        except IOError:
            try:
                f = open('/proc/stb/video/videomode', 'w')
                f.write(mode_50)
                f.close()
            except IOError:
                print '[AVSwitch] setting videomode failed.'

        map = {'cvbs': 0,
         'rgb': 1,
         'svideo': 2,
         'yuv': 3}
        self.setColorFormat(map[config.av.colorformat.value])
        if about.getCPUString().startswith('STx'):
            from enigma import gMainDC
            gMainDC.getInstance().setResolution(-1, -1)
        return
示例#2
0
	def ResolutionSelect(self, Resolution):
		if not Resolution is None:
			if isinstance(Resolution[1], str):
				open("/proc/stb/video/videomode", "w").write(Resolution[1])
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(-1, -1)
		return
示例#3
0
	def _cb_stop_browser(self):
		self._close_timer.stop()

		try:
			if self._cb_set_title in vbcfg.g_main.vbhandler.onSetTitleCB:
				vbcfg.g_main.vbhandler.onSetTitleCB.remove(self._cb_set_title)
		except Exception:
			pass

		try:
			if self._cb_close_window in vbcfg.g_main.vbhandler.onCloseCB:
				vbcfg.g_main.vbhandler.onCloseCB.remove(self._cb_close_window)
		except Exception:
			pass

		self.toggle_top()

		from enigma import gMainDC
		gMainDC.getInstance().setResolution(self.WIDTH, self.HEIGHT)
		vbcfg.setPosition(vbcfg.g_position)

		fbClass.getInstance().unlock()
		eRCInput.getInstance().unlock()
		getDesktop(0).paint()
		self.is_browser_opened = False

		vbcfg.LOG("Stop Browser")
		self.setTitle(_("BrowserMain"))
		if self.m_url is not None:
			self.keyCancel()
			if vbcfg.g_service:
				self.session.nav.playService(vbcfg.g_service)
		else:
			self.keyRight()
			self.keyLeft()
	def setMode(self, port, mode, rate, force = None):
		print "[VideoHardware] setMode - port:", port, "mode:", mode, "rate:", rate
		# we can ignore "port"
		self.current_mode = mode
		self.current_port = port
		modes = self.rates[mode][rate]

		mode_50 = modes.get(50)
		mode_60 = modes.get(60)
		if mode_50 is None or force == 60:
			mode_50 = mode_60
		if mode_60 is None or force == 50:
			mode_60 = mode_50

		try:
			open("/proc/stb/video/videomode_50hz", "w").write(mode_50)
			open("/proc/stb/video/videomode_60hz", "w").write(mode_60)
		except IOError:
			try:
				# fallback if no possibility to setup 50/60 hz mode
				open("/proc/stb/video/videomode", "w").write(mode_50)
			except IOError:
				print "[VideoHardware] setting videomode failed."

		try:
			open("/etc/videomode", "w").write(mode_50) # use 50Hz mode (if available) for booting
		except IOError:
			print "[VideoHardware] writing initial videomode to /etc/videomode failed."

		#call setResolution() with -1,-1 to read the new scrren dimesions without changing the framebuffer resolution
		from enigma import gMainDC
		gMainDC.getInstance().setResolution(-1, -1)

		self.updateAspect(None)
		self.updateColor(port)
示例#5
0
文件: ui.py 项目: BlackHole/enigma2-1
	def Exit(self):
		del self.picload

		if config.usage.pic_resolution.value and (self.size_w, self.size_h) != eval(config.usage.pic_resolution.value):
			gMainDC.getInstance().setResolution(self.size_w, self.size_h)
			getDesktop(0).resize(eSize(self.size_w, self.size_h))

		self.close(self.lastindex + self.dirlistcount)
示例#6
0
    def setMode(self, port, mode, rate, force=None):
        print "[VideoMode] setMode - port: %s, mode: %s, rate: %s" % (port, mode, rate)

        # config.av.videoport.setValue(port)
        # we can ignore "port"
        self.current_mode = mode
        self.current_port = port
        modes = self.rates[mode][rate]

        mode_50 = modes.get(50)
        mode_60 = modes.get(60)
        if mode_50 is None or force == 60:
            mode_50 = mode_60
        if mode_60 is None or force == 50:
            mode_60 = mode_50

        mode_etc = None
        if os.path.exists("/proc/stb/video/videomode_50hz") and getBoxType() not in ("gb800solo", "gb800se", "gb800ue"):
            try:
                f = open("/proc/stb/video/videomode_50hz", "w")
                f.write(mode_50)
                f.close()
            except IOError:
                print "setting videomode_50hz failed."

        if os.path.exists("/proc/stb/video/videomode_60hz") and getBoxType() not in ("gb800solo", "gb800se", "gb800ue"):
            try:
                f = open("/proc/stb/video/videomode_60hz", "w")
                f.write(mode_60)
                f.close()
            except IOError:
                print "setting videomode failed."
        try:
            mode_etc = modes.get(int(rate[:2]))
            f = open("/proc/stb/video/videomode", "w")
            f.write(mode_etc)
            f.close()
        except:  # not support 50Hz, 60Hz for 1080p
            try:
                # fallback if no possibility to setup 50/60 hz mode
                f = open("/proc/stb/video/videomode", "w")
                f.write(mode_50)
                f.close()
            except IOError:
                print "setting videomode failed."

        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        self.setColorFormat(map[config.av.colorformat.value])

        if about.getCPUString().startswith("STx"):
            # call setResolution() with -1,-1 to read the new scrren dimensions without changing the framebuffer resolution
            from enigma import gMainDC

            gMainDC.getInstance().setResolution(-1, -1)
示例#7
0
	def setMode(self, port, mode, rate, force=None):
		# config.av.videoport.setValue(port)
		# we can ignore "port"
		self.current_mode = mode
		self.current_port = port
		modes = self.rates[mode][rate]

		mode_50 = modes.get(50)
		mode_60 = modes.get(60)
		if mode_50 is None or force == 60:
			mode_50 = mode_60
		if mode_60 is None or force == 50:
			mode_60 = mode_50

		if os.path.exists('/proc/stb/video/videomode_50hz') and getBoxType() not in ('gb800solo', 'gb800se', 'gb800ue'):
			try:
				f = open("/proc/stb/video/videomode_50hz", "w")
				f.write(mode_50)
				f.close()
			except:
				print "[AVSwitch] failed to set videomode_50hz to", mode_50

		if os.path.exists('/proc/stb/video/videomode_60hz') and getBoxType() not in ('gb800solo', 'gb800se', 'gb800ue'):
			try:
				f = open("/proc/stb/video/videomode_60hz", "w")
				f.write(mode_60)
				f.close()
			except:
				print "[AVSwitch] failed to set videomode_60hz to", mode_60

		try:
			if rate == "multi":
				mode_etc = mode_50
			else:
				mode_etc = modes.get(int(rate[:2]))
			f = open("/proc/stb/video/videomode", "w")
			f.write(mode_etc)
			f.close()
		except:  # not support 50Hz, 60Hz for 1080p
			try:
				# fallback if no possibility to setup 50/60 hz mode
				f = open("/proc/stb/video/videomode", "w")
				f.write(mode_50)
				f.close()
			except IOError as err:
				print "[AVSwitch] setting videomode failed:", err

		self.setColorFormat({"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}[config.av.colorformat.value])
		if about.getCPUString().startswith('STx'):
			#call setResolution() with -1,-1 to read the new scrren dimesions without changing the framebuffer resolution
			from enigma import gMainDC
			gMainDC.getInstance().setResolution(-1, -1)
示例#8
0
	def resolutionCheck(self, result):
		gMainDC.getInstance().setResolution(self.x, self.y)
		if not result:
			self.resetEHD()
		else:
			if BoxType in config.plugins.MyMetrixLiteOther.EHDtested.value and len(config.plugins.MyMetrixLiteOther.EHDtested.value.split('_|_')) == 2:
				config.plugins.MyMetrixLiteOther.EHDtested.value += config.plugins.MyMetrixLiteOther.EHDenabled.value
			else:
				config.plugins.MyMetrixLiteOther.EHDtested.value = BoxType + '_|_' + config.plugins.MyMetrixLiteOther.EHDenabled.value
			config.plugins.MyMetrixLiteOther.save()
			configfile.save()
			ActivateSkinSettings().initConfigs()
			self.checkEHDtested()
			self["config"].setList(self.getMenuItemList())
示例#9
0
 def resolutionTest(self, result):
     if not result:
         self.resetFHD()
         return
     gMainDC.getInstance().setResolution(1920, 1080)
     self.session.openWithCallback(
         self.resolutionCheck,
         MessageBox,
         _(
             "Can you see this, then is the receiver ready for FHD - skin.\n\nDo you want to change from HD to FHD - skin?"
         ),
         default=False,
         timeout=10,
     )
示例#10
0
	def setMode(self, port, mode, rate, force = None):
		print "[VideoMode] setMode - port: %s, mode: %s, rate: %s" % (port, mode, rate)

		# config.av.videoport.setValue(port)
		# we can ignore "port"
		self.current_mode = mode
		self.current_port = port
		modes = self.rates[mode][rate]


		mode_50 = modes.get(50)
		mode_60 = modes.get(60)
		if mode_50 is None or force == 60:
			mode_50 = mode_60
		if mode_60 is None or force == 50:
			mode_60 = mode_50

		try:
			f = open("/proc/stb/video/videomode_50hz", "w")
			f.write(mode_50)
			f.close()
			f = open("/proc/stb/video/videomode_60hz", "w")
			f.write(mode_60)
			f.close()
		except IOError:
			try:
				# fallback if no possibility to setup 50/60 hz mode
				f = open("/proc/stb/video/videomode", "w")
				f.write(mode_50)
				f.close()
			except IOError:
				print "[AVSwitch] setting videomode failed."

#		try:
#			# use 50Hz mode (if available) for booting
#			f = open("/etc/videomode", "w")
#			f.write(mode_50)
#			f.close()
#		except IOError:
#			print "[AVSwitch] writing initial videomode to /etc/videomode failed."

		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		self.setColorFormat(map[config.av.colorformat.value])

		if about.getCPUString().startswith('STx'):
			#call setResolution() with -1,-1 to read the new scrren dimensions without changing the framebuffer resolution
			from enigma import gMainDC
			gMainDC.getInstance().setResolution(-1, -1)
示例#11
0
文件: AVSwitch.py 项目: sodo13/EG-gui
    def setMode(self, port, mode, rate, force = None):
        print '[VideoMode] setMode - port: %s, mode: %s, rate: %s' % (port, mode, rate)
        self.current_mode = mode
        self.current_port = port
        modes = self.rates[mode][rate]
        mode_50 = modes.get(50)
        mode_60 = modes.get(60)
        if mode_50 is None or force == 60:
            mode_50 = mode_60
        if mode_60 is None or force == 50:
            mode_60 = mode_50
        mode_etc = None
        if os.path.exists('/proc/stb/video/videomode_50hz') and getBoxType() not in ('gb800solo', 'gb800se', 'gb800ue'):
            f = open('/proc/stb/video/videomode_50hz', 'w')
            f.write(mode_50)
            f.close()
        try:
            if os.path.exists('/proc/stb/video/videomode_60hz') and getBoxType() not in ('gb800solo', 'gb800se', 'gb800ue'):
                if getBrandOEM() not in 'ini':
                    f = open('/proc/stb/video/videomode_60hz', 'w')
                    f.write(mode_60)
                    f.close()
        except:
            print 'Problems with RW /proc/stb/video/videomode_60hz'

        try:
            mode_etc = modes.get(int(rate[:2]))
            f = open('/proc/stb/video/videomode', 'w')
            f.write(mode_etc)
            f.close()
        except:
            try:
                f = open('/proc/stb/video/videomode', 'w')
                f.write(mode_50)
                f.close()
            except IOError:
                print 'setting videomode failed.'

        map = {'cvbs': 0,
         'rgb': 1,
         'svideo': 2,
         'yuv': 3}
        self.setColorFormat(map[config.av.colorformat.value])
        if about.getCPUString().startswith('STx'):
            from enigma import gMainDC
            gMainDC.getInstance().setResolution(-1, -1)
示例#12
0
文件: skin.py 项目: st7TEAM/SWF-GUI
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for skininclude in skin.findall("include"):
		filename = skininclude.attrib.get("filename")
		if filename:
			skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
			if not fileExists(skinfile):
				skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
			print "[SKIN] loading include:", skinfile
			try:
				loadSkin(skinfile)
			except Exception, err:
				print "not loading user skin: ", err
示例#13
0
	def __init__(self, session):
		Screen.__init__(self, session)

		self.xres, self.yres = getDesktop(0).size().width(), getDesktop(0).size().height()

		if (self.xres, self.yres) != (1920, 1080):
			gMainDC.getInstance().setResolution(1920, 1080)
			getDesktop(0).resize(eSize(1920, 1080))

		self["actions"] = NumberActionMap(["InputActions", "OkCancelActions"],
		{
			"1": self.keyNumber,
			"2": self.keyNumber,
			"3": self.keyNumber,
			"4": self.keyNumber,
			"5": self.keyNumber,
			"ok": self.ok,
			"cancel": self.cancel
		})
示例#14
0
	def __init__(self, session, xres=1280, yres=720):
		Screen.__init__(self, session)

		self.xres, self.yres = getDesktop(0).size().width(), getDesktop(0).size().height()

		if (self.xres, self.yres) != (xres, yres):
			gMainDC.getInstance().setResolution(xres, yres)
			getDesktop(0).resize(eSize(xres, yres))
			self.onClose.append(self.__close)

		self["actions"] = NumberActionMap(["InputActions", "OkCancelActions"],
		{
			"1": self.keyNumber,
			"2": self.keyNumber,
			"3": self.keyNumber,
			"4": self.keyNumber,
			"5": self.keyNumber,
			"7": self.keyNumber,
			"ok": self.ok,
			"cancel": self.cancel
		})
示例#15
0
	def setMode(self, port, mode, rate, force = None):
		print "[VideoHardware] setMode - port: %s, mode: %s, rate: %s" % (port, mode, rate)

		# config.av.videoport.setValue(port)
		# we can ignore "port"
		self.current_mode = mode
		self.current_port = port
		modes = self.rates[mode][rate]

		mode_50 = modes.get(50)
		mode_60 = modes.get(60)
		if mode_50 is None or force == 60:
			mode_50 = mode_60
		if mode_60 is None or force == 50:
			mode_60 = mode_50

		if os.path.exists('/proc/stb/video/videomode_50hz') and getBoxType() not in ('gb800solo', 'gb800se', 'gb800ue'):
			f = open("/proc/stb/video/videomode_50hz", "w")
			f.write(mode_50)
			f.close()
		if os.path.exists('/proc/stb/video/videomode_60hz') and getBoxType() not in ('gb800solo', 'gb800se', 'gb800ue'):
			f = open("/proc/stb/video/videomode_60hz", "w")
			f.write(mode_60)
			f.close()
		try:
			set_mode = modes.get(int(rate[:2]))
		except: # not support 50Hz, 60Hz for 1080p
			set_mode = mode_50
		f = open("/proc/stb/video/videomode", "w")
		f.write(set_mode)
		f.close()
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		self.setColorFormat(map[config.av.colorformat.value])
		if about.getCPUString().startswith('STx'):
			#call setResolution() with -1,-1 to read the new scrren dimesions without changing the framebuffer resolution
			from enigma import gMainDC
			gMainDC.getInstance().setResolution(-1, -1)
示例#16
0
def loadSingleSkinData(desktop, skin, path_prefix):
    """loads skin data like colors, windowstyle etc."""
    assert skin.tag == "skin", "root element in skin must be 'skin'!"
    for c in skin.findall("output"):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:  # framebuffer
            for res in c.findall("resolution"):
                get_attr = res.attrib.get
                xres = get_attr("xres")
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr("yres")
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr("bpp")
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                #print "Resolution:", xres,yres,bpp
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    # load palette (not yet implemented)
                    pass

    for skininclude in skin.findall("include"):
        filename = skininclude.attrib.get("filename")
        if filename:
            skinfile = resolveFilename(SCOPE_ACTIVE_SKIN,
                                       filename,
                                       path_prefix=path_prefix)
            if not fileExists(skinfile):
                skinfile = resolveFilename(SCOPE_SKIN_IMAGE,
                                           filename,
                                           path_prefix=path_prefix)
            if fileExists(skinfile):
                print "[SKIN] loading include:", skinfile
                loadSkin(skinfile)
            else:
                print "[SKIN] Can not find include file:", filename
        else:
            print "[SKIN] include: need to specify 'filename=\"path\"' attribute"

    for c in skin.findall('switchpixmap'):
        for pixmap in c.findall('pixmap'):
            get_attr = pixmap.attrib.get
            name = get_attr('name')
            if not name:
                raise SkinError('pixmap needs name attribute')
            filename = get_attr('filename')
            if not filename:
                raise SkinError('pixmap needs filename attribute')
            resolved_png = resolveFilename(SCOPE_ACTIVE_SKIN,
                                           filename,
                                           path_prefix=path_prefix)
            if fileExists(resolved_png):
                switchPixmap[name] = resolved_png
            else:
                raise SkinError(
                    'switchpixmap pixmap filename="%s" (%s) not found' %
                    (filename, resolved_png))

    for c in skin.findall("colors"):
        for color in c.findall("color"):
            get_attr = color.attrib.get
            name = get_attr("name")
            if not name:
                raise SkinError('color needs name attribute')
            color = get_attr("value")
            if not color:
                raise SkinError('color needs value attribute')
            colorNames[name] = parseColor(color)

    for c in skin.findall("fonts"):
        for font in c.findall("font"):
            get_attr = font.attrib.get
            filename = get_attr("filename", "<NONAME>")
            name = get_attr("name", "Regular")
            scale = get_attr("scale")
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr("replacement") and True or False
            render = get_attr("render")
            if render:
                render = int(render)
            else:
                render = 0
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(
                    resolved_font
            ):  #when font is not available look at current skin path
                resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename)
                if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)):
                    resolved_font = resolveFilename(SCOPE_CURRENT_SKIN,
                                                    filename)
                elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN,
                                                filename)):
                    resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN,
                                                    filename)
            addFont(resolved_font, name, scale, is_replacement, render)
            #print "Font: ", resolved_font, name, scale, is_replacement
        for alias in c.findall("alias"):
            get = alias.attrib.get
            try:
                name = get("name")
                font = get("font")
                size = int(get("size"))
                height = int(get("height", size))  # to be calculated some day
                width = int(get("width", size))
                global fonts
                fonts[name] = (font, size, height, width)
            except Exception, ex:
                print "[SKIN] bad font alias", ex
示例#17
0
 def resolutionCheck(self, result):
     gMainDC.getInstance().setResolution(self.x, self.y)
     if not result:
         self.resetFHD()
     else:
         self.InstallCheck()
示例#18
0
文件: skin.py 项目: aitchala/enigma2
def loadSingleSkinData(desktop, skin, path_prefix):
    """loads skin data like colors, windowstyle etc."""
    assert skin.tag == "skin", "root element in skin must be 'skin'!"

    #print "***SKIN: ", path_prefix

    for c in skin.findall("output"):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:  # framebuffer
            for res in c.findall("resolution"):
                xres = int(res.get("xres", "720"))
                yres = int(res.get("yres", "576"))
                bpp = int(res.get("bpp", "32"))
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres, bpp)
                desktop.resize(eSize(xres, yres))
                break

    for c in skin.findall("colors"):
        for color in c.findall("color"):
            get_attr = color.attrib.get
            name = get_attr("name")
            color = get_attr("value")
            if name and color:
                colorNames[name] = parseColor(color)
                #print "Color:", name, color
            else:
                raise SkinError("need color and name, got %s %s" %
                                (name, color))

    for c in skin.findall("listboxcontent"):
        for offset in c.findall("offset"):
            get_attr = offset.attrib.get
            name = get_attr("name")
            value = get_attr("value")
            if name and value:
                if name == "left":
                    eListboxPythonStringContent.setLeftOffset(
                        parseValue(value))
                elif name == "right":
                    eListboxPythonStringContent.setRightOffset(
                        parseValue(value))
                else:
                    raise SkinError(
                        "got listboxcontent offset '%s'' but 'left' or 'right' is allowed only"
                        % name)
        for font in c.findall("font"):
            get_attr = font.attrib.get
            name = get_attr("name")
            font = get_attr("font")
            if name and font:
                if name == "string":
                    eListboxPythonStringContent.setFont(
                        parseFont(font, ((1, 1), (1, 1))))
                elif name == "config_description":
                    eListboxPythonConfigContent.setDescriptionFont(
                        parseFont(font, ((1, 1), (1, 1))))
                elif name == "config_value":
                    eListboxPythonConfigContent.setValueFont(
                        parseFont(font, ((1, 1), (1, 1))))
                else:
                    raise SkinError(
                        "got listboxcontent font '%s' but 'string', 'config_description' or 'config_value' is allowed only"
                        % name)
        for value in c.findall("value"):
            get_attr = value.attrib.get
            name = get_attr("name")
            value = get_attr("value")
            if name and value:
                if name == "string_item_height":
                    eListboxPythonStringContent.setItemHeight(
                        parseValue(value))
                elif name == "config_item_height":
                    eListboxPythonConfigContent.setItemHeight(
                        parseValue(value))
                else:
                    raise SkinError(
                        "got listboxcontent value '%s' but 'string_item_height' or 'config_item_height' is allowed only"
                        % name)

    for c in skin.findall("fonts"):
        for font in c.findall("font"):
            get_attr = font.attrib.get
            filename = get_attr("filename", "<NONAME>")
            name = get_attr("name", "Regular")
            scale = get_attr("scale")
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr("replacement") and True or False
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(
                    resolved_font
            ):  #when font is not available look at current skin path
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)
            #print "Font: ", resolved_font, name, scale, is_replacement

    for c in skin.findall("subtitles"):
        from enigma import eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall("sub"):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr("font"), scale)
            col = get_attr("foregroundColor")
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(0xFFFFFF)
                haveColor = 0
            col = get_attr("shadowColor")
            if col:
                shadowColor = parseColor(col)
            else:
                shadowColor = gRGB(0)
            shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
            face = eSubtitleWidget.__dict__[get_attr("name")]
            eSubtitleWidget.setFontStyle(face, font, haveColor,
                                         foregroundColor, shadowColor,
                                         shadowOffset)

    for windowstyle in skin.findall("windowstyle"):
        style = eWindowStyleSkinned()
        id = windowstyle.attrib.get("id")
        if id:
            id = int(id)
        else:
            id = 0
        #print "windowstyle:", id

        # defaults
        font = gFont("Regular", 20)
        offset = eSize(20, 5)

        for title in windowstyle.findall("title"):
            get_attr = title.attrib.get
            offset = parseSize(get_attr("offset"), ((1, 1), (1, 1)))
            font = parseFont(get_attr("font"), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        #print "  ", font, offset

        for borderset in windowstyle.findall("borderset"):
            bsName = str(borderset.attrib.get("name"))
            for pixmap in borderset.findall("pixmap"):
                get_attr = pixmap.attrib.get
                bpName = get_attr("pos")
                if "filename" in pixmap.attrib:
                    filename = get_attr("filename")
                    if filename and bpName:
                        png = loadPixmap(
                            resolveFilename(SCOPE_SKIN_IMAGE,
                                            filename,
                                            path_prefix=path_prefix), desktop)
                        style.setPixmap(eWindowStyleSkinned.__dict__[bsName],
                                        eWindowStyleSkinned.__dict__[bpName],
                                        png)
                elif "color" in pixmap.attrib:
                    color = parseColor(get_attr("color"))
                    size = int(get_attr("size"))
                    Log.w("%s: %s @ %s" % (bpName, color.argb(), size))
                    style.setColorBorder(eWindowStyleSkinned.__dict__[bsName],
                                         eWindowStyleSkinned.__dict__[bpName],
                                         color, size)

        for color in windowstyle.findall("color"):
            get_attr = color.attrib.get
            colorType = get_attr("name")
            color = parseColor(get_attr("color"))
            try:
                style.setColor(eWindowStyleSkinned.__dict__["col" + colorType],
                               color)
            except:
                raise SkinError("Unknown color %s" % (colorType))

        for listfont in windowstyle.findall("listfont"):
            get_attr = listfont.attrib.get
            fontType = get_attr("type")
            fontSize = int(get_attr("size"))
            fontFace = get_attr("font")
            try:
                Log.i("########### ADDING %s: %s" % (fontType, fontSize))
                style.setListFont(
                    eWindowStyleSkinned.__dict__["listFont" + fontType],
                    fontSize, fontFace)
            except:
                raise SkinError("Unknown listFont %s" % (fontType))

        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)

    for windowstylescrollbar in skin.findall("windowstylescrollbar"):
        style = eWindowStyleScrollbar()
        id = windowstylescrollbar.attrib.get("id")
        if id:
            id = int(id)
        else:
            id = 4
        for value in windowstylescrollbar.findall("value"):
            get_attr = value.attrib.get
            vType = get_attr("name")
            v = get_attr("value")
            if vType in ("BackgroundPixmapTopHeight",
                         "BackgroundPixmapBeginSize"):
                style.setBackgroundPixmapTopHeight(int(v))
            elif vType in ("BackgroundPixmapBottomHeight",
                           "BackgroundPixmapEndSize"):
                style.setBackgroundPixmapBottomHeight(int(v))
            elif vType in ("ValuePixmapTopHeight", "ValuePixmapBeginSize"):
                style.setValuePixmapTopHeight(int(v))
            elif vType in ("ValuePixmapBottomHeight", "ValuePixmapEndSize"):
                style.setValuePixmapBottomHeight(int(v))
            elif vType == "ScrollbarWidth":
                style.setScrollbarWidth(int(v))
            elif vType == "ScrollbarBorderWidth":
                style.setScrollbarBorderWidth(int(v))
        for pixmap in windowstylescrollbar.findall("pixmap"):
            get_attr = pixmap.attrib.get
            vType = get_attr("name")
            filename = get_attr("filename")
            if filename:
                if vType == "BackgroundPixmap":
                    png = loadPixmap(
                        resolveFilename(SCOPE_SKIN_IMAGE,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setBackgroundPixmap(png)
                elif vType == "ValuePixmap":
                    png = loadPixmap(
                        resolveFilename(SCOPE_SKIN_IMAGE,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setValuePixmap(png)
        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)

    for components in skin.findall("components"):
        for component in components.findall("component"):
            componentSizes.apply(component.attrib)
            for template in component.findall("template"):
                componentSizes.addTemplate(component.attrib, template.text)

    for l in skin.findall("layouts"):
        for layout in l.findall("layout"):
            layouts.apply(layout)
示例#19
0
文件: skin.py 项目: kingvuplus/ops
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for skininclude in skin.findall('include'):
        filename = skininclude.attrib.get('filename')
        if filename:
            skinfile = resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix)
            if not fileExists(skinfile):
                skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
            if fileExists(skinfile):
                print '[SKIN] loading include:', skinfile
                loadSkin(skinfile)

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
            else:
                raise SkinError('need color and name, got %s %s' % (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            render = get_attr('render')
            if render:
                render = int(render)
            else:
                render = 0
            resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
            if not fileExists(resolved_font):
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement, render)

        for alias in c.findall('alias'):
            get = alias.attrib.get
            try:
                name = get('name')
                font = get('font')
                size = int(get('size'))
                height = int(get('height', size))
                width = int(get('width', size))
                fonts[name] = (font,
                 size,
                 height,
                 width)
            except Exception as ex:
                print '[SKIN] bad font alias', ex

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('subtitles'):
        from enigma import eWidget, eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        style_id = windowstyle.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    png = loadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType], color)
            except:
                raise SkinError('Unknown color %s' % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(style_id, style)

    for margin in skin.findall('margin'):
        style_id = margin.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        r = eRect(0, 0, 0, 0)
        v = margin.attrib.get('left')
        if v:
            r.setLeft(int(v))
        v = margin.attrib.get('top')
        if v:
            r.setTop(int(v))
        v = margin.attrib.get('right')
        if v:
            r.setRight(int(v))
        v = margin.attrib.get('bottom')
        if v:
            r.setBottom(int(v))
        getDesktop(style_id).setMargins(r)
示例#20
0
def loadSingleSkinData(desktop, skin, path_prefix):
    """loads skin data like colors, windowstyle etc."""
    assert skin.tag == "skin", "root element in skin must be 'skin'!"

    #print "***SKIN: ", path_prefix

    for c in skin.findall("output"):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:  # framebuffer
            for res in c.findall("resolution"):
                get_attr = res.attrib.get
                xres = get_attr("xres")
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr("yres")
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr("bpp")
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                #print "Resolution:", xres,yres,bpp
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    # load palette (not yet implemented)
                    pass

    for c in skin.findall("colors"):
        for color in c.findall("color"):
            get_attr = color.attrib.get
            name = get_attr("name")
            color = get_attr("value")
            if name and color:
                colorNames[name] = parseColor(color)
                #print "Color:", name, color
            else:
                raise SkinError("need color and name, got %s %s" %
                                (name, color))

    for c in skin.findall("fonts"):
        for font in c.findall("font"):
            get_attr = font.attrib.get
            filename = get_attr("filename", "<NONAME>")
            name = get_attr("name", "Regular")
            scale = get_attr("scale")
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr("replacement") and True or False
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(
                    resolved_font
            ):  #when font is not available look at current skin path
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)
            #print "Font: ", resolved_font, name, scale, is_replacement

    for c in skin.findall("subtitles"):
        from enigma import eWidget, eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall("sub"):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr("font"), scale)
            col = get_attr("foregroundColor")
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(0xFFFFFF)
                haveColor = 0
            col = get_attr("shadowColor")
            if col:
                shadowColor = parseColor(col)
            else:
                shadowColor = gRGB(0)
            shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
            face = eSubtitleWidget.__dict__[get_attr("name")]
            eSubtitleWidget.setFontStyle(face, font, haveColor,
                                         foregroundColor, shadowColor,
                                         shadowOffset)

    for windowstyle in skin.findall("windowstyle"):
        style = eWindowStyleSkinned()
        id = windowstyle.attrib.get("id")
        if id:
            id = int(id)
        else:
            id = 0
        #print "windowstyle:", id

        # defaults
        font = gFont("Regular", 20)
        offset = eSize(20, 5)

        for title in windowstyle.findall("title"):
            get_attr = title.attrib.get
            offset = parseSize(get_attr("offset"), ((1, 1), (1, 1)))
            font = parseFont(get_attr("font"), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        #print "  ", font, offset

        for borderset in windowstyle.findall("borderset"):
            bsName = str(borderset.attrib.get("name"))
            for pixmap in borderset.findall("pixmap"):
                get_attr = pixmap.attrib.get
                bpName = get_attr("pos")
                filename = get_attr("filename")
                if filename and bpName:
                    png = loadPixmap(
                        resolveFilename(SCOPE_SKIN_IMAGE,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName],
                                    eWindowStyleSkinned.__dict__[bpName], png)
                #print "  borderset:", bpName, filename

        for color in windowstyle.findall("color"):
            get_attr = color.attrib.get
            colorType = get_attr("name")
            color = parseColor(get_attr("color"))
            try:
                style.setColor(eWindowStyleSkinned.__dict__["col" + colorType],
                               color)
            except:
                raise SkinError("Unknown color %s" % (colorType))
                #pass

            #print "  color:", type, color

        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)
示例#21
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			render = get_attr("render")
			if render:
				render = int(render)
			else:
				render = 0
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement, render)
			#print "Font: ", resolved_font, name, scale, is_replacement

	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("borderColor")
			if col:
				borderColor = parseColor(col)
			else:
				borderColor = gRGB(0)
			borderwidth = get_attr("borderWidth")
			if borderwidth is None:
				# default: use a subtitle border
				borderWidth = 3
			else:
				borderWidth = int(borderwidth)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		id = windowstyle.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 0
		#print "windowstyle:", id

		# defaults
		font = gFont("Regular", 20)
		offset = eSize(20, 5)

		for title in windowstyle.findall("title"):
			get_attr = title.attrib.get
			offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
			font = parseFont(get_attr("font"), ((1,1),(1,1)))

		style.setTitleFont(font);
		style.setTitleOffset(offset)
		#print "  ", font, offset

		for borderset in windowstyle.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				get_attr = pixmap.attrib.get
				bpName = get_attr("pos")
				filename = get_attr("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
				#print "  borderset:", bpName, filename

		for color in windowstyle.findall("color"):
			get_attr = color.attrib.get
			colorType = get_attr("name")
			color = parseColor(get_attr("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except:
				raise SkinError("Unknown color %s" % (colorType))
				#pass

			#print "  color:", type, color

		x = eWindowStyleManager.getInstance()
		x.setStyle(id, style)
示例#22
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
                if color[0] != '#':
                    for key in colorNames:
                        if key == color:
                            colorNamesHuman[name] = colorNamesHuman[key]
                            break

                else:
                    humancolor = color[1:]
                    if len(humancolor) >= 6:
                        colorNamesHuman[name] = int(humancolor, 16)
            else:
                raise SkinError('need color and name, got %s %s' %
                                (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(resolved_font):
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                if name.find('Font') != -1:
                    font = value.split(';')
                    if isinstance(font, list) and len(font) == 2:
                        parameters[name] = (str(font[0]), int(font[1]))
                else:
                    parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('constant-widgets'):
        for constant_widget in c.findall('constant-widget'):
            get = constant_widget.attrib.get
            name = get('name')
            if name:
                constant_widgets[name] = constant_widget

    for c in skin.findall('variables'):
        for parameter in c.findall('variable'):
            get = parameter.attrib.get
            name = get('name')
            value = get('value')
            x, y = value.split(',')
            if value and name:
                variables[name] = str(x) + ',' + str(y)

    for c in skin.findall('subtitles'):
        from enigma import eWidget, eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor,
                                         foregroundColor, borderColor,
                                         borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        id = windowstyle.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    png = loadPixmap(
                        resolveFilename(SCOPE_SKIN_IMAGE,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName],
                                    eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType],
                               color)
            except:
                raise SkinError('Unknown color %s' % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)
示例#23
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass
				if yres >= 1080:
					parameters["AutotimerEnabledIcon"] = (2,1,38,36)
					parameters["AutotimerRecordIcon"] = (42,5,30,30)
					parameters["ChoicelistDash"] = (0,3,1000,30)
					parameters["ChoicelistName"] = (68,3,1000,30)
					parameters["ChoicelistIcon"] = (7,0,52,38)
					parameters["ConfigListSeperator"] = 300
					parameters["DreamexplorerName"] = (62,0,1200,38)
					parameters["DreamexplorerIcon"] = (15,4,30,30)
					parameters["FileListName"] = (68,4,1000,34)
					parameters["FileListIcon"] = (7,4,52,37)
					parameters["FileListMultiName"] = (90,3,1000,32)
					parameters["FileListMultiIcon"] = (45, 4, 30, 30)
					parameters["FileListMultiLock"] = (2,0,36,36)
					parameters["HelpMenuListHlp"] = (0,0,900,42)
					parameters["HelpMenuListExtHlp0"] = (0,0,900,39)
					parameters["HelpMenuListExtHlp1"] = (0,42,900,30)
					parameters["PartnerBoxEntryListName"] = (8,2,225,38)
					parameters["PartnerBoxEntryListIP"] = (180,2,225,38)
					parameters["PartnerBoxEntryListPort"] = (405,2,150,38)
					parameters["PartnerBoxEntryListType"] = (615,2,150,38)
					parameters["PartnerBoxTimerServicename"] = (0,0,45)
					parameters["PartnerBoxTimerName"] = (0,42,30)
					parameters["PartnerBoxE1TimerTime"] = (0,78,255,30)
					parameters["PartnerBoxE1TimerState"] = (255,78,255,30)
					parameters["PartnerBoxE2TimerTime"] = (0,78,225,30)
					parameters["PartnerBoxE2TimerState"] = (225,78,225,30)
					parameters["PartnerBoxE2TimerIcon"] = (1050,8,20,20)
					parameters["PartnerBoxE2TimerIconRepeat"] = (1050,38,20,20)
					parameters["PartnerBoxBouquetListName"] = (0,0,45)
					parameters["PartnerBoxChannelListName"] = (0,0,45)
					parameters["PartnerBoxChannelListTitle"] = (0,42,30)
					parameters["PartnerBoxChannelListTime"] = (0,78,225,30)
					parameters["PicturePlayerThumb"] = (30,285,45,300,30,25)
					parameters["PlayListName"] = (38,2,1000,34)
					parameters["PlayListIcon"] = (7,7,24,24)
					parameters["PluginBrowserName"] = (180,8,38)
					parameters["PluginBrowserDescr"] = (180,42,25)
					parameters["PluginBrowserIcon"] = (15,8,150,60)
					parameters["PluginBrowserDownloadName"] = (120,8,38)
					parameters["PluginBrowserDownloadDescr"] = (120,42,25)
					parameters["PluginBrowserDownloadIcon"] = (15,0,90,76)
					parameters["ServiceInfo"] = (0,0,450,50)
					parameters["ServiceInfoLeft"] = (0,0,450,45)
					parameters["ServiceInfoRight"] = (450,0,1000,45)
					parameters["SelectionListDescr"] = (45,3,1000,32)
					parameters["SelectionListLock"] = (0,2,36,36)
					parameters["SelectionListLockOff"] = (0,2,36,36)
					parameters["VirtualKeyboard"] = (68,68)
					parameters["SHOUTcastListItem"] = (30,27,35,96,35,33,60,32)
					parameters["EPGImportFilterListDescr"] = (30,3,500,30)
					parameters["EPGImportFilterListLockOff"] = (0,0,30,30)
					parameters["EPGImportFilterListLockOn"] = (0,0,30,30)

	for skininclude in skin.findall("include"):
		filename = skininclude.attrib.get("filename")
		if filename:
			skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
			if not fileExists(skinfile):
				skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
			if fileExists(skinfile):
				print "[Skin] loading include:", skinfile
				loadSkin(skinfile)

	for c in skin.findall('switchpixmap'):
		for pixmap in c.findall('pixmap'):
			get_attr = pixmap.attrib.get
			name = get_attr('name')
			if not name:
				raise SkinError('[Skin] pixmap needs name attribute')
			filename = get_attr('filename')
			if not filename:
				raise SkinError('[Skin] pixmap needs filename attribute')
			resolved_png = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
			if fileExists(resolved_png):
				switchPixmap[name] = resolved_png
			else:
				raise SkinError('[Skin] switchpixmap pixmap filename="%s" (%s) not found' % (filename, resolved_png))

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("[Skin] need color and name, got %s %s" % (name, color))

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			render = get_attr("render")
			if render:
				render = int(render)
			else:
				render = 0
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename)
				if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)):
					resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)):
					resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)
			addFont(resolved_font, name, scale, is_replacement, render)
			#print "Font: ", resolved_font, name, scale, is_replacement
		for alias in c.findall("alias"):
			get = alias.attrib.get
			try:
				name = get("name")
				font = get("font")
				size = int(get("size"))
				height = int(get("height", size)) # to be calculated some day
				width = int(get("width", size))
				global fonts
				fonts[name] = (font, size, height, width)
			except Exception, ex:
				print "[Skin] bad font alias", ex
示例#24
0
文件: skin.py 项目: kingvuplus/boom
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall("output"):
        id = c.attrib.get("id")
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall("resolution"):
                get_attr = res.attrib.get
                xres = get_attr("xres")
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr("yres")
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr("bpp")
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC

                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for skininclude in skin.findall("include"):
        filename = skininclude.attrib.get("filename")
        if filename:
            skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
            if not fileExists(skinfile):
                skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
            if fileExists(skinfile):
                print "[SKIN] loading include:", skinfile
                loadSkin(skinfile)

    for c in skin.findall("colors"):
        for color in c.findall("color"):
            get_attr = color.attrib.get
            name = get_attr("name")
            color = get_attr("value")
            if name and color:
                colorNames[name] = parseColor(color)
            else:
                raise SkinError("need color and name, got %s %s" % (name, color))

    for c in skin.findall("fonts"):
        for font in c.findall("font"):
            get_attr = font.attrib.get
            filename = get_attr("filename", "<NONAME>")
            name = get_attr("name", "Regular")
            scale = get_attr("scale")
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr("replacement") and True or False
            render = get_attr("render")
            if render:
                render = int(render)
            else:
                render = 0
            resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
            if not fileExists(resolved_font):
                resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename)
                if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)):
                    resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)):
                    resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)
            addFont(resolved_font, name, scale, is_replacement, render)

        for alias in c.findall("alias"):
            get = alias.attrib.get
            try:
                name = get("name")
                font = get("font")
                size = int(get("size"))
                height = int(get("height", size))
                width = int(get("width", size))
                fonts[name] = (font, size, height, width)
            except Exception as ex:
                print "[SKIN] bad font alias", ex

    for c in skin.findall("parameters"):
        for parameter in c.findall("parameter"):
            get = parameter.attrib.get
            try:
                name = get("name")
                value = get("value")
                parameters[name] = map(int, value.split(","))
            except Exception as ex:
                print "[SKIN] bad parameter", ex

    for c in skin.findall("subtitles"):
        from enigma import eSubtitleWidget

        scale = ((1, 1), (1, 1))
        for substyle in c.findall("sub"):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr("font"), scale)
            col = get_attr("foregroundColor")
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr("borderColor")
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr("borderWidth")
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr("name")]
            eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

    for windowstyle in skin.findall("windowstyle"):
        style = eWindowStyleSkinned()
        style_id = windowstyle.attrib.get("id")
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        font = gFont("Regular", 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall("title"):
            get_attr = title.attrib.get
            offset = parseSize(get_attr("offset"), ((1, 1), (1, 1)))
            font = parseFont(get_attr("font"), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall("borderset"):
            bsName = str(borderset.attrib.get("name"))
            for pixmap in borderset.findall("pixmap"):
                get_attr = pixmap.attrib.get
                bpName = get_attr("pos")
                filename = get_attr("filename")
                if filename and bpName:
                    pngfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
                    if fileExists(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)):
                        pngfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
                    png = loadPixmap(pngfile, desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall("color"):
            get_attr = color.attrib.get
            colorType = get_attr("name")
            color = parseColor(get_attr("color"))
            try:
                style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
            except:
                raise SkinError("Unknown color %s" % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(style_id, style)

    for margin in skin.findall("margin"):
        style_id = margin.attrib.get("id")
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        r = eRect(0, 0, 0, 0)
        v = margin.attrib.get("left")
        if v:
            r.setLeft(int(v))
        v = margin.attrib.get("top")
        if v:
            r.setTop(int(v))
        v = margin.attrib.get("right")
        if v:
            r.setRight(int(v))
        v = margin.attrib.get("bottom")
        if v:
            r.setBottom(int(v))
        getDesktop(style_id).setMargins(r)

    return
示例#25
0
def loadSingleSkinData(desktop, skin, path_prefix):
    """loads skin data like colors, windowstyle etc."""
    assert skin.tag == "skin", "root element in skin must be 'skin'!"

    #print "***SKIN: ", path_prefix

    for c in skin.findall("output"):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:  # framebuffer
            for res in c.findall("resolution"):
                get_attr = res.attrib.get
                xres = get_attr("xres")
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr("yres")
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr("bpp")
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                #print "Resolution:", xres,yres,bpp
                config.skin.xres.value = xres
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    # load palette (not yet implemented)
                    pass

    for c in skin.findall("colors"):
        for color in c.findall("color"):
            get_attr = color.attrib.get
            name = get_attr("name")
            color = get_attr("value")
            if name and color:
                colorNames[name] = parseColor(color)
                #print "Color:", name, color
            else:
                raise SkinError("need color and name, got %s %s" %
                                (name, color))

    for c in skin.findall("fonts"):
        for font in c.findall("font"):
            get_attr = font.attrib.get
            filename = get_attr("filename", "<NONAME>")
            name = get_attr("name", "Regular")
            scale = get_attr("scale")
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr("replacement") and True or False
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(
                    resolved_font
            ):  #when font is not available look at current skin path
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)
            #print "Font: ", resolved_font, name, scale, is_replacement
        for alias in c.findall("alias"):
            get = alias.attrib.get
            try:
                name = get("name")
                font = get("font")
                size = int(get("size"))
                height = int(get("height", size))  # to be calculated some day
                width = int(get("width", size))
                global fonts
                fonts[name] = (font, size, height, width)
            except Exception, ex:
                print "[SKIN] bad font alias", ex

        for alias in c.findall("alias"):
            get = alias.attrib.get
            try:
                name = get("name")
                font = get("font")
                size = int(get("size"))
                height = int(get("height", size))  # to be calculated some day
                width = int(get("width", size))
                global fonts
                fonts[name] = (font, size, height, width)
            except Exception, ex:
                print "[SKIN] bad font alias", ex
示例#26
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
                if color[0] != '#':
                    for key in colorNames:
                        if key == color:
                            colorNamesHuman[name] = colorNamesHuman[key]
                            break

                else:
                    humancolor = color[1:]
                    if len(humancolor) >= 6:
                        colorNamesHuman[name] = int(humancolor, 16)
            else:
                raise SkinError('need color and name, got %s %s' % (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
            if not fileExists(resolved_font):
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                if name.find('Font') != -1:
                    font = value.split(';')
                    if isinstance(font, list) and len(font) == 2:
                        parameters[name] = (str(font[0]), int(font[1]))
                else:
                    parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('constant-widgets'):
        for constant_widget in c.findall('constant-widget'):
            get = constant_widget.attrib.get
            name = get('name')
            if name:
                constant_widgets[name] = constant_widget

    for c in skin.findall('variables'):
        for parameter in c.findall('variable'):
            get = parameter.attrib.get
            name = get('name')
            value = get('value')
            x, y = value.split(',')
            if value and name:
                variables[name] = str(x) + ',' + str(y)

    for c in skin.findall('subtitles'):
        from enigma import eWidget, eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        id = windowstyle.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType], color)
            except:
                raise SkinError('Unknown color %s' % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)
示例#27
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for skininclude in skin.findall('include'):
        filename = skininclude.attrib.get('filename')
        if filename:
            skinfile = resolveFilename(SCOPE_CURRENT_SKIN,
                                       filename,
                                       path_prefix=path_prefix)
            if not fileExists(skinfile):
                skinfile = resolveFilename(SCOPE_SKIN_IMAGE,
                                           filename,
                                           path_prefix=path_prefix)
            if fileExists(skinfile):
                print '[SKIN] loading include:', skinfile
                loadSkin(skinfile)

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
            else:
                raise SkinError('need color and name, got %s %s' %
                                (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            render = get_attr('render')
            if render:
                render = int(render)
            else:
                render = 0
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(resolved_font):
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement, render)

        for alias in c.findall('alias'):
            get = alias.attrib.get
            try:
                name = get('name')
                font = get('font')
                size = int(get('size'))
                height = int(get('height', size))
                width = int(get('width', size))
                fonts[name] = (font, size, height, width)
            except Exception as ex:
                print '[SKIN] bad font alias', ex

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('subtitles'):
        from enigma import eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor,
                                         foregroundColor, borderColor,
                                         borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        style_id = windowstyle.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    png = loadPixmap(
                        resolveFilename(SCOPE_CURRENT_SKIN,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName],
                                    eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType],
                               color)
            except:
                raise SkinError("Unknown color %s" % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(style_id, style)

    for margin in skin.findall('margin'):
        style_id = margin.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        r = eRect(0, 0, 0, 0)
        v = margin.attrib.get('left')
        if v:
            r.setLeft(int(v))
        v = margin.attrib.get('top')
        if v:
            r.setTop(int(v))
        v = margin.attrib.get('right')
        if v:
            r.setRight(int(v))
        v = margin.attrib.get('bottom')
        if v:
            r.setBottom(int(v))
        getDesktop(style_id).setMargins(r)
示例#28
0
文件: skin.py 项目: kingvuplus/test
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"

	#print "***SKIN: ", path_prefix

	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				if color[0] != '#':
					for key in colorNames:
						if key == color:
							colorNamesHuman[name] = colorNamesHuman[key]
							break
				else:
					humancolor = color[1:]
					if len(humancolor) >= 6:
						colorNamesHuman[name] = int(humancolor,16)
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement)
			#print "Font: ", resolved_font, name, scale, is_replacement

	for c in skin.findall("parameters"):
		for parameter in c.findall("parameter"):
			get = parameter.attrib.get
			try:
				name = get("name")
				value = get("value")
				if name.find('Font') != -1:
					font = value.split(";")
					if isinstance(font, list) and len(font) == 2:
						parameters[name] = (str(font[0]), int(font[1]))
				else:
					parameters[name] = map(int, value.split(","))
			except Exception, ex:
			 	print "[SKIN] bad parameter", ex
示例#29
0
	def setMode(self, port, mode, rate, force = None):
		print "[AVSwitch] setMode - port: %s, mode: %s, rate: %s" % (port, mode, rate)

		# config.av.videoport.setValue(port)
		# we can ignore "port"
		self.current_mode = mode
		self.current_port = port
		modes = self.rates[mode][rate]


		mode_50 = modes.get(50)
		mode_60 = modes.get(60)
		mode_24 = modes.get(24)

		if mode_50 is None or force == 60:
			mode_50 = mode_60
		if mode_60 is None or force == 50:
			mode_60 = mode_50
		if mode_24 is None or force:
			mode_24 = mode_60
			if force == 50:
				mode_24 = mode_50

		try:
			f = open("/proc/stb/video/videomode_50hz", "w")
			f.write(mode_50)
			f.close()
			f = open("/proc/stb/video/videomode_60hz", "w")
			f.write(mode_60)
			f.close()
		except IOError:
			try:
				# fallback if no possibility to setup 50/60 hz mode
				f = open("/proc/stb/video/videomode", "w")
				f.write(mode_50)
				f.close()
			except IOError:
				print "[AVSwitch] setting videomode failed."

		if SystemInfo["have24hz"]:
			try:
				open("/proc/stb/video/videomode_24hz", "w").write(mode_24)
			except IOError:
				print "[VideoHardware] cannot open /proc/stb/video/videomode_24hz"

		if getBrandOEM() in ('gigablue',):
			try:
				# use 50Hz mode (if available) for booting
				f = open("/etc/videomode", "w")
				f.write(mode_50)
				f.close()
			except IOError:
				print "[AVSwitch] writing initial videomode to /etc/videomode failed."

		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		self.setColorFormat(map[config.av.colorformat.value])

		if about.getCPUString().startswith('STx'):
			#call setResolution() with -1,-1 to read the new scrren dimensions without changing the framebuffer resolution
			from enigma import gMainDC
			gMainDC.getInstance().setResolution(-1, -1)
示例#30
0
文件: ui.py 项目: kingvuplus/PB-gui
	def __init__(self, session, filelist, index, path):

		self.textcolor = config.pic.textcolor.value
		self.bgcolor = config.pic.bgcolor.value
		space = config.pic.framesize.value

		self.size_w = size_w = getDesktop(0).size().width()
		self.size_h = size_h = getDesktop(0).size().height()

		if config.usage.pic_resolution.value and (size_w, size_h) != eval(config.usage.pic_resolution.value):
			(size_w, size_h) = eval(config.usage.pic_resolution.value)
			gMainDC.getInstance().setResolution(size_w, size_h)
			getDesktop(0).resize(eSize(size_w, size_h))

		self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
			<eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
			<widget name=\"point\" position=\""+ str(space+5) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/record.png\" alphatest=\"on\" /> \
			<widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/ico_mp_play.png\"  alphatest=\"on\" /> \
			<widget source=\"file\" render=\"Label\" position=\""+ str(space+45) + "," + str(space) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" borderWidth=\"1\" borderColor=\"#000000\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"

		Screen.__init__(self, session)

		self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
		{
			"cancel": self.Exit,
			"green": self.PlayPause,
			"yellow": self.PlayPause,
			"blue": self.nextPic,
			"red": self.prevPic,
			"left": self.prevPic,
			"right": self.nextPic,
			"showEventInfo": self.StartExif,
		}, -1)

		self["point"] = Pixmap()
		self["pic"] = Pixmap()
		self["play_icon"] = Pixmap()
		self["file"] = StaticText(_("please wait, loading picture..."))

		self.old_index = 0
		self.filelist = []
		self.lastindex = index
		self.currPic = []
		self.shownow = True
		self.dirlistcount = 0

		for x in filelist:
			if len(filelist[0]) == 3: #orig. filelist
				if not x[0][1]:
					self.filelist.append(path + x[0][0])
				else:
					self.dirlistcount += 1
			elif len(filelist[0]) == 2: #scanlist
				if not x[0][1]:
					self.filelist.append(x[0][0])
				else:
					self.dirlistcount += 1
			else: # thumbnaillist
				self.filelist.append(x[T_FULL])

		self.maxentry = len(self.filelist)-1
		self.index = index - self.dirlistcount
		if self.index < 0:
			self.index = 0

		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.finish_decode)

		self.slideTimer = eTimer()
		self.slideTimer.callback.append(self.slidePic)

		if self.maxentry >= 0:
			self.onLayoutFinish.append(self.setPicloadConf)
示例#31
0
	def switchbackResolution(self):
		if (self.xres, self.yres) != (1920, 1080):
			gMainDC.getInstance().setResolution(self.xres, self.yres)
			getDesktop(0).resize(eSize(self.xres, self.yres))
示例#32
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""Loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0:  # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				# print "[Skin] Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp)
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# Load palette (Not yet implemented!)
					pass
				if yres >= 1080:
					parameters["FileListName"] = (68, 4, 1000, 34)
					parameters["FileListIcon"] = (7, 4, 52, 37)
					parameters["FileListMultiName"] = (90, 3, 1000, 32)
					parameters["FileListMultiIcon"] = (45, 4, 30, 30)
					parameters["FileListMultiLock"] = (2, 0, 36, 36)
					parameters["ChoicelistDash"] = (0, 3, 1000, 30)
					parameters["ChoicelistName"] = (68, 3, 1000, 30)
					parameters["ChoicelistNameSingle"] = (7, 3, 1000, 30)
					parameters["ChoicelistIcon"] = (7, 0, 52, 38)
					parameters["PluginBrowserName"] = (180, 8, 38)
					parameters["PluginBrowserDescr"] = (180, 42, 25)
					parameters["PluginBrowserIcon"] = (15, 8, 150, 60)
					parameters["PluginBrowserDownloadName"] = (120, 8, 38)
					parameters["PluginBrowserDownloadDescr"] = (120, 42, 25)
					parameters["PluginBrowserDownloadIcon"] = (15, 0, 90, 76)
					parameters["ServiceInfoLeft"] = (0, 0, 450, 45)
					parameters["ServiceInfoRight"] = (450, 0, 1000, 45)
					parameters["SelectionListDescr"] = (45, 6, 1000, 45)
					parameters["SelectionListLock"] = (0, 2, 36, 36)
					parameters["ConfigListSeperator"] = 500
					parameters["VirtualKeyboard"] = (68, 68)
					parameters["PartnerBoxEntryListName"] = (8, 2, 225, 38)
					parameters["PartnerBoxEntryListIP"] = (180, 2, 225, 38)
					parameters["PartnerBoxEntryListPort"] = (405, 2, 150, 38)
					parameters["PartnerBoxEntryListType"] = (615, 2, 150, 38)
					parameters["PartnerBoxTimerServicename"] = (0, 0, 45)
					parameters["PartnerBoxTimerName"] = (0, 42, 30)
					parameters["PartnerBoxE1TimerTime"] = (0, 78, 255, 30)
					parameters["PartnerBoxE1TimerState"] = (255, 78, 255, 30)
					parameters["PartnerBoxE2TimerTime"] = (0, 78, 225, 30)
					parameters["PartnerBoxE2TimerState"] = (225, 78, 225, 30)
					parameters["PartnerBoxE2TimerIcon"] = (1050, 8, 20, 20)
					parameters["PartnerBoxE2TimerIconRepeat"] = (1050, 38, 20, 20)
					parameters["PartnerBoxBouquetListName"] = (0, 0, 45)
					parameters["PartnerBoxChannelListName"] = (0, 0, 45)
					parameters["PartnerBoxChannelListTitle"] = (0, 42, 30)
					parameters["PartnerBoxChannelListTime"] = (0, 78, 225, 30)
					parameters["HelpMenuListHlp"] = (0, 0, 900, 42)
					parameters["HelpMenuListExtHlp0"] = (0, 0, 900, 39)
					parameters["HelpMenuListExtHlp1"] = (0, 42, 900, 30)
					parameters["AboutHddSplit"] = 1
					parameters["DreamexplorerName"] = (62, 0, 1200, 38)
					parameters["DreamexplorerIcon"] = (15, 4, 30, 30)
					parameters["PicturePlayerThumb"] = (30, 285, 45, 300, 30, 25)
					parameters["PlayListName"] = (38, 2, 1000, 34)
					parameters["PlayListIcon"] = (7, 7, 24, 24)
					parameters["SHOUTcastListItem"] = (30, 27, 35, 96, 35, 33, 60, 32)
					parameters["AutotimerListIcon"] = (3, -1, 36, 36)
					parameters["AutotimerListRectypeicon"] = (39, 4, 30, 30)
					parameters["AutotimerListTimerName"] = (76, 4, 26, 32)
					parameters["AutotimerListTimespan"] = (2, 40, 5, 25)
					parameters["AutotimerListChannels"] = (2, 60, 4, 32)
					parameters["AutotimerListHasTimespan"] = (154, 4, 150, 25)
					parameters["AutotimerListDays"] = (1, 40, 5, 25)
	for skininclude in skin.findall("include"):
		filename = skininclude.attrib.get("filename")
		if filename:
			skinfile = resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix)
			if not fileExists(skinfile):
				skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
			if fileExists(skinfile):
				print "[Skin] Loading included file '%s'." % skinfile
				loadSkin(skinfile)
	for c in skin.findall("switchpixmap"):
		for pixmap in c.findall("pixmap"):
			get_attr = pixmap.attrib.get
			name = get_attr("name")
			if not name:
				raise SkinError("Pixmap needs name attribute")
			filename = get_attr("filename")
			if not filename:
				raise SkinError("Pixmap needs filename attribute")
			resolved_png = resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix)
			if fileExists(resolved_png):
				switchPixmap[name] = LoadPixmap(resolved_png, cached=True)
			else:
				raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved_png))
	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				# print "[Skin] Color name='%s', color='%s'." % (name, color)
			else:
				raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color))
	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			render = get_attr("render")
			if render:
				render = int(render)
			else:
				render = 0
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font):  # when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement, render)
			# print "Font: ", resolved_font, name, scale, is_replacement
		fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=path_prefix)
		if fileExists(fallbackFont):
			addFont(fallbackFont, "Fallback", 100, -1, 0)
		for alias in c.findall("alias"):
			get = alias.attrib.get
			try:
				name = get("name")
				font = get("font")
				size = int(get("size"))
				height = int(get("height", size))  # To be calculated some day.
				width = int(get("width", size))
				global fonts
				fonts[name] = (font, size, height, width)
				# print "[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width)
			except Exception, ex:
				print "[Skin] Error: Bad font alias -", ex
示例#33
0
def loadSingleSkinData(desktop, screenID, domSkin, pathSkin, scope=SCOPE_CURRENT_SKIN):
	"""Loads skin data like colors, windowstyle etc."""
	assert domSkin.tag == "skin", "root element in skin must be 'skin'!"
	global colors, fonts, menus, parameters, setups, switchPixmap
	for tag in domSkin.findall("output"):
		scrnID = int(tag.attrib.get("id", GUI_SKIN_ID))
		if scrnID == GUI_SKIN_ID:
			for res in tag.findall("resolution"):
				xres = res.attrib.get("xres")
				xres = int(xres) if xres else 720
				yres = res.attrib.get("yres")
				yres = int(yres) if yres else 576
				bpp = res.attrib.get("bpp")
				bpp = int(bpp) if bpp else 32
				# print("[Skin] DEBUG: Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp))
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					pass  # Load palette (Not yet implemented!)
				if yres >= 1080:
					parameters["AutotimerEnabledIcon"] = (2, 1, 38, 36)
					parameters["AutotimerRecordIcon"] = (42, 5, 30, 30)
					parameters["ChoicelistDash"] = (0, 3, 1000, 30)
					parameters["ChoicelistIcon"] = (7, 0, 52, 38)
					parameters["ChoicelistName"] = (68, 3, 1000, 30)
					parameters["ConfigListSeperator"] = 300
					parameters["DreamexplorerIcon"] = (15, 4, 30, 30)
					parameters["DreamexplorerName"] = (62, 0, 1200, 38)
					parameters["EPGImportFilterListDescr"] = (30, 3, 500, 30)
					parameters["EPGImportFilterListLockOff"] = (0, 0, 30, 30)
					parameters["EPGImportFilterListLockOn"] = (0, 0, 30, 30)
					parameters["ExpandableListCategory"] = (60, 0, 655, 38)
					parameters["ExpandableListIcon"] = (5, 0, 45, 38)
					parameters["ExpandableListItem"] = (105, 0, 620, 38)
					parameters["ExpandableListLock"] = (60, 1, 38, 36)
					parameters["FileListIcon"] = (7, 4, 52, 37)
					parameters["FileListMultiIcon"] = (45, 4, 30, 30)
					parameters["FileListMultiLock"] = (2, 0, 36, 36)
					parameters["FileListMultiName"] = (90, 3, 1000, 32)
					parameters["FileListName"] = (68, 4, 1000, 34)
					parameters["HelpMenuListExtHlp0"] = (0, 0, 900, 39)
					parameters["HelpMenuListExtHlp1"] = (0, 42, 900, 30)
					parameters["HelpMenuListHlp"] = (0, 0, 900, 42)
					parameters["PartnerBoxBouquetListName"] = (0, 0, 45)
					parameters["PartnerBoxChannelListName"] = (0, 0, 45)
					parameters["PartnerBoxChannelListTime"] = (0, 78, 225, 30)
					parameters["PartnerBoxChannelListTitle"] = (0, 42, 30)
					parameters["PartnerBoxE1TimerState"] = (255, 78, 255, 30)
					parameters["PartnerBoxE1TimerTime"] = (0, 78, 255, 30)
					parameters["PartnerBoxE2TimerIcon"] = (1050, 8, 20, 20)
					parameters["PartnerBoxE2TimerIconRepeat"] = (1050, 38, 20, 20)
					parameters["PartnerBoxE2TimerState"] = (225, 78, 225, 30)
					parameters["PartnerBoxE2TimerTime"] = (0, 78, 225, 30)
					parameters["PartnerBoxEntryListIP"] = (180, 2, 225, 38)
					parameters["PartnerBoxEntryListName"] = (8, 2, 225, 38)
					parameters["PartnerBoxEntryListPort"] = (405, 2, 150, 38)
					parameters["PartnerBoxEntryListType"] = (615, 2, 150, 38)
					parameters["PartnerBoxTimerName"] = (0, 42, 30)
					parameters["PartnerBoxTimerServicename"] = (0, 0, 45)
					parameters["PicturePlayerThumb"] = (30, 285, 45, 300, 30, 25)
					parameters["PlayListIcon"] = (7, 7, 24, 24)
					parameters["PlayListName"] = (38, 2, 1000, 34)
					parameters["PluginBrowserDescr"] = (180, 42, 25)
					parameters["PluginBrowserDownloadDescr"] = (120, 42, 25)
					parameters["PluginBrowserDownloadIcon"] = (15, 0, 90, 76)
					parameters["PluginBrowserDownloadName"] = (120, 8, 38)
					parameters["PluginBrowserIcon"] = (15, 8, 150, 60)
					parameters["PluginBrowserName"] = (180, 8, 38)
					parameters["SHOUTcastListItem"] = (30, 27, 35, 96, 35, 33, 60, 32)
					parameters["SelectionListDescr"] = (45, 3, 1000, 32)
					parameters["SelectionListLock"] = (0, 2, 36, 36)
					parameters["SelectionListLockOff"] = (0, 2, 36, 36)
					parameters["ServiceInfo"] = (0, 0, 450, 50)
					parameters["ServiceInfoLeft"] = (0, 0, 450, 45)
					parameters["ServiceInfoRight"] = (450, 0, 1000, 45)
					parameters["VirtualKeyBoard"] = (68, 68)
					parameters["VirtualKeyBoardAlignment"] = (0, 0)
					parameters["VirtualKeyBoardPadding"] = (7, 7)
					parameters["VirtualKeyBoardShiftColors"] = (0x00ffffff, 0x00ffffff, 0x0000ffff, 0x00ff00ff)
	for tag in domSkin.findall("include"):
		filename = tag.attrib.get("filename")
		if filename:
			filename = resolveFilename(scope, filename, path_prefix=pathSkin)
			if isfile(filename):
				loadSkin(filename, scope=scope, desktop=desktop, screenID=screenID)
			else:
				raise SkinError("Included file '%s' not found" % filename)
	for tag in domSkin.findall("switchpixmap"):
		for pixmap in tag.findall("pixmap"):
			name = pixmap.attrib.get("name")
			if not name:
				raise SkinError("Pixmap needs name attribute")
			filename = pixmap.attrib.get("filename")
			if not filename:
				raise SkinError("Pixmap needs filename attribute")
			resolved = resolveFilename(scope, filename, path_prefix=pathSkin)
			if isfile(resolved):
				switchPixmap[name] = LoadPixmap(resolved, cached=True)
			else:
				raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved))
	for tag in domSkin.findall("colors"):
		for color in tag.findall("color"):
			name = color.attrib.get("name")
			color = color.attrib.get("value")
			if name and color:
				colors[name] = parseColor(color)
				# print("[Skin] DEBUG: Color name='%s', color='%s'." % (name, color))
			else:
				raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color))
	for tag in domSkin.findall("fonts"):
		for font in tag.findall("font"):
			filename = font.attrib.get("filename", "<NONAME>")
			name = font.attrib.get("name", "Regular")
			scale = font.attrib.get("scale")
			scale = int(scale) if scale else 100
			isReplacement = font.attrib.get("replacement") and True or False
			render = font.attrib.get("render")
			if render:
				render = int(render)
			else:
				render = 0
			filename = resolveFilename(SCOPE_FONTS, filename, path_prefix=pathSkin)
			if isfile(filename):
				addFont(filename, name, scale, isReplacement, render)
				# Log provided by C++ addFont code.
				# print("[Skin] Add font: Font path='%s', name='%s', scale=%d, isReplacement=%s, render=%d." % (filename, name, scale, isReplacement, render))
			else:
				raise SkinError("Font file '%s' not found" % filename)
		fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=pathSkin)
		if isfile(fallbackFont):
			addFont(fallbackFont, "Fallback", 100, -1, 0)
		# else:  # As this is optional don't raise an error.
		# 	raise SkinError("Fallback font '%s' not found" % fallbackFont)
		for alias in tag.findall("alias"):
			try:
				name = alias.attrib.get("name")
				font = alias.attrib.get("font")
				size = int(alias.attrib.get("size"))
				height = int(alias.attrib.get("height", size))  # To be calculated some day.
				width = int(alias.attrib.get("width", size))
				fonts[name] = (font, size, height, width)
				# print("[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width))
			except Exception as err:
				raise SkinError("Bad font alias: '%s'" % str(err))
	for tag in domSkin.findall("parameters"):
		for parameter in tag.findall("parameter"):
			try:
				name = parameter.attrib.get("name")
				value = parameter.attrib.get("value")
				parameters[name] = map(parseParameter, [x.strip() for x in value.split(",")]) if "," in value else parseParameter(value)
			except Exception as err:
				raise SkinError("Bad parameter: '%s'" % str(err))
	for tag in domSkin.findall("menus"):
		for setup in tag.findall("menu"):
			key = setup.attrib.get("key")
			image = setup.attrib.get("image")
			if key and image:
				menus[key] = image
				# print("[Skin] DEBUG: Menu key='%s', image='%s'." % (key, image))
			else:
				raise SkinError("Tag menu needs key and image, got key='%s' and image='%s'" % (key, image))
	for tag in domSkin.findall("setups"):
		for setup in tag.findall("setup"):
			key = setup.attrib.get("key")
			image = setup.attrib.get("image")
			if key and image:
				setups[key] = image
				# print("[Skin] DEBUG: Setup key='%s', image='%s'." % (key, image))
			else:
				raise SkinError("Tag setup needs key and image, got key='%s' and image='%s'" % (key, image))
	for tag in domSkin.findall("subtitles"):
		from enigma import eSubtitleWidget
		scale = ((1, 1), (1, 1))
		for substyle in tag.findall("sub"):
			font = parseFont(substyle.attrib.get("font"), scale)
			col = substyle.attrib.get("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = substyle.attrib.get("borderColor")
			if col:
				borderColor = parseColor(col)
			else:
				borderColor = gRGB(0)
			borderwidth = substyle.attrib.get("borderWidth")
			if borderwidth is None:
				borderWidth = 3  # Default: Use a subtitle border.
			else:
				borderWidth = int(borderwidth)
			face = eSubtitleWidget.__dict__[substyle.attrib.get("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)
	for tag in domSkin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		scrnID = int(tag.attrib.get("id", GUI_SKIN_ID))
		font = gFont("Regular", 20)  # Default
		offset = eSize(20, 5)  # Default
		for title in tag.findall("title"):
			offset = parseSize(title.attrib.get("offset"), ((1, 1), (1, 1)))
			font = parseFont(title.attrib.get("font"), ((1, 1), (1, 1)))
		style.setTitleFont(font)
		style.setTitleOffset(offset)
		# print("[Skin] DEBUG: WindowStyle font, offset - '%s' '%s'." % (str(font), str(offset)))
		for borderset in tag.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				bpName = pixmap.attrib.get("pos")
				filename = pixmap.attrib.get("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(scope, filename, path_prefix=pathSkin), desktop)
					try:
						style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
					except Exception:
						pass
				# print("[Skin] DEBUG: WindowStyle borderset name, filename - '%s' '%s'." % (bpName, filename))
		for color in tag.findall("color"):
			colorType = color.attrib.get("name")
			color = parseColor(color.attrib.get("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except Exception:
				raise SkinError("Unknown color type '%s'" % colorType)
			# print("[Skin] DEBUG: WindowStyle color type, color -" % (colorType, str(color)))
		x = eWindowStyleManager.getInstance()
		x.setStyle(scrnID, style)
	for tag in domSkin.findall("margin"):
		scrnID = int(tag.attrib.get("id", GUI_SKIN_ID))
		r = eRect(0, 0, 0, 0)
		v = tag.attrib.get("left")
		if v:
			r.setLeft(int(v))
		v = tag.attrib.get("top")
		if v:
			r.setTop(int(v))
		v = tag.attrib.get("right")
		if v:
			r.setRight(int(v))
		v = tag.attrib.get("bottom")
		if v:
			r.setBottom(int(v))
		# The "desktop" parameter is hard-coded to the GUI screen, so we must ask
		# for the one that this actually applies to.
		getDesktop(scrnID).setMargins(r)
示例#34
0
 def resolutionCheck(self, result):
     gMainDC.getInstance().setResolution(self.x, self.y)
     if not result:
         self.resetFHD()
     else:
         self.InstallCheck()
示例#35
0
	def __close(self):
		gMainDC.getInstance().setResolution(self.xres, self.yres)
		getDesktop(0).resize(eSize(self.xres, self.yres))
示例#36
0
文件: skin.py 项目: st7TEAM/dreambox
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"

	#print "***SKIN: ", path_prefix

	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("listboxcontent"):
		for offset in c.findall("offset"):
			get_attr = offset.attrib.get
			name = get_attr("name")
			value = get_attr("value")
			if name and value:
				if name == "left":
					eListboxPythonStringContent.setLeftOffset(parseValue(value))
				elif name == "right":
					eListboxPythonStringContent.setRightOffset(parseValue(value))
				else:
					raise SkinError("got listboxcontent offset '%s'' but 'left' or 'right' is allowed only" % name)
		for font in c.findall("font"):
			get_attr = font.attrib.get
			name = get_attr("name")
			font = get_attr("font")
			if name and font:
				if name == "string":
					eListboxPythonStringContent.setFont(parseFont(font, ((1,1),(1,1))))
				elif name == "config_description":
					eListboxPythonConfigContent.setDescriptionFont(parseFont(font, ((1,1),(1,1))))
				elif name == "config_value":
					eListboxPythonConfigContent.setValueFont(parseFont(font, ((1,1),(1,1))))
				else:
					raise SkinError("got listboxcontent font '%s' but 'string', 'config_description' or 'config_value' is allowed only" % name)
		for value in c.findall("value"):
			get_attr = value.attrib.get
			name = get_attr("name")
			value = get_attr("value")
			if name and value:
				if name == "string_item_height":
					eListboxPythonStringContent.setItemHeight(parseValue(value))
				elif name == "config_item_height":
					eListboxPythonConfigContent.setItemHeight(parseValue(value))
				else:
					raise SkinError("got listboxcontent value '%s' but 'string_item_height' or 'config_item_height' is allowed only" % name)

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement)
			#print "Font: ", resolved_font, name, scale, is_replacement

	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("shadowColor")
			if col:
				shadowColor = parseColor(col)
			else:
				shadowColor = gRGB(0)
			shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		id = windowstyle.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 0
		#print "windowstyle:", id

		# defaults
		font = gFont("Regular", 20)
		offset = eSize(20, 5)

		for title in windowstyle.findall("title"):
			get_attr = title.attrib.get
			offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
			font = parseFont(get_attr("font"), ((1,1),(1,1)))

		style.setTitleFont(font);
		style.setTitleOffset(offset)
		#print "  ", font, offset

		for borderset in windowstyle.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				get_attr = pixmap.attrib.get
				bpName = get_attr("pos")
				filename = get_attr("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
				#print "  borderset:", bpName, filename

		for color in windowstyle.findall("color"):
			get_attr = color.attrib.get
			colorType = get_attr("name")
			color = parseColor(get_attr("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except:
				raise SkinError("Unknown color %s" % (colorType))
				#pass

			#print "  color:", type, color

		x = eWindowStyleManager.getInstance()
		x.setStyle(id, style)

	for windowstylescrollbar in skin.findall("windowstylescrollbar"):
		style = eWindowStyleScrollbar()
		id = windowstylescrollbar.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 4
		for value in windowstylescrollbar.findall("value"):
			get_attr = value.attrib.get
			vType = get_attr("name")
			v = get_attr("value")
			if vType == "BackgroundPixmapTopHeight":
				style.setBackgroundPixmapTopHeight(int(v))
			elif vType == "BackgroundPixmapBottomHeight":
				style.setBackgroundPixmapBottomHeight(int(v))
			elif vType == "ValuePixmapTopHeight":
				style.setValuePixmapTopHeight(int(v))
			elif vType == "ValuePixmapBottomHeight":
				style.setValuePixmapBottomHeight(int(v))
			elif vType == "ScrollbarWidth":
				style.setScrollbarWidth(int(v))
			elif vType == "ScrollbarBorderWidth":
				style.setScrollbarBorderWidth(int(v))
		for pixmap in windowstylescrollbar.findall("pixmap"):
			get_attr = pixmap.attrib.get
			vType = get_attr("name")
			filename = get_attr("filename")
			if filename:
				if vType == "BackgroundPixmap":
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setBackgroundPixmap(png)
				elif vType == "ValuePixmap":
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setValuePixmap(png)
		x = eWindowStyleManager.getInstance()
		x.setStyle(id, style)
示例#37
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass
				if yres >= 1080:
					parameters["FileListName"] = (68,4,1000,34)
					parameters["FileListIcon"] = (7,4,52,37)
					parameters["FileListMultiName"] = (90,3,1000,32)
					parameters["FileListMultiIcon"] = (45, 4, 30, 30)
					parameters["FileListMultiLock"] = (2,0,36,36)
					parameters["ChoicelistDash"] = (0,3,1000,30)
					parameters["ChoicelistName"] = (68,3,1000,30)
					parameters["ChoicelistIcon"] = (7,0,52,38)
					parameters["PluginBrowserName"] = (180,8,38)
					parameters["PluginBrowserDescr"] = (180,42,25)
					parameters["PluginBrowserIcon"] = (15,8,150,60)
					parameters["PluginBrowserDownloadName"] = (120,8,38)
					parameters["PluginBrowserDownloadDescr"] = (120,42,25)
					parameters["PluginBrowserDownloadIcon"] = (15,0,90,76)
					parameters["ServiceInfo"] = (0,0,450,50)
					parameters["ServiceInfoLeft"] = (0,0,450,45)
					parameters["ServiceInfoRight"] = (450,0,1000,45)
					parameters["SelectionListDescr"] = (45,3,1000,32)
					parameters["SelectionListLock"] = (0,2,36,36)
					parameters["ConfigListSeperator"] = 300
					parameters["VirtualKeyboard"] = (68,68)
					parameters["PartnerBoxEntryListName"] = (8,2,225,38)
					parameters["PartnerBoxEntryListIP"] = (180,2,225,38)
					parameters["PartnerBoxEntryListPort"] = (405,2,150,38)
					parameters["PartnerBoxEntryListType"] = (615,2,150,38)
					parameters["PartnerBoxTimerServicename"] = (0,0,45)
					parameters["PartnerBoxTimerName"] = (0,42,30)
					parameters["PartnerBoxE1TimerTime"] = (0,78,255,30)
					parameters["PartnerBoxE1TimerState"] = (255,78,255,30)
					parameters["PartnerBoxE2TimerTime"] = (0,78,225,30)
					parameters["PartnerBoxE2TimerState"] = (225,78,225,30)
					parameters["PartnerBoxE2TimerIcon"] = (1050,8,20,20)
					parameters["PartnerBoxE2TimerIconRepeat"] = (1050,38,20,20)
					parameters["PartnerBoxBouquetListName"] = (0,0,45)
					parameters["PartnerBoxChannelListName"] = (0,0,45)
					parameters["PartnerBoxChannelListTitle"] = (0,42,30)
					parameters["PartnerBoxChannelListTime"] = (0,78,225,30)
					parameters["HelpMenuListHlp"] = (0,0,900,42)
					parameters["HelpMenuListExtHlp0"] = (0,0,900,39)
					parameters["HelpMenuListExtHlp1"] = (0,42,900,30)
					parameters["AboutHddSplit"] = 1
					parameters["DreamexplorerName"] = (62,0,1200,38)
					parameters["DreamexplorerIcon"] = (15,4,30,30)
					parameters["PicturePlayerThumb"] = (30,285,45,300,30,25)
					parameters["PlayListName"] = (38,2,1000,34)
					parameters["PlayListIcon"] = (7,7,24,24)
					parameters["SHOUTcastListItem"] = (30,27,35,96,35,33,60,32)

	for skininclude in skin.findall("include"):
		filename = skininclude.attrib.get("filename")
		if filename:
			skinfile = resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix)
			if not fileExists(skinfile):
				skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
			if fileExists(skinfile):
				print "[SKIN] loading include:", skinfile
				loadSkin(skinfile)

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			render = get_attr("render")
			if render:
				render = int(render)
			else:
				render = 0
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement, render)
			#print "Font: ", resolved_font, name, scale, is_replacement
		for alias in c.findall("alias"):
			get = alias.attrib.get
			try:
				name = get("name")
				font = get("font")
				size = int(get("size"))
				height = int(get("height", size)) # to be calculated some day
				width = int(get("width", size))
				global fonts
				fonts[name] = (font, size, height, width)
			except Exception, ex:
				print "[SKIN] bad font alias", ex
示例#38
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for skininclude in skin.findall("include"):
		filename = skininclude.attrib.get("filename")
		if filename:
			skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
			if not fileExists(skinfile):
				skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
			if fileExists(skinfile):
				print "[SKIN] loading include:", skinfile
				loadSkin(skinfile)

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("parameters"):
		for parameter in c.findall("parameter"):
			get = parameter.attrib.get
			try:
				name = get("name")
				value = get("value")
				if name.find('Font') != -1:
					font = value.split(";")
					if isinstance(font, list) and len(font) == 2:
						parameters[name] = (str(font[0]), int(font[1]))
				else:
					parameters[name] = map(int, value.split(","))
			except Exception, ex:
			 	print "[SKIN] bad parameter", ex
示例#39
0
文件: ui.py 项目: BlackHole/enigma2-1
	def __init__(self, session, filelist, index, path):

		self.textcolor = config.pic.textcolor.value
		self.bgcolor = config.pic.bgcolor.value
		space = config.pic.framesize.value

		self.size_w = size_w = getDesktop(0).size().width()
		self.size_h = size_h = getDesktop(0).size().height()

		if config.usage.pic_resolution.value and (size_w, size_h) != eval(config.usage.pic_resolution.value):
			(size_w, size_h) = eval(config.usage.pic_resolution.value)
			gMainDC.getInstance().setResolution(size_w, size_h)
			getDesktop(0).resize(eSize(size_w, size_h))

		self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
			<eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
			<widget name=\"point\" position=\""+ str(space+5) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/record.png\" alphatest=\"on\" /> \
			<widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/ico_mp_play.png\"  alphatest=\"on\" /> \
			<widget source=\"file\" render=\"Label\" position=\""+ str(space+45) + "," + str(space) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" borderWidth=\"1\" borderColor=\"#000000\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"

		Screen.__init__(self, session)

		self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
		{
			"cancel": self.Exit,
			"green": self.PlayPause,
			"yellow": self.PlayPause,
			"blue": self.nextPic,
			"red": self.prevPic,
			"left": self.prevPic,
			"right": self.nextPic,
			"showEventInfo": self.StartExif,
			"contextMenu": self.KeyMenu,
		}, -1)

		self["point"] = Pixmap()
		self["pic"] = Pixmap()
		self["play_icon"] = Pixmap()
		self["file"] = StaticText(_("please wait, loading picture..."))

		self.old_index = 0
		self.filelist = []
		self.lastindex = index
		self.currPic = []
		self.shownow = True
		self.dirlistcount = 0

		for x in filelist:
			if len(filelist[0]) == 3: #orig. filelist
				if not x[0][1]:
					self.filelist.append(path + x[0][0])
				else:
					self.dirlistcount += 1
			elif len(filelist[0]) == 2: #scanlist
				if not x[0][1]:
					self.filelist.append(x[0][0])
				else:
					self.dirlistcount += 1
			else: # thumbnaillist
				self.filelist.append(x[T_FULL])

		self.maxentry = len(self.filelist)-1
		self.index = index - self.dirlistcount
		if self.index < 0:
			self.index = 0

		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.finish_decode)

		self.slideTimer = eTimer()
		self.slideTimer.callback.append(self.slidePic)

		if self.maxentry >= 0:
			self.onLayoutFinish.append(self.setPicloadConf)
示例#40
0
	def __close(self):
		gMainDC.getInstance().setResolution(self.xres, self.yres)
		getDesktop(0).resize(eSize(self.xres, self.yres))
示例#41
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for skininclude in skin.findall("include"):
		filename = skininclude.attrib.get("filename")
		if filename:
			skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
			if not fileExists(skinfile):
				skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
			if fileExists(skinfile):
				print "[SKIN] loading include:", skinfile
				loadSkin(skinfile)

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			render = get_attr("render")
			if render:
				render = int(render)
			else:
				render = 0
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename)
				if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)):
					resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)):
					resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)
			addFont(resolved_font, name, scale, is_replacement, render)
			#print "Font: ", resolved_font, name, scale, is_replacement
		for alias in c.findall("alias"):
			get = alias.attrib.get
			try:
				name = get("name")
				font = get("font")
				size = int(get("size"))
				height = int(get("height", size)) # to be calculated some day
				width = int(get("width", size))
				global fonts
				fonts[name] = (font, size, height, width)
			except Exception, ex:
				print "[SKIN] bad font alias", ex
示例#42
0
	def resolutionTest(self, result):
		if not result:
			self.resetEHD()
			return
		gMainDC.getInstance().setResolution(int(1280*self.EHDfactor), int(720*self.EHDfactor))
		self.session.openWithCallback(self.resolutionCheck, MessageBox, _("If you can see this then is your receiver compatible.\nDo you want change from %s to %s - skin resolution?") % (self.EHDtext_old, self.EHDtxt), default = False, timeout = 10)