Skip to content

Commit

Permalink
prepared addition of custom viewtypes via GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
mad-max committed Feb 14, 2012
1 parent 25298a6 commit ef8ad8a
Show file tree
Hide file tree
Showing 45 changed files with 4,501 additions and 2 deletions.
3 changes: 2 additions & 1 deletion 720p/MyVideoNav.xml
@@ -1,7 +1,7 @@
<window id="25">
<defaultcontrol always="true">9999</defaultcontrol>
<allowoverlay>no</allowoverlay>
<views>50,51,500,550,551,560,501,508,504,503,505,511,727,723,519,520,725,543,724,728,746,514,596,58</views>
<views>50,51,500,550,551,560,501,508,504,503,505,511,727,723,519,520,725,543,724,728,746,514,596,58,1001</views>
<controls>
<control type="button" id="9999"> <!-- TVTunes mod -->
<description>trigger</description>
Expand Down Expand Up @@ -61,6 +61,7 @@
<include>WallStreamView2</include> <!-- view id = 514 -->
<include>3d_CoverView</include>
<include>Viewtype_Showcase</include>
<include>Include_CustomView</include>


</control>
Expand Down
66 changes: 66 additions & 0 deletions 720p/custom_ModSetting_1144.xml
Expand Up @@ -156,6 +156,11 @@
<label>40056</label>
<label2>40057</label2>
<onclick>-</onclick>
</item>
<item id="5">
<label>Custom Views</label>
<label2>Custom Views</label2>
<onclick>-</onclick>
</item>
</content>
</control>
Expand Down Expand Up @@ -859,6 +864,67 @@
<!-- FILL IN HERE -->
</control>
</control>


<!-- CUSTOM VIEWS -->
<control type="group">
<control type="grouplist" id="9005">
<visible>Container(9000).Hasfocus(5)</visible>
<posx>290</posx>
<posy>60</posy>
<width>750</width>
<height>530</height>
<itemgap>-1</itemgap>
<pagecontrol>61</pagecontrol>
<onleft>9000</onleft>
<onright>61</onright>
<onup>9005</onup>
<ondown>9005</ondown>
<control type="label" id="400">
<width>750</width>
<height>45</height>
<font>font13_title</font>
<label>Views</label>
<textcolor>blue</textcolor>
<shadowcolor>black</shadowcolor>
<align>center</align>
<aligny>center</aligny>
</control>
<control type="button" id="501">
<width>750</width>
<height>40</height>
<font>font13</font>
<label>Add via ZIP</label>
<textcolor>grey2</textcolor>
<focusedcolor>white</focusedcolor>
<texturefocus>MenuItemFO.png</texturefocus>
<texturenofocus>MenuItemNF.png</texturenofocus>
<onclick>Skin.SetFile(NewView,.zip)</onclick>
<onclick>RunScript(special://skin/scripts/script.influence_view.installer/default.py,$INFO[Skin.String(NewView)])</onclick>
</control>

<control type="button" id="502">
<width>750</width>
<height>40</height>
<font>font13</font>
<label>Reinstall Views</label>
<textcolor>grey2</textcolor>
<focusedcolor>white</focusedcolor>
<texturefocus>MenuItemFO.png</texturefocus>
<texturenofocus>MenuItemNF.png</texturenofocus>
<align>left</align>
<aligny>center</aligny>
<include condition="Skin.HasSetting(ViewCustom1001_IsInstall)">ViewCustom1001_ReInstall</include>
<visible>Skin.HasSetting(ViewCustom1001_IsInstall)</visible>
</control>

<include condition="Skin.HasSetting(ViewCustom1001_IsInstall)">ViewCustom1001_Init</include>


<!-- FILL IN HERE -->
</control>
</control>
<!-- END OF CUSTOM VIEWS -->
<control type="scrollbar" id="61">
<posx>1060</posx>
<posy>60</posy>
Expand Down
16 changes: 15 additions & 1 deletion 720p/includes.xml
Expand Up @@ -51,7 +51,21 @@
<camera x="640" y="200" />
<animation effect="rotatey" center="50" start="-30" end="-30" time="0" condition="true">Conditional</animation>
</include>


<include name="Include_CustomView">
<include condition="Skin.HasSetting(ViewCustom1001_IsEnable)">ViewCustom1001_Mod</include>
</include>

<include name="Include_CustomView_Cust">
<include condition="Skin.HasSetting(ViewCustom1001_IsEnable)">ViewCustom1001_Custom</include>
</include>

<include name="ViewCustom1001_ReInstall">
<onclick>RunScript(special://skin/scripts/script.influence_view.reinstall/default.py,1001)</onclick>
</include>

<include file="View_Custom1001.xml" />

<include name="CommonPageCount">
<control type="label">
<description>Page Count Label</description>
Expand Down
59 changes: 59 additions & 0 deletions scripts/AddView.py
@@ -0,0 +1,59 @@
import xbmc
from xbmcgui import Window
import re
import sys
import os
import zipfile

def unzip( filename, destination=None, report=False ):
from zipfile import ZipFile
base_dir = ""

zip = ZipFile( filename, "r" )
namelist = zip.namelist()
total_items = len( namelist ) or 1
diff = 100.0 / total_items
percent = 0

if os.path.isdir( base_dir ):
shutil2.rmtree( base_dir )
os.makedirs( base_dir )
for count, item in enumerate( namelist ):
percent += diff
if report:
if DIALOG_PROGRESS.iscanceled():
break
DIALOG_PROGRESS.update( int( percent ), _( 188 ) % ( count + 1, total_items ), item, _( 110 ) )
#print round( percent, 2 ), item
if not item.endswith( "/" ):
root, name = os.path.split( item )
directory = os.path.normpath( os.path.join( destination, root ) )
if not os.path.isdir( directory ): os.makedirs( directory )
file( os.path.join( directory, name ), "wb" ).write( zip.read( item ) )
zip.close()
del zip
return base_dir, True

return "", False

class Main:
def __init__( self ):
#self.ZipSource = sys.argv[1]
fz="C:\Documents and Settings\trioual\Desktop\ProtoVue.zip","r"
ListView = ['1001','1002','1003','1004','1005','1006','1007','1008','1009','1010']
for v in ListView:
print v;
if xbmc.getCondVisibility("!Skin.HasSetting(ViewCustom%s_IsThere)" % (v) ):
#-- Cette vue n'est pas installée
unzip(fz,xbmc.translatePath( "special://skin/" ))
SrcView=open('special://skin/720p/View_Custom.xml','r')
NewView=open('special://skin/720p/View_Custom%s.xml' % (v),'w')
f=NewView.readlines()
SrcView.close
for l in f:
NewView.write(l.replace("##@@##",v))
NewView.close
break

if ( __name__ == "__main__" ):
Main()
12 changes: 12 additions & 0 deletions scripts/DelView.py
@@ -0,0 +1,12 @@
import re
import sys
import os

class Main:
def __init__( self ):
self.NumView = sys.argv[1]
os.remove('special://skin/720p/Custom_View%s.xml' % self.NumView)
os.rmdir('special://skin/media/Custom_Media%s' % self.NumView)

if ( __name__ == "__main__" ):
Main()
16 changes: 16 additions & 0 deletions scripts/script.glassview/addon.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.glassview"
name="glassview"
version="1.0.0"
provider-name="Frost (passion-xbmc.org)">
<requires>
<import addon="xbmc.python" version="1.0"/>
</requires>
<extension point="xbmc.python.library"
library="default.py" />
<extension point="xbmc.addon.metadata">
<summary>Simple addon installer for skinner</summary>
<description>Simple addon installer for skinner</description>
<platform>all</platform>
</extension>
</addon>
110 changes: 110 additions & 0 deletions scripts/script.glassview/default.py
@@ -0,0 +1,110 @@
"""
Simple addon installer for skinner
"""


#Modules General
import os
import sys
import urllib
from traceback import print_exc

#Modules XBMC
import xbmc
import xbmcgui
from xbmcaddon import Addon

# addon constants
__addonID__ = "skin.glass.svn" # get addon id
__settings__ = Addon( __addonID__ ) # get Addon object
__localize__ = __settings__.getLocalizedString


REPO_PACKAGE_DIR = "special://home/addons/packages/"

SILENT = True
DIALOG_PROGRESS = xbmcgui.DialogProgress()


def download( url, destination=REPO_PACKAGE_DIR ):
try:
if not SILENT:
DIALOG_PROGRESS.create( __settings__.getAddonInfo( "name" ) )
destination = xbmc.translatePath( destination ) + os.path.basename( url )
def _report_hook( count, blocksize, totalsize ):
if not SILENT:
percent = int( float( count * blocksize * 100 ) / totalsize )
DIALOG_PROGRESS.update( percent, "Downloading: %s " % url, "to: %s" % destination )
fp, h = urllib.urlretrieve( url, destination, _report_hook )
print fp, h
return fp
except:
print_exc()
if not SILENT:
DIALOG_PROGRESS.close()
return ""


def install( filename ):
from resources.lib.extractor import extract
return extract( filename, xbmc.translatePath( "special://skin" ) )


def notification( header="", message="", sleep=5000, icon=__settings__.getAddonInfo( "icon" ) ):
""" Will display a notification dialog with the specified header and message,
in addition you can set the length of time it displays in milliseconds and a icon image.
"""
xbmc.executebuiltin( "XBMC.Notification(%s,%s,%i,%s)" % ( header, message, sleep, icon ) )


if ( __name__ == "__main__" ):
try: testurl = sys.argv[ 1 ]
except: print_exc()
else:
try:
NAME = sys.argv[ 2 ]
SILENT = sys.argv[ 3 ] != "false"
except: print_exc()
print "LE SCRIPT EST RENDU A FAIRE CECI 'download' " + testurl

newaddon = download( testurl )
print "resultat de newaddon " + newaddon

if newaddon:
fp, ok = install( newaddon )
print fp, ok
if newaddon:
ListView = ['1001','1002','1003','1004','1005','1006','1007','1008','1009','1010','1011','1012','1013','1014','1015','1016','1017','1018','1019','1020']
print ListView
ViewOK=False
for v in ListView:
print v;
if xbmc.getCondVisibility("!Skin.HasSetting(ViewCustom%s_IsInstall)" % (v) ) or os.access(xbmc.translatePath('special://skin/1080i/View_Custom%s.xml' % v),os.F_OK)==False:
print testurl
fp, ok = install( testurl )
SrcView=open(xbmc.translatePath('special://skin/720p/View_Custom.xml'),'r')
NewView=open(xbmc.translatePath('special://skin/1080i/View_Custom%s.xml' % (v)),'w')
SaveView=open(xbmc.translatePath('special://masterprofile/View_Custom%s.xml' % (v)),'w')
f=SrcView.readlines()
SrcView.close
for l in f:
NewView.write(l.replace("##@@##",v))
SaveView.write(l.replace("##@@##",v))
NewView.close
SaveView.close
ViewOK=True
xbmc.executebuiltin( "Skin.SetBool(ViewCustom%s_IsInstall)" % ( v ) )
xbmc.executebuiltin( "Skin.SetString(ViewCustom%s_Name,%s)" % ( v, NAME ) )
try: os.remove(xbmc.translatePath('special://skin/720p/View_Custom.xml'))
except: print "erreur os.remove(%s)" % xbmc.translatePath('special://skin/720p/View_Custom.xml')
break
try: os.remove(xbmc.translatePath('special://masterprofile/720p/View_Custom.xml'))
except: print "erreur os.remove(%s)" % xbmc.translatePath('special://masterprofile/720p/View_Custom.xml')
break

if ViewOK:
#xbmcgui.Dialog().ok( "View %s installed and save in userdata" % (v), "XBMC requires restart!" )
xbmcgui.Dialog().ok( xbmc.getLocalizedString(31152) %v, xbmc.getLocalizedString(31153) )
else:
#xbmcgui.Dialog().ok( "Error","No more custom view available." )
xbmcgui.Dialog().ok( xbmc.getLocalizedString(257),xbmc.getLocalizedString(31154) )
1 change: 1 addition & 0 deletions scripts/script.glassview/resources/__init__.py
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
Binary file added scripts/script.glassview/resources/__init__.pyc
Binary file not shown.
Binary file added scripts/script.glassview/resources/__init__.pyo
Binary file not shown.
1 change: 1 addition & 0 deletions scripts/script.glassview/resources/lib/__init__.py
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
Binary file added scripts/script.glassview/resources/lib/__init__.pyc
Binary file not shown.
Binary file added scripts/script.glassview/resources/lib/__init__.pyo
Binary file not shown.

0 comments on commit ef8ad8a

Please sign in to comment.