Add timeout items to the StatusBar. These items will disappear after N

seconds.
Add warning items to the StatusBar.
Show warning when trying to resume a torrent past the stop share ratio.
This commit is contained in:
Andrew Resch 2008-03-10 08:18:39 +00:00
parent 4f0882ebbe
commit 616fa74051
4 changed files with 36 additions and 4 deletions

1
TODO
View File

@ -7,7 +7,6 @@
* Implement 'Classic' mode
* Add autoload folder
* Add wizard
* Add decay items to statusbar.. items that will disappear after X seconds
* Add command line option to change config dir.. --config
* Add method for plugins to add labels
* Add context menus for labels.. ie. setting options for all torrents in label

View File

@ -53,6 +53,7 @@ class Torrent:
# Get a reference to the TorrentQueue
self.torrentqueue = component.get("TorrentQueue")
self.signals = component.get("SignalManager")
# Set the filename
self.filename = filename
@ -323,6 +324,7 @@ class Torrent:
# If the torrent has already reached it's 'stop_seed_ratio' then do not do anything
if self.config["stop_seed_at_ratio"]:
if self.get_ratio() >= self.config["stop_seed_ratio"]:
self.signals.emit("torrent_resume_at_stop_ratio")
return
# If the torrent is a seed and there are already the max number of seeds

View File

@ -31,6 +31,8 @@
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import gtk
import deluge.component as component
from deluge.ui.client import aclient as client
from deluge.ui.signalreceiver import SignalReceiver
@ -61,6 +63,8 @@ class Signals(component.Component):
self.config_value_changed)
self.receiver.connect_to_signal("torrent_queue_changed",
self.torrent_queue_changed)
self.receiver.connect_to_signal("torrent_resume_at_stop_ratio",
self.torrent_resume_at_stop_ratio)
def stop(self):
try:
@ -115,3 +119,7 @@ class Signals(component.Component):
log.debug("torrent_queue_changed signal received..")
component.get("TorrentView").update()
def torrent_resume_at_stop_ratio(self):
log.debug("torrent_resume_at_stop_ratio")
component.get("StatusBar").display_warning(
text=_("Torrent is past stop ratio."))

View File

@ -32,6 +32,7 @@
# statement from all source files in the program, then also delete it here.
import gtk
import gobject
import deluge.component as component
import deluge.common
@ -92,6 +93,9 @@ class StatusBarItem:
def get_eventbox(self):
return self._ebox
def get_text(self):
return self._label.get_text()
class StatusBar(component.Component):
def __init__(self):
component.Component.__init__(self, "StatusBar", interval=3000)
@ -116,6 +120,7 @@ class StatusBar(component.Component):
"max_upload_speed": self._on_max_upload_speed,
"dht": self._on_dht
}
self.current_warnings = []
# Add a HBox to the statusbar after removing the initial label widget
self.hbox = gtk.HBox()
self.hbox.set_spacing(10)
@ -150,7 +155,7 @@ class StatusBar(component.Component):
self.dht_item = StatusBarItem(
image=deluge.common.get_pixmap("dht16.png"))
self.health_item = self.add_item(
stock=gtk.STOCK_NO,
stock=gtk.STOCK_DIALOG_ERROR,
text=_("No Incoming Connections!"),
callback=self._on_health_icon_clicked)
@ -200,6 +205,24 @@ class StatusBar(component.Component):
except Exception, e:
log.debug("Unable to remove widget: %s", e)
def add_timeout_item(self, seconds=3, image=None, stock=None, text=None, callback=None):
"""Adds an item to the StatusBar for seconds"""
item = self.add_item(image, stock, text, callback)
# Start a timer to remove this item in seconds
gobject.timeout_add(seconds * 1000, self.remove_item, item)
def display_warning(self, text, callback=None):
"""Displays a warning to the user in the status bar"""
if text not in self.current_warnings:
item = self.add_item(
stock=gtk.STOCK_DIALOG_WARNING, text=text, callback=callback)
self.current_warnings.append(text)
gobject.timeout_add(3000, self.remove_warning, item)
def remove_warning(self, item):
self.current_warnings.remove(item.get_text())
self.remove_item(item)
def clear_statusbar(self):
def remove(child):
self.hbox.remove(child)