Пример #1
0
    def __init__(self, session):
        self.session = session
        Screen.__init__(self, session)
        # self.skinName = "Tetris_v1"
        if isFHD():
            self.skinName = "Tetrisfhd"
        else:
            self.skinName = "Tetrishd"
        self.setTitle("Tetris %s" % VERSION)
        self["actions"] = ActionMap(
            ["TetrisActions"], {
                "cancel": self.cancel,
                "up": self.up,
                "down": self.down,
                "left": self.left,
                "right": self.right,
                "ok": self.ok,
                "red": self.red,
                "green": self.green,
                "yellow": self.yellow,
                "blue": self.blue,
            }, -1)

        self["canvas"] = CanvasSource()
        self["preview"] = CanvasSource()
        self["previewtext"] = Label("Next Block:")
        self["key_red"] = Label("Exit")
        self["key_green"] = Label("Tetris Start")
        self["state"] = Label()
        self["lines"] = Label()
        self["level"] = Label()
        self["points"] = Label()
        self.onLayoutFinish.append(self.setupBoard)
Пример #2
0
	def __init__(self, session, fe_num, text):
		Screen.__init__(self, session)
		Screen.setTitle(self, _("Blind scan state"))
		self.skinName = ["DmmBlindscanState", "SatBlindscanState2"]
		self["list"] = List()
		self["text"] = Label()
		self["text"].setText(text)
		self["post_action"] = Label()
		self["progress"] = Label()
		self["key_red"] = StaticText(_("Cancel"))
		self["key_green"] = StaticText("Auto / Manual")
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"ok": self.keyOk,
			"cancel": self.keyCancel,
			"red": self.keyCancel,
			"green": self.keyGreen,
		}, -2)
		self.fe_num = fe_num
		self["constellation"] = CanvasSource()
		self.onLayoutFinish.append(self.updateConstellation)
		self.tmr = eTimer()
		self.tmr.callback.append(self.updateConstellation)
		self.constellation_supported = None
		if fe_num != -1:
			self.post_action = 1
			self.finished = 0
			self.keyGreen()
		else:
			self.post_action = -1
Пример #3
0
    def __init__(self, session):

        Screen.__init__(self, session)
        self.session = session

        self["preview"] = CanvasSource()

        #ConfigListScreen.__init__(self, self.list(), session = session)
        list = []
        ConfigListScreen.__init__(self, list)

        self["actions"] = ActionMap(
            [
                "OkCancelActions", "ColorActions", "DirectionActions",
                "EPGSelectActions"
            ], {
                "cancel": self.close,
                "left": self.keyLeft,
                "right": self.keyRight,
                "down": self.keyDown,
                "up": self.keyUp,
                "red": self.close,
            }, -1)

        self["bgcolor"] = Label(_(" "))
        self["fgcolor"] = Label(_(" "))
        self["bgcolor1a"] = Label(_(" "))
        self["fgcolor1a"] = Label(_(" "))
        self["txtcolor"] = Label(_(" "))
        self.timer = eTimer()
        self.timer.callback.append(self.list)
        self.onLayoutFinish.append(self.list)
        self.onLayoutFinish.append(self.previewSkin)
Пример #4
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.setTitle(_("Pixel Test"))

        self["Canvas"] = CanvasSource()
        self.fontsize = getDesktop(0).size().height() == 1080 and 30 or 20
        self.xres, self.yres = getDesktop(0).size().width(), getDesktop(
            0).size().height()

        self["actions"] = NumberActionMap(
            ["InputActions", "OkCancelActions", "ColorActions"], {
                "1": self.keyNumber,
                "2": self.keyNumber,
                "3": self.keyNumber,
                "4": self.keyNumber,
                "5": self.keyNumber,
                "6": self.keyNumber,
                "7": self.keyNumber,
                "8": self.keyNumber,
                "red": self.togglered,
                "green": self.togglegreen,
                "yellow": self.intro,
                "blue": self.toggleblue,
                "ok": self.ok,
                "cancel": self.cancel,
                "left": self.left,
                "right": self.right,
            })
        self.intro()
Пример #5
0
	def __init__(self, session):
		Screen.__init__(self, session)
		self["Canvas"] = CanvasSource()

		self.basic_colors = [RGB(255, 255, 255), RGB(255, 255, 0), RGB(0, 255, 255), RGB(0, 255, 0), RGB(255, 0, 255), RGB(255, 0, 0), RGB(0, 0, 255), RGB(0, 0, 0)]

		if fileExists("/proc/stb/fb/dst_left"):
			self.left = open("/proc/stb/fb/dst_left", "r").read()
			self.width = open("/proc/stb/fb/dst_width", "r").read()
			self.top = open("/proc/stb/fb/dst_top", "r").read()
			self.height = open("/proc/stb/fb/dst_height", "r").read()
			if self.left != "00000000" or self.top != "00000000" or self.width != "000002d0" or self.height != "0000000240":
				open("/proc/stb/fb/dst_left", "w").write("00000000")
				open("/proc/stb/fb/dst_width", "w").write("000002d0")
				open("/proc/stb/fb/dst_top", "w").write("00000000")
				open("/proc/stb/fb/dst_height", "w").write("0000000240")
				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,
			"6": self.keyNumber,
			"7": self.keyNumber,
			"ok": self.callNext,
			"cancel": self.close,
		})
		self.testpic_brightness()
Пример #6
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self["Canvas"] = CanvasSource()

        self.basic_colors = [
            RGB(255, 255, 255),
            RGB(255, 255, 0),
            RGB(0, 255, 255),
            RGB(0, 255, 0),
            RGB(255, 0, 255),
            RGB(255, 0, 0),
            RGB(0, 0, 255),
            RGB(0, 0, 0)
        ]

        self["actions"] = ActionMap(
            ["InputActions", "OkCancelActions"],
            {
                "1": self.testpic_brightness,
                "2": self.testpic_contrast,
                #			"3": self.testpic_colors,
                "3": self.testpic_filter,
                "4": self.testpic_gamma,
                "5": self.testpic_fubk,
                "ok": self.callNext,
                "cancel": self.close,
            })
        self.testpic_brightness()
Пример #7
0
 def __init__(self, session, fe_num, text):
     Screen.__init__(self, session)
     self["list"] = List()
     self["text"] = Label()
     self["text"].setText(text)
     self["post_action"] = Label()
     self["progress"] = Label()
     self["actions"] = ActionMap(
         ["OkCancelActions", "ColorActions"], {
             "ok": self.keyOk,
             "cancel": self.keyCancel,
             "red": self.keyCancel,
             "green": self.keyGreen,
         }, -2)
     self.fe_num = fe_num
     self["constellation"] = CanvasSource()
     self.onLayoutFinish.append(self.updateConstellation)
     self.tmr = eTimer()
     self.tmr.callback.append(self.updateConstellation)
     self.constellation_supported = None
     if fe_num != -1:
         self.post_action = 1
         self.finished = 0
         self.keyGreen()
     else:
         self.post_action = -1
Пример #8
0
    def __init__(self, session):
        log("", self, "Moodlamp Opened succesfull..")
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)

        self.cfglist = []
        ConfigListScreen.__init__(self,
                                  self.cfglist,
                                  session,
                                  on_change=self._changed)

        self._session = session
        self._hasChanged = False

        self.selected = None
        self.controller = None

        self["txt_green"] = Label()
        self["txt_yellow"] = Label()

        self["canvas_text"] = StaticText()

        self["help"] = StaticText()

        self["btn_green"] = Pixmap()
        self["btn_yellow"] = Pixmap()

        self["statusbar"] = Pixmap()
        self["txt_statusbar"] = Label()
        self["txt_statusbar_info"] = Label()

        self["Canvas"] = CanvasSource()

        self["setupActions"] = ActionMap(
            ["SetupActions", "ColorActions", "EL_Settings"], {
                "green": self.keySave,
                "red": self.keyCancel,
                "cancel": self.keyCancel,
                "ok": self.ok,
                "left": self.keyLeft,
                "right": self.keyRight,
                "bouquet_up": self.keyBouquetUp,
                "bouquet_down": self.keyBouquetDown,
                "jumpNextMark": self.keyNext,
                "jumpPreviousMark": self.keyPrev,
            }, -2)

        self["txt_green"].setText(_("Save"))

        self["canvas_text"].text = _("Static color:")
        self.createList()

        log("", self, "Finisch layout..")

        self["config"].onSelectionChanged.append(self.updateHelp)
        self.onLayoutFinish.append(self.finishLayout)
Пример #9
0
    def __init__(self, session):
        Screen.__init__(self, session)

        port = config.av.videoport.value
        self.hasUHD = port and config.av.videomode[port].value.startswith(
            "2160")

        self["Canvas"] = CanvasSource()

        self.basic_colors = [
            RGB(255, 255, 255),
            RGB(255, 255, 0),
            RGB(0, 255, 255),
            RGB(0, 255, 0),
            RGB(255, 0, 255),
            RGB(255, 0, 0),
            RGB(0, 0, 255),
            RGB(0, 0, 0)
        ]
        self.fontsize = getDesktop(0).size().height() == 1080 and 30 or 20

        if fileExists("/proc/stb/fb/dst_left"):
            print("[VideoFinetune] Read /proc/stb/fb/dst_left")
            self.left = open("/proc/stb/fb/dst_left", "r").read()
            print("[VideoFinetune] Read /proc/stb/fb/dst_width")
            self.width = open("/proc/stb/fb/dst_width", "r").read()
            print("[VideoFinetune] Read /proc/stb/fb/dst_top")
            self.top = open("/proc/stb/fb/dst_top", "r").read()
            print("[VideoFinetune] Read /proc/stb/fb/dst_height")
            self.height = open("/proc/stb/fb/dst_height", "r").read()
            if self.left != "00000000" or self.top != "00000000" or self.width != "000002d0" or self.height != "0000000240":
                print("[VideoFinetune] Write to /proc/stb/fb/dst_left")
                open("/proc/stb/fb/dst_left", "w").write("00000000")
                print("[VideoFinetune] Write to /proc/stb/fb/dst_width")
                open("/proc/stb/fb/dst_width", "w").write("000002d0")
                print("[VideoFinetune] Write to /proc/stb/fb/dst_top")
                open("/proc/stb/fb/dst_top", "w").write("00000000")
                print("[VideoFinetune] Write to /proc/stb/fb/dst_height")
                open("/proc/stb/fb/dst_height", "w").write("0000000240")
                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,
                "6": self.keyNumber,
                "7": self.keyNumber,
                "8": self.keyNumber,
                "9": self.keyNumber,
                "ok": self.callNext,
                "cancel": self.close,
            })
        self.testpic_brightness()
Пример #10
0
    def __init__(self, session):
        self.csize = 42
        self.fsize = 50
        self.bsize = 4

        self.cw = 7 * self.fsize + 2 * self.bsize
        self.ch = 7 * self.fsize + 2 * self.bsize

        layout = resolveFilename(SCOPE_CURRENT_PLUGIN,
                                 "Extensions/vierg/layout.png")

        # set skin...
        vierg.skin = """
			<screen position="center,center" size="378,440" title="Vier Gewinnt %s" >
				<widget source="Canvas" render="Canvas" position="10,0" size="358,358" zPosition="1" />
				<ePixmap name="layout" position="0,0" zPosition="2" size="378,440" pixmap="%s" transparent="1" alphatest="on" />
				<widget name="message" position="0,360" size="378,30" zPosition="3" backgroundColor="#062748" valign="center" halign="center" font="Regular;26"/>
				<ePixmap name="red"   position=" 10,390" zPosition="3" size="140,40" pixmap="buttons/red.png" transparent="1" alphatest="on" />
				<ePixmap name="green" position="228,390" zPosition="3" size="140,40" pixmap="buttons/green.png" transparent="1" alphatest="on" />
				<widget name="key_red"   position=" 10,390" zPosition="4" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
				<widget name="key_green" position="228,390" zPosition="4" size="140,40" valign="center" halign="center"  font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
			</screen>""" % (VERSION, layout)

        self.skin = vierg.skin
        Screen.__init__(self, session)
        self["Canvas"] = CanvasSource()
        self["message"] = Label(_(" "))
        self["key_red"] = Button(_("quit game"))
        self["key_green"] = Button(_("new game"))

        self["actions"] = ActionMap(
            ["WizardActions", "ColorActions", "SetupActions"], {
                "ok": self.ok_pressed,
                "left": self.left_pressed,
                "right": self.right_pressed,
                "red": self.quit,
                "green": self.new_game,
                "cancel": self.quit,
            })

        self.blue = 0x0000ff
        self.red = 0xff0000
        self.bg1 = 0x373737
        self.bg0 = 0x062748

        self.aniTimer = eTimer()
        self.aniTimer.callback.append(self.aniTimerHandler)

        self.onLayoutFinish.append(self.new_game)
Пример #11
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.setTitle(_("VideoFinetune"))
        self.skinAttributes = None
        self["Canvas"] = CanvasSource()

        self.basic_colors = [
            RGB(255, 255, 255),
            RGB(255, 255, 0),
            RGB(0, 255, 255),
            RGB(0, 255, 0),
            RGB(255, 0, 255),
            RGB(255, 0, 0),
            RGB(0, 0, 255),
            RGB(0, 0, 0)
        ]
        self.MyFontSize = 20

        if getDesktop(0).size().width() > 1280:
            self.MyFontSize = 28

        if fileExists("/proc/stb/fb/dst_left"):
            self.left = open("/proc/stb/fb/dst_left", "r").read()
            self.width = open("/proc/stb/fb/dst_width", "r").read()
            self.top = open("/proc/stb/fb/dst_top", "r").read()
            self.height = open("/proc/stb/fb/dst_height", "r").read()
            if self.left != "00000000" or self.top != "00000000" or self.width != "000002d0" or self.height != "0000000240":
                open("/proc/stb/fb/dst_left", "w").write("00000000")
                open("/proc/stb/fb/dst_width", "w").write("000002d0")
                open("/proc/stb/fb/dst_top", "w").write("00000000")
                open("/proc/stb/fb/dst_height", "w").write("0000000240")
                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,
                "6": self.keyNumber,
                "7": self.keyNumber,
                "ok": self.callNext,
                "cancel": self.close,
            })
        self.testpic_brightness()
Пример #12
0
    def __init__(self, session, title="", color=""):
        self.session = session
        Screen.__init__(self, session)

        list = []
        ConfigListScreen.__init__(self, list)

        self["actions"] = ActionMap(
            [
                "KravenHDConfigActions", "OkCancelActions", "DirectionActions",
                "ColorActions", "InputActions"
            ], {
                "upUp": self.keyUpLong,
                "downUp": self.keyDownLong,
                "up": self.keyUp,
                "down": self.keyDown,
                "left": self.keyLeft,
                "right": self.keyRight,
                "green": self.save,
                "ok": self.save,
                "red": self.exit,
                "cancel": self.exit
            }, -1)

        self["key_red"] = StaticText(_("Exit"))
        self["key_green"] = StaticText(_("Save Color"))
        self["Title"] = StaticText(_("Color Selection"))
        self["preview"] = CanvasSource()

        self.newcolor = color

        self.newcolor = self.newcolor[-6:]
        config.plugins.KravenHD.SelfColorR.value = int(self.newcolor[0:2], 16)
        config.plugins.KravenHD.SelfColorG.value = int(self.newcolor[2:4], 16)
        config.plugins.KravenHD.SelfColorB.value = int(self.newcolor[4:6], 16)

        self.timer = eTimer()
        self.timer.callback.append(self.colorselectionlist)
        self.mylist()
Пример #13
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self["Canvas"] = CanvasSource()

        self.basic_colors = [
            RGB(255, 255, 255),
            RGB(255, 255, 0),
            RGB(0, 255, 255),
            RGB(0, 255, 0),
            RGB(255, 0, 255),
            RGB(255, 0, 0),
            RGB(0, 0, 255),
            RGB(0, 0, 0)
        ]
        tlf = TemplatedListFonts()
        self._textFont = gFont(tlf.face(tlf.BIGGER), tlf.size(tlf.BIGGER))

        self._headerSize = tlf.size(tlf.BIGGER) * 2
        self._headerFont = gFont(tlf.face(tlf.BIGGER), self._headerSize)
        self._headerSize = int(self._headerSize * 1.5)

        self["actions"] = ActionMap(
            ["InputActions", "OkCancelActions"],
            {
                "1": self.testpic_brightness,
                "2": self.testpic_contrast,
                #			"3": self.testpic_colors,
                "3": self.testpic_filter,
                "4": self.testpic_gamma,
                "5": self.testpic_fubk,
                "ok": self.callNext,
                "cancel": self.close,
            })

        self._size = None
        self.next = None
        self._clear()
        self.onLayoutFinish.append(self._onLayoutFinish)
Пример #14
0
    def __init__(self, session):
        # get framebuffer resolution...
        desk = getDesktop(0)
        w = int(desk.size().width())
        h = int(desk.size().height())

        # display window in center...
        x = (w - 520) / 2
        y = (h - 390) / 2

        # set skin...
        # ToDo: change for HD Skins...
        Sudoku.skin = """
			<screen position="%d,%d" size="520,390" title="Sudoku 0.1" >
				<widget source="Canvas" render="Canvas" position="10,20" size="354,354" />
				<widget name="gamelevel" position="380,25" size="140,40" font="Regular;21"/>
				<ePixmap name="green"    position="375,98"   zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
				<ePixmap name="yellow"  position="375,178" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
				<ePixmap name="blue" position="375,258" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
				<ePixmap name="red"   position="375,338" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
				<widget name="key_green"    position="375,98"   zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
				<widget name="key_yellow"  position="375,178" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
				<widget name="key_blue" position="375,258" zPosition="5" size="140,40" valign="center" halign="center"  font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
				<widget name="key_red"   position="375,338" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
			</screen>""" % (x, y)

        # i'm not really sure if this is the right way to get the background color from a skinned window?
        # there must exist a better way? everything is taken from skin.py
        # find xml for actual skin...
        filename = resolveFilename(SCOPE_CURRENT_SKIN) + "skin.xml"
        actualSkin = xml.etree.cElementTree.parse(filename).getroot()

        # get colors from skin and write to dictionary
        colorNames = dict()
        for c in actualSkin.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] = color
                    #print "Color:", name, color

        # find colors for skinned window...
        for windowstyle in actualSkin.findall("windowstyle"):
            # look or skinned window...
            if windowstyle.attrib.get("id") == "0":
                for color in windowstyle.findall("color"):
                    get_attr = color.attrib.get
                    type = get_attr("name")
                    color = get_attr("color")
                    # is it a "named" color?
                    if color[0] != '#':
                        # is "named" color, have to look in dictionary...
                        color = colorNames[color]
                    #print type, color
                    # at least get the background color...
                    if type == "Background":
                        bgcolor = int(color[1:], 0x10)
        #if not bgcolor:
        bgcolor = RGB(0, 0, 0)

        self.skin = Sudoku.skin
        Screen.__init__(self, session)
        self["Canvas"] = CanvasSource()
        self["gamelevel"] = Label(_(" <    easy    >"))
        self["key_green"] = Button(_("new game"))
        self["key_yellow"] = Button(_("check game"))
        self["key_blue"] = Button(_("restart game"))
        self["key_red"] = Button(_("solve game"))

        self.cnt = 0
        self.timer = eTimer()
        self.timer.callback.append(self.timerHandler)

        self.xFocus = 4
        self.yFocus = 4

        self.gameLevel = 0

        self["actions"] = ActionMap(
            ["WizardActions", "ColorActions", "SetupActions"], {
                "0": self.bt_0_pressed,
                "1": self.bt_1_pressed,
                "2": self.bt_2_pressed,
                "3": self.bt_3_pressed,
                "4": self.bt_4_pressed,
                "5": self.bt_5_pressed,
                "6": self.bt_6_pressed,
                "7": self.bt_7_pressed,
                "8": self.bt_8_pressed,
                "9": self.bt_9_pressed,
                "up": self.up_pressed,
                "down": self.down_pressed,
                "left": self.left_pressed,
                "right": self.right_pressed,
                "red": self.bt_solve_game,
                "green": self.bt_new_game,
                "yellow": self.bt_check_game,
                "blue": self.bt_restart_game,
                "cancel": self.quit,
                "deleteForward": self.next_pressed,
                "deleteBackward": self.previous_pressed,
            })
        # fill canvas with background color...
        self["Canvas"].fill(0, 0, 354, 354, bgcolor)

        self.board_cells = []
        self.board_values = []
        # ToDo: change for HD Skins...
        GROUP_SIZE = 108
        CELL_SIZE = 35
        CELL_OFFSET = 4

        for j in range(9):
            tmp = []
            for i in range(9):
                cell = SudokuCell(
                    self["Canvas"],
                    j * (CELL_SIZE + CELL_OFFSET) + (j / 3) *
                    (GROUP_SIZE - 3 * CELL_SIZE),
                    i * (CELL_SIZE + CELL_OFFSET) + (i / 3) *
                    (GROUP_SIZE - 3 * CELL_SIZE), CELL_SIZE, CELL_SIZE)
                tmp.append(cell)
            self.board_cells.append(tmp)

        row = [0, 0, 0, 0, 0, 0, 0, 0, 0]
        for i in range(0, 9):
            self.board_values.append(row[:])

        self.onLayoutFinish.append(self.load_game)
Пример #15
0
    def __init__(self, session, currentTitle, currentUrl, menulist=None):
        Screen.__init__(self, session)

        self.currentUrl = currentUrl
        self.currentTitle = currentTitle

        #Menu
        if menulist is None:
            self.menu = MenuList([
                (_("Bookmarks"), self.MENU_BOOKMARKS),
                (_("History"), self.MENU_HISTORY),
                (_("Downloads"), self.MENU_DOWNLOADS),
                (_("Certificates"), self.MENU_CERTS),
                (_("Cookies"), self.MENU_COOKIES),
                (_("Settings"), self.MENU_SETTINGS),
            ],
                                 enableWrapAround=True)
        else:
            self.menu = MenuList(menulist, enableWrapAround=True)
        self["menu"] = self.menu

        self["statuslabel"] = Label("")
        self["statuslabel"].hide()

        #Color Buttons
        self["button_red"] = Boolean(False)
        self["button_green"] = Boolean(False)
        self["button_yellow"] = Boolean(False)
        self["button_blue"] = Boolean(False)
        self.red = Label("")
        self.green = Label("")
        self.yellow = Label("")
        self.blue = Label("")
        self["red"] = self.red
        self["green"] = self.green
        self["yellow"] = self.yellow
        self["blue"] = self.blue

        #Lists
        self.detailList = List([], enableWrapAround=True)
        self.detailConfigList = ConfigList([])
        self.detailConfigList.l.setSeperation((BrowserMenu.width - 210) / 2)
        config.plugins.WebBrowser.storage.enabled.addNotifier(
            self.__cfgExpandableElementChanged, initial_call=False)
        config.plugins.WebBrowser.storage.enabled.addNotifier(
            self.__cfgStoragePathChanged, initial_call=False)
        config.plugins.WebBrowser.storage.path.addNotifier(
            self.__cfgStoragePathChanged, initial_call=False)

        self.detailInput = EnhancedInput()

        self["list"] = self.detailList
        self["config"] = self.detailConfigList
        self["input"] = self.detailInput
        self["line"] = CanvasSource()

        self.__cfgCreateSetup()

        self.__db = BrowserDB.getInstance()
        self.__curMenu = self.MENU_BOOKMARKS
        self.__bmList = None
        self.__hisList = None
        self.__crtList = None
        self.__ckList = None
        self.__bmNeedle = ""
        self.__bmFilterTimer = eTimer()
        self.__bmFilterTimer_conn = self.__bmFilterTimer.timeout.connect(
            self.__bmFilterCB)
        self.__hisNeedle = ""
        self.__hisFilterTimer = eTimer()
        self.__hisFilterTimer_conn = self.__hisFilterTimer.timeout.connect(
            self.__hisFilterCB)
        self.__dlRefreshTimer = eTimer()
        self.__dlRefreshTimer_conn = self.__dlRefreshTimer.timeout.connect(
            self.__dlBuildList)
        self.__statusTimer = eTimer()
        self.__statusTimer_conn = self.__statusTimer.timeout.connect(
            self.__hideStatus)
        self.__actions = []

        self.onFirstExecBegin.append(self.__drawSeparator)
        self.onFirstExecBegin.append(self.__onMenuChanged)
        self.onExecBegin.append(self.__reloadData)
        self.onShow.append(self.setKeyboardModeAscii)

        self["actions"] = ActionMap(
            ["BrowserActions", "ColorActions"],
            {
                "ok": self.__actionOk,
                "enter": self.__actionOk,
                "exit": self.__actionExit,
                "pageUp": self.__actionMenuUp,
                "pageDown": self.__actionMenuDown,
                "up": boundFunction(self.__action, "up"),
                "down": boundFunction(self.__action, "down"),
                "left": boundFunction(self.__action, "left"),
                "right": boundFunction(self.__action, "right"),
                "red": boundFunction(self.__action, "red"),
                "green": boundFunction(self.__action, "green"),
                "yellow": boundFunction(self.__action, "yellow"),
                "blue": boundFunction(self.__action, "blue"),
                "backspace": boundFunction(self.__action, "backspace"),
                "delete": boundFunction(self.__action, "delete"),
                "ascii": boundFunction(self.__action, "ascii"),
                # TODO "text" : self.__text
            },
            -2)

        self["numberactions"] = NumberActionMap(
            ["NumberActions"], {
                "1": self.__keyNumberGlobal,
                "2": self.__keyNumberGlobal,
                "3": self.__keyNumberGlobal,
                "4": self.__keyNumberGlobal,
                "5": self.__keyNumberGlobal,
                "6": self.__keyNumberGlobal,
                "7": self.__keyNumberGlobal,
                "8": self.__keyNumberGlobal,
                "9": self.__keyNumberGlobal,
                "0": self.__keyNumberGlobal
            }, -2)

        self.__actionFuncs = {
            self.MENU_BOOKMARKS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.selectPrevious,
                "right": self.detailList.pageDown,
                "ok": self.__bmOk,
                "enter": self.__bmOk,
                "red": self.__bmDelete,
                "green": self.__bmAdd,
                "yellow": self.__bmEdit,
                "blue": self.__bmSetCurrentAsHome,
                "backspace": self.__bmKeyBackspace,
                "delete": self.__bmKeyDelete,
                "ascii": self.__bmKeyAscii,
            },
            self.MENU_HISTORY: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "ok": self.__hisOk,
                "enter": self.__hisOk,
                "red": self.__hisClear,
                "blue": self.__hisSetCurrentAsHome,
                "backspace": self.__hisKeyBackspace,
                "delete": self.__hisKeyDelete,
                "ascii": self.__hisKeyAscii,
            },
            self.MENU_SETTINGS: {
                "up": self.__cfgKeyUp,
                "down": self.__cfgKeyDown,
                "left": self.__cfgKeyLeft,
                "right": self.__cfgKeyRight,
                "ok": self.__cfgKeyOK,
                "enter": self.__cfgKeyOK,
                "red": self.__cfgCancel,
                "green": self.__cfgSave,
                "backspace": self.__cfgKeyBackspace,
                "delete": self.__cfgKeyDelete,
                "ascii": self.__cfgKeyAscii,
            },
            self.MENU_DOWNLOADS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__dlAbort,
            },
            self.MENU_CERTS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__crtDelete,
                "green": self.__crtDetails,
            },
            self.MENU_COOKIES: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__ckDelete,
                "blue": self.__ckDeleteAll,
            }
        }
Пример #16
0
    def __init__(self, session):
        # get framebuffer resolution...
        desk = getDesktop(0)
        wdesktop = int(desk.size().width())
        # cellsize depends from framebuffer resolution...
        if wdesktop == 720:
            CELL_SIZE = 20
        elif wdesktop == 1024:
            CELL_SIZE = 30
        elif wdesktop == 1280:
            CELL_SIZE = 40
        else:
            CELL_SIZE = 50
        # calculate skindata...
        CELL_OFFSET = 2
        cellfield = XMAX * CELL_SIZE + (XMAX - 1) * CELL_OFFSET
        CW = 2 * cellfield + 150  # canvas w
        CH = cellfield  # canvas h
        X0_OFFSET = 0  # xoffset cellfield box
        X1_OFFSET = cellfield + 150  # xoffset cellfield you
        W = CW + 10  # window w
        H = CH + 40  # window h
        WX = cellfield + 10  # widgets xoffset
        W0Y = 25  # widget0 yoffset
        W1Y = cellfield - 116  # widget1 yoffset
        W2Y = cellfield - 66  # widget2 yoffset
        W3Y = cellfield - 16  # widget3 yoffset

        # set skin...
        Schiffe.skin = """
            <screen position="center,center" size="%d,%d" title="Schiffe versenken %s" >
                <widget source="Canvas" render="Canvas" position="5,20" size="%d,%d" />
                <widget name="message" position="%d,%d" size="140,40" valign="center" halign="center" font="Regular;21"/>
                <ePixmap name="green"    position="%d,%d"   zPosition="4" size="140,40" pixmap="buttons/green.png" transparent="1" alphatest="on" />
                <ePixmap name="blue" position="%d,%d" zPosition="4" size="140,40" pixmap="buttons/blue.png" transparent="1" alphatest="on" />
                <ePixmap name="red"   position="%d,%d" zPosition="4" size="140,40" pixmap="buttons/red.png" transparent="1" alphatest="on" />
                <widget name="key_green"    position="%d,%d"   zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
                <widget name="key_blue" position="%d,%d" zPosition="5" size="140,40" valign="center" halign="center"  font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
                <widget name="key_red"   position="%d,%d" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
            </screen>""" % (W, H, VERSION, CW, CH, WX, W0Y, WX, W1Y, WX, W2Y,
                            WX, W3Y, WX, W1Y, WX, W2Y, WX, W3Y)

        if isFHD():
            Schiffe.skin = """
                <screen name="Schiffe" position="center,140" size="1800,900" title="Schiffe" backgroundColor="#101010">
                    <ePixmap position="0,0" size="1800,900" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Schiffe/pic/Schiffe.jpg" />
                    <ePixmap position="1050,170" size="130,400" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Schiffe/pic/ship.jpg" zPosition="5" />
                    <widget name="message" position="50,10" size="350,70" valign="center" halign="center" font="Regular;40" foregroundColor="yellow" backgroundColor="#000000" transparent="1" zPosition="1" />
                    <widget source="Canvas" render="Canvas" position="520,150" size="1200,550" backgroundColor="#60ffffff" transparent="1" alphatest="blend" zPosition="2" />
                    <ePixmap position="50,150" pixmap="buttons/key_green.png" size="80,40" alphatest="blend" zPosition="2" />
                    <widget name="key_green" font="Regular;30" position="135,150" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
                    <ePixmap position="50,200" pixmap="buttons/key_red.png" size="80,40" alphatest="blend" zPosition="2" />
                    <widget name="key_red" font="Regular;30" position="135,200" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
                    <ePixmap position="50,250" pixmap="buttons/key_blue.png" size="80,40" alphatest="blend" zPosition="2" />
                    <widget name="key_blue" font="Regular;30" position="135,250" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
                    <eLabel position="50,300" size="300,3" backgroundColor="#202020" zPosition="1" />
                    <ePixmap position="48,332" size="80,80" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Schiffe/pic/rocket.png" alphatest="blend" zPosition="1" />
                    <widget name="result" render="Label" position="131,335" size="200,34" font="Regular;30" halign="left" foregroundColor="yellow" backgroundColor="#000000" transparent="1" zPosition="3" />
                    <widget name="movex" render="Label" position="130,375" size="200,34" font="Regular;30" halign="left" foregroundColor="yellow" backgroundColor="#000000" transparent="1" zPosition="3" />
                </screen>"""

        # get window background color - find xml for actual skin...
        filename = resolveFilename(SCOPE_GUISKIN, "skin.xml")
        actualSkin = parse(filename).getroot()

        # get colors from skin and write to dictionary
        colorNames = dict()
        for c in actualSkin.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] = color

        # find colors for skinned window...
        for windowstyle in actualSkin.findall("windowstyle"):
            # look or skinned window...
            if windowstyle.attrib.get("id") == "0":
                for color in windowstyle.findall("color"):
                    get_attr = color.attrib.get
                    type = get_attr("name")
                    color = get_attr("color")
                    # is it a "named" color?
                    if color[0] != '#':
                        # is "named" color, have to look in dictionary...
                        color = colorNames[color]
                    # at least get the background color...
                    if type == "Background":
                        bgcolor = int(color[1:], 0x10)
        if not bgcolor:
            bgcolor = RGB(0, 0, 0)

        self.skin = Schiffe.skin
        Screen.__init__(self, session)
        self.setTitle("Schiffe versenken %s" % VERSION)
        self["Canvas"] = CanvasSource()
        self["message"] = Label(_("Status"))
        self["key_green"] = Button(_("New Game"))
        self["key_blue"] = Button(_("Solve Game"))
        self["key_red"] = Button(_("Quit Game"))
        self["result"] = Label(_(""))
        self["movex"] = Label(_(""))
        self.cnt = 0
        self.timer = eTimer()
        self.timer.callback.append(self.timerHandler)

        self.message = 0

        self["actions"] = ActionMap(
            ["WizardActions", "ColorActions", "SetupActions"], {
                "ok": self.ok_pressed,
                "up": self.up_pressed,
                "down": self.down_pressed,
                "left": self.left_pressed,
                "right": self.right_pressed,
                "red": self.quit_game,
                "green": self.new_game,
                "blue": self.solve_game,
                "cancel": self.quit_game
            })

        # fill canvas with background color...
        self["Canvas"].fill(0, 0, CW, CH, bgcolor)

        self.you = []
        self.box = []
        self.youCells = []
        self.boxCells = []

        for j in range(YMAX):
            for i in range(XMAX):
                cell = GameCell(self["Canvas"],
                                i * (CELL_SIZE + CELL_OFFSET) + X0_OFFSET,
                                j * (CELL_SIZE + CELL_OFFSET), CELL_SIZE,
                                CELL_SIZE)
                self.boxCells.append(cell)

        for j in range(YMAX):
            for i in range(XMAX):
                cell = GameCell(self["Canvas"],
                                i * (CELL_SIZE + CELL_OFFSET) + X1_OFFSET,
                                j * (CELL_SIZE + CELL_OFFSET), CELL_SIZE,
                                CELL_SIZE)
                self.youCells.append(cell)

        self.onLayoutFinish.append(self.load_game)
Пример #17
0
class Browser(Screen, HelpableScreen):

	def __init__(self, session, fullscreen = False, url = None, isHbbtv = False, isTransparent = False, hbbtvMenu = None):
		size = getDesktop(0).size()
		width = int(size.width() * 0.9)
		fwidth = int(size.width())
		height = int(size.height() * 0.85)
		fheight = int(size.height())

		Browser.skin = """
			<screen name="Browser" position="center,center" size="%(w)d,%(h)d" title="Web Browser" backgroundColor="#FF000000">
				<widget name="cursor" position="0,0" size="19,30" zPosition="1" alphatest="on"/>
				<widget name="url" position="0,0" zPosition="2" size="%(w)d,25" font="Regular;20" halign="left" valign="bottom" backgroundColor="background"/>
				<widget name="loading" position="%(loadingX)d,0" zPosition="3" size="150,25" font="Regular;20" halign="right" valign="bottom" backgroundColor="background"/>
				<widget name="urlList" position="0,30" zPosition="2" size="%(w)d,150" backgroundColor="background"/>
				<widget name="text" position="%(textX)d,100" size="350,40" font="Regular;20"  zPosition="2" halign="center" valign="center" backgroundColor="background"/>
				<widget source="webnavigation" render="WebView" position="0,25" zPosition="0" size="%(w)d,%(mainH)d" transparent="1"/>
				<widget source="canvas" render="Canvas" position="0,25" zPosition="1" size="%(w)d,%(mainH)d" backgroundColor="#FF000000" transparent="1" alphatest="on"/>

				<group name="_buttonBar">
					<widget name="buttonBar" position="0,%(btnBarY)d" size="%(w)d,30" zPosition="0" backgroundColor="background" transparent="0" />
					<ePixmap pixmap="skin_default/buttons/button_red_off.png" position="5,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_red" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_red.png" position="5,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="red" position="25,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1" />

					<ePixmap pixmap="skin_default/buttons/button_green_off.png" position="195,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_green" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_green.png" position="195,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="green" position="215,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<ePixmap pixmap="skin_default/buttons/button_yellow_off.png" position="385,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_yellow" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_yellow.png" position="385,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="yellow" position="405,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<ePixmap pixmap="skin_default/buttons/button_blue_off.png" position="585,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_blue" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_blue.png" position="585,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="blue" position="605,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>
				</group>
				<widget name="statuslabel" position="%(notifX)d,%(btnTxtY)d" size="350,20" font="Regular;18"  zPosition="3" halign="right" valign="center" backgroundColor="background" />
			</screen>
			""" %{	"w" : width,
					"h" : height,
					"loadingX" : width-150,
					"textX" : (width - 375) / 2,
					"mainH" : height-55,
					"btnY" : height-22,
					"btnTxtY" : height-24,
					"btnBarY" : height - 30,
					"notifX" : width-350
				}

		Browser.skinFullscreen = """
			<screen name="BrowserFullscreen" flags="wfNoBorder" position="center,center" size="%(w)d,%(h)d" title="Web Browser" backgroundColor="#FF000000">
				<widget name="cursor" position="0,0" size="19,30" zPosition="1" alphatest="on"/>
				<widget name="url" position="75,75" zPosition="2" size="%(urlW)d,25" font="Regular;20" halign="left" valign="bottom" backgroundColor="background"/>
				<widget name="loading" position="%(loadingX)d,%(loadingY)d" zPosition="2" size="200,50" font="Regular;20" halign="center" valign="center" backgroundColor="background"/>
				<widget name="urlList" position="75,100" zPosition="2" size="%(urlW)d,150" backgroundColor="background" transparent="0" />
				<widget name="text" position="%(textX)d,100" size="350,40" font="Regular;20"  zPosition="2" halign="center" valign="center" backgroundColor="background" transparent="0" />
				<widget source="webnavigation" render="WebView" position="0,0" zPosition="0" size="%(w)d,%(h)d" transparent="1"/>
				<widget source="canvas" render="Canvas" position="0,0" zPosition="1" size="%(w)d,%(h)d" backgroundColor="#FF000000" transparent="1" alphatest="on"/>

				<group name="_buttonBar">
					<widget name="buttonBar" position="%(btnBarX)d,%(btnBarY)d" size="200,110" zPosition="0" backgroundColor="background" transparent="0" />
					<widget source="button_red_off" render="Pixmap" pixmap="skin_default/buttons/button_red_off.png" position="%(btnX)d,%(btnRedY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_red" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_red.png" position="%(btnX)d,%(btnRedY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="red" position="%(btnTxtX)d,%(btnRedY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<widget source="button_green_off" render="Pixmap" pixmap="skin_default/buttons/button_green_off.png" position="%(btnX)d,%(btnGreenY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_green" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_green.png" position="%(btnX)d,%(btnGreenY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="green" position="%(btnTxtX)d,%(btnGreenY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<widget source="button_yellow_off" render="Pixmap" pixmap="skin_default/buttons/button_yellow_off.png" position="%(btnX)d,%(btnYellowY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_yellow" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_yellow.png" position="%(btnX)d,%(btnYellowY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="yellow" position="%(btnTxtX)d,%(btnYellowY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<widget source="button_blue_off" render="Pixmap" pixmap="skin_default/buttons/button_blue_off.png" position="%(btnX)d,%(btnBlueY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_blue" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_blue.png" position="%(btnX)d,%(btnBlueY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="blue" position="%(btnTxtX)d,%(btnBlueY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>
				</group>

				<widget name="statuslabel" position="%(notifX)d,%(loadingY)d" size="350,50" zPosition="1" font="Regular;18" halign="center" valign="center" backgroundColor="background" transparent="0" />
			</screen>
			""" %{	"w" : fwidth,
					"h" : fheight,
					"urlW": fwidth - 150,
					"loadingY" : fheight - 125,
					"loadingX" : ( fwidth / 2 ) - 75,
					"textX" : (fwidth - 375) / 2,
					"mainH" : fheight-55,
					"btnBarX": fwidth - 75 - 200,
					"btnBarY": fheight - 75 - 108,
					"btnX" : fwidth - 75 - 190,
					"btnTxtX" : fwidth - 75 - 165,
					"btnRedY" : fheight - 75 - 100,
					"btnGreenY" : fheight - 75 - 75,
					"btnYellowY" : fheight - 75 - 50,
					"btnBlueY" : fheight - 75 - 25,
					"notifX" : ( fwidth / 2 ) - 175,
				}

		self.__isHbbtv = isHbbtv
		if self.__isHbbtv:
			isTransparent = fullscreen = True

		self.__hbbtvMenu = hbbtvMenu

		self.__isTransparent = isTransparent
		self.__fullscreen = fullscreen
		if self.__fullscreen:
			Browser.skin = Browser.skinFullscreen

		Screen.__init__(self, session)
		HelpableScreen.__init__(self)

		if self.__fullscreen:
			self.skinName = "BrowserFullscreen"

		self.__startUrl = url

		self["loading"] = Label("")

		self.urlInput = EnhancedInput()
		self["url"] = self.urlInput

		self.textInput = Input()
		self["text"] = self.textInput
		self.textInput.hide()

		self.statuslabel = Label("")
		self["statuslabel"] = self.statuslabel
		self.statuslabel.hide();

		self.urlInputEnabled = False

		self.webnavigation = WebNavigation()
		self.webnavigation.zoomFactor = 1.0
		self.__onStoragePathChanged()
		self["webnavigation"] = self.webnavigation

		self.__urlList = MenuList([], enableWrapAround = True, content = eListboxPythonStringContent)
		self["urlList"] = self.__urlList

		self.canvas =  CanvasSource()
		self["canvas"] = self.canvas

		self["buttonBar"] = Label("")
		self["button_red_off"] = Boolean(True)
		self["button_green_off"] = Boolean(True)
		self["button_yellow_off"] = Boolean(True)
		self["button_blue_off"] = Boolean(True)
		self["button_red"] = Boolean(True)
		self["button_green"] = Boolean(False)
		self["button_yellow"] = Boolean(True)
		self["button_blue"] = Boolean(True)
		self["red"] = Label(_("Mouse Off"))
		self["green"] = Label("")
		self["yellow"] = Label(_("Navigation"))
		self["blue"] = Label(_("Pagescroll"))

		self["cursor"] = Pixmap()
		self.__cursorPos = ePoint(50,50)
		self.__mouseMode = False

		self.__db = BrowserDB.getInstance()
		self.pageTitle = ""

		self.__urlSuggestionTimer = eTimer()
		self.__urlSuggestionTimer_conn = self.__urlSuggestionTimer.timeout.connect(self.__onSuggestionTimeout)
		self.__inputTimer = eTimer()
		self.__inputTimer_conn = self.__inputTimer.timeout.connect(self.onInputTimer)
		self.__statusTimer = eTimer()
		self.__statusTimer_conn = self.__statusTimer.timeout.connect(self.__hideStatus)

		self.__scrollMode = False
		self.__zoomMode = False
		self.__isInput = False
		self.__hasSslErrors = False
		self.__handledUnsupportedContent = False
		self.__currentPEM = None
		self.__currentUser = None
		self.__currentPass = None
		self.__currentRealm = None
		self.__keyboardMode = eRCInput.getInstance().getKeyboardMode()

		self.onFirstExecBegin.append(self.__onFirstExecBegin)
		self.onExecEnd = []
		self.onPageLoadFinished = []
		self.onActionTv = []
		self.onActionRecord = []
		self.onUrlChanged = []

		self["helpableactions"] = HelpableActionMap(self, "BrowserActions",
		{
			"exit": (self.__actionExit, _("Close the browser")),
			"url": (self.__actionEnterUrl, _("Enter web address or search term")),
			"back": self.__actionBack,
			"forward": self.__actionForward,
			"left": self.__actionLeft,
			"right": self.__actionRight,
			"up": self.__actionUp,
			"down": self.__actionDown,
			"pageUp": (self.__actionPageUp, _("Page Up / Zoom in")),
			"pageDown": (self.__actionPageDown, _("Page Down / Zoom out")),
			"seekBack": boundFunction(self.__actionNavigate, eWebView.navMediaRewind),
			"seekFwd": boundFunction(self.__actionNavigate, eWebView.navMediaFastForward),
			"tab": (boundFunction(self.__actionNavigate, eWebView.navTab), _("Tab")),
			"backspace": (self.__actionBackspace, _("Backspace / Navigate back")),
			"backtab": boundFunction(self.__actionNavigate, eWebView.navBacktab),
			"delete": (self.__actionDelete, _("Delete / Navigate forward")),
			"ascii": self.__actionAscii,
			"text" : (self.__actionVirtualAscii, _("Open Virtual Keyboard")),
			"ok" : self.__actionOk,
			"enter" : self.__actionEnter,
			"menu" : (self.__actionMenu, _("Menu")),
			"fullscreen" : self.__actionFullscreen,
			"play" : self.__actionPlay,
			"pause" : self.__actionPause,
			"playpause" : self.__actionPlayPause,
			"stop" : self.actionStop,
			"tv" : self.__actionTv,
			"record" : self.__actionRecord,
		}, -2)

		self["coloractions"] = ActionMap(["ColorActions"],
		{
			"red" : self.__actionRed,
			"green" : self.__actionGreen,
			"yellow" : self.__actionYellow,
			"blue" : self.__actionBlue,
		})

		self["numberactions"] = NumberActionMap(["NumberActions"],
		{
			"1": self.keyNumberGlobal,
			"2": self.keyNumberGlobal,
			"3": self.keyNumberGlobal,
			"4": self.keyNumberGlobal,
			"5": self.keyNumberGlobal,
			"6": self.keyNumberGlobal,
			"7": self.keyNumberGlobal,
			"8": self.keyNumberGlobal,
			"9": self.keyNumberGlobal,
			"0": self.keyNumberGlobal
		})

	def execEnd(self):
		Screen.execEnd(self)
		for fnc in self.onExecEnd:
			fnc()

	def setBackgroundTransparent(self, enabled):
		self.webnavigation.setBackgroundTransparent(enabled)

	def __setKeyBoardModeAscii(self):
		eRCInput.getInstance().setKeyboardMode(eRCInput.kmAscii)

	def __unsetKeyBoardModeAscii(self):
		eRCInput.getInstance().setKeyboardMode(self.__keyboardMode)

	def __setStatus(self, text):
		print "[Browser].__setStatus"
		self.statuslabel.setText(text)
		self.statuslabel.show()
		self.__statusTimer.startLongTimer(3)

	def __hideStatus(self):
		self["statuslabel"].hide()
		self.__statusTimer.stop()

	def __setMouseMode(self, enabled):
		self.__mouseMode = enabled
		if enabled:
			self.__setCursor()
			self["cursor"].show()
			self["red"].setText("Mouse On")
			self.__clearCanvas()
		else:
			self["cursor"].hide()
			self["red"].setText("Mouse Off")

	def __actionExit(self):
		if self.__isHbbtv:
			self.__actionExitCB(True)
			return
		self.session.openWithCallback(self.__actionExitCB, MessageBox, _("Do you really want to exit the browser?"), type = MessageBox.TYPE_YESNO)

	def __actionExitCB(self, confirmed):
		if confirmed:
			self.__urlSuggestionTimer.stop()
			self.__inputTimer.stop()
			if not self.__isHbbtv:
				config.plugins.WebBrowser.lastvisited.value = self.webnavigation.url
				config.plugins.WebBrowser.lastvisited.save()
			self.__persistCookies()
			self.close()

	def __onFirstExecBegin(self):
		self["cursor"].instance.setPixmapFromFile(resolveFilename(SCOPE_PLUGINS, "Extensions/Browser/cursor.png"))
		self.__setCursor()
		self.__setMouseMode(self.__mouseMode)

		#enable/disable transparent background
		self.setBackgroundTransparent(self.__isTransparent)
		#set Accept-Language header to current language
		lang = '-'.join(language.getLanguage().split('_'))
		self.webnavigation.setAcceptLanguage(lang)
		self.__registerCallbacks()
		self.__urlList.hide()
		self.__restoreCookies()
		if self.__fullscreen:
			self.__showHideBars(False)
			self.__showHideButtonBar(False)
		if self.__startUrl is None:
			if config.plugins.WebBrowser.startPage.value == "home":
				self.__actionHome()
			else:
				self.setUrl(config.plugins.WebBrowser.lastvisited.value)
		else:
			self.setUrl(self.__startUrl)

	def __clearCanvas(self):
		size = getDesktop(0).size()
		self.canvas.fill(0, 0, size.width(), size.height(), 0xFF000000)
		self.canvas.flush()

	def __onStoragePathChanged(self):
		if config.plugins.WebBrowser.storage.enabled.value:
			self.webnavigation.enablePersistentStorage(config.plugins.WebBrowser.storage.path.value)

	def __onMicroFocusChanged(self, x, y, w, h, isInput):
		if not self.__isHbbtv and not self.__mouseMode:
			self.__cursorPos.setX(x)
			self.__cursorPos.setY(y)

			if self.__isInput and not isInput:
				self.__unsetKeyBoardModeAscii()

			self.__isInput = isInput
			if self.__isInput:
				self.setKeyboardModeAscii()

			self.__clearCanvas()
			lw = 4 #line width
			y = y
			x = x - lw
			w = w + lw
			blo = y + h #bottom line offset
			color =0xFF9900 #line color

			self.canvas.fill(x, y, lw, h, color)#left line
			self.canvas.fill(x, blo, w, lw, color)#bottom line
			self.canvas.flush()#Done -> Flush

	def __onSuggestionTimeout(self):
		needle = self.urlInput.getText()
		if needle != "":
			list = self.__db.suggsetUrls(self.urlInput.getText())
			list.insert(0, needle)
			list.insert(1, _("Search for '%s'") %needle)
			self.__urlList.setList(list)
			self.__urlList.moveToIndex(0)
			self.__urlList.show()
		else:
			self.__urlList.hide()

	def __onAuthRequired(self, token, user, password, realm):
		if self.__currentUser != None and self.__currentPassword != None and realm == self.__currentRealm:
			d = eDict()
			d.setString("user", self.__currentUser)
			d.setString("password", self.__currentPassword)
			self.webnavigation.setDict(token, d)
			self.__currentUser = None
			self.__currentPassword = None
			self.__currentRealm = None
		else:
			msgbox = self.session.openWithCallback(self.__onAuthRequiredCB, HttpAuthenticationDialog, user, password, realm)
			msgbox.setTitle(_("Authentication required"))

	def __onAuthRequiredCB(self, dict):
		if dict != None:
			self.__currentUser = dict["user"]
			self.__currentPassword = dict["password"]
			self.__currentRealm = dict["realm"]
			self.setUrl(self.webnavigation.url)

	def __onProxyAuthRequired(self, token, user, password, realm):
		self.onAuthRequired(token, user, password, realm)

	def __onDownloadRequested(self, url):
		print "[Browser].__onDownloadRequested '%s'" %(url)
		filename = url_unquote(url).split("/")[-1]
		localfile = "%s/%s" %(config.plugins.WebBrowser.downloadpath.value, filename)
		downloadManager.AddJob(DownloadJob(url, localfile, filename))
		self.session.open(MessageBox, _("Download started..."), type = MessageBox.TYPE_INFO, timeout = 3)

	def __onUnsupportedContent(self, url, contentType):
		print "[Browser].__onUnsupportedContent 'url=%s; contentType='%s'" %(url, contentType)
		self.__handledUnsupportedContent = True
		if contentType.startswith("video") or contentType.startswith("audio"):
			list = [( _("Download"), ("download", url) ),
					( _("Play"), ("play", url) )]
			self.session.openWithCallback(self.__onUnsupportedContentCB, ChoiceBox, title=_("You've selected a media file what do you want to do?"), list = list)
		else:
			self.__onDownloadRequested(url)

	def __onUnsupportedContentCB(self, answer):
		if answer != None:
			answer = answer and answer[1]
			if answer[0] == "download":
				self.__onDownloadRequested(answer[1])
			else:
				service = eServiceReference(4097,0,answer[1])
				self.session.open(MoviePlayer, service)

	def __actionMenu(self):
		if self.__isHbbtv:
			if self.__hbbtvMenu is not None:
				self.__hbbtvMenu()
			return

		self.__urlSuggestionTimer.stop()
		self.__inputTimer.stop()
		self.__urlList.hide()
		self.__persistCookies()
		self.session.openWithCallback(self.__menuCB, BrowserMenu, self.pageTitle, self.webnavigation.url)

	def __menuCB(self, actions = None):
		if actions != None:
			for action in actions:
				if action[0] == BrowserMenu.ACTION_BOOKMARK:
					self.setUrl(action[1])
				elif action[0] == BrowserMenu.ACTION_COOKIES:
					self.__restoreCookies()
				elif action[0] == BrowserMenu.ACTION_STORAGE_PATH:
					self.__onStoragePathChanged()

		if self.skinName == "BrowserFullscreen" and not config.plugins.WebBrowser.fullscreen.value:
			self.__requireRestart()
		if self.skinName != "BrowserFullscreen" and config.plugins.WebBrowser.fullscreen.value:
			self.__requireRestart()

	def __requireRestart(self):
		text = _("Some of the configuration changes require a restart of the Browser.\nDo you want to restart the Browser now?")
		msgbox = self.session.openWithCallback(self.__requireRestartCB, MessageBox, text, type = MessageBox.TYPE_YESNO)
		msgbox.setTitle(_("Restart required"))

	def __requireRestartCB(self, confirmed):
		if confirmed:
			self.close(self.session, True, self.webnavigation.url)

	def __enableUrlInput(self):
		self.urlInputEnabled = True
		self.urlInput.markAll()
		self.__setKeyBoardModeAscii()
		if self.__fullscreen:
			self.__showHideBars()

	def __disableUrlInput(self, hide = True):
		self.urlInputEnabled = False
		self.__urlSuggestionTimer.stop()
		self.__urlList.hide()
		self.urlInput.markNone()
		if not self.__isInput:
			self.__unsetKeyBoardModeAscii()
		if self.__fullscreen and hide:
			self.__showHideBars(False)

	def __showHideButtonBar(self, visible = True):
		if visible:
			self["_buttonBar"].show()
		else:
			self["_buttonBar"].hide()
			
		used_buttons = ("button_red_off", "button_green_off", "button_yellow_off",
			"button_blue_off", "button_red", "button_yellow", "button_blue")
		for button in used_buttons:
			self[button].setBoolean(visible)
		#disable green
		self["button_green"].setBoolean(False)

	def __showHideBars(self, visible = True):
		if self.__fullscreen:
			if visible:
				self.urlInput.show()
			else:
				self.urlInput.hide()

			if not self.__isHbbtv:
				self.__showHideButtonBar(visible)

	def __registerCallbacks(self):
		print "[Browser].__registerCallbacks"
		self.webnavigation.onUrlChanged.append(self.__onUrlChanged)
		self.webnavigation.onTitleChanged.append(self.__onTitleChanged)
		self.webnavigation.onLoadProgress.append(self.__onLoadProgress)
		self.webnavigation.onLoadFinished.append(self.__onLoadFinished)
		self.webnavigation.onDownloadRequested.append(self.__onDownloadRequested)
		self.webnavigation.onUnsupportedContent.append(self.__onUnsupportedContent)
		self.webnavigation.onMicroFocusChanged.append(self.__onMicroFocusChanged)
		self.webnavigation.onWindowRequested.append(self.__onWindowRequested)
		self.webnavigation.onSslErrors.append(self.__onSslErrors)
		self.webnavigation.onAuthRequired.append(self.__onAuthRequired)
		self.webnavigation.onProxyAuthRequired.append(self.__onProxyAuthRequired)

	def __actionOk(self):
		if self.textInput.visible:
			self.onInputTimer()
		elif self.urlInputEnabled:
			if self.__urlList.visible and self.__urlList.getSelectedIndex() > 0:
				if self.__urlList.getSelectedIndex() == 1:
					self.__searchUsingCurrentUrlValue()
					self.__disableUrlInput(False)
				else:
					self.urlInput.setText(self.__urlList.getCurrent())
					self.urlInput.end()
					self.__urlList.hide()
			else:
				self.setUrl(self.urlInput.getText())
				self.__isInput = False
				self.__disableUrlInput(False)

		else:
			if self.__mouseMode:
				self.webnavigation.leftClick(self.__cursorPos)
			else:
				self.__actionNavigate(eWebView.navOpenLink)

	def __actionEnter(self):
		if self.textInput.visible or self.urlInputEnabled:
			self.__actionOk()
		else:
			if self.__mouseMode:
				self.webnavigation.leftClick(self.__cursorPos)
			else:
				self.__actionNavigate(eWebView.navOpenLink)

	def __actionPlay(self):
		self.__actionNavigate(eWebView.navMediaPlay)

	def __actionPause(self):
		self.__actionNavigate(eWebView.navMediaPause)

	def __actionPlayPause(self):
		self.__actionNavigate(eWebView.navMediaPlay) #playpause doesn't work anywhere, but play does (HBBTV)

	def actionStop(self):
		self.__actionNavigate(eWebView.navMediaStop)

	def __actionBack(self):
		if self.__isHbbtv:
			self.__actionNavigate(eWebView.navBack)
		else:
			self.__actionNavigate(eWebView.navBackExplicit)

	def __actionForward(self):
		if self.__isHbbtv:
			self.__actionNavigate(eWebView.navForward)
		else:
			self.__actionNavigate(eWebView.navForwardExplicit)

	def __actionBackspace(self):
		if self.textInput.visible:
			self.restartTimer()
			self.textInput.deleteBackward()
		elif self.urlInputEnabled:
			self.urlInput.deleteBackward()
			self.__onUrlInputChanged()
		else:
			if self.__isInput:
				self.__actionNavigate(eWebView.navBackspace)
			else:
				self.__actionBack()

	def __actionDelete(self):
		if self.textInput.visible:
			self.restartTimer()
			self.textInput.delete()
		elif self.urlInputEnabled:
			self.urlInput.delete()
			self.__onUrlInputChanged()
		else:
			if self.__isInput:
				self.__actionNavigate(eWebView.navDelete)
			else:
				self.__actionForward()

	def __moveCursor(self, x=0, y=0):
		if x != 0 or y != 0:
			wSize = self.webnavigation.size
			#horizontal
			if x != 0:
				x = self.__cursorPos.x() + x
				w = wSize.width()
				if x <= 2:
					x = 2
					self.__scroll(0-int(config.plugins.WebBrowser.scrollOffset.value), 0)
				elif x >= w-2:
					x = w-2
					self.__scroll(int(config.plugins.WebBrowser.scrollOffset.value), 0)
				self.__cursorPos.setX(x)
			#vertical
			if y != 0:
				y = self.__cursorPos.y() + y
				h = wSize.height()
				if y < 2:
					y = 2
					self.__scroll(0, 0-int(config.plugins.WebBrowser.scrollOffset.value))
				elif y > h-2:
					y = h-2
					self.__scroll(0, int(config.plugins.WebBrowser.scrollOffset.value))
				self.__cursorPos.setY(y)
		self.__setCursor()

	def __setCursor(self):
		wPos = self.webnavigation.position
		relPos = None
		if wPos.x() > 0 or wPos.y() > 0:
			relPos = ePoint(self.__cursorPos.x() + wPos.x(), self.__cursorPos.y() + wPos.y())
		else:
			relPos = self.__cursorPos
		self["cursor"].move(relPos)

	def __actionLeft(self):
		if self.urlInputEnabled:
			self.urlInput.left()
		elif self.__scrollMode:
			self.__scroll(0-int(config.plugins.WebBrowser.scrollOffset.value), 0)
		elif self.textInput.visible:
			self.restartTimer()
			self.textInput.left()
		else:
			if self.__mouseMode:
				self.__moveCursor(x=-10)
			else:
				self.__actionNavigate(eWebView.navLeft)

	def __actionRight(self):
		if self.urlInputEnabled:
			self.urlInput.right()
		elif self.__scrollMode:
			self.__scroll(int(config.plugins.WebBrowser.scrollOffset.value), 0)
		elif self.textInput.visible:
			self.restartTimer()
			self.textInput.right()
		else:
			if self.__mouseMode:
				self.__moveCursor(x=10)
			else:
				self.__actionNavigate(eWebView.navRight)

	def __actionUp(self):
		if self.urlInputEnabled:
			if self.__urlList.visible:
				self.__urlList.up()
		elif self.__scrollMode:
			self.__scroll(0, 0-int(config.plugins.WebBrowser.scrollOffset.value))
		elif self.textInput.visible:
			self.restartTimer()
			self.textInput.up()
		else:
			if self.__mouseMode:
				self.__moveCursor(y=-10)
			else:
				self.__actionNavigate(eWebView.navUp)

	def __actionDown(self):
		if self.urlInputEnabled:
			if self.__urlList.visible:
				self.__urlList.down()
			#else:
			#	self.urlInput.down()
		elif self.__scrollMode:
			self.__scroll(0, int(config.plugins.WebBrowser.scrollOffset.value))
		elif self.textInput.visible:
			self.restartTimer()
			self.textInput.down()
		else:
			if self.__mouseMode:
				self.__moveCursor(y=10)
			else:
				self.__actionNavigate(eWebView.navDown)

	def __actionTv(self):
		for fnc in self.onActionTv:
			if fnc() is True: #Function told us to stop handling
				return

	def __actionRecord(self):
		for fnc in self.onActionRecord:
			if fnc() is True: #Function told us to stop handling
				return

	def __scroll(self, dx, dy):
		self.webnavigation.scroll(dx, dy)

	def __actionRed(self):
		if self.__isHbbtv:
			self.__actionNavigate(eWebView.navRed)
		else:
			self.__setMouseMode(not self.__mouseMode)

	def __actionGreen(self):
		self.__actionNavigate(eWebView.navGreen)

	def __actionYellow(self):
		if self.__isHbbtv:
			self.__actionNavigate(eWebView.navYellow)
		else:
			self.__scrollMode = not self.__scrollMode
			enDis = _("disabled")
			mode = _("Navigation")
			if self.__scrollMode:
				enDis = _("enabled")
				mode = _("Scrolling")
			text = _("Scroll mode is now %s") %enDis
			self["yellow"].setText(mode)
			self.__setStatus(text)

	def __actionBlue(self):
		if self.__isHbbtv:
			self.__actionNavigate(eWebView.navBlue)
		else:
			self.__zoomMode = not self.__zoomMode
			enDis = _("disabled")
			mode = _("Pagescroll")
			if self.__zoomMode:
				enDis = _("enabled")
				mode = _("Zoom")
			text = _("Zoom mode is now %s") %enDis
			self["blue"].setText(mode)
			self.__setStatus(text)

	def restartTimer(self):
		self.__inputTimer.stop()
		self.__inputTimer.startLongTimer(5)

	def __onUrlChanged(self, url):
		if url != None:
			self.__clearCanvas()
			self.urlInput.setText(url)
			self.urlInput.markNone()
			if self.__fullscreen and not self.__isHbbtv:
				self.__showHideBars()

			for fnc in self.onUrlChanged:
				fnc(url)

	def __onTitleChanged(self, title):
		if title != None:
			self.pageTitle = title
			self.setTitle("Web Browser - %s" %self.pageTitle)

	def __onLoadProgress(self, progress):
		print "[Browser].__onLoadProgress %s" %progress
		if(progress < 100):
			self["loading"].show()
			self["loading"].setText(_("Loading... %s%%" %progress))
		else:
			self["loading"].hide()
			self["loading"].setText("")

	def __onLoadFinished(self, val):
		print "[Browser].__onLoadFinished %s" %val
		if val == 1:
			if not self.__isHbbtv:
				self.__db.addToHistory(HistoryItem(title = self.pageTitle, url = self.webnavigation.url));
			if self.__fullscreen:
				self.__showHideBars(False)
		else:
			if not self.__hasSslErrors and not self.__handledUnsupportedContent:
				self.__handledUnsupportedContent = False
		for fnc in self.onPageLoadFinished:
			fnc()

	def __searchUsingCurrentUrlValue(self):
		needle = self.urlInput.getText()
		if needle != "":
			needle = needle.replace("http://", "").replace("https://", "").replace("ftp://", "")
			self.__onSearchRequested(needle)

	def __onSearchRequested(self, needle):
		if needle != "" and needle != None:
			needle = url_quote_plus(needle)
			url = "%s%s" %(config.plugins.WebBrowser.searchProvider.value, needle)
			self.setUrl(url)

	def __onWindowRequested(self, url):
		print "[Browser].__onWindowRequested :: '%s'" %url
		self.setUrl(url)

	def __onSslErrors(self, token, errors, pems):
		print "[Browser].__onSslErrors :: 'token='%s', errors='%s'" %(token, errors)
		self.__hasSslErrors = True
		cnt = 0
		perrors = {}
		pems = list(pems)
		pems.sort()
		for bytes in pems:
			pem = "".join(map(chr, bytes))
			if pem.strip() != "":
				messages = perrors.get(pem, [])
				messages.append(errors[cnt])
				perrors[pem] = messages
				cnt += 1

		for pem, messages in perrors.iteritems():
			cert = Certificate(-1, self.__getCurrentNetloc(), pem)
			checkVal = self.__db.checkCert( cert ) == BrowserDB.CERT_UNKOWN
			if checkVal == BrowserDB.CERT_OK:
				print "[Browser].__onSslErrors :: netloc/pem combination known and trusted!"
				dict = eDict()
				dict.setFlag("ignore")
				self.webnavigation.setDict(token, dict)
			else:
				print "[Browser].__onSslErrors :: netloc/pem combination NOT known and/or trusted!"
				self.__currentPEM = pem

				errorstr = ""
				for m in messages:
					errorstr = "%s\n%s" %(m, errorstr)

				text = ""
				if checkVal == BrowserDB.CERT_UNKOWN:
					text = _("A certificate for the desired secure connection has the following errors:\n%s\nDo you want to add an exception for this certificate and accept connections to this host anyways?") %errorstr
				elif checkVal == BrowserDB.CERT_CHANGED:
					text = _("ATTENTION!\nPotential security breach detected!\nA certificate for the desired secure connection has CHANGED!\nIn addition it has the following errors:\n%s\nDo you want to add an exception for this certificate and accept connections to this host anyways?") %errorstr
				msgbox = self.session.openWithCallback( self.__onSslErrorCB, MessageBox, text, type = MessageBox.TYPE_YESNO)
				msgbox.setTitle(_("Certificate errors!"))

	def __onSslErrorCB(self, confirmed):
		self.__hasSslErrors = False
		if confirmed:
			print "[Browser].__onSslErrorCB :: loc='%s', PEM='%s'" %(self.__getCurrentNetloc(), self.__currentPEM)
			self.__db.addCert( Certificate(-1, self.__getCurrentNetloc(), self.__currentPEM) )
			self.setUrl(self.webnavigation.url)

	def __getCurrentNetloc(self):
		return self.__getNetloc(self.webnavigation.url)

	def __getNetloc(self, url):
		return urlparse(url).netloc

	def __actionHome(self):
		self.setUrl(config.plugins.WebBrowser.home.value)

	def __actionEnterUrl(self):
		if self.urlInputEnabled:
			self.__disableUrlInput()
		else:
			self.__enableUrlInput()

	def setUrl(self, url):
		if url != None:
			if url.find("://") == -1:
				url = "http://%s" %url
			if url:
				self.webnavigation.url = url

	def getUserAgent(self):
		return self.webnavigation.useragent

	def setUserAgent(self, useragent):
		self.webnavigation.useragent = useragent

	def __actionAscii(self):
		if self.urlInputEnabled:
			self.urlInput.handleAscii(getPrevAsciiCode())
			self.__onUrlInputChanged()
		elif self.__isInput:
			self.webnavigation.changed(WebNavigation.COMMAND_ASCII_INPUT, getPrevAsciiCode())
		else:
			self.__actionNavigateNumber(chr(getPrevAsciiCode()))

	def __actionNavigateNumber(self, char):
		print "[Browser].__actionNavigateNumber %s" %char
		nav = { '0' : eWebView.nav0,
				'1' : eWebView.nav1,
				'2' : eWebView.nav2,
				'3' : eWebView.nav3,
				'4' : eWebView.nav4,
				'5' : eWebView.nav5,
				'6' : eWebView.nav6,
				'7' : eWebView.nav7,
				'8' : eWebView.nav8,
				'9' : eWebView.nav9,
				}

		action = nav.get(str(char), None)
		if action != None:
			if self.__mouseMode:
				self.__actionMouseJump(char)
			else:
				self.__actionNavigate(action)

	def __actionMouseJump(self, char):
		size = self.webnavigation.size
		off = 100 #offset

		hcenter = size.width() / 2
		vcenter = size.height() / 2

		roff = size.width() - off #right offset
		boff = size.height() - off # bottom offset

		offsets = {
			'1' : [off,off],
			'2' : [hcenter, off],
			'3' : [roff, off],
			'4' : [off, vcenter],
			'5' : [hcenter, vcenter],
			'6' : [roff, vcenter],
			'7' : [off, boff],
			'8' : [hcenter, boff],
			'9' : [roff, boff],
			}
		offset = offsets.get(str(char), None)
		if offset:
			self.__cursorPos.setX(offset[0])
			self.__cursorPos.setY(offset[1])
			self.__setCursor()

	def __actionVirtualAscii(self):
		self.session.openWithCallback(self.sendTextAsAscii, VirtualKeyBoard, title="Browser Input")

	def __actionPageUp(self):
		if self.__zoomMode:
			self.webnavigation.zoomFactor += 0.1
		else:
			self.__actionNavigate(eWebView.navPageUp)

	def __actionPageDown(self):
		if self.__zoomMode:
			self.webnavigation.zoomFactor -= 0.1
		else:
			self.__actionNavigate(eWebView.navPageDown)

	def sendTextAsAscii(self, text):
		if text != None:
			for c in text:
				self.webnavigation.changed(WebNavigation.COMMAND_ASCII_INPUT, ord(c))

	def __actionNavigate(self, param):
		if not self.urlInputEnabled and not self.textInput.visible:
			self.webnavigation.changed(WebNavigation.COMMAND_NAVIGATE, param)

	def keyNumberGlobal(self, number):
		if self.urlInputEnabled:
			self.urlInput.number(number)
			self.__onUrlInputChanged()
		elif self.__isInput:
			self.textInput.show()
			self.restartTimer()
			self.textInput.number(number)
		else:
			self.__actionNavigateNumber(number)

	def __onUrlInputChanged(self):
		if not self.__urlSuggestionTimer.isActive():
			self.__urlSuggestionTimer.startLongTimer(1)

	def onInputTimer(self):
		self.__inputTimer.stop()
		self.textInput.hide()
		text = self.textInput.getText()
		self.textInput.setText("")
		if text != "" and text != None:
			self.sendTextAsAscii(text)

	def __actionFullscreen(self):
		self.webnavigation.size = (self.width, self.height)
		self.webnavigation.position = (0, 0)

	def __restoreCookies(self):
		cookies = self.__db.getCookies()
		print "[Browser].__restoreCookies ::: restoring %s cookies" %len(cookies)
		rawCookies = []
		for cookie in cookies:
			rawCookies.append( b64encode(cookie.raw) )
		self.webnavigation.cookies = ','.join(rawCookies)

	def __persistCookies(self):
		rawCookies = self.webnavigation.cookies
		if rawCookies.strip() != "":
			rawCookies = rawCookies.split(",")
			cookies = []
			cookie = None
			for rawCookie in rawCookies:
				cookie = Cookie.fromRawString(b64decode(rawCookie))
				if cookie != None:
					cookies.append( cookie )
			print "[Browser].__persistCookies ::: persisting %s cookies" %len(cookies)
			self.__db.persistCookies(cookies)
		else:
			print "[Browser].__persistCookies ::: NO cookies to be persisted"
Пример #18
0
	def __init__(self, session, fullscreen = False, url = None, isHbbtv = False, isTransparent = False, hbbtvMenu = None):
		size = getDesktop(0).size()
		width = int(size.width() * 0.9)
		fwidth = int(size.width())
		height = int(size.height() * 0.85)
		fheight = int(size.height())

		Browser.skin = """
			<screen name="Browser" position="center,center" size="%(w)d,%(h)d" title="Web Browser" backgroundColor="#FF000000">
				<widget name="cursor" position="0,0" size="19,30" zPosition="1" alphatest="on"/>
				<widget name="url" position="0,0" zPosition="2" size="%(w)d,25" font="Regular;20" halign="left" valign="bottom" backgroundColor="background"/>
				<widget name="loading" position="%(loadingX)d,0" zPosition="3" size="150,25" font="Regular;20" halign="right" valign="bottom" backgroundColor="background"/>
				<widget name="urlList" position="0,30" zPosition="2" size="%(w)d,150" backgroundColor="background"/>
				<widget name="text" position="%(textX)d,100" size="350,40" font="Regular;20"  zPosition="2" halign="center" valign="center" backgroundColor="background"/>
				<widget source="webnavigation" render="WebView" position="0,25" zPosition="0" size="%(w)d,%(mainH)d" transparent="1"/>
				<widget source="canvas" render="Canvas" position="0,25" zPosition="1" size="%(w)d,%(mainH)d" backgroundColor="#FF000000" transparent="1" alphatest="on"/>

				<group name="_buttonBar">
					<widget name="buttonBar" position="0,%(btnBarY)d" size="%(w)d,30" zPosition="0" backgroundColor="background" transparent="0" />
					<ePixmap pixmap="skin_default/buttons/button_red_off.png" position="5,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_red" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_red.png" position="5,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="red" position="25,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1" />

					<ePixmap pixmap="skin_default/buttons/button_green_off.png" position="195,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_green" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_green.png" position="195,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="green" position="215,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<ePixmap pixmap="skin_default/buttons/button_yellow_off.png" position="385,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_yellow" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_yellow.png" position="385,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="yellow" position="405,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<ePixmap pixmap="skin_default/buttons/button_blue_off.png" position="585,%(btnY)d" size="15,16" alphatest="on" />
					<widget source="button_blue" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_blue.png" position="585,%(btnY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="blue" position="605,%(btnTxtY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>
				</group>
				<widget name="statuslabel" position="%(notifX)d,%(btnTxtY)d" size="350,20" font="Regular;18"  zPosition="3" halign="right" valign="center" backgroundColor="background" />
			</screen>
			""" %{	"w" : width,
					"h" : height,
					"loadingX" : width-150,
					"textX" : (width - 375) / 2,
					"mainH" : height-55,
					"btnY" : height-22,
					"btnTxtY" : height-24,
					"btnBarY" : height - 30,
					"notifX" : width-350
				}

		Browser.skinFullscreen = """
			<screen name="BrowserFullscreen" flags="wfNoBorder" position="center,center" size="%(w)d,%(h)d" title="Web Browser" backgroundColor="#FF000000">
				<widget name="cursor" position="0,0" size="19,30" zPosition="1" alphatest="on"/>
				<widget name="url" position="75,75" zPosition="2" size="%(urlW)d,25" font="Regular;20" halign="left" valign="bottom" backgroundColor="background"/>
				<widget name="loading" position="%(loadingX)d,%(loadingY)d" zPosition="2" size="200,50" font="Regular;20" halign="center" valign="center" backgroundColor="background"/>
				<widget name="urlList" position="75,100" zPosition="2" size="%(urlW)d,150" backgroundColor="background" transparent="0" />
				<widget name="text" position="%(textX)d,100" size="350,40" font="Regular;20"  zPosition="2" halign="center" valign="center" backgroundColor="background" transparent="0" />
				<widget source="webnavigation" render="WebView" position="0,0" zPosition="0" size="%(w)d,%(h)d" transparent="1"/>
				<widget source="canvas" render="Canvas" position="0,0" zPosition="1" size="%(w)d,%(h)d" backgroundColor="#FF000000" transparent="1" alphatest="on"/>

				<group name="_buttonBar">
					<widget name="buttonBar" position="%(btnBarX)d,%(btnBarY)d" size="200,110" zPosition="0" backgroundColor="background" transparent="0" />
					<widget source="button_red_off" render="Pixmap" pixmap="skin_default/buttons/button_red_off.png" position="%(btnX)d,%(btnRedY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_red" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_red.png" position="%(btnX)d,%(btnRedY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="red" position="%(btnTxtX)d,%(btnRedY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<widget source="button_green_off" render="Pixmap" pixmap="skin_default/buttons/button_green_off.png" position="%(btnX)d,%(btnGreenY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_green" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_green.png" position="%(btnX)d,%(btnGreenY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="green" position="%(btnTxtX)d,%(btnGreenY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<widget source="button_yellow_off" render="Pixmap" pixmap="skin_default/buttons/button_yellow_off.png" position="%(btnX)d,%(btnYellowY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_yellow" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_yellow.png" position="%(btnX)d,%(btnYellowY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="yellow" position="%(btnTxtX)d,%(btnYellowY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>

					<widget source="button_blue_off" render="Pixmap" pixmap="skin_default/buttons/button_blue_off.png" position="%(btnX)d,%(btnBlueY)d" size="15,16" zPosition="1" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget source="button_blue" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_blue.png" position="%(btnX)d,%(btnBlueY)d" size="15,16" alphatest="on">
						<convert type="ConditionalShowHide" />
					</widget>
					<widget name="blue" position="%(btnTxtX)d,%(btnBlueY)d" size="160,25" zPosition="1" font="Regular;18" halign="left" valign="top" backgroundColor="background" transparent="1"/>
				</group>

				<widget name="statuslabel" position="%(notifX)d,%(loadingY)d" size="350,50" zPosition="1" font="Regular;18" halign="center" valign="center" backgroundColor="background" transparent="0" />
			</screen>
			""" %{	"w" : fwidth,
					"h" : fheight,
					"urlW": fwidth - 150,
					"loadingY" : fheight - 125,
					"loadingX" : ( fwidth / 2 ) - 75,
					"textX" : (fwidth - 375) / 2,
					"mainH" : fheight-55,
					"btnBarX": fwidth - 75 - 200,
					"btnBarY": fheight - 75 - 108,
					"btnX" : fwidth - 75 - 190,
					"btnTxtX" : fwidth - 75 - 165,
					"btnRedY" : fheight - 75 - 100,
					"btnGreenY" : fheight - 75 - 75,
					"btnYellowY" : fheight - 75 - 50,
					"btnBlueY" : fheight - 75 - 25,
					"notifX" : ( fwidth / 2 ) - 175,
				}

		self.__isHbbtv = isHbbtv
		if self.__isHbbtv:
			isTransparent = fullscreen = True

		self.__hbbtvMenu = hbbtvMenu

		self.__isTransparent = isTransparent
		self.__fullscreen = fullscreen
		if self.__fullscreen:
			Browser.skin = Browser.skinFullscreen

		Screen.__init__(self, session)
		HelpableScreen.__init__(self)

		if self.__fullscreen:
			self.skinName = "BrowserFullscreen"

		self.__startUrl = url

		self["loading"] = Label("")

		self.urlInput = EnhancedInput()
		self["url"] = self.urlInput

		self.textInput = Input()
		self["text"] = self.textInput
		self.textInput.hide()

		self.statuslabel = Label("")
		self["statuslabel"] = self.statuslabel
		self.statuslabel.hide();

		self.urlInputEnabled = False

		self.webnavigation = WebNavigation()
		self.webnavigation.zoomFactor = 1.0
		self.__onStoragePathChanged()
		self["webnavigation"] = self.webnavigation

		self.__urlList = MenuList([], enableWrapAround = True, content = eListboxPythonStringContent)
		self["urlList"] = self.__urlList

		self.canvas =  CanvasSource()
		self["canvas"] = self.canvas

		self["buttonBar"] = Label("")
		self["button_red_off"] = Boolean(True)
		self["button_green_off"] = Boolean(True)
		self["button_yellow_off"] = Boolean(True)
		self["button_blue_off"] = Boolean(True)
		self["button_red"] = Boolean(True)
		self["button_green"] = Boolean(False)
		self["button_yellow"] = Boolean(True)
		self["button_blue"] = Boolean(True)
		self["red"] = Label(_("Mouse Off"))
		self["green"] = Label("")
		self["yellow"] = Label(_("Navigation"))
		self["blue"] = Label(_("Pagescroll"))

		self["cursor"] = Pixmap()
		self.__cursorPos = ePoint(50,50)
		self.__mouseMode = False

		self.__db = BrowserDB.getInstance()
		self.pageTitle = ""

		self.__urlSuggestionTimer = eTimer()
		self.__urlSuggestionTimer_conn = self.__urlSuggestionTimer.timeout.connect(self.__onSuggestionTimeout)
		self.__inputTimer = eTimer()
		self.__inputTimer_conn = self.__inputTimer.timeout.connect(self.onInputTimer)
		self.__statusTimer = eTimer()
		self.__statusTimer_conn = self.__statusTimer.timeout.connect(self.__hideStatus)

		self.__scrollMode = False
		self.__zoomMode = False
		self.__isInput = False
		self.__hasSslErrors = False
		self.__handledUnsupportedContent = False
		self.__currentPEM = None
		self.__currentUser = None
		self.__currentPass = None
		self.__currentRealm = None
		self.__keyboardMode = eRCInput.getInstance().getKeyboardMode()

		self.onFirstExecBegin.append(self.__onFirstExecBegin)
		self.onExecEnd = []
		self.onPageLoadFinished = []
		self.onActionTv = []
		self.onActionRecord = []
		self.onUrlChanged = []

		self["helpableactions"] = HelpableActionMap(self, "BrowserActions",
		{
			"exit": (self.__actionExit, _("Close the browser")),
			"url": (self.__actionEnterUrl, _("Enter web address or search term")),
			"back": self.__actionBack,
			"forward": self.__actionForward,
			"left": self.__actionLeft,
			"right": self.__actionRight,
			"up": self.__actionUp,
			"down": self.__actionDown,
			"pageUp": (self.__actionPageUp, _("Page Up / Zoom in")),
			"pageDown": (self.__actionPageDown, _("Page Down / Zoom out")),
			"seekBack": boundFunction(self.__actionNavigate, eWebView.navMediaRewind),
			"seekFwd": boundFunction(self.__actionNavigate, eWebView.navMediaFastForward),
			"tab": (boundFunction(self.__actionNavigate, eWebView.navTab), _("Tab")),
			"backspace": (self.__actionBackspace, _("Backspace / Navigate back")),
			"backtab": boundFunction(self.__actionNavigate, eWebView.navBacktab),
			"delete": (self.__actionDelete, _("Delete / Navigate forward")),
			"ascii": self.__actionAscii,
			"text" : (self.__actionVirtualAscii, _("Open Virtual Keyboard")),
			"ok" : self.__actionOk,
			"enter" : self.__actionEnter,
			"menu" : (self.__actionMenu, _("Menu")),
			"fullscreen" : self.__actionFullscreen,
			"play" : self.__actionPlay,
			"pause" : self.__actionPause,
			"playpause" : self.__actionPlayPause,
			"stop" : self.actionStop,
			"tv" : self.__actionTv,
			"record" : self.__actionRecord,
		}, -2)

		self["coloractions"] = ActionMap(["ColorActions"],
		{
			"red" : self.__actionRed,
			"green" : self.__actionGreen,
			"yellow" : self.__actionYellow,
			"blue" : self.__actionBlue,
		})

		self["numberactions"] = NumberActionMap(["NumberActions"],
		{
			"1": self.keyNumberGlobal,
			"2": self.keyNumberGlobal,
			"3": self.keyNumberGlobal,
			"4": self.keyNumberGlobal,
			"5": self.keyNumberGlobal,
			"6": self.keyNumberGlobal,
			"7": self.keyNumberGlobal,
			"8": self.keyNumberGlobal,
			"9": self.keyNumberGlobal,
			"0": self.keyNumberGlobal
		})
Пример #19
0
    def __init__(self, session):
        # get framebuffer resolution...
        desk = getDesktop(0)
        wdesktop = int(desk.size().width())

        # cellsize depends from framebuffer resolution...
        if wdesktop == 720:
            CELL_SIZE = 20
        elif wdesktop == 1024:
            CELL_SIZE = 30
        elif wdesktop == 1280:
            CELL_SIZE = 40
        else:
            CELL_SIZE = 20

        # calculate skindata...
        CELL_OFFSET = 2
        cellfield = XMAX * CELL_SIZE + (XMAX - 1) * CELL_OFFSET
        CW = 2 * cellfield + 150  # canvas w
        CH = cellfield  # canvas h
        X0_OFFSET = 0  # xoffset cellfield box
        X1_OFFSET = cellfield + 150  # xoffset cellfield you
        W = CW + 10  # window w
        H = CH + 40  # window h
        WX = cellfield + 10  # widgets xoffset
        W0Y = 25  # widget0 yoffset
        W1Y = cellfield - 116  # widget1 yoffset
        W2Y = cellfield - 66  # widget2 yoffset
        W3Y = cellfield - 16  # widget3 yoffset

        # set skin...
        Schiffe.skin = """
			<screen position="center,center" size="%d,%d" title="Schiffe versenken %s" >
				<widget source="Canvas" render="Canvas" position="5,20" size="%d,%d" />
				<widget name="message" position="%d,%d" size="140,40" valign="center" halign="center" font="Regular;21"/>
				<ePixmap name="green"    position="%d,%d"   zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
				<ePixmap name="blue" position="%d,%d" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
				<ePixmap name="red"   position="%d,%d" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
				<widget name="key_green"    position="%d,%d"   zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
				<widget name="key_blue" position="%d,%d" zPosition="5" size="140,40" valign="center" halign="center"  font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
				<widget name="key_red"   position="%d,%d" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
			</screen>""" % (W, H, VERSION, CW, CH, WX, W0Y, WX, W1Y, WX, W2Y, WX, W3Y,
                   WX, W1Y, WX, W2Y, WX, W3Y)

        # get window background color - find xml for actual skin...
        filename = resolveFilename(SCOPE_CURRENT_SKIN, "skin.xml")
        actualSkin = xml.etree.cElementTree.parse(filename).getroot()

        # get colors from skin and write to dictionary
        colorNames = dict()
        for c in actualSkin.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] = color

        # find colors for skinned window...
        for windowstyle in actualSkin.findall("windowstyle"):
            # look or skinned window...
            if windowstyle.attrib.get("id") == "0":
                for color in windowstyle.findall("color"):
                    get_attr = color.attrib.get
                    type = get_attr("name")
                    color = get_attr("color")
                    # is it a "named" color?
                    if color[0] != '#':
                        # is "named" color, have to look in dictionary...
                        color = colorNames[color]
                    # at least get the background color...
                    if type == "Background":
                        bgcolor = int(color[1:], 0x10)
        if not bgcolor:
            bgcolor = RGB(0, 0, 0)

        self.skin = Schiffe.skin
        Screen.__init__(self, session)
        self["Canvas"] = CanvasSource()
        self["message"] = Label(_("Status"))
        self["key_green"] = Button(_("new game"))
        self["key_blue"] = Button(_("solve game"))
        self["key_red"] = Button(_("quit game"))

        self.cnt = 0
        self.timer = eTimer()
        self.timer.callback.append(self.timerHandler)

        self.message = 0

        self["actions"] = ActionMap(
            ["WizardActions", "ColorActions", "SetupActions"], {
                "ok": self.ok_pressed,
                "up": self.up_pressed,
                "down": self.down_pressed,
                "left": self.left_pressed,
                "right": self.right_pressed,
                "red": self.quit_game,
                "green": self.new_game,
                "blue": self.solve_game,
                "cancel": self.quit_game
            })

        # fill canvas with background color...
        self["Canvas"].fill(0, 0, CW, CH, bgcolor)

        self.you = []
        self.box = []
        self.youCells = []
        self.boxCells = []

        for j in range(YMAX):
            for i in range(XMAX):
                cell = GameCell(self["Canvas"],
                                i * (CELL_SIZE + CELL_OFFSET) + X0_OFFSET,
                                j * (CELL_SIZE + CELL_OFFSET), CELL_SIZE,
                                CELL_SIZE)
                self.boxCells.append(cell)

        for j in range(YMAX):
            for i in range(XMAX):
                cell = GameCell(self["Canvas"],
                                i * (CELL_SIZE + CELL_OFFSET) + X1_OFFSET,
                                j * (CELL_SIZE + CELL_OFFSET), CELL_SIZE,
                                CELL_SIZE)
                self.youCells.append(cell)

        self.onLayoutFinish.append(self.load_game)
Пример #20
0
    def __init__(self, session):
        # get framebuffer resolution...
        desk = getDesktop(0)
        w = int(desk.size().width())
        h = int(desk.size().height())
        # display window in center...
        if isFHD():
            x = 60
            y = 140
        else:
            x = 0
            y = 0
            # x = (w - 520) // 2
            # y = (h - 390) // 2
        # set skin...
        if isFHD():
            Sudoku.skin = """
					<screen name="Sudoku" position="60,140" size="1800,900" title="Sudoku" backgroundColor="#101010">
						<ePixmap position="0,0" size="1800,900" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Sudoku/pic/sudoku.jpg" />
						<widget name="gamelevel" position="145,80" size="331,70" valign="center" halign="center" font="Regular;40" foregroundColor="yellow" backgroundColor="#000000" transparent="1" zPosition="1" />
						<widget source="Canvas" render="Canvas" position="1025,99" size="696,661" backgroundColor="#60ffffff" transparent="1" alphatest="blend" zPosition="2" />
						<ePixmap position="50,250" pixmap="buttons/key_green.png" size="80,40" alphatest="blend" zPosition="2" />
						<widget name="key_green" font="Regular;30" position="132,250" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
						<ePixmap position="50,300" pixmap="buttons/key_red.png" size="80,40" alphatest="blend" zPosition="2" />
						<widget name="key_red" font="Regular;30" position="132,300" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
						<ePixmap position="50,350" pixmap="buttons/key_blue.png" size="80,40" alphatest="blend" zPosition="2" />
						<widget name="key_blue" font="Regular;30" position="132,350" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
						<eLabel position="50,410" size="450,3" backgroundColor="#202020" zPosition="1" />
						<ePixmap position="62,77" size="80,80" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Sudoku/pic/rocket.png" alphatest="blend" zPosition="3" />
						<widget name="result" render="Label" position="80,499" size="835,276" font="Regular; 32" halign="left" foregroundColor="#ffff00" backgroundColor="#000000" transparent="1" zPosition="3" />
						<widget name="movex" render="Label" position="133,193" size="229,50" font="Regular; 34" halign="left" foregroundColor="yellow" backgroundColor="#000000" transparent="1" zPosition="3" />
					</screen>"""
            # % (x, y)

        else:
            Sudoku.skin = """
						<screen name="Sudoku" position="0,0" size="1260,720" title="Sudoku" backgroundColor="#101010">
						<ePixmap position="0,0" size="1259,720" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Sudoku/pic/sudokuHD.jpg" />
						<widget name="gamelevel" position="58,104" size="250,50" valign="center" halign="center" font="Regular; 34" foregroundColor="yellow" backgroundColor="#000000" transparent="1" zPosition="1" />
						<widget source="Canvas" render="Canvas" position="534,28" size="696,661" backgroundColor="#60ffffff" transparent="1" alphatest="blend" zPosition="2" />
						<widget name="key_green" font="Regular;30" position="135,165" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
						<widget name="key_red" font="Regular;30" position="135,216" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
						<widget name="key_blue" font="Regular;30" position="133,265" size="450,40" halign="left" valign="center" backgroundColor="black" zPosition="1" transparent="1" />
						<eLabel position="50,315" size="300,3" backgroundColor="#202020" zPosition="1" />
						<ePixmap position="50,7" size="80,80" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Sudoku/pic/rocket.png" alphatest="blend" zPosition="3" />
						<widget name="result" render="Label" position="12,316" size="510,370" font="Regular; 22" halign="left" foregroundColor="#ffff00" backgroundColor="#000000" transparent="1" zPosition="4" valign="top" />
						<widget name="movex" render="Label" position="324,103" size="186,50" font="Regular; 34" halign="right" foregroundColor="yellow" backgroundColor="dark" transparent="1" zPosition="3" />
						<eLabel name="" position="13,316" size="510,370" zPosition="2" />
						<eLabel name="" position="134,164" size="385,138" />
						<eLabel name="" position="57,211" size="70,40" backgroundColor="red" zPosition="3" />
						<eLabel name="" position="56,261" size="70,40" backgroundColor="blue" zPosition="3" />
						<eLabel name="" position="57,164" size="70,40" zPosition="3" backgroundColor="green" />
						</screen>
						"""
            # % (x, y)

        # i'm not really sure if this is the right way to get the background color from a skinned window?
        # there must exist a better way? everything is taken from skin.py
        # find xml for actual skin...
        filename = resolveFilename(SCOPE_GUISKIN) + "skin.xml"
        actualSkin = parse(filename).getroot()

        # get colors from skin and write to dictionary
        colorNames = dict()
        for c in actualSkin.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] = color
                    #print("Color:", name, color)

        # find colors for skinned window...
        for windowstyle in actualSkin.findall("windowstyle"):
            # look or skinned window...
            if windowstyle.attrib.get("id") == "0":
                for color in windowstyle.findall("color"):
                    get_attr = color.attrib.get
                    type = get_attr("name")
                    color = get_attr("color")
                    # is it a "named" color?
                    if color[0] != '#':
                        # is "named" color, have to look in dictionary...
                        color = colorNames[color]
                    #print(type, color)
                    # at least get the background color...
                    if type == "Background":
                        bgcolor = int(color[1:], 0x10)
        # if not bgcolor:
        bgcolor = RGB(0, 0, 0)

        self.skin = Sudoku.skin
        Screen.__init__(self, session)
        self.setTitle("Sudoku %s" % VERSION)
        self["Canvas"] = CanvasSource()
        self["gamelevel"] = Label(_(" <    easy    >"))
        self["key_green"] = Button(_("new game"))
        self["key_yellow"] = Button(_("check game"))
        self["key_blue"] = Button(_("restart game"))
        self["key_red"] = Button(_("solve game"))
        self["result"] = Label(_(helper))
        self["movex"] = Label(_(""))

        self.cnt = 0
        self.timer = eTimer()
        self.timer.callback.append(self.timerHandler)

        self.xFocus = 4
        self.yFocus = 4

        self.gameLevel = 0

        self["actions"] = ActionMap(
            ["WizardActions", "ColorActions", "SetupActions"], {
                "0": self.bt_0_pressed,
                "1": self.bt_1_pressed,
                "2": self.bt_2_pressed,
                "3": self.bt_3_pressed,
                "4": self.bt_4_pressed,
                "5": self.bt_5_pressed,
                "6": self.bt_6_pressed,
                "7": self.bt_7_pressed,
                "8": self.bt_8_pressed,
                "9": self.bt_9_pressed,
                "up": self.up_pressed,
                "down": self.down_pressed,
                "left": self.left_pressed,
                "right": self.right_pressed,
                "red": self.bt_solve_game,
                "green": self.bt_new_game,
                "yellow": self.bt_check_game,
                "blue": self.bt_restart_game,
                "cancel": self.quit,
                "deleteForward": self.next_pressed,
                "deleteBackward": self.previous_pressed,
            })
        # fill canvas with background color...

        # self["Canvas"].fill(0, 0, 354, 354, bgcolor)
        # if isFHD():
        self["Canvas"].fill(0, 0, 500, 500, bgcolor)
        #

        self.board_cells = []
        self.board_values = []
        # ToDo: change for HD Skins...

        # edit lululla original
        # GROUP_SIZE = 108
        # CELL_SIZE = 35
        # CELL_OFFSET = 4

        # if isFHD():
        GROUP_SIZE = 208
        CELL_SIZE = 70
        CELL_OFFSET = 4

        for j in range(9):
            tmp = []
            for i in range(9):
                cell = SudokuCell(
                    self["Canvas"],
                    j * (CELL_SIZE + CELL_OFFSET) + (j // 3) *
                    (GROUP_SIZE - 3 * CELL_SIZE),
                    i * (CELL_SIZE + CELL_OFFSET) + (i // 3) *
                    (GROUP_SIZE - 3 * CELL_SIZE), CELL_SIZE, CELL_SIZE)
                tmp.append(cell)
            self.board_cells.append(tmp)

        row = [0, 0, 0, 0, 0, 0, 0, 0, 0]
        for i in range(0, 9):
            self.board_values.append(row[:])

        self.onLayoutFinish.append(self.load_game)