Close #1205 add free space icon to gtkui
This commit is contained in:
parent
c1200ed63f
commit
ce23ff34a7
|
@ -752,11 +752,12 @@ class Core(component.Component):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def get_free_space(self, path):
|
def get_free_space(self, path=None):
|
||||||
"""
|
"""
|
||||||
Returns the number of free bytes at path
|
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
|
:type path: string
|
||||||
|
|
||||||
:returns: the number of free bytes at path
|
:returns: the number of free bytes at path
|
||||||
|
@ -765,6 +766,8 @@ class Core(component.Component):
|
||||||
:raises InvalidPathError: if the path is invalid
|
:raises InvalidPathError: if the path is invalid
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if not path:
|
||||||
|
path = self.config["download_location"]
|
||||||
return deluge.common.free_space(path)
|
return deluge.common.free_space(path)
|
||||||
|
|
||||||
@export
|
@export
|
||||||
|
|
|
@ -180,6 +180,11 @@ class StatusBar(component.Component):
|
||||||
self.dht_item = StatusBarItem(
|
self.dht_item = StatusBarItem(
|
||||||
image=deluge.common.get_pixmap("dht16.png"), tooltip=_("DHT Nodes"))
|
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(
|
self.health_item = self.add_item(
|
||||||
stock=gtk.STOCK_DIALOG_ERROR,
|
stock=gtk.STOCK_DIALOG_ERROR,
|
||||||
text=_("No Incoming Connections!"),
|
text=_("No Incoming Connections!"),
|
||||||
|
@ -208,6 +213,7 @@ class StatusBar(component.Component):
|
||||||
self.remove_item(self.not_connected_item)
|
self.remove_item(self.not_connected_item)
|
||||||
self.remove_item(self.health_item)
|
self.remove_item(self.health_item)
|
||||||
self.remove_item(self.traffic_item)
|
self.remove_item(self.traffic_item)
|
||||||
|
self.remove_item(self.diskspace_item)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug("Unable to remove StatusBar item: %s", e)
|
log.debug("Unable to remove StatusBar item: %s", e)
|
||||||
self.show_not_connected()
|
self.show_not_connected()
|
||||||
|
@ -278,6 +284,7 @@ class StatusBar(component.Component):
|
||||||
keys.append("has_incoming_connections")
|
keys.append("has_incoming_connections")
|
||||||
|
|
||||||
client.core.get_session_status(keys).addCallback(self._on_get_session_status)
|
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):
|
def on_configvaluechanged_event(self, key, value):
|
||||||
"""
|
"""
|
||||||
|
@ -323,6 +330,9 @@ class StatusBar(component.Component):
|
||||||
if self.health:
|
if self.health:
|
||||||
self.remove_item(self.health_item)
|
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):
|
def _on_max_download_speed(self, max_download_speed):
|
||||||
self.max_download_speed = max_download_speed
|
self.max_download_speed = max_download_speed
|
||||||
self.update_download_label()
|
self.update_download_label()
|
||||||
|
@ -463,3 +473,6 @@ class StatusBar(component.Component):
|
||||||
|
|
||||||
def _on_traffic_item_clicked(self, widget, event):
|
def _on_traffic_item_clicked(self, widget, event):
|
||||||
component.get("Preferences").show("Network")
|
component.get("Preferences").show("Network")
|
||||||
|
|
||||||
|
def _on_diskspace_item_clicked(self, widget, event):
|
||||||
|
component.get("Preferences").show("Downloads")
|
||||||
|
|
|
@ -273,7 +273,7 @@ class SystemTray(component.Component):
|
||||||
"""Called when the tray icon is left clicked."""
|
"""Called when the tray icon is left clicked."""
|
||||||
self.blink(False)
|
self.blink(False)
|
||||||
|
|
||||||
if self.window.active():
|
if self.window.active() or self.window.visible():
|
||||||
self.window.hide()
|
self.window.hide()
|
||||||
else:
|
else:
|
||||||
if self.config["lock_tray"]:
|
if self.config["lock_tray"]:
|
||||||
|
|
Loading…
Reference in New Issue