From ce23ff34a779af973d3d344c4fc2eb2b55a40690 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Wed, 31 Mar 2010 18:15:29 -0700 Subject: [PATCH] Close #1205 add free space icon to gtkui --- deluge/core/core.py | 7 +++++-- deluge/ui/gtkui/statusbar.py | 13 +++++++++++++ deluge/ui/gtkui/systemtray.py | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index 5ce594b11..164a4bdca 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -752,11 +752,12 @@ class Core(component.Component): return d @export - def get_free_space(self, path): + def get_free_space(self, path=None): """ Returns the number of free bytes at path - :param path: the path to check free space at + :param path: the path to check free space at, if None, use the default + download location :type path: string :returns: the number of free bytes at path @@ -765,6 +766,8 @@ class Core(component.Component): :raises InvalidPathError: if the path is invalid """ + if not path: + path = self.config["download_location"] return deluge.common.free_space(path) @export diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index 41c001676..a95e78b61 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -180,6 +180,11 @@ class StatusBar(component.Component): self.dht_item = StatusBarItem( image=deluge.common.get_pixmap("dht16.png"), tooltip=_("DHT Nodes")) + self.diskspace_item = self.add_item( + stock=gtk.STOCK_HARDDISK, + callback=self._on_diskspace_item_clicked, + tooltip=_("Free Disk Space")) + self.health_item = self.add_item( stock=gtk.STOCK_DIALOG_ERROR, text=_("No Incoming Connections!"), @@ -208,6 +213,7 @@ class StatusBar(component.Component): self.remove_item(self.not_connected_item) self.remove_item(self.health_item) self.remove_item(self.traffic_item) + self.remove_item(self.diskspace_item) except Exception, e: log.debug("Unable to remove StatusBar item: %s", e) self.show_not_connected() @@ -278,6 +284,7 @@ class StatusBar(component.Component): keys.append("has_incoming_connections") client.core.get_session_status(keys).addCallback(self._on_get_session_status) + client.core.get_free_space().addCallback(self._on_get_free_space) def on_configvaluechanged_event(self, key, value): """ @@ -323,6 +330,9 @@ class StatusBar(component.Component): if self.health: self.remove_item(self.health_item) + def _on_get_free_space(self, space): + self.diskspace_item.set_text(deluge.common.fsize(space)) + def _on_max_download_speed(self, max_download_speed): self.max_download_speed = max_download_speed self.update_download_label() @@ -463,3 +473,6 @@ class StatusBar(component.Component): def _on_traffic_item_clicked(self, widget, event): component.get("Preferences").show("Network") + + def _on_diskspace_item_clicked(self, widget, event): + component.get("Preferences").show("Downloads") diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 2ed896782..c2b44e333 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -273,7 +273,7 @@ class SystemTray(component.Component): """Called when the tray icon is left clicked.""" self.blink(False) - if self.window.active(): + if self.window.active() or self.window.visible(): self.window.hide() else: if self.config["lock_tray"]: