Added a table view of the list of torrents

This commit is contained in:
Artem Glebov 2013-04-25 14:36:16 +03:00
parent 5ecb3a2e6e
commit cc36c737b7
6 changed files with 137 additions and 4 deletions

View file

@ -31,6 +31,7 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
self.torrents = {}
self.timer = None
self.filter = lambda x : True
self.view = 'list'
def get_settings(self):
params = {
'address': __settings__.getSetting('rpc_host'),
@ -78,12 +79,22 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
message = _(9000) # Unexpected error
xbmcgui.Dialog().ok(_(2), message)
return False
self.view = 'list'
self.getControl(120).setVisible(True)
self.getControl(122).setVisible(False)
self.updateTorrents()
p.close()
self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrents)
self.timer.start()
def updateTorrents(self):
list = self.getControl(120)
def getCurrentViewControlID(self):
if self.view == 'list':
return 120
elif self.view == 'table':
return 122
def getCurrentViewControl(self):
return self.getControl(self.getCurrentViewControlID())
def showTorrents(self):
list = self.getCurrentViewControl()
self.torrents = self.transmission.info()
self.torrents = dict((k, v) for (k, v) in self.torrents.items() if self.filter(v))
i = 0
@ -114,8 +125,11 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
# Update again, after an interval
self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrents)
self.timer.start()
def updateTorrents(self):
self.torrents = self.transmission.info()
self.showTorrents()
def onClick(self, controlID):
list = self.getControl(120)
list = self.getCurrentViewControl()
if (controlID == 111):
# Add torrent
engines = [
@ -207,7 +221,7 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
except err:
xbmcgui.Dialog().ok(_(2), _(9001))
self.close()
if (controlID == 120):
if (controlID == self.getCurrentViewControlID()):
# Do nothing, just select the item
pass
if (controlID == 125):
@ -225,6 +239,16 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
self.getControl(125).setSelected(False)
self.getControl(126).setSelected(False)
self.filter = lambda torrent : True if torrent.status == "seeding" else False
if (controlID == 128):
self.view = 'list'
self.showTorrents()
self.getControl(120).setVisible(True)
self.getControl(122).setVisible(False)
if (controlID == 129):
self.view = 'table'
self.showTorrents()
self.getControl(120).setVisible(False)
self.getControl(122).setVisible(True)
def onDoubleClick(self, controlID):
if (controlID == 120):
# A torrent was chosen, show details

View file

@ -276,6 +276,115 @@
</control>
</focusedlayout>
</control>
<control type="list" id="122">
<description>Torrent table</description>
<posx>135</posx>
<posy>35</posy>
<width>800</width>
<height>480</height>
<viewtype label="Torrent table">table</viewtype>
<orientation>vertical</orientation>
<visible>true</visible>
<onleft>111</onleft>
<onright>117</onright>
<pagecontrol>121</pagecontrol>
<itemlayout width="560" height="40">
<control type="image">
<posx>0</posx>
<posy>0</posy>
<width>800</width>
<height>40</height>
<texture>list-bg.png</texture>
</control>
<control type="image">
<posx>10</posx>
<posy>5</posy>
<width>32</width>
<height>32</height>
<texture>icons/$INFO[ListItem.Property(TorrentStatusIcon)]</texture>
</control>
<control type="label">
<posx>90</posx>
<posy>5</posy>
<width>630</width>
<height>20</height>
<label>$INFO[ListItem.label]</label>
</control>
<control type="label">
<posx>735</posx>
<posy>5</posy>
<width>60</width>
<height>20</height>
<label>$INFO[ListItem.Property(TorrentProgress)]</label>
</control>
</itemlayout>
<focusedlayout width="560" height="40">
<control type="image">
<posx>0</posx>
<posy>0</posy>
<width>800</width>
<height>40</height>
<visible>Control.HasFocus(120)</visible>
<texture border="5">list-bg-selected.png</texture>
</control>
<control type="image">
<posx>0</posx>
<posy>0</posy>
<width>800</width>
<height>40</height>
<visible>!Control.HasFocus(120)</visible>
<texture border="5">list-bg-selected-nofocus.png</texture>
</control>
<control type="image">
<posx>10</posx>
<posy>5</posy>
<width>32</width>
<height>32</height>
<texture>icons/$INFO[ListItem.Property(TorrentStatusIcon)]</texture>
</control>
<control type="label">
<posx>90</posx>
<posy>5</posy>
<width>630</width>
<height>20</height>
<label>$INFO[ListItem.label]</label>
<scroll>true</scroll>
</control>
<control type="label">
<posx>735</posx>
<posy>5</posy>
<width>60</width>
<height>20</height>
<label>$INFO[ListItem.Property(TorrentProgress)]</label>
</control>
</focusedlayout>
</control>
<control type="button" id="128">
<description>List view button</description>
<posx>840</posx>
<posy>520</posy>
<width>40</width>
<height>30</height>
<label>-</label>
<font>-</font>
<onclick>PreviousMenu</onclick>
<texturefocus>list-focus.png</texturefocus>
<texturenofocus>list.png</texturenofocus>
<visible>true</visible>
</control>
<control type="button" id="129">
<description>Table view button</description>
<posx>880</posx>
<posy>520</posy>
<width>40</width>
<height>30</height>
<label>-</label>
<font>-</font>
<onclick>PreviousMenu</onclick>
<texturefocus>table-focus.png</texturefocus>
<texturenofocus>table.png</texturenofocus>
<visible>true</visible>
</control>
<control type="button" id="117">
<description>Exit</description>
<posx>850</posx>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B