Fix up showing speeds in titlebar and make it an option

This commit is contained in:
Andrew Resch 2008-12-09 05:27:01 +00:00
parent 513c783045
commit be0c891dd8
4 changed files with 924 additions and 862 deletions

File diff suppressed because it is too large Load Diff

View File

@ -107,7 +107,8 @@ DEFAULT_PREFS = {
"show_statusbar": True, "show_statusbar": True,
"sidebar_show_zero": False, "sidebar_show_zero": False,
"sidebar_show_trackers": False, "sidebar_show_trackers": False,
"sidebar_position": 170 "sidebar_position": 170,
"show_rate_in_title": False
} }
class GtkUI: class GtkUI:

View File

@ -72,6 +72,8 @@ class MainWindow(component.Component):
self.vpaned.connect("notify::position", self.on_vpaned_position_event) self.vpaned.connect("notify::position", self.on_vpaned_position_event)
self.window.connect("expose-event", self.on_expose_event) self.window.connect("expose-event", self.on_expose_event)
self.config.register_set_function("show_rate_in_title", self._on_set_show_rate_in_title)
if not(self.config["start_in_tray"] and \ if not(self.config["start_in_tray"] and \
self.config["enable_system_tray"]) and not \ self.config["enable_system_tray"]) and not \
self.window.get_property("visible"): self.window.get_property("visible"):
@ -196,13 +198,20 @@ class MainWindow(component.Component):
def on_expose_event(self, widget, event): def on_expose_event(self, widget, event):
component.get("SystemTray").blink(False) component.get("SystemTray").blink(False)
def stop(self):
self.window.set_title("Deluge")
def update(self): def update(self):
self.send_status_request() # Update the window title
def _on_get_session_status(status):
download_rate = deluge.common.fspeed(status["download_rate"])
upload_rate = deluge.common.fspeed(status["upload_rate"])
self.window.set_title("Deluge - %s %s %s %s" % (_("Down:"), download_rate, _("Up:"), upload_rate))
if self.config["show_rate_in_title"]:
client.get_session_status(_on_get_session_status, ["download_rate", "upload_rate"])
def send_status_request(self): def _on_set_show_rate_in_title(self, key, value):
client.get_session_status(self._on_get_session_status, ["download_rate", "upload_rate"]) if value:
self.update()
def _on_get_session_status(self, status): else:
self.download_rate = deluge.common.fsize(status["download_rate"]) self.window.set_title("Deluge")
self.upload_rate = deluge.common.fsize(status["upload_rate"])
self.window.set_title("Deluge - %s %s/s|%s %s/s" % (_("Down:"), self.download_rate, _("Up:"), self.upload_rate))

View File

@ -422,6 +422,8 @@ class Preferences(component.Component):
self.gtkui_config["lock_tray"]) self.gtkui_config["lock_tray"])
self.glade.get_widget("chk_classic_mode").set_active( self.glade.get_widget("chk_classic_mode").set_active(
self.gtkui_config["classic_mode"]) self.gtkui_config["classic_mode"])
self.glade.get_widget("chk_show_rate_in_title").set_active(
self.gtkui_config["show_rate_in_title"])
## Other tab ## ## Other tab ##
self.glade.get_widget("chk_show_new_releases").set_active( self.glade.get_widget("chk_show_new_releases").set_active(
@ -606,6 +608,8 @@ class Preferences(component.Component):
new_gtkui_config["tray_password"] = passhex new_gtkui_config["tray_password"] = passhex
new_gtkui_config["classic_mode"] = \ new_gtkui_config["classic_mode"] = \
self.glade.get_widget("chk_classic_mode").get_active() self.glade.get_widget("chk_classic_mode").get_active()
new_gtkui_config["show_rate_in_title"] = \
self.glade.get_widget("chk_show_rate_in_title").get_active()
## Notification tab ## ## Notification tab ##
new_gtkui_config["ntf_tray_blink"] = \ new_gtkui_config["ntf_tray_blink"] = \