Added status icons to the torrent list screen

This commit is contained in:
Correl Roush 2011-11-30 22:24:50 -05:00
parent db2bf3fa6c
commit 14025aa7c4
4 changed files with 64 additions and 68 deletions

View file

@ -68,13 +68,9 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
self.repeater = Repeater(1.0, self.updateTorrents) self.repeater = Repeater(1.0, self.updateTorrents)
self.repeater.start() self.repeater.start()
def updateTorrents(self): def updateTorrents(self):
list = self.getControl(20) list = self.getControl(120)
statuses = {'stopped': _(302),
'seeding': _(301),
'downloading': _(300)}
torrents = self.transmission.info() torrents = self.transmission.info()
for i, torrent in torrents.iteritems(): for i, torrent in torrents.iteritems():
status = statuses[torrent.status]
statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \ statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \
{'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \ {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \ 'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
@ -88,9 +84,12 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
# Update existing list item # Update existing list item
l = self.list[i] l = self.list[i]
self.torrents = torrents self.torrents = torrents
statusicons = {'stopped': 'pause.png',
'seeding': 'ok.png',
'downloading': 'down.png'}
l.setLabel(torrent.name) l.setLabel(torrent.name)
l.setLabel2(statusline) l.setLabel2(statusline)
l.setProperty('TorrentStatus', status) l.setProperty('TorrentStatusIcon', statusicons[torrent.status])
l.setProperty('TorrentID', str(i)) l.setProperty('TorrentID', str(i))
l.setProperty('TorrentProgress', "%.2f" % torrent.progress) l.setProperty('TorrentProgress', "%.2f" % torrent.progress)
l.setInfo('torrent', torrent.fields) l.setInfo('torrent', torrent.fields)
@ -107,8 +106,8 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
list.setEnabled(bool(torrents)) list.setEnabled(bool(torrents))
def onClick(self, controlID): def onClick(self, controlID):
list = self.getControl(20) list = self.getControl(120)
if (controlID == 11): if (controlID == 111):
# Add torrent # Add torrent
engines = [ engines = [
(_(200), None), (_(200), None),
@ -157,32 +156,32 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
except: except:
xbmcgui.Dialog().ok(_(0), _(293)) xbmcgui.Dialog().ok(_(0), _(293))
return return
if (controlID == 12): if (controlID == 112):
# Remove selected torrent # Remove selected torrent
item = list.getSelectedItem() item = list.getSelectedItem()
if item and xbmcgui.Dialog().yesno(_(0), 'Remove \'%s\'?' % self.torrents[int(item.getProperty('TorrentID'))].name): if item and xbmcgui.Dialog().yesno(_(0), 'Remove \'%s\'?' % self.torrents[int(item.getProperty('TorrentID'))].name):
remove_data = xbmcgui.Dialog().yesno(_(0), 'Remove data as well?') remove_data = xbmcgui.Dialog().yesno(_(0), 'Remove data as well?')
self.transmission.remove(int(item.getProperty('TorrentID')), remove_data) self.transmission.remove(int(item.getProperty('TorrentID')), remove_data)
if (controlID == 13): if (controlID == 113):
# Stop selected torrent # Stop selected torrent
item = list.getSelectedItem() item = list.getSelectedItem()
if item: if item:
self.transmission.stop(int(item.getProperty('TorrentID'))) self.transmission.stop(int(item.getProperty('TorrentID')))
if (controlID == 14): if (controlID == 114):
# Start selected torrent # Start selected torrent
item = list.getSelectedItem() item = list.getSelectedItem()
if item: if item:
self.transmission.start(int(item.getProperty('TorrentID'))) self.transmission.start(int(item.getProperty('TorrentID')))
if (controlID == 15): if (controlID == 115):
# Stop all torrents # Stop all torrents
self.transmission.stop(self.torrents.keys()) self.transmission.stop(self.torrents.keys())
if (controlID == 16): if (controlID == 116):
# Start all torrents # Start all torrents
self.transmission.start(self.torrents.keys()) self.transmission.start(self.torrents.keys())
if (controlID == 17): if (controlID == 117):
# Exit button # Exit button
self.close() self.close()
if (controlID == 20): if (controlID == 120):
# A torrent was chosen, show details # A torrent was chosen, show details
item = list.getSelectedItem() item = list.getSelectedItem()
w = TorrentInfoGUI("script-Transmission-details.xml",os.getcwd() ,"Default") w = TorrentInfoGUI("script-Transmission-details.xml",os.getcwd() ,"Default")

View file

@ -1,5 +1,5 @@
<window> <window>
<defaultcontrol always="true">11</defaultcontrol> <defaultcontrol always="true">111</defaultcontrol>
<allowoverlays>false</allowoverlays> <allowoverlays>false</allowoverlays>
<coordinates> <coordinates>
<system>1</system> <system>1</system>
@ -33,7 +33,7 @@
<posx>0</posx> <posx>0</posx>
<posy>10</posy> <posy>10</posy>
<!-- Button Group --> <!-- Button Group -->
<control type="button" id="11"> <control type="button" id="111">
<description>Add torrent</description> <description>Add torrent</description>
<posx>0</posx> <posx>0</posx>
<posy>0</posy> <posy>0</posy>
@ -44,13 +44,13 @@
<textoffsety>45</textoffsety> <textoffsety>45</textoffsety>
<label>SCRIPT101</label> <label>SCRIPT101</label>
<font>font12_title</font> <font>font12_title</font>
<onright>20</onright> <onright>120</onright>
<ondown>12</ondown> <ondown>112</ondown>
<onup>17</onup> <onup>117</onup>
<texturefocus>add-focus.png</texturefocus> <texturefocus>add-focus.png</texturefocus>
<texturenofocus>add-nofocus.png</texturenofocus> <texturenofocus>add-nofocus.png</texturenofocus>
</control> </control>
<control type="button" id="12"> <control type="button" id="112">
<description>Remove torrent</description> <description>Remove torrent</description>
<posx>0</posx> <posx>0</posx>
<posy>75</posy> <posy>75</posy>
@ -61,13 +61,13 @@
<textoffsety>45</textoffsety> <textoffsety>45</textoffsety>
<label>SCRIPT102</label> <label>SCRIPT102</label>
<font>font12_title</font> <font>font12_title</font>
<onright>20</onright> <onright>120</onright>
<onup>11</onup> <onup>111</onup>
<ondown>13</ondown> <ondown>113</ondown>
<texturefocus>remove-focus.png</texturefocus> <texturefocus>remove-focus.png</texturefocus>
<texturenofocus>remove-nofocus.png</texturenofocus> <texturenofocus>remove-nofocus.png</texturenofocus>
</control> </control>
<control type="button" id="13"> <control type="button" id="113">
<description>Stop torrent</description> <description>Stop torrent</description>
<posx>0</posx> <posx>0</posx>
<posy>150</posy> <posy>150</posy>
@ -78,13 +78,13 @@
<textoffsety>45</textoffsety> <textoffsety>45</textoffsety>
<label>SCRIPT103</label> <label>SCRIPT103</label>
<font>font12_title</font> <font>font12_title</font>
<onright>20</onright> <onright>120</onright>
<onup>12</onup> <onup>112</onup>
<ondown>14</ondown> <ondown>114</ondown>
<texturefocus>stop-focus.png</texturefocus> <texturefocus>stop-focus.png</texturefocus>
<texturenofocus>stop-nofocus.png</texturenofocus> <texturenofocus>stop-nofocus.png</texturenofocus>
</control> </control>
<control type="button" id="14"> <control type="button" id="114">
<description>Start torrent</description> <description>Start torrent</description>
<posx>0</posx> <posx>0</posx>
<posy>225</posy> <posy>225</posy>
@ -95,13 +95,13 @@
<textoffsety>45</textoffsety> <textoffsety>45</textoffsety>
<label>SCRIPT104</label> <label>SCRIPT104</label>
<font>font12_title</font> <font>font12_title</font>
<onright>20</onright> <onright>120</onright>
<onup>13</onup> <onup>113</onup>
<ondown>15</ondown> <ondown>115</ondown>
<texturefocus>start-focus.png</texturefocus> <texturefocus>start-focus.png</texturefocus>
<texturenofocus>start-nofocus.png</texturenofocus> <texturenofocus>start-nofocus.png</texturenofocus>
</control> </control>
<control type="button" id="15"> <control type="button" id="115">
<description>Stop all torrents</description> <description>Stop all torrents</description>
<posx>0</posx> <posx>0</posx>
<posy>300</posy> <posy>300</posy>
@ -112,13 +112,13 @@
<textoffsety>45</textoffsety> <textoffsety>45</textoffsety>
<label>SCRIPT105</label> <label>SCRIPT105</label>
<font>font12_title</font> <font>font12_title</font>
<onright>20</onright> <onright>120</onright>
<onup>14</onup> <onup>114</onup>
<ondown>16</ondown> <ondown>116</ondown>
<texturefocus>stopall-focus.png</texturefocus> <texturefocus>stopall-focus.png</texturefocus>
<texturenofocus>stopall-nofocus.png</texturenofocus> <texturenofocus>stopall-nofocus.png</texturenofocus>
</control> </control>
<control type="button" id="16"> <control type="button" id="116">
<description>Start all torrents</description> <description>Start all torrents</description>
<posx>0</posx> <posx>0</posx>
<posy>375 </posy> <posy>375 </posy>
@ -129,13 +129,13 @@
<textoffsety>45</textoffsety> <textoffsety>45</textoffsety>
<label>SCRIPT106</label> <label>SCRIPT106</label>
<font>font12_title</font> <font>font12_title</font>
<onright>20</onright> <onright>120</onright>
<onup>15</onup> <onup>115</onup>
<ondown>17</ondown> <ondown>117</ondown>
<texturefocus>startall-focus.png</texturefocus> <texturefocus>startall-focus.png</texturefocus>
<texturenofocus>startall-nofocus.png</texturenofocus> <texturenofocus>startall-nofocus.png</texturenofocus>
</control> </control>
<control type="button" id="17"> <control type="button" id="117">
<description>Exit</description> <description>Exit</description>
<posx>0</posx> <posx>0</posx>
<posy>450</posy> <posy>450</posy>
@ -146,11 +146,11 @@
<textoffsety>45</textoffsety> <textoffsety>45</textoffsety>
<label>SCRIPT107</label> <label>SCRIPT107</label>
<font>font12_title</font> <font>font12_title</font>
<onright>20</onright> <onright>120</onright>
<onup>16</onup> <onup>116</onup>
<texturefocus>exit-focus.png</texturefocus> <texturefocus>exit-focus.png</texturefocus>
<texturenofocus>exit-nofocus.png</texturenofocus> <texturenofocus>exit-nofocus.png</texturenofocus>
<ondown>11</ondown> <ondown>111</ondown>
</control> </control>
</control> </control>
<!-- <!--
@ -162,7 +162,7 @@
<texture>blue.png</texture> <texture>blue.png</texture>
</control> </control>
--> -->
<control type="list" id="20"> <control type="list" id="120">
<description>Torrent list</description> <description>Torrent list</description>
<posx>135</posx> <posx>135</posx>
<posy>35</posy> <posy>35</posy>
@ -171,8 +171,8 @@
<viewtype label="Torrent List">list</viewtype> <viewtype label="Torrent List">list</viewtype>
<orientation>vertical</orientation> <orientation>vertical</orientation>
<visible>true</visible> <visible>true</visible>
<onleft>11</onleft> <onleft>111</onleft>
<onright>17</onright> <onright>117</onright>
<itemlayout width="560" height="70"> <itemlayout width="560" height="70">
<control type="image"> <control type="image">
<posx>0</posx> <posx>0</posx>
@ -181,26 +181,24 @@
<height>70</height> <height>70</height>
<texture>list-bg.png</texture> <texture>list-bg.png</texture>
</control> </control>
<control type="label"> <control type="image">
<posx>10</posx> <posx>10</posx>
<posy>0</posy> <posy>0</posy>
<width>110</width> <width>64</width>
<height>20</height> <height>64</height>
<label>[$INFO[ListItem.Property(TorrentStatus)]]</label> <texture>icons/$INFO[ListItem.Property(TorrentStatusIcon)]</texture>
<scroll>true</scroll>
</control> </control>
<control type="label"> <control type="label">
<posx>120</posx> <posx>90</posx>
<posy>0</posy> <posy>0</posy>
<width>680</width> <width>700</width>
<height>20</height> <height>20</height>
<label>$INFO[ListItem.label]</label> <label>$INFO[ListItem.label]</label>
<scroll>true</scroll>
</control> </control>
<control type="progress"> <control type="progress">
<posx>10</posx> <posx>90</posx>
<posy>40</posy> <posy>40</posy>
<width>790</width> <width>700</width>
<height>20</height> <height>20</height>
<info>ListItem.Property(TorrentProgress)</info> <info>ListItem.Property(TorrentProgress)</info>
</control> </control>
@ -211,7 +209,7 @@
<posy>0</posy> <posy>0</posy>
<width>800</width> <width>800</width>
<height>70</height> <height>70</height>
<visible>Control.HasFocus(20)</visible> <visible>Control.HasFocus(120)</visible>
<texture border="5">list-bg-selected.png</texture> <texture border="5">list-bg-selected.png</texture>
</control> </control>
<control type="image"> <control type="image">
@ -219,29 +217,28 @@
<posy>0</posy> <posy>0</posy>
<width>800</width> <width>800</width>
<height>70</height> <height>70</height>
<visible>!Control.HasFocus(20)</visible> <visible>!Control.HasFocus(120)</visible>
<texture border="5">list-bg-selected-nofocus.png</texture> <texture border="5">list-bg-selected-nofocus.png</texture>
</control> </control>
<control type="label"> <control type="image">
<posx>10</posx> <posx>10</posx>
<posy>0</posy> <posy>0</posy>
<width>110</width> <width>64</width>
<height>20</height> <height>64</height>
<label>[$INFO[ListItem.Property(TorrentStatus)]]</label> <texture>icons/$INFO[ListItem.Property(TorrentStatusIcon)]</texture>
<scroll>true</scroll>
</control> </control>
<control type="label"> <control type="label">
<posx>120</posx> <posx>90</posx>
<posy>0</posy> <posy>0</posy>
<width>680</width> <width>700</width>
<height>20</height> <height>20</height>
<label>$INFO[ListItem.label]</label> <label>$INFO[ListItem.label]</label>
<scroll>true</scroll> <scroll>true</scroll>
</control> </control>
<control type="progress"> <control type="progress">
<posx>10</posx> <posx>90</posx>
<posy>40</posy> <posy>40</posy>
<width>790</width> <width>700</width>
<height>20</height> <height>20</height>
<info>ListItem.Property(TorrentProgress)</info> <info>ListItem.Property(TorrentProgress)</info>
</control> </control>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB