Changeset 7321 for ipk/source


Ignore:
Timestamp:
Apr 24, 2011, 8:56:13 PM (15 years ago)
Author:
madie
Message:

[ipk] update foreca to v 1.3 (thx bb)

Location:
ipk/source
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • ipk/source/infos_foreca/CONTROL/control

    r7205 r7321  
    11Package: enigma2-plugin-infos-foreca
    2 Version: 1.2
     2Version: 1.3
    33Architecture: sh4
    44OE: Weatherinfos for your AAF Duckbox
  • ipk/source/infos_foreca/CONTROL/preinst

    r7319 r7321  
    2121        SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | tail -n1`
    2222        FREE=`expr $SPACE - 100`
    23         SIZE=560
     23        SIZE=680
    2424        echo "checking freespace"
    2525        echo packege size $SIZE kb
  • ipk/source/infos_foreca/usr/lib/enigma2/python/Plugins/Extensions/Foreca/plugin.py

    r7205 r7321  
    1111#   Wir wuenschen allen Benutzern herrliches Wetter!
    1212#
    13 #                 Version 1.1
     13#                 Version 1.3
    1414#
    1515#                  12.04.2011
     
    2626from Components.AVSwitch import AVSwitch
    2727from Components.Label import Label
     28from Components.Button import Button
    2829from Components.Sources.StaticText import StaticText
    2930from Components.ScrollLabel import ScrollLabel
     
    3334from Components.PluginComponent import plugins
    3435from Components.Console import Console
     36from Components.config import *
     37from Components.ConfigList import ConfigList, ConfigListScreen
    3538from enigma import eListboxPythonMultiContent, ePicLoad, eServiceReference, eTimer, getDesktop, gFont, RT_HALIGN_LEFT
    36 
    3739from os import listdir, popen
    3840from Plugins.Plugin import PluginDescriptor
     
    4951from Tools.LoadPixmap import LoadPixmap
    5052from twisted.web.client import downloadPage, getPage
     53from Screens.InfoBarGenerics import InfoBarResolutionSelection
     54
    5155import htmlentitydefs, re, urllib2, urllib
    5256from re import sub, split, search, match, findall
     
    5660
    5761
    58 ###################################################
    59 
     62config.plugins.foreca = ConfigSubsection()
     63config.plugins.foreca.Device = ConfigSelection(default="/usr/lib/enigma2/python/Plugins/Extensions/Foreca/bilder/", choices = [("/usr/lib/enigma2/python/Plugins/Extensions/Foreca/", _("...Plugins/Extensions/Foreca/")), ("/media/hdd/Foreca/", _("/media/hdd/Foreca/")), ("/var/swap/Foreca/", _("/var/swap/Foreca/"))])
     64config.plugins.foreca.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))])
     65config.plugins.foreca.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
     66config.plugins.foreca.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
     67config.plugins.foreca.framesize = ConfigInteger(default=5, limits=(5, 99))
     68config.plugins.foreca.remove = ConfigSelection(default="0", choices = [("0", _("Yes")), ("1", _("No"))])
     69config.plugins.foreca.slidetime = ConfigInteger(default=1, limits=(1, 60))
     70config.plugins.foreca.infoline = ConfigEnableDisable(default=True)
     71config.plugins.foreca.loop = ConfigEnableDisable(default=False)
     72
     73
     74global MAIN_PAGE
    6075MAIN_PAGE = "http://www.foreca.at"
    6176PNG_PATH = resolveFilename(SCOPE_PLUGINS)+"/Extensions/Foreca/picon/"
    6277deviceName = HardwareInfo().get_device_name()
    6378
    64 global MAIN_PAGE
     79
    6580
    6681#---------------------- Skin Funktionen ---------------------------------------------------
     
    7186def getScale():
    7287        return AVSwitch().getFramebufferScale()
     88
     89#------------------------------------------------------------------------------------------
     90#---------------------- class InfoBarAspectSelection --------------------------------------
     91#------------------------------------------------------------------------------------------
     92
     93class InfoBarAspectSelection:
     94        STATE_HIDDEN = 0
     95        STATE_ASPECT = 1
     96        STATE_RESOLUTION = 2
     97        def __init__(self):
     98                self["AspectSelectionAction"] = HelpableActionMap(self, "InfobarAspectSelectionActions",
     99                        {
     100                                "aspectSelection": (self.ExGreen_toggleGreen, _("Aspect list...")),
     101                        })
     102                self.__ExGreen_state = self.STATE_HIDDEN
     103        def ExGreen_doAspect(self):
     104                self.__ExGreen_state = self.STATE_ASPECT
     105                self.aspectSelection()
     106        def ExGreen_doResolution(self):
     107                self.__ExGreen_state = self.STATE_RESOLUTION
     108                self.resolutionSelection()
     109        def ExGreen_doHide(self):
     110                self.__ExGreen_state = self.STATE_HIDDEN
     111        def ExGreen_toggleGreen(self, arg=""):
     112                print self.__ExGreen_state
     113                if self.__ExGreen_state == self.STATE_HIDDEN:
     114                        print "self.STATE_HIDDEN"
     115                        self.ExGreen_doAspect()
     116                elif self.__ExGreen_state == self.STATE_ASPECT:
     117                        print "self.STATE_ASPECT"
     118                        self.ExGreen_doResolution()
     119                elif self.__ExGreen_state == self.STATE_RESOLUTION:
     120                        print "self.STATE_RESOLUTION"
     121                        self.ExGreen_doHide()
     122        def aspectSelection(self):
     123                selection = 0
     124                tlist = []
     125                tlist.append((_("Resolution"), "resolution"))
     126                tlist.append(("", ""))
     127                tlist.append(("Letterbox", "letterbox"))
     128                tlist.append(("PanScan", "panscan"))
     129                tlist.append(("Non Linear", "non"))
     130                tlist.append(("Bestfit", "bestfit"))
     131                mode = open("/proc/stb/video/policy").read()[:-1]
     132                print mode
     133                for x in range(len(tlist)):
     134                        if tlist[x][1] == mode:
     135                                selection = x
     136                keys = ["green", "",  "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
     137                self.session.openWithCallback(self.aspectSelected, ChoiceBox, title=_("Please select an aspect ratio..."), list = tlist, selection = selection, keys = keys)
     138        def aspectSelected(self, aspect):
     139                if not aspect is None:
     140                        if isinstance(aspect[1], str):
     141                                if aspect[1] == "resolution":
     142                                        self.ExGreen_toggleGreen()
     143                                else:
     144                                        open("/proc/stb/video/policy", "w").write(aspect[1])
     145                                        self.ExGreen_doHide()
     146                return
     147
    73148
    74149#------------------------------------------------------------------------------------------
     
    229304class ForecaPreview(Screen, HelpableScreen):
    230305        def __init__(self, session):
    231                 global MAIN_PAGE
     306                global MAIN_PAGE, menu
    232307                self.session = session
    233308                MAIN_PAGE = "http://www.foreca.at"
     
    256331                ##print "Desktop ", size, width
    257332                if width == 1024:
    258                         self.skin = """<screen position="center,65" size="880,480" title="Foreca Wetterprognose V 1.2" backgroundColor="#b0b0b0" >"""
     333                        self.skin = """<screen position="center,65" size="880,480" title="Foreca Wetterprognose V 1.3" backgroundColor="#b0b0b0" >"""
    259334                        self.skin += """<widget name="MainList" position="0,65" size="880,363" zPosition="3" backgroundColor="#b0b0b0" backgroundColorSelected="#f7f7f7" selectionDisabled="1" scrollbarMode="showOnDemand" />
    260335                        <widget source="Titel" render="Label" position="120,3" zPosition="3" size="740,40" font="Regular;36" valign="center" halign="left" transparent="1" foregroundColor="#000000"/>
     
    273348                </screen>"""
    274349                else:
    275                         self.skin = """<screen position="center,center" size="890,505" title="Foreca Wetterprognose V 1.2" backgroundColor="#b0b0b0" >"""
     350                        self.skin = """<screen position="center,center" size="890,505" title="Foreca Wetterprognose V 1.3" backgroundColor="#b0b0b0" >"""
    276351                        self.skin += """<widget name="MainList" position="0,90" size="890,365" zPosition="3" backgroundColor="#b0b0b0" backgroundColorSelected="#f7f7f7" selectionDisabled="1" scrollbarMode="showOnDemand" />
    277352                        <widget source="Titel" render="Label" position="120,13" zPosition="3" size="740,40" font="Regular;36" valign="center" halign="left" transparent="1" foregroundColor="#000000"/>
     
    311386                        {
    312387                                "cancel": (self.exit, "Beenden"),
    313                                 "menu": (self.info, "Menu"),
     388                                "menu": (self.Menu, "Menu"),
    314389                                "showEventInfo": (self.info, "Info"),
    315                                 "ok": (self.Menu, "Menu"),
     390                                "ok": (self.OK, "Menu"),
    316391                                "left": (self.left, "Seite hoch"),
    317392                                "right": (self.right, "Seite runter"),
     
    375450
    376451        def exit(self):
     452                os.system("rm /tmp/sat.jpg; rm /tmp/sat.html; rm /tmp/meteogram.png")
    377453                self.close()
    378454                self.deactivateCacheDialog()
     
    455531                self.StartPage()
    456532
    457         def Menu(self):
     533        def OK(self):
    458534                global city
    459535                panelmenu = ""
    460536                city = self.ort
    461                 self.session.openWithCallback(self.MenuCallback, CityPanel,panelmenu)
     537                self.session.openWithCallback(self.OKCallback, CityPanel,panelmenu)
    462538
    463539        def info(self):
     
    465541                self.session.open( MessageBox, message, MessageBox.TYPE_INFO)
    466542
    467 
    468         def MenuCallback(self):
     543        def OKCallback(self):
    469544                global city
    470545                self.ort = city
     
    472547                ##print "MenuCallback "
    473548
     549        def Menu(self):
     550                self.session.openWithCallback(self.MenuCallback, SatPanel, self.ort)
     551
     552        def MenuCallback(self):
     553                global menu
     554
     555#
    474556#------------------------------------------------------------------------------------------
    475557        def loadPicture(self,url=""):
    476                 ##print "here4"
    477558                devicepath = "/tmp/meteogram.png"
    478559                path = "/tmp"
     
    649730                self.session = session
    650731                self.skin = """
    651                         <screen name="SenderPanel" position="center,center" size="430,540" title="Staedte Auswahl" backgroundColor="#252525">
     732                        <screen name="CityPanel" position="center,center" size="430,540" title="Staedte Auswahl" backgroundColor="#252525">
    652733                                <widget name="Mlist" position="10,10" size="400,490" zPosition="3" backgroundColor="#252525"  backgroundColorSelected="#565656" scrollbarMode="showOnDemand" />
    653734                                <eLabel position="0,515" zPosition="2" size="430,1" backgroundColor="#c1cdc1" />
     
    755836
    756837        def blue(self):
    757                 city = self['Mlist'].l.getCurrent()[0][0]
     838                city = self['Mlist'].l.getCurrentSelection()[0][0]
    758839                ##print "[Foreca] Service:", city
    759840                fwrite = open("/usr/lib/enigma2/python/Plugins/Extensions/Foreca/startservice.cfg", "w")
     
    797878                #res.append(MultiContentEntryPixmapAlphaTest(pos=(2, 5), size=(100, 60), png=entry[0]))  # png vorn
    798879                res.append(MultiContentEntryText(pos=(30, 6), size=(300, 35), font=0, text=entry[0], color=mblau, color_sel=mblau, backcolor_sel=grau))
     880                return res
     881
     882#------------------------------------------------------------------------------------------
     883
     884# -------------------------------------------------------------------
     885class SatPanelList(MenuList):
     886        def __init__(self, list, font0 = 28, font1 = 16, itemHeight = 142, enableWrapAround = True):
     887                MenuList.__init__(self, [], False, eListboxPythonMultiContent)
     888                self.l.setFont(0, gFont("Regular", font0))
     889                self.l.setFont(1, gFont("Regular", font1))
     890                self.l.setItemHeight(itemHeight)
     891
     892# -------------------------------------------------------------------
     893class SatPanel(Screen, HelpableScreen):
     894        def __init__(self, session, ort):
     895                self.session = session
     896                self.ort = ort
     897                self.skin = """
     898                        <screen name="SatPanel" position="center,center" size="630,500" title="Satelliten - Bilder / Karten" backgroundColor="#252525">
     899                                <widget name="Mlist" position="10,10" size="600,430" zPosition="3" backgroundColor="#252525"  backgroundColorSelected="#565656" scrollbarMode="showOnDemand" />
     900
     901                                <eLabel position="0,445" zPosition="2" size="630,1" backgroundColor="#c1cdc1" />
     902                                <widget source="key_blue" render="Label" position="260,457" zPosition="2" size="290,30" font="Regular;20" valign="center" halign="left" transparent="1" />
     903                                <ePixmap position="200,460" size="36,20" pixmap="skin_default/buttons/key_blue.png" transparent="1" alphatest="on" />
     904
     905                        </screen>"""
     906
     907                Screen.__init__(self, session)
     908                self.Mlist = []
     909
     910                self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('satellit'), _("Satelliten Bild"), 'satellit')))
     911                self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('niederschlag'), _("Niederschlags Karte"), 'niederschlag')))
     912                self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('bewoelkung'), _("Bewölkung Bild"), 'bewoelkung')))
     913                #self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('luftdruck'), _("Luftdruck Karte"), 'luftdruck')))
     914
     915
     916                self.onChangedEntry = []
     917                if (getDesktop(0).size().width() == 1280):
     918                                self["Mlist"] = SatPanelList([])
     919                else:
     920                                self["Mlist"] = SatPanelList([], font0=24, font1=15, itemHeight=60)
     921                self["Mlist"].l.setList(self.Mlist)
     922                self["Mlist"].selectionEnabled(1)
     923                self["key_blue"] = StaticText()
     924                self["key_blue"].text = _("Einstellungen")
     925
     926                HelpableScreen.__init__(self)
     927                self["actions"] = HelpableActionMap(self, "AAFKeyActions",
     928                        {
     929                                "cancel": (self.Exit, "Beenden"),
     930                                "left": (self.left, "Seite hoch"),
     931                                "right": (self.right, "Seite runter"),
     932                                "up": (self.up, "Hoch"),
     933                                "down": (self.down, "Runter"),
     934                                "blue": (self.PicSetupMenu, "blue"),
     935                                "ok": (self.ok, "OK"),
     936                        }, -2)
     937
     938        def up(self):
     939                self["Mlist"].up()
     940                self["Mlist"].selectionEnabled(1)
     941
     942        def down(self):
     943                self["Mlist"].down()
     944                self["Mlist"].selectionEnabled(1)
     945
     946        def left(self):
     947                self["Mlist"].pageUp()
     948
     949        def right(self):
     950                self["Mlist"].pageDown()
     951
     952        def Exit(self):
     953                global menu
     954                menu = "stop"
     955                self.close()
     956
     957        def ok(self):
     958                #global menu
     959                menu = self['Mlist'].l.getCurrentSelection()[0][2]
     960                ##print "druecke OK", menu
     961                #self.close()
     962                self.SatBild()
     963
     964        def SatEntryComponent(self,file):
     965                png = LoadPixmap("/usr/lib/enigma2/python/Plugins/Extensions/Foreca/thumb/" + file + ".png")
     966                res = (png)
     967                return res
     968
     969        def PicSetupMenu(self):
     970                self.session.open(PicSetup)
     971               
     972#------------------------------------------------------------------------------------------
     973        def SatBild(self):
     974
     975                #message = "%s" % (_("Satelittenbilder werden geladen .....\n\n                       "))
     976                #self.session.open( MessageBox, message, MessageBox.TYPE_INFO, timeout=4)
     977
     978                menu = self['Mlist'].l.getCurrentSelection()[0][2]
     979                if menu == "satellit":
     980                        # http://www.foreca.de/Austria/Linz?map=sat
     981                        devicepath = "/tmp/sat.html"
     982                        url = "http://www.foreca.at/" + self.ort + "?map=sat"
     983
     984#------------------------------------------------------------------------------------------
     985                if menu == "niederschlag":
     986                        devicepath = "/tmp/sat.html"
     987                        url = "http://www.foreca.at/" + self.ort + "?map=rain"
     988
     989#------------------------------------------------------------------------------------------
     990                if menu == "bewoelkung":
     991                        devicepath = "/tmp/sat.html"
     992                        url = "http://www.foreca.at/" + self.ort + "?map=cloud"
     993
     994#------------------------------------------------------------------------------------------
     995                       
     996                if menu == "luftdruck":
     997                        devicepath = "/tmp/sat.html"
     998                        url = "http://www.foreca.at/" + self.ort + "?map=pressure"
     999
     1000#------------------------------------------------------------------------------------------
     1001
     1002
     1003                # Lade Kategorie Seite und suche BildLink
     1004                h = urllib.urlretrieve(url, devicepath)
     1005                fd=open(devicepath)
     1006                html=fd.read()
     1007                fd.close()
     1008
     1009                fulltext = re.compile(r'http://cache-(.+?) ', re.DOTALL)
     1010                PressureLink = fulltext.findall(html)
     1011                PicLink = PressureLink[0]
     1012                PicLink = "http://cache-" +     PicLink
     1013
     1014                # Lade Bilder fuer Slideshow
     1015                devicepath = "/usr/lib/enigma2/python/Plugins/Extensions/Foreca/bilder/sat"
     1016                max = int(len(PressureLink))-2
     1017                print "max= ", str(max)
     1018                zehner = "1"
     1019                x = 0
     1020                while x < max:
     1021                        url = "http://cache-" + PressureLink[x]
     1022                        print str(x), url
     1023                        h = urllib.urlretrieve(url, devicepath + zehner + str(x) + ".jpg")
     1024                        x = x + 1
     1025                        if x > 9:
     1026                                zehner = "2"
     1027
     1028                self.session.open(View_Slideshow, 0, True)
     1029
     1030#------------------------------------------------------------------------------------------
     1031
     1032        def SatEntryItem(self,entry):
     1033                rot = 16711680
     1034                gruen = 60928
     1035                dgruen = 52480
     1036                drot = 0xf47d19
     1037                mblau = 8900346
     1038                hblau = 11592447
     1039                dblau = 5215437
     1040                weiss = 0xffffff
     1041                orange = 0xf47d19
     1042                grau = 0x565656
     1043
     1044                res = [entry]
     1045                #       return (eListboxPythonMultiContent.TYPE_TEXT, pos[0], pos[1], size[0], size[1], font, flags, text, color, color_sel, backcolor, backcolor_sel, border_width, border_color)
     1046                res.append(MultiContentEntryPixmapAlphaTest(pos=(2, 5), size=(200, 140), png=entry[0]))  # png vorn
     1047                res.append(MultiContentEntryText(pos=(240, 45), size=(340, 50), font=0, text=entry[1], color=mblau, color_sel=mblau, backcolor_sel=grau))
    7991048                return res
    8001049
     
    8581107
    8591108#------------------------------------------------------------------------------------------
    860 #-----------------------Haupt Programm ----------------------------------------------------
     1109class View_Slideshow(Screen, InfoBarAspectSelection, InfoBarResolutionSelection):
     1110        def __init__(self, session, pindex, startslide):
     1111
     1112                print "SlideShow is running ......."
     1113                self.textcolor = config.plugins.foreca.textcolor.value
     1114                self.bgcolor = config.plugins.foreca.bgcolor.value
     1115                space = config.plugins.foreca.framesize.value
     1116                size_w = getDesktop(0).size().width()
     1117                size_h = getDesktop(0).size().height()
     1118
     1119                self.skindir = "/tmp"
     1120                self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
     1121                        <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
     1122                        <widget name=\"point\" position=\""+ str(space+5) + "," + str(space+10) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/record.png\" alphatest=\"on\" /> \
     1123                        <widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+10) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/ico_mp_play.png\"  alphatest=\"on\" /> \
     1124                        <widget name=\"file\" position=\""+ str(space+45) + "," + str(space+8) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"
     1125                Screen.__init__(self, session)
     1126
     1127                InfoBarAspectSelection.__init__(self)
     1128                self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
     1129                {
     1130                        "cancel": self.Exit,
     1131                        "yellow": self.PlayPause,
     1132                        "blue": self.sleepTimer,
     1133                        "left": self.prevPic,
     1134                        "right": self.nextPic,
     1135                }, -1)
     1136                self["point"] = Pixmap()
     1137                self["pic"] = Pixmap()
     1138                self["play_icon"] = Pixmap()
     1139                self["file"] = Label(_("please wait, loading picture..."))
     1140                self.old_index = 0
     1141                self.picfilelist = []
     1142                self.lastindex = pindex
     1143                self.currPic = []
     1144                self.shownow = True
     1145                self.dirlistcount = 0
     1146
     1147                devicepath = config.plugins.foreca.Device.value
     1148                currDir = devicepath
     1149                self.filelist = FileList(currDir, showDirectories = False, matchingPattern = "^.*\.(jpg)", useServiceRef = False)
     1150
     1151                for x in self.filelist.getFileList():
     1152                                if x[0][1] == False:
     1153                                        self.picfilelist.append(currDir + x[0][0])
     1154                                else:
     1155                                        self.dirlistcount += 1
     1156
     1157                self.maxentry = len(self.picfilelist)-1
     1158                self.pindex = pindex - self.dirlistcount
     1159                if self.pindex < 0:
     1160                        self.pindex = 0
     1161                self.picload = ePicLoad()
     1162                self.picload.PictureData.get().append(self.finish_decode)
     1163                self.slideTimer = eTimer()
     1164                self.slideTimer.callback.append(self.slidePic)
     1165                if self.maxentry >= 0:
     1166                        self.onLayoutFinish.append(self.setPicloadConf)
     1167                if startslide == True:
     1168                        self.PlayPause();
     1169
     1170        def setPicloadConf(self):
     1171                sc = getScale()
     1172                self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.plugins.foreca.resize.value), self.bgcolor])
     1173                self["play_icon"].hide()
     1174                if config.plugins.foreca.infoline.value == False:
     1175                        self["file"].hide()
     1176                self.start_decode()
     1177
     1178        def ShowPicture(self):
     1179                if self.shownow and len(self.currPic):
     1180                        self.shownow = False
     1181                        self["file"].setText(self.currPic[0])
     1182                        self.lastindex = self.currPic[1]
     1183                        self["pic"].instance.setPixmap(self.currPic[2].__deref__())
     1184                        self.currPic = []
     1185                        self.next()
     1186                        self.start_decode()
     1187
     1188        def finish_decode(self, picInfo=""):
     1189                self["point"].hide()
     1190                ptr = self.picload.getData()
     1191                if ptr != None:
     1192                        text = ""
     1193                        try:
     1194                                text = picInfo.split('\n',1)
     1195                                text = "(" + str(self.pindex+1) + "/" + str(self.maxentry+1) + ") " + text[0].split('/')[-1]
     1196                        except:
     1197                                pass
     1198                        self.currPic = []
     1199                        self.currPic.append(text)
     1200                        self.currPic.append(self.pindex)
     1201                        self.currPic.append(ptr)
     1202                        self.ShowPicture()
     1203
     1204        def start_decode(self):
     1205                self.picload.startDecode(self.picfilelist[self.pindex])
     1206                self["point"].show()
     1207
     1208        def next(self):
     1209                self.pindex += 1
     1210                if self.pindex > self.maxentry:
     1211                        self.pindex = 0
     1212
     1213        def prev(self):
     1214                self.pindex -= 1
     1215                if self.pindex < 0:
     1216                        self.pindex = self.maxentry
     1217
     1218        def slidePic(self):
     1219                print "[Picasa] slide to next Picture index=" + str(self.lastindex)
     1220                if config.plugins.foreca.loop.value==False and self.lastindex == self.maxentry:
     1221                        self.PlayPause()
     1222                self.shownow = True
     1223                self.ShowPicture()
     1224
     1225        def PlayPause(self):
     1226                if self.slideTimer.isActive():
     1227                        self.slideTimer.stop()
     1228                        self["play_icon"].hide()
     1229                else:
     1230                        self.slideTimer.start(config.plugins.foreca.slidetime.value*1000)
     1231                        self["play_icon"].show()
     1232                        self.nextPic()
     1233
     1234        def prevPic(self):
     1235                self.currPic = []
     1236                self.pindex = self.lastindex
     1237                self.prev()
     1238                self.start_decode()
     1239                self.shownow = True
     1240
     1241        def nextPic(self):
     1242                self.shownow = True
     1243                self.ShowPicture()
     1244
     1245        def Exit(self):
     1246                del self.picload
     1247                self.close(self.lastindex + self.dirlistcount)
     1248
     1249        def sleepTimer(self):
     1250                from Screens.SleepTimerEdit import SleepTimerEdit
     1251                self.session.open(SleepTimerEdit)
     1252
     1253#------------------------------------------------------------------------------------------
     1254#-------------------------------- Foreca Settings -----------------------------------------
     1255#------------------------------------------------------------------------------------------
     1256class PicSetup(Screen):
     1257        skin = """<screen position="center,center" size="480,260" title="Foreca SlideShow Settings" backgroundColor="#000000" >
     1258                <widget name="liste" position="5,5" size="470,250" scrollbarMode="showOnDemand" />
     1259                <eLabel backgroundColor="red" position="28,250" size="140,3" zPosition="2"/>
     1260                <eLabel backgroundColor="green" position="228,250" size="140,3" zPosition="2"/>
     1261                <widget name="key_red" position="28,218" zPosition="3" size="140,40" font="Regular;19" valign="center" halign="center" transparent="1" />
     1262                <widget name="key_green" position="228,218" zPosition="3" size="140,40" font="Regular;19" valign="center" halign="center" transparent="1" />
     1263        </screen>"""
     1264
     1265        def __init__(self, session):
     1266                self.skin = PicSetup.skin
     1267                Screen.__init__(self, session)
     1268                self["key_red"] = Button(_("Back"))
     1269                self["key_green"] = Button(_("Save"))
     1270                self["actions"] = NumberActionMap(["SetupActions", "ColorActions"],
     1271                {
     1272                        "ok": self.save,
     1273                        "green": self.save,
     1274                        "cancel": self.close,
     1275                        "red": self.close,
     1276                        "left": self.keyLeft,
     1277                        "right": self.keyRight,
     1278                        "0": self.keyNumber,
     1279                        "1": self.keyNumber,
     1280                        "2": self.keyNumber,
     1281                        "3": self.keyNumber,
     1282                        "4": self.keyNumber,
     1283                        "5": self.keyNumber,
     1284                        "6": self.keyNumber,
     1285                        "7": self.keyNumber,
     1286                        "8": self.keyNumber,
     1287                        "9": self.keyNumber
     1288                }, -3)
     1289                self.list = []
     1290                self["liste"] = ConfigList(self.list)
     1291
     1292                #self.list.append(getConfigListEntry(_("Picture Y moving"), config.plugins.foreca.max_offsety))
     1293                #self.list.append(getConfigListEntry(_("delete cached Pictures"), config.plugins.foreca.remove))
     1294                #self.list.append(getConfigListEntry(_("Picture Cache"), config.plugins.foreca.Device))
     1295                self.list.append(getConfigListEntry(_("Scaling Mode"), config.plugins.foreca.resize))
     1296                self.list.append(getConfigListEntry(_("Frame size in full view"), config.plugins.foreca.framesize))
     1297                self.list.append(getConfigListEntry(_("backgroundcolor"), config.plugins.foreca.bgcolor))
     1298                self.list.append(getConfigListEntry(_("Textcolor"), config.plugins.foreca.textcolor))
     1299                self.list.append(getConfigListEntry(_("SlideTime"), config.plugins.foreca.slidetime))
     1300                self.list.append(getConfigListEntry(_("Show Infoline"), config.plugins.foreca.infoline))
     1301                self.list.append(getConfigListEntry(_("slide picture in loop"), config.plugins.foreca.loop))
     1302
     1303        def save(self):
     1304                for x in self["liste"].list:
     1305                                x[1].save()
     1306                config.save()
     1307                self.close()
     1308
     1309        def keyLeft(self):
     1310                self["liste"].handleKey(KEY_LEFT)
     1311        def keyRight(self):
     1312                self["liste"].handleKey(KEY_RIGHT)
     1313        def keyNumber(self, number):
     1314                self["liste"].handleKey(KEY_0 + number)
     1315
     1316#------------------------------------------------------------------------------------------
     1317#------------------------------------- Haupt Programm -------------------------------------
    8611318#------------------------------------------------------------------------------------------
    8621319def start(session, **kwargs):
  • ipk/source/swapinfos_foreca/CONTROL/control

    r7286 r7321  
    11Package: enigma2-plugin-swapinfos-foreca
    2 Version: 1.2
     2Version: 1.3
    33Description: Weatherinfo Plugin for Swapstick
    44Section: infos
  • ipk/source/swapinfos_foreca/var/swap/extensions/Foreca/plugin.py

    r7286 r7321  
    1111#   Wir wuenschen allen Benutzern herrliches Wetter!
    1212#
    13 #                 Version 1.1
     13#                 Version 1.3
    1414#
    1515#                  12.04.2011
     
    2626from Components.AVSwitch import AVSwitch
    2727from Components.Label import Label
     28from Components.Button import Button
    2829from Components.Sources.StaticText import StaticText
    2930from Components.ScrollLabel import ScrollLabel
     
    3334from Components.PluginComponent import plugins
    3435from Components.Console import Console
     36from Components.config import *
     37from Components.ConfigList import ConfigList, ConfigListScreen
    3538from enigma import eListboxPythonMultiContent, ePicLoad, eServiceReference, eTimer, getDesktop, gFont, RT_HALIGN_LEFT
    36 
    3739from os import listdir, popen
    3840from Plugins.Plugin import PluginDescriptor
     
    4951from Tools.LoadPixmap import LoadPixmap
    5052from twisted.web.client import downloadPage, getPage
     53from Screens.InfoBarGenerics import InfoBarResolutionSelection
     54
    5155import htmlentitydefs, re, urllib2, urllib
    5256from re import sub, split, search, match, findall
     
    5660
    5761
    58 ###################################################
    59 
     62config.plugins.foreca = ConfigSubsection()
     63config.plugins.foreca.Device = ConfigSelection(default="/usr/lib/enigma2/python/Plugins/Extensions/Foreca/bilder/", choices = [("/usr/lib/enigma2/python/Plugins/Extensions/Foreca/", _("...Plugins/Extensions/Foreca/")), ("/media/hdd/Foreca/", _("/media/hdd/Foreca/")), ("/var/swap/Foreca/", _("/var/swap/Foreca/"))])
     64config.plugins.foreca.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))])
     65config.plugins.foreca.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
     66config.plugins.foreca.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
     67config.plugins.foreca.framesize = ConfigInteger(default=5, limits=(5, 99))
     68config.plugins.foreca.remove = ConfigSelection(default="0", choices = [("0", _("Yes")), ("1", _("No"))])
     69config.plugins.foreca.slidetime = ConfigInteger(default=1, limits=(1, 60))
     70config.plugins.foreca.infoline = ConfigEnableDisable(default=True)
     71config.plugins.foreca.loop = ConfigEnableDisable(default=False)
     72
     73
     74global MAIN_PAGE
    6075MAIN_PAGE = "http://www.foreca.at"
    6176PNG_PATH = resolveFilename(SCOPE_PLUGINS)+"/Extensions/Foreca/picon/"
    6277deviceName = HardwareInfo().get_device_name()
    6378
    64 global MAIN_PAGE
     79
    6580
    6681#---------------------- Skin Funktionen ---------------------------------------------------
     
    7186def getScale():
    7287        return AVSwitch().getFramebufferScale()
     88
     89#------------------------------------------------------------------------------------------
     90#---------------------- class InfoBarAspectSelection --------------------------------------
     91#------------------------------------------------------------------------------------------
     92
     93class InfoBarAspectSelection:
     94        STATE_HIDDEN = 0
     95        STATE_ASPECT = 1
     96        STATE_RESOLUTION = 2
     97        def __init__(self):
     98                self["AspectSelectionAction"] = HelpableActionMap(self, "InfobarAspectSelectionActions",
     99                        {
     100                                "aspectSelection": (self.ExGreen_toggleGreen, _("Aspect list...")),
     101                        })
     102                self.__ExGreen_state = self.STATE_HIDDEN
     103        def ExGreen_doAspect(self):
     104                self.__ExGreen_state = self.STATE_ASPECT
     105                self.aspectSelection()
     106        def ExGreen_doResolution(self):
     107                self.__ExGreen_state = self.STATE_RESOLUTION
     108                self.resolutionSelection()
     109        def ExGreen_doHide(self):
     110                self.__ExGreen_state = self.STATE_HIDDEN
     111        def ExGreen_toggleGreen(self, arg=""):
     112                print self.__ExGreen_state
     113                if self.__ExGreen_state == self.STATE_HIDDEN:
     114                        print "self.STATE_HIDDEN"
     115                        self.ExGreen_doAspect()
     116                elif self.__ExGreen_state == self.STATE_ASPECT:
     117                        print "self.STATE_ASPECT"
     118                        self.ExGreen_doResolution()
     119                elif self.__ExGreen_state == self.STATE_RESOLUTION:
     120                        print "self.STATE_RESOLUTION"
     121                        self.ExGreen_doHide()
     122        def aspectSelection(self):
     123                selection = 0
     124                tlist = []
     125                tlist.append((_("Resolution"), "resolution"))
     126                tlist.append(("", ""))
     127                tlist.append(("Letterbox", "letterbox"))
     128                tlist.append(("PanScan", "panscan"))
     129                tlist.append(("Non Linear", "non"))
     130                tlist.append(("Bestfit", "bestfit"))
     131                mode = open("/proc/stb/video/policy").read()[:-1]
     132                print mode
     133                for x in range(len(tlist)):
     134                        if tlist[x][1] == mode:
     135                                selection = x
     136                keys = ["green", "",  "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
     137                self.session.openWithCallback(self.aspectSelected, ChoiceBox, title=_("Please select an aspect ratio..."), list = tlist, selection = selection, keys = keys)
     138        def aspectSelected(self, aspect):
     139                if not aspect is None:
     140                        if isinstance(aspect[1], str):
     141                                if aspect[1] == "resolution":
     142                                        self.ExGreen_toggleGreen()
     143                                else:
     144                                        open("/proc/stb/video/policy", "w").write(aspect[1])
     145                                        self.ExGreen_doHide()
     146                return
     147
    73148
    74149#------------------------------------------------------------------------------------------
     
    229304class ForecaPreview(Screen, HelpableScreen):
    230305        def __init__(self, session):
    231                 global MAIN_PAGE
     306                global MAIN_PAGE, menu
    232307                self.session = session
    233308                MAIN_PAGE = "http://www.foreca.at"
     
    256331                ##print "Desktop ", size, width
    257332                if width == 1024:
    258                         self.skin = """<screen position="center,65" size="880,480" title="Foreca Wetterprognose V 1.2" backgroundColor="#b0b0b0" >"""
     333                        self.skin = """<screen position="center,65" size="880,480" title="Foreca Wetterprognose V 1.3" backgroundColor="#b0b0b0" >"""
    259334                        self.skin += """<widget name="MainList" position="0,65" size="880,363" zPosition="3" backgroundColor="#b0b0b0" backgroundColorSelected="#f7f7f7" selectionDisabled="1" scrollbarMode="showOnDemand" />
    260335                        <widget source="Titel" render="Label" position="120,3" zPosition="3" size="740,40" font="Regular;36" valign="center" halign="left" transparent="1" foregroundColor="#000000"/>
     
    273348                </screen>"""
    274349                else:
    275                         self.skin = """<screen position="center,center" size="890,505" title="Foreca Wetterprognose V 1.2" backgroundColor="#b0b0b0" >"""
     350                        self.skin = """<screen position="center,center" size="890,505" title="Foreca Wetterprognose V 1.3" backgroundColor="#b0b0b0" >"""
    276351                        self.skin += """<widget name="MainList" position="0,90" size="890,365" zPosition="3" backgroundColor="#b0b0b0" backgroundColorSelected="#f7f7f7" selectionDisabled="1" scrollbarMode="showOnDemand" />
    277352                        <widget source="Titel" render="Label" position="120,13" zPosition="3" size="740,40" font="Regular;36" valign="center" halign="left" transparent="1" foregroundColor="#000000"/>
     
    311386                        {
    312387                                "cancel": (self.exit, "Beenden"),
    313                                 "menu": (self.info, "Menu"),
     388                                "menu": (self.Menu, "Menu"),
    314389                                "showEventInfo": (self.info, "Info"),
    315                                 "ok": (self.Menu, "Menu"),
     390                                "ok": (self.OK, "Menu"),
    316391                                "left": (self.left, "Seite hoch"),
    317392                                "right": (self.right, "Seite runter"),
     
    375450
    376451        def exit(self):
     452                os.system("rm /tmp/sat.jpg; rm /tmp/sat.html; rm /tmp/meteogram.png")
    377453                self.close()
    378454                self.deactivateCacheDialog()
     
    455531                self.StartPage()
    456532
    457         def Menu(self):
     533        def OK(self):
    458534                global city
    459535                panelmenu = ""
    460536                city = self.ort
    461                 self.session.openWithCallback(self.MenuCallback, CityPanel,panelmenu)
     537                self.session.openWithCallback(self.OKCallback, CityPanel,panelmenu)
    462538
    463539        def info(self):
     
    465541                self.session.open( MessageBox, message, MessageBox.TYPE_INFO)
    466542
    467 
    468         def MenuCallback(self):
     543        def OKCallback(self):
    469544                global city
    470545                self.ort = city
     
    472547                ##print "MenuCallback "
    473548
     549        def Menu(self):
     550                self.session.openWithCallback(self.MenuCallback, SatPanel, self.ort)
     551
     552        def MenuCallback(self):
     553                global menu
     554
     555#
    474556#------------------------------------------------------------------------------------------
    475557        def loadPicture(self,url=""):
    476                 ##print "here4"
    477558                devicepath = "/tmp/meteogram.png"
    478559                path = "/tmp"
     
    649730                self.session = session
    650731                self.skin = """
    651                         <screen name="SenderPanel" position="center,center" size="430,540" title="Staedte Auswahl" backgroundColor="#252525">
     732                        <screen name="CityPanel" position="center,center" size="430,540" title="Staedte Auswahl" backgroundColor="#252525">
    652733                                <widget name="Mlist" position="10,10" size="400,490" zPosition="3" backgroundColor="#252525"  backgroundColorSelected="#565656" scrollbarMode="showOnDemand" />
    653734                                <eLabel position="0,515" zPosition="2" size="430,1" backgroundColor="#c1cdc1" />
     
    755836
    756837        def blue(self):
    757                 city = self['Mlist'].l.getCurrent()[0][0]
     838                city = self['Mlist'].l.getCurrentSelection()[0][0]
    758839                ##print "[Foreca] Service:", city
    759840                fwrite = open("/usr/lib/enigma2/python/Plugins/Extensions/Foreca/startservice.cfg", "w")
     
    797878                #res.append(MultiContentEntryPixmapAlphaTest(pos=(2, 5), size=(100, 60), png=entry[0]))  # png vorn
    798879                res.append(MultiContentEntryText(pos=(30, 6), size=(300, 35), font=0, text=entry[0], color=mblau, color_sel=mblau, backcolor_sel=grau))
     880                return res
     881
     882#------------------------------------------------------------------------------------------
     883
     884# -------------------------------------------------------------------
     885class SatPanelList(MenuList):
     886        def __init__(self, list, font0 = 28, font1 = 16, itemHeight = 142, enableWrapAround = True):
     887                MenuList.__init__(self, [], False, eListboxPythonMultiContent)
     888                self.l.setFont(0, gFont("Regular", font0))
     889                self.l.setFont(1, gFont("Regular", font1))
     890                self.l.setItemHeight(itemHeight)
     891
     892# -------------------------------------------------------------------
     893class SatPanel(Screen, HelpableScreen):
     894        def __init__(self, session, ort):
     895                self.session = session
     896                self.ort = ort
     897                self.skin = """
     898                        <screen name="SatPanel" position="center,center" size="630,500" title="Satelliten - Bilder / Karten" backgroundColor="#252525">
     899                                <widget name="Mlist" position="10,10" size="600,430" zPosition="3" backgroundColor="#252525"  backgroundColorSelected="#565656" scrollbarMode="showOnDemand" />
     900
     901                                <eLabel position="0,445" zPosition="2" size="630,1" backgroundColor="#c1cdc1" />
     902                                <widget source="key_blue" render="Label" position="260,457" zPosition="2" size="290,30" font="Regular;20" valign="center" halign="left" transparent="1" />
     903                                <ePixmap position="200,460" size="36,20" pixmap="skin_default/buttons/key_blue.png" transparent="1" alphatest="on" />
     904
     905                        </screen>"""
     906
     907                Screen.__init__(self, session)
     908                self.Mlist = []
     909
     910                self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('satellit'), _("Satelliten Bild"), 'satellit')))
     911                self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('niederschlag'), _("Niederschlags Karte"), 'niederschlag')))
     912                self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('bewoelkung'), _("Bewölkung Bild"), 'bewoelkung')))
     913                #self.Mlist.append(self.SatEntryItem((self.SatEntryComponent('luftdruck'), _("Luftdruck Karte"), 'luftdruck')))
     914
     915
     916                self.onChangedEntry = []
     917                if (getDesktop(0).size().width() == 1280):
     918                                self["Mlist"] = SatPanelList([])
     919                else:
     920                                self["Mlist"] = SatPanelList([], font0=24, font1=15, itemHeight=60)
     921                self["Mlist"].l.setList(self.Mlist)
     922                self["Mlist"].selectionEnabled(1)
     923                self["key_blue"] = StaticText()
     924                self["key_blue"].text = _("Einstellungen")
     925
     926                HelpableScreen.__init__(self)
     927                self["actions"] = HelpableActionMap(self, "AAFKeyActions",
     928                        {
     929                                "cancel": (self.Exit, "Beenden"),
     930                                "left": (self.left, "Seite hoch"),
     931                                "right": (self.right, "Seite runter"),
     932                                "up": (self.up, "Hoch"),
     933                                "down": (self.down, "Runter"),
     934                                "blue": (self.PicSetupMenu, "blue"),
     935                                "ok": (self.ok, "OK"),
     936                        }, -2)
     937
     938        def up(self):
     939                self["Mlist"].up()
     940                self["Mlist"].selectionEnabled(1)
     941
     942        def down(self):
     943                self["Mlist"].down()
     944                self["Mlist"].selectionEnabled(1)
     945
     946        def left(self):
     947                self["Mlist"].pageUp()
     948
     949        def right(self):
     950                self["Mlist"].pageDown()
     951
     952        def Exit(self):
     953                global menu
     954                menu = "stop"
     955                self.close()
     956
     957        def ok(self):
     958                #global menu
     959                menu = self['Mlist'].l.getCurrentSelection()[0][2]
     960                ##print "druecke OK", menu
     961                #self.close()
     962                self.SatBild()
     963
     964        def SatEntryComponent(self,file):
     965                png = LoadPixmap("/usr/lib/enigma2/python/Plugins/Extensions/Foreca/thumb/" + file + ".png")
     966                res = (png)
     967                return res
     968
     969        def PicSetupMenu(self):
     970                self.session.open(PicSetup)
     971               
     972#------------------------------------------------------------------------------------------
     973        def SatBild(self):
     974
     975                #message = "%s" % (_("Satelittenbilder werden geladen .....\n\n                       "))
     976                #self.session.open( MessageBox, message, MessageBox.TYPE_INFO, timeout=4)
     977
     978                menu = self['Mlist'].l.getCurrentSelection()[0][2]
     979                if menu == "satellit":
     980                        # http://www.foreca.de/Austria/Linz?map=sat
     981                        devicepath = "/tmp/sat.html"
     982                        url = "http://www.foreca.at/" + self.ort + "?map=sat"
     983
     984#------------------------------------------------------------------------------------------
     985                if menu == "niederschlag":
     986                        devicepath = "/tmp/sat.html"
     987                        url = "http://www.foreca.at/" + self.ort + "?map=rain"
     988
     989#------------------------------------------------------------------------------------------
     990                if menu == "bewoelkung":
     991                        devicepath = "/tmp/sat.html"
     992                        url = "http://www.foreca.at/" + self.ort + "?map=cloud"
     993
     994#------------------------------------------------------------------------------------------
     995                       
     996                if menu == "luftdruck":
     997                        devicepath = "/tmp/sat.html"
     998                        url = "http://www.foreca.at/" + self.ort + "?map=pressure"
     999
     1000#------------------------------------------------------------------------------------------
     1001
     1002
     1003                # Lade Kategorie Seite und suche BildLink
     1004                h = urllib.urlretrieve(url, devicepath)
     1005                fd=open(devicepath)
     1006                html=fd.read()
     1007                fd.close()
     1008
     1009                fulltext = re.compile(r'http://cache-(.+?) ', re.DOTALL)
     1010                PressureLink = fulltext.findall(html)
     1011                PicLink = PressureLink[0]
     1012                PicLink = "http://cache-" +     PicLink
     1013
     1014                # Lade Bilder fuer Slideshow
     1015                devicepath = "/usr/lib/enigma2/python/Plugins/Extensions/Foreca/bilder/sat"
     1016                max = int(len(PressureLink))-2
     1017                print "max= ", str(max)
     1018                zehner = "1"
     1019                x = 0
     1020                while x < max:
     1021                        url = "http://cache-" + PressureLink[x]
     1022                        print str(x), url
     1023                        h = urllib.urlretrieve(url, devicepath + zehner + str(x) + ".jpg")
     1024                        x = x + 1
     1025                        if x > 9:
     1026                                zehner = "2"
     1027
     1028                self.session.open(View_Slideshow, 0, True)
     1029
     1030#------------------------------------------------------------------------------------------
     1031
     1032        def SatEntryItem(self,entry):
     1033                rot = 16711680
     1034                gruen = 60928
     1035                dgruen = 52480
     1036                drot = 0xf47d19
     1037                mblau = 8900346
     1038                hblau = 11592447
     1039                dblau = 5215437
     1040                weiss = 0xffffff
     1041                orange = 0xf47d19
     1042                grau = 0x565656
     1043
     1044                res = [entry]
     1045                #       return (eListboxPythonMultiContent.TYPE_TEXT, pos[0], pos[1], size[0], size[1], font, flags, text, color, color_sel, backcolor, backcolor_sel, border_width, border_color)
     1046                res.append(MultiContentEntryPixmapAlphaTest(pos=(2, 5), size=(200, 140), png=entry[0]))  # png vorn
     1047                res.append(MultiContentEntryText(pos=(240, 45), size=(340, 50), font=0, text=entry[1], color=mblau, color_sel=mblau, backcolor_sel=grau))
    7991048                return res
    8001049
     
    8581107
    8591108#------------------------------------------------------------------------------------------
    860 #-----------------------Haupt Programm ----------------------------------------------------
     1109class View_Slideshow(Screen, InfoBarAspectSelection, InfoBarResolutionSelection):
     1110        def __init__(self, session, pindex, startslide):
     1111
     1112                print "SlideShow is running ......."
     1113                self.textcolor = config.plugins.foreca.textcolor.value
     1114                self.bgcolor = config.plugins.foreca.bgcolor.value
     1115                space = config.plugins.foreca.framesize.value
     1116                size_w = getDesktop(0).size().width()
     1117                size_h = getDesktop(0).size().height()
     1118
     1119                self.skindir = "/tmp"
     1120                self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
     1121                        <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
     1122                        <widget name=\"point\" position=\""+ str(space+5) + "," + str(space+10) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/record.png\" alphatest=\"on\" /> \
     1123                        <widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+10) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/ico_mp_play.png\"  alphatest=\"on\" /> \
     1124                        <widget name=\"file\" position=\""+ str(space+45) + "," + str(space+8) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"
     1125                Screen.__init__(self, session)
     1126
     1127                InfoBarAspectSelection.__init__(self)
     1128                self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
     1129                {
     1130                        "cancel": self.Exit,
     1131                        "yellow": self.PlayPause,
     1132                        "blue": self.sleepTimer,
     1133                        "left": self.prevPic,
     1134                        "right": self.nextPic,
     1135                }, -1)
     1136                self["point"] = Pixmap()
     1137                self["pic"] = Pixmap()
     1138                self["play_icon"] = Pixmap()
     1139                self["file"] = Label(_("please wait, loading picture..."))
     1140                self.old_index = 0
     1141                self.picfilelist = []
     1142                self.lastindex = pindex
     1143                self.currPic = []
     1144                self.shownow = True
     1145                self.dirlistcount = 0
     1146
     1147                devicepath = config.plugins.foreca.Device.value
     1148                currDir = devicepath
     1149                self.filelist = FileList(currDir, showDirectories = False, matchingPattern = "^.*\.(jpg)", useServiceRef = False)
     1150
     1151                for x in self.filelist.getFileList():
     1152                                if x[0][1] == False:
     1153                                        self.picfilelist.append(currDir + x[0][0])
     1154                                else:
     1155                                        self.dirlistcount += 1
     1156
     1157                self.maxentry = len(self.picfilelist)-1
     1158                self.pindex = pindex - self.dirlistcount
     1159                if self.pindex < 0:
     1160                        self.pindex = 0
     1161                self.picload = ePicLoad()
     1162                self.picload.PictureData.get().append(self.finish_decode)
     1163                self.slideTimer = eTimer()
     1164                self.slideTimer.callback.append(self.slidePic)
     1165                if self.maxentry >= 0:
     1166                        self.onLayoutFinish.append(self.setPicloadConf)
     1167                if startslide == True:
     1168                        self.PlayPause();
     1169
     1170        def setPicloadConf(self):
     1171                sc = getScale()
     1172                self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.plugins.foreca.resize.value), self.bgcolor])
     1173                self["play_icon"].hide()
     1174                if config.plugins.foreca.infoline.value == False:
     1175                        self["file"].hide()
     1176                self.start_decode()
     1177
     1178        def ShowPicture(self):
     1179                if self.shownow and len(self.currPic):
     1180                        self.shownow = False
     1181                        self["file"].setText(self.currPic[0])
     1182                        self.lastindex = self.currPic[1]
     1183                        self["pic"].instance.setPixmap(self.currPic[2].__deref__())
     1184                        self.currPic = []
     1185                        self.next()
     1186                        self.start_decode()
     1187
     1188        def finish_decode(self, picInfo=""):
     1189                self["point"].hide()
     1190                ptr = self.picload.getData()
     1191                if ptr != None:
     1192                        text = ""
     1193                        try:
     1194                                text = picInfo.split('\n',1)
     1195                                text = "(" + str(self.pindex+1) + "/" + str(self.maxentry+1) + ") " + text[0].split('/')[-1]
     1196                        except:
     1197                                pass
     1198                        self.currPic = []
     1199                        self.currPic.append(text)
     1200                        self.currPic.append(self.pindex)
     1201                        self.currPic.append(ptr)
     1202                        self.ShowPicture()
     1203
     1204        def start_decode(self):
     1205                self.picload.startDecode(self.picfilelist[self.pindex])
     1206                self["point"].show()
     1207
     1208        def next(self):
     1209                self.pindex += 1
     1210                if self.pindex > self.maxentry:
     1211                        self.pindex = 0
     1212
     1213        def prev(self):
     1214                self.pindex -= 1
     1215                if self.pindex < 0:
     1216                        self.pindex = self.maxentry
     1217
     1218        def slidePic(self):
     1219                print "[Picasa] slide to next Picture index=" + str(self.lastindex)
     1220                if config.plugins.foreca.loop.value==False and self.lastindex == self.maxentry:
     1221                        self.PlayPause()
     1222                self.shownow = True
     1223                self.ShowPicture()
     1224
     1225        def PlayPause(self):
     1226                if self.slideTimer.isActive():
     1227                        self.slideTimer.stop()
     1228                        self["play_icon"].hide()
     1229                else:
     1230                        self.slideTimer.start(config.plugins.foreca.slidetime.value*1000)
     1231                        self["play_icon"].show()
     1232                        self.nextPic()
     1233
     1234        def prevPic(self):
     1235                self.currPic = []
     1236                self.pindex = self.lastindex
     1237                self.prev()
     1238                self.start_decode()
     1239                self.shownow = True
     1240
     1241        def nextPic(self):
     1242                self.shownow = True
     1243                self.ShowPicture()
     1244
     1245        def Exit(self):
     1246                del self.picload
     1247                self.close(self.lastindex + self.dirlistcount)
     1248
     1249        def sleepTimer(self):
     1250                from Screens.SleepTimerEdit import SleepTimerEdit
     1251                self.session.open(SleepTimerEdit)
     1252
     1253#------------------------------------------------------------------------------------------
     1254#-------------------------------- Foreca Settings -----------------------------------------
     1255#------------------------------------------------------------------------------------------
     1256class PicSetup(Screen):
     1257        skin = """<screen position="center,center" size="480,260" title="Foreca SlideShow Settings" backgroundColor="#000000" >
     1258                <widget name="liste" position="5,5" size="470,250" scrollbarMode="showOnDemand" />
     1259                <eLabel backgroundColor="red" position="28,250" size="140,3" zPosition="2"/>
     1260                <eLabel backgroundColor="green" position="228,250" size="140,3" zPosition="2"/>
     1261                <widget name="key_red" position="28,218" zPosition="3" size="140,40" font="Regular;19" valign="center" halign="center" transparent="1" />
     1262                <widget name="key_green" position="228,218" zPosition="3" size="140,40" font="Regular;19" valign="center" halign="center" transparent="1" />
     1263        </screen>"""
     1264
     1265        def __init__(self, session):
     1266                self.skin = PicSetup.skin
     1267                Screen.__init__(self, session)
     1268                self["key_red"] = Button(_("Back"))
     1269                self["key_green"] = Button(_("Save"))
     1270                self["actions"] = NumberActionMap(["SetupActions", "ColorActions"],
     1271                {
     1272                        "ok": self.save,
     1273                        "green": self.save,
     1274                        "cancel": self.close,
     1275                        "red": self.close,
     1276                        "left": self.keyLeft,
     1277                        "right": self.keyRight,
     1278                        "0": self.keyNumber,
     1279                        "1": self.keyNumber,
     1280                        "2": self.keyNumber,
     1281                        "3": self.keyNumber,
     1282                        "4": self.keyNumber,
     1283                        "5": self.keyNumber,
     1284                        "6": self.keyNumber,
     1285                        "7": self.keyNumber,
     1286                        "8": self.keyNumber,
     1287                        "9": self.keyNumber
     1288                }, -3)
     1289                self.list = []
     1290                self["liste"] = ConfigList(self.list)
     1291
     1292                #self.list.append(getConfigListEntry(_("Picture Y moving"), config.plugins.foreca.max_offsety))
     1293                #self.list.append(getConfigListEntry(_("delete cached Pictures"), config.plugins.foreca.remove))
     1294                #self.list.append(getConfigListEntry(_("Picture Cache"), config.plugins.foreca.Device))
     1295                self.list.append(getConfigListEntry(_("Scaling Mode"), config.plugins.foreca.resize))
     1296                self.list.append(getConfigListEntry(_("Frame size in full view"), config.plugins.foreca.framesize))
     1297                self.list.append(getConfigListEntry(_("backgroundcolor"), config.plugins.foreca.bgcolor))
     1298                self.list.append(getConfigListEntry(_("Textcolor"), config.plugins.foreca.textcolor))
     1299                self.list.append(getConfigListEntry(_("SlideTime"), config.plugins.foreca.slidetime))
     1300                self.list.append(getConfigListEntry(_("Show Infoline"), config.plugins.foreca.infoline))
     1301                self.list.append(getConfigListEntry(_("slide picture in loop"), config.plugins.foreca.loop))
     1302
     1303        def save(self):
     1304                for x in self["liste"].list:
     1305                                x[1].save()
     1306                config.save()
     1307                self.close()
     1308
     1309        def keyLeft(self):
     1310                self["liste"].handleKey(KEY_LEFT)
     1311        def keyRight(self):
     1312                self["liste"].handleKey(KEY_RIGHT)
     1313        def keyNumber(self, number):
     1314                self["liste"].handleKey(KEY_0 + number)
     1315
     1316#------------------------------------------------------------------------------------------
     1317#------------------------------------- Haupt Programm -------------------------------------
    8611318#------------------------------------------------------------------------------------------
    8621319def start(session, **kwargs):
Note: See TracChangeset for help on using the changeset viewer.