From dc63d26cfe966a27c93e6d4a425118ffbf54809f Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Fri, 21 Nov 2008 09:35:29 +0000 Subject: [PATCH] Add protocol traffic statusbar item --- deluge/data/pixmaps/traffic.svg | 81 ++++++++++++++++++++++++++++++ deluge/data/pixmaps/traffic16.png | Bin 0 -> 618 bytes deluge/ui/gtkui/statusbar.py | 37 ++++++++++---- 3 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 deluge/data/pixmaps/traffic.svg create mode 100644 deluge/data/pixmaps/traffic16.png diff --git a/deluge/data/pixmaps/traffic.svg b/deluge/data/pixmaps/traffic.svg new file mode 100644 index 000000000..53a827cbb --- /dev/null +++ b/deluge/data/pixmaps/traffic.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/deluge/data/pixmaps/traffic16.png b/deluge/data/pixmaps/traffic16.png new file mode 100644 index 0000000000000000000000000000000000000000..fb392b3adb5c087f08ce14314e9575d0e2c06398 GIT binary patch literal 618 zcmeAS@N?(olHy`uVBq!ia0y~yVBlw9U=ZM7V_;x78K%m@z`(##?Bp53!NI{%!;#X# zz`(#+;1OBOz`&3Q!i=HX6ZSGNFi4iTMwA5Sr^!NZ>{OvT|fWi zyIVW`@7_>lnV%-crjd}6@?_IT-}n4yXD1ywa^}#2#7D=DpExpQY2u?(1&`0XGv$e3 zc>MqWe@O{RNz2?nmwr1Jsm(Unyurx8z`)?ok6(T>8XxN4p6ktCKhNIa>y(BI?^nym z)&Hq2djFJfMw*zLn;T#D{V#SYy#mSg#h*Dh6iVN;Htz8LTw(avKI7M;hkvzCm>GL& zzWmndvC>2Sp2gdn>*eDO=afDE^2>hx{Mf(c?>-nm6z{j=QaruUW^c7-cVlCtV}Q>o zkIPqTr|p=-*7a=v{`K`AyF+Ww9Y{F4q43?lat*U&ZjPjb2Qt$fpZ)pwv-kJs-|my% z$gKH)^XAN%7e%FSWpSy8v*!Q$``Y|*WAF0$i*KAcb?)ob-sbnZ+S10x*6P}AX_ls* zeGMY%E2sD0x2vsr?#igt`Zuv=TXE)Tv9z#n`~Uy1yA*a=++297NW%1>2QA0%zmKn% zPz%?w+*|$iK)eIep;3fe){r=eKpHdY^j}UB2kU z|NsB*OG-#ce0U}moIdx&KHjJ7X7}b59n-v!W5vwO%ziGWm3Ow~Yq#iX2|wrSKmPx( bXJa^TtHF?8B(#Nrfq}u()z4*}Q$iB}y@emZ literal 0 HcmV?d00001 diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index 6573df4a7..12949ac96 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -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")