mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-25 17:45:26 +00:00
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:
parent
4f0882ebbe
commit
616fa74051
1
TODO
1
TODO
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
@ -114,4 +118,8 @@ class Signals(component.Component):
|
||||
def torrent_queue_changed(self):
|
||||
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."))
|
||||
|
@ -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
|
||||
@ -91,6 +92,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):
|
||||
@ -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)
|
||||
|
||||
@ -199,7 +204,25 @@ class StatusBar(component.Component):
|
||||
self.hbox.remove(item.get_eventbox())
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user