mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-17 05:47:50 +00:00
Add protocol traffic statusbar item
This commit is contained in:
parent
f5ad01a865
commit
dc63d26cfe
81
deluge/data/pixmaps/traffic.svg
Normal file
81
deluge/data/pixmaps/traffic.svg
Normal file
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="744.09448819"
|
||||
height="1052.3622047"
|
||||
id="svg2517"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
sodipodi:docname="traffic.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
inkscape:export-filename="/home/andrew/Projects/deluge/trunk/deluge/data/pixmaps/traffic16.png"
|
||||
inkscape:export-xdpi="2.459017"
|
||||
inkscape:export-ydpi="2.459017">
|
||||
<defs
|
||||
id="defs2519">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 526.18109 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="744.09448 : 526.18109 : 1"
|
||||
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
|
||||
id="perspective2525" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
gridtolerance="10000"
|
||||
guidetolerance="10"
|
||||
objecttolerance="10"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.35"
|
||||
inkscape:cx="375"
|
||||
inkscape:cy="520"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="709"
|
||||
inkscape:window-x="50"
|
||||
inkscape:window-y="25" />
|
||||
<metadata
|
||||
id="metadata2522">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
style="opacity:0.8;fill:#b7e399;fill-opacity:1;stroke:#000000;stroke-width:14.10382843;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 424.45502,812.39589 C 493.83075,744.33666 563.48855,676.45312 632.86428,608.39408 C 595.53708,608.32578 558.1166,608.46218 520.78921,608.39408 C 520.78921,527.80078 520.78921,447.20747 520.78921,366.61417 C 454.46776,366.61417 388.14611,366.61417 321.82448,366.61417 C 321.82448,446.99752 321.82448,527.38089 321.82448,607.76445 C 287.43309,607.70139 252.95569,607.82731 218.5643,607.76445 C 287.17399,676.07595 355.84554,744.0842 424.45502,812.39589 z"
|
||||
id="path2528"
|
||||
inkscape:export-filename="/home/andrew/Projects/deluge/trunk/deluge/data/pixmaps/traffic32.png"
|
||||
inkscape:export-xdpi="4.9180341"
|
||||
inkscape:export-ydpi="4.9180341" />
|
||||
<path
|
||||
style="opacity:0.8;fill:#93beff;fill-opacity:1;stroke:#000000;stroke-width:14.10382843;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 295.88359,240.8999 C 365.25932,308.95913 434.91712,376.84267 504.29285,444.90171 C 466.96565,444.97001 429.54517,444.83361 392.21778,444.90171 C 392.21778,525.49501 392.21778,606.08832 392.21778,686.68162 C 325.89633,686.68162 259.57468,686.68162 193.25305,686.68162 C 193.25305,606.29827 193.25305,525.9149 193.25305,445.53134 C 158.86166,445.5944 124.38426,445.46848 89.992873,445.53134 C 158.60256,377.21984 227.27411,309.21159 295.88359,240.8999 z"
|
||||
id="rect2634"
|
||||
inkscape:export-filename="/home/andrew/Projects/deluge/trunk/deluge/data/pixmaps/traffic32.png"
|
||||
inkscape:export-xdpi="4.9180341"
|
||||
inkscape:export-ydpi="4.9180341" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.8 KiB |
BIN
deluge/data/pixmaps/traffic16.png
Normal file
BIN
deluge/data/pixmaps/traffic16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 618 B |
@ -115,6 +115,8 @@ class StatusBar(component.Component):
|
||||
self.dht_nodes = 0
|
||||
self.dht_status = False
|
||||
self.health = False
|
||||
self.download_protocol_rate = 0.0
|
||||
self.upload_protocol_rate = 0.0
|
||||
|
||||
self.config_value_changed_dict = {
|
||||
"max_connections_global": self._on_max_connections_global,
|
||||
@ -159,6 +161,11 @@ class StatusBar(component.Component):
|
||||
callback=self._on_upload_item_clicked,
|
||||
tooltip=_("Upload Speed"))
|
||||
|
||||
self.traffic_item = self.add_item(
|
||||
image=deluge.common.get_pixmap("traffic16.png"),
|
||||
callback=self._on_traffic_item_clicked,
|
||||
tooltip=_("Protocol Traffic Upload/Download"))
|
||||
|
||||
self.dht_item = StatusBarItem(
|
||||
image=deluge.common.get_pixmap("dht16.png"))
|
||||
self.tooltips.set_tip(self.dht_item.get_eventbox(), "DHT Nodes")
|
||||
@ -192,6 +199,7 @@ class StatusBar(component.Component):
|
||||
self.remove_item(self.upload_item)
|
||||
self.remove_item(self.not_connected_item)
|
||||
self.remove_item(self.health_item)
|
||||
self.remove_item(self.traffic_item)
|
||||
except Exception, e:
|
||||
log.debug("Unable to remove StatusBar item: %s", e)
|
||||
self.show_not_connected()
|
||||
@ -253,8 +261,9 @@ class StatusBar(component.Component):
|
||||
client.get_num_connections(self._on_get_num_connections)
|
||||
if self.dht_status:
|
||||
client.get_dht_nodes(self._on_get_dht_nodes)
|
||||
client.get_download_rate(self._on_get_download_rate)
|
||||
client.get_upload_rate(self._on_get_upload_rate)
|
||||
client.get_session_status(self._on_get_session_status,
|
||||
["upload_rate", "download_rate", "payload_upload_rate", "payload_download_rate"])
|
||||
|
||||
if not self.health:
|
||||
# Only request health status while False
|
||||
client.get_health(self._on_get_health)
|
||||
@ -287,22 +296,23 @@ class StatusBar(component.Component):
|
||||
else:
|
||||
self.remove_item(self.dht_item)
|
||||
|
||||
def _on_get_session_status(self, status):
|
||||
self.download_rate = deluge.common.fsize(status["payload_download_rate"])
|
||||
self.upload_rate = deluge.common.fsize(status["payload_upload_rate"])
|
||||
self.download_protocol_rate = (status["download_rate"] - status["payload_download_rate"]) / 1024
|
||||
self.upload_protocol_rate = (status["upload_rate"] - status["payload_upload_rate"]) / 1024
|
||||
self.update_download_label()
|
||||
self.update_upload_label()
|
||||
self.update_traffic_label()
|
||||
|
||||
def _on_max_download_speed(self, max_download_speed):
|
||||
self.max_download_speed = max_download_speed
|
||||
self.update_download_label()
|
||||
|
||||
def _on_get_download_rate(self, download_rate):
|
||||
self.download_rate = deluge.common.fsize(download_rate)
|
||||
self.update_download_label()
|
||||
|
||||
def _on_max_upload_speed(self, max_upload_speed):
|
||||
self.max_upload_speed = max_upload_speed
|
||||
self.update_upload_label()
|
||||
|
||||
def _on_get_upload_rate(self, upload_rate):
|
||||
self.upload_rate = deluge.common.fsize(upload_rate)
|
||||
self.update_upload_label()
|
||||
|
||||
def _on_get_health(self, value):
|
||||
self.health = value
|
||||
if self.health:
|
||||
@ -341,6 +351,10 @@ class StatusBar(component.Component):
|
||||
|
||||
self.upload_item.set_text(label_string)
|
||||
|
||||
def update_traffic_label(self):
|
||||
label_string = "%.2f/%.2f KiB/s" % (self.upload_protocol_rate, self.download_protocol_rate)
|
||||
self.traffic_item.set_text(label_string)
|
||||
|
||||
def update(self):
|
||||
# Send status request
|
||||
self.send_status_request()
|
||||
@ -433,3 +447,6 @@ class StatusBar(component.Component):
|
||||
|
||||
def _on_notconnected_item_clicked(self, widget, event):
|
||||
component.get("ConnectionManager").show()
|
||||
|
||||
def _on_traffic_item_clicked(self, widget, event):
|
||||
component.get("Preferences").show("Network")
|
||||
|
Loading…
x
Reference in New Issue
Block a user