Ejemplo n.º 1
0
 def initialiseSkin(self):
     element, path = domScreens.get("SkinSelector", (None, None))
     if element is None:  # This skin does not have a SkinConverter screen.
         buildSkin = True
     else:  # Test the skin's SkinConverter screen to ensure it works with the new code.
         buildSkin = False
         widgets = element.findall("widget")
         if widgets is not None:
             for widget in widgets:
                 name = widget.get("name", None)
                 source = widget.get("source", None)
                 if name and name in (
                         "Preview", "SkinList") or source == "introduction":
                     print(
                         "[SkinSelector] Warning: Current skin '%s' does not support this version of SkinSelector!    Please contact the skin's author!"
                         % config.skin.primary_skin.value)
                     del domScreens[
                         "SkinSelector"]  # It is incompatible, delete the screen from the skin.
                     buildSkin = True
                     break
     if buildSkin:  # Build the embedded skin and scale it to the current screen resolution.
         # The skin template is designed for a HD screen so the scaling factor is 720.
         SkinSelector.skin = SkinSelector.skinTemplate % tuple([
             x * getDesktop(0).size().height() / 720
             for x in SkinSelector.scaleData
         ])
         # print("[SkinSelector] DEBUG: Height=%d\n" % getDesktop(0).size().height(), SkinSelector.skin)
     else:
         SkinSelector.skin = "<screen />"
Ejemplo n.º 2
0
	def applySkin(self, desktop, screen):
		if self.skinAttributes is not None:
			myScreen, path = domScreens.get(screen.__class__.__name__, (None, None))
			skinPathPrefix = getattr(screen, "skin_path", path)
			pixmap = None
			attribs = []
			for (attrib, value) in self.skinAttributes:
				if attrib == "pixmaps":
					pixmaps = value.split(",")
					for pix in pixmaps:
						if fileExists(resolveFilename(SCOPE_GUISKIN, pix, path_prefix=skinPathPrefix)):
							pngfile = resolveFilename(SCOPE_GUISKIN, pix, path_prefix=skinPathPrefix)
						elif fileExists(resolveFilename(SCOPE_LCDSKIN, pix, path_prefix=skinPathPrefix)):
							pngfile = resolveFilename(SCOPE_LCDSKIN, pix, path_prefix=skinPathPrefix)
						else:
							pngfile = ""
						if pngfile and isfile(pngfile):
							self.pixmaps.append(loadPixmap(pngfile, desktop))
					if not pixmap:
						if fileExists(resolveFilename(SCOPE_GUISKIN, pixmaps[0], path_prefix=skinPathPrefix)):
							pixmap = resolveFilename(SCOPE_GUISKIN, pixmaps[0], path_prefix=skinPathPrefix)
						elif fileExists(resolveFilename(SCOPE_LCDSKIN, pixmaps[0], path_prefix=skinPathPrefix)):
							pixmap = resolveFilename(SCOPE_LCDSKIN, pixmaps[0], path_prefix=skinPathPrefix)
				elif attrib == "pixmap":
					if fileExists(resolveFilename(SCOPE_GUISKIN, value, path_prefix=skinPathPrefix)):
						pixmap = resolveFilename(SCOPE_GUISKIN, value, path_prefix=skinPathPrefix)
					elif fileExists(resolveFilename(SCOPE_LCDSKIN, value, path_prefix=skinPathPrefix)):
						pixmap = resolveFilename(SCOPE_LCDSKIN, value, path_prefix=skinPathPrefix)
				else:
					attribs.append((attrib, value))
			if pixmap:
				attribs.append(("pixmap", pixmap))
			self.skinAttributes = attribs
		return GUIComponent.applySkin(self, desktop, screen)
Ejemplo n.º 3
0
	def __init__(self, session, screenTitle=_("GUI Skin")):
		Screen.__init__(self, session, mandatoryWidgets=["description", "skins"])
		HelpableScreen.__init__(self)

		element = domScreens.get("SkinSelector", (None, None))[0]
		Screen.setTitle(self, screenTitle)
		self.rootDir = resolveFilename(SCOPE_SKIN)
		self.config = config.skin.primary_skin
		self.current = currentPrimarySkin
		self.xmlList = ["skin.xml"]
		self.onChangedEntry = []
		self["skins"] = List(enableWrapAround=True)
		self["preview"] = Pixmap()
		self["key_red"] = StaticText(_("Cancel"))
		self["key_green"] = StaticText(_("Save"))
		self["description"] = StaticText(_("Please wait... Loading list..."))
		self["actions"] = HelpableNumberActionMap(self, ["SetupActions", "DirectionActions", "ColorActions"], {
			"ok": (self.save, _("Save and activate the currently selected skin")),
			"cancel": (self.cancel, _("Cancel any changes to the currently active skin")),
			"close": (self.cancelRecursive, _("Cancel any changes to the currently active skin and exit all menus")),
			"red": (self.cancel, _("Cancel any changes to the currently active skin")),
			"green": (self.save, _("Save and activate the currently selected skin")),
			"up": (self.up, _("Move to the previous skin")),
			"down": (self.down, _("Move to the next skin")),
			"left": (self.left, _("Move to the previous page")),
			"right": (self.right, _("Move to the next page"))
		}, -1, description=_("Skin Selection Actions"))
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.onLayoutFinish.append(self.layoutFinished)
Ejemplo n.º 4
0
    def __init__(self, session, screenTitle=_("GUI Skin")):
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)

        element = domScreens.get("SkinSelector", (None, None))[0]
        if element and 'introduction' in [
                widget.get('source', None)
                for widget in element.findall("widget")
        ]:
            #screen from loaded skin is  not compatible so remove the screen
            del domScreens["SkinSelector"]
        if SkinSelector.skin is None or "SkinSelector" not in domScreens:
            # The skin template is designed for a HD screen so the scaling factor is 720.
            SkinSelector.skin = SkinSelector.skinTemplate % tuple([
                x * getDesktop(0).size().height() / 720
                for x in SkinSelector.scaleData
            ])
        Screen.setTitle(self, screenTitle)
        self.rootDir = resolveFilename(SCOPE_SKIN)
        self.config = config.skin.primary_skin
        self.current = currentPrimarySkin
        self.xmlList = ["skin.xml"]
        self.onChangedEntry = []
        self["skins"] = List(enableWrapAround=True)
        self["preview"] = Pixmap()
        self["key_red"] = StaticText(_("Cancel"))
        self["key_green"] = StaticText(_("Save"))
        self["description"] = StaticText(_("Please wait... Loading list..."))
        self["actions"] = HelpableNumberActionMap(self, [
            "SetupActions", "DirectionActions", "ColorActions"
        ], {
            "ok":
            (self.save, _("Save and activate the currently selected skin")),
            "cancel": (self.cancel,
                       _("Cancel any changes to the currently active skin")),
            "close":
            (self.cancelRecursive,
             _("Cancel any changes to the currently active skin and exit all menus"
               )),
            "red": (self.cancel,
                    _("Cancel any changes to the currently active skin")),
            "green":
            (self.save, _("Save and activate the currently selected skin")),
            "up": (self.up, _("Move to the previous skin")),
            "down": (self.down, _("Move to the next skin")),
            "left": (self.left, _("Move to the previous page")),
            "right": (self.right, _("Move to the next page"))
        },
                                                  -1,
                                                  description=_(
                                                      "Skin Selection Actions")
                                                  )
        self.picload = ePicLoad()
        self.picload.PictureData.get().append(self.showPic)
        self.onLayoutFinish.append(self.layoutFinished)
Ejemplo n.º 5
0
	def hackSkin(self):  # This is a hack to ensure the SkinConverter screen works with the new code.
		rescueSkin = """
	<screen name="SkinSelector" position="center,center" size="%d,%d">
		<widget name="preview" position="center,%d" size="%d,%d" alphatest="blend" />
		<widget source="skins" render="Listbox" position="center,%d" size="%d,%d" enableWrapAround="1" scrollbarMode="showOnDemand" transparent="1">
			<convert type="TemplatedMultiContent">
				{
				"template": [
					MultiContentEntryText(pos = (%d, 0), size = (%d, %d), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_CENTER, text = 1),
					MultiContentEntryText(pos = (%d, 0), size = (%d, %d), font = 0, flags = RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text = 2)
				],
				"fonts": [gFont("Regular",%d)],
				"itemHeight": %d
				}
			</convert>
		</widget>
		<widget source="description" render="Label" position="center,%d" size="%d,%d" font="Regular;%d" transparent="1" valign="center" />
		<widget source="key_red" render="Pixmap" pixmap="buttons/key_red_fill.png" position="%d,e-%d" size="%d,%d" alphatest="blend" objectTypes="key_red,StaticText" scale="1">
 			<convert type="ConditionalShowHide" />
 		</widget>
		<widget source="key_red" render="Label" position="%d,e-%d" size="%d,%d" backgroundColor="key_red" font="Regular;%d" foregroundColor="key_text" halign="center" transparent="1" valign="center" zPosition="+1" />
		<widget source="key_green" render="Pixmap" pixmap="buttons/key_green_fill.png" position="%d,e-%d" size="%d,%d" alphatest="blend" objectTypes="key_green,StaticText" scale="1">
 			<convert type="ConditionalShowHide" />
 		</widget>
		<widget source="key_green" render="Label" position="%d,e-%d" size="%d,%d" backgroundColor="key_green" font="Regular;%d" foregroundColor="key_text" halign="center" transparent="1" valign="center" zPosition="+1" />
	</screen>"""
		rescueData = [630, 570, 10, 356, 200, 230, 610, 240, 10, 290, 30, 310, 280, 30, 25, 30, 490, 610, 25, 20, 10, 50, 140, 40, 10, 50, 140, 40, 20, 160, 50, 140, 40, 160, 50, 140, 40, 20]
		replaceSkin = False
		element, path = domScreens.get("SkinSelector", (None, None))
		if element is not None:
			widgets = element.findall("widget")
			if widgets is not None:
				for widget in widgets:
					name = widget.get("name", None)
					if name == "Preview":
						replaceSkin = True
					if name == "SkinList":
						replaceSkin = True
					source = widget.get("source", None)
					if source == "introduction":
						replaceSkin = True
		height = getDesktop(0).size().height()
		if replaceSkin:
			height = 720 if height < 720 else height
			rescueData = [x * height / 720 for x in rescueData]
			element = xml.etree.cElementTree.fromstring(rescueSkin % tuple(rescueData))
			domScreens["SkinSelector"] = (element, path)