Merge branch 'master' into pieces-progress-bar

Conflicts:
	deluge/ui/gtkui/glade/main_window.glade
This commit is contained in:
Pedro Algarvio 2011-05-29 20:00:25 +01:00
commit c4dbf017a5
7 changed files with 296 additions and 314 deletions

View File

@ -78,6 +78,12 @@ def filter_one_keyword(torrent_ids, keyword):
yield torrent_id
break
def filter_by_name(torrent_ids, search_string):
all_torrents = component.get("TorrentManager").torrents
for torrent_id in torrent_ids:
if search_string[0].lower() in all_torrents[torrent_id].filename.lower():
yield torrent_id
def tracker_error_filter(torrent_ids, values):
filtered_torrent_ids = []
tm = component.get("TorrentManager")
@ -108,6 +114,7 @@ class FilterManager(component.Component):
self.torrents = core.torrentmanager
self.registered_filters = {}
self.register_filter("keyword", filter_keywords)
self.register_filter("name", filter_by_name)
self.tree_fields = {}
self.register_tree_field("state", self._init_state_tree)

View File

@ -246,14 +246,20 @@ class DelugeRPCProtocol(Protocol):
Sends an error response with the contents of the exception that was raised.
"""
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
self.sendData((
RPC_ERROR,
request_id,
exceptionType.__name__,
exceptionValue._args,
exceptionValue._kwargs,
"".join(traceback.format_tb(exceptionTraceback))
))
try:
self.sendData((
RPC_ERROR,
request_id,
exceptionType.__name__,
exceptionValue._args,
exceptionValue._kwargs,
"".join(traceback.format_tb(exceptionTraceback))
))
except Exception, err:
log.error("An exception occurred while sending RPC_ERROR to "
"client. Error to send(exception goes next): %s",
"".join(traceback.format_tb(exceptionTraceback)))
log.exception(err)
if method == "daemon.info":
# This is a special case and used in the initial connection process

View File

@ -189,14 +189,14 @@ class Torrent(object):
else:
self.owner = owner
# Keep trac of last seen complete
# Keep track of last seen complete
if state:
self._last_seen_complete = state.last_seen_complete or 0.0
else:
self._last_seen_complete = 0.0
# Keep track if we're forcing a recheck of the torrent so that we can
# repause it after its done if necessary
# re-pause it after its done if necessary
self.forcing_recheck = False
self.forcing_recheck_paused = False
@ -359,7 +359,7 @@ class Torrent(object):
# Set the tracker list in the torrent object
self.trackers = trackers
if len(trackers) > 0:
# Force a reannounce if there is at least 1 tracker
# Force a re-announce if there is at least 1 tracker
self.force_reannounce()
self.tracker_host = None

View File

@ -226,9 +226,10 @@ class Core(CorePluginBase):
if filename in self.invalid_torrents:
self.invalid_torrents[filename] += 1
if self.invalid_torrents[filename] >= MAX_NUM_ATTEMPTS:
log.warning("Maximum attepts reached while trying "
"to add the torrent file with the path"
" %s", filepath)
log.warning(
"Maximum attempts reached while trying to add the "
"torrent file with the path %s", filepath
)
os.rename(filepath, filepath + ".invalid")
del self.invalid_torrents[filename]
else:
@ -261,16 +262,34 @@ class Core(CorePluginBase):
os.rename(filepath, filepath + watchdir['append_extension'])
elif watchdir.get('copy_torrent_toggle'):
copy_torrent_path = watchdir['copy_torrent']
copy_torrent_file = os.path.join(copy_torrent_path, filename)
log.debug("Moving added torrent file \"%s\" to \"%s\"",
os.path.basename(filepath), copy_torrent_path)
os.rename(
filepath, os.path.join(copy_torrent_path, filename)
)
try:
os.rename(filepath, copy_torrent_file)
except OSError, why:
if why.errno == 18:
# This can happen for different mount points
from shutil import copyfile
try:
copyfile(filepath, copy_torrent_file)
os.remove(filepath)
except OSError:
# Last Resort!
try:
open(copy_torrent_file, 'wb').write(
open(filepath, 'rb').read()
)
os.remove(filepath)
except OSError, why:
raise why
else:
raise why
else:
os.remove(filepath)
def on_update_watchdir_error(self, failure, watchdir_id):
"""Disables any watch folders with unhandled exceptions."""
"""Disables any watch folders with un-handled exceptions."""
self.disable_watchdir(watchdir_id)
log.error("Disabling '%s', error during update: %s",
self.watchdirs[watchdir_id]["path"], failure)

View File

@ -213,7 +213,7 @@
<property name="max_length">65535</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property>
<property name="adjustment">25 1 100 1 10 0</property>
<property name="adjustment">25 1 65535 0 10 0</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
@ -292,6 +292,7 @@
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<widget class="GtkTreeView" id="smtp_recipients">
<property name="visible">True</property>

View File

@ -384,174 +384,217 @@
</packing>
</child>
<child>
<widget class="GtkToolbar" id="toolbar">
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkToolButton" id="toolbutton_add">
<widget class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Add torrent</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Add Torrent</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-add</property>
<signal name="clicked" handler="on_toolbutton_add_clicked"/>
<child>
<widget class="GtkToolButton" id="toolbutton_add">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Add torrent</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Add Torrent</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-add</property>
<signal name="clicked" handler="on_toolbutton_add_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_remove">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Remove torrent</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Remove Torrent</property>
<property name="stock_id">gtk-remove</property>
<signal name="clicked" handler="on_toolbutton_remove_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="separatortoolitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_pause">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Pause the selected torrents</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Pause</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-pause</property>
<signal name="clicked" handler="on_toolbutton_pause_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_resume">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Resume the selected torrents</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Resume</property>
<property name="stock_id">gtk-media-play</property>
<signal name="clicked" handler="on_toolbutton_resume_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="separatortoolitem2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_queue_up">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Queue Torrent Up</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Queue Up</property>
<property name="stock_id">gtk-go-up</property>
<signal name="clicked" handler="on_toolbutton_queue_up_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_queue_down">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Queue Torrent Down</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Queue Down</property>
<property name="stock_id">gtk-go-down</property>
<signal name="clicked" handler="on_toolbutton_queue_down_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="toolbutton1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_preferences">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Preferences</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Preferences</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-preferences</property>
<signal name="clicked" handler="on_toolbutton_preferences_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_connectionmanager">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Connection Manager</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Connection Manager</property>
<property name="stock_id">gtk-network</property>
<signal name="clicked" handler="on_toolbutton_connectionmanager_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_remove">
<widget class="GtkEntry" id="search_torrents_entry">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Remove torrent</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Remove Torrent</property>
<property name="stock_id">gtk-remove</property>
<signal name="clicked" handler="on_toolbutton_remove_clicked"/>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Search torrents by name</property>
<property name="invisible_char">•</property>
<property name="truncate_multiline">True</property>
<property name="caps_lock_warning">False</property>
<property name="secondary_icon_stock">gtk-clear</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">True</property>
<property name="primary_icon_sensitive">False</property>
<property name="secondary_icon_sensitive">True</property>
<property name="secondary_icon_tooltip_text" translatable="yes">Clear the search</property>
<signal name="changed" handler="on_search_torrents_entry_changed"/>
<signal name="icon_press" handler="on_search_torrents_entry_icon_press"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="separatortoolitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_pause">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Pause the selected torrents</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Pause</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-pause</property>
<signal name="clicked" handler="on_toolbutton_pause_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_resume">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Resume the selected torrents</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Resume</property>
<property name="stock_id">gtk-media-play</property>
<signal name="clicked" handler="on_toolbutton_resume_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="separatortoolitem2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_queue_up">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Queue Torrent Up</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Queue Up</property>
<property name="stock_id">gtk-go-up</property>
<signal name="clicked" handler="on_toolbutton_queue_up_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_queue_down">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Queue Torrent Down</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Queue Down</property>
<property name="stock_id">gtk-go-down</property>
<signal name="clicked" handler="on_toolbutton_queue_down_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="toolbutton1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_preferences">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Preferences</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Preferences</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-preferences</property>
<signal name="clicked" handler="on_toolbutton_preferences_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_connectionmanager">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Connection Manager</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Connection Manager</property>
<property name="stock_id">gtk-network</property>
<signal name="clicked" handler="on_toolbutton_connectionmanager_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@ -787,152 +830,6 @@
</widget>
</child>
</widget>
<widget class="GtkMenu" id="menu_file_tab">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkImageMenuItem" id="menuitem_open_file">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_menuitem_open_file_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="menuitem3">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem_expand_all">
<property name="label" translatable="yes">_Expand All</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_expand_all_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-zoom-fit</property>
<property name="icon-size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="menuitem_priority_sep">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem_donotdownload">
<property name="label" translatable="yes">_Do Not Download</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_donotdownload_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-no</property>
<property name="icon-size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem_normal">
<property name="label" translatable="yes">_Normal Priority</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_normal_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-yes</property>
<property name="icon-size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem_high">
<property name="label" translatable="yes">_High Priority</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_high_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-go-up</property>
<property name="icon-size">1</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem_highest">
<property name="label" translatable="yes">Hi_ghest Priority</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_highest_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-goto-top</property>
<property name="icon-size">1</property>
</widget>
</child>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="menu_peer_tab">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkImageMenuItem" id="menuitem4">
<property name="label" translatable="yes">_Add Peer</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Add a peer by its IP</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_add_peer_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
<property name="icon-size">1</property>
</widget>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="move_storage_dialog">
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -2877,6 +2774,7 @@
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_chk_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
@ -2949,6 +2847,7 @@
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_chk_toggled"/>
</widget>
</child>
</widget>

View File

@ -46,6 +46,8 @@ import logging
import warnings
from urlparse import urlparse
from twisted.internet import reactor
import deluge.common
import deluge.component as component
from deluge.ui.client import client
@ -270,6 +272,7 @@ class TorrentView(listview.ListView, component.Component):
# Set filter to None for now
self.filter = None
self.search_pending = None
### Connect Signals ###
# Connect to the 'button-press-event' to know when to bring up the
@ -287,6 +290,15 @@ class TorrentView(listview.ListView, component.Component):
self.treeview.connect("key-press-event", self.on_key_press_event)
self.treeview.connect("columns-changed", self.on_columns_changed_event)
self.search_torrents_entry = self.window.main_glade.get_widget("search_torrents_entry")
self.search_torrents_entry.connect(
"icon-press", self.on_search_torrents_entry_icon_press
)
self.search_torrents_entry.connect(
"changed", self.on_search_torrents_entry_changed
)
client.register_event_handler("TorrentStateChangedEvent", self.on_torrentstatechanged_event)
client.register_event_handler("TorrentAddedEvent", self.on_torrentadded_event)
client.register_event_handler("TorrentRemovedEvent", self.on_torrentremoved_event)
@ -319,6 +331,8 @@ class TorrentView(listview.ListView, component.Component):
# We need to clear the liststore
self.liststore.clear()
self.prev_status = {}
self.filter = None
self.search_torrents_entry.set_text("")
def shutdown(self):
"""Called when GtkUi is exiting"""
@ -335,7 +349,10 @@ class TorrentView(listview.ListView, component.Component):
"""Sets filters for the torrentview..
see: core.get_torrents_status
"""
search_filter = self.filter and self.filter.get('name', None) or None
self.filter = dict(filter_dict) #copied version of filter_dict.
if search_filter and 'name' not in filter_dict:
self.filter['name'] = search_filter
self.update()
def set_columns_to_update(self, columns=None):
@ -379,6 +396,9 @@ class TorrentView(listview.ListView, component.Component):
def update(self):
if self.got_state:
if self.search_pending is not None and self.search_pending.active():
# An update request is scheduled, let's wait for that one
return
# Send a status request
gobject.idle_add(self.send_status_request)
@ -600,3 +620,33 @@ class TorrentView(listview.ListView, component.Component):
torrentmenu = component.get("MenuBar").torrentmenu
torrentmenu.popup(None, None, None, 3, event.time)
return True
def on_search_torrents_entry_icon_press(self, entry, icon, event):
if icon != gtk.ENTRY_ICON_SECONDARY:
return
if self.search_pending and self.search_pending.active():
self.search_pending.cancel()
entry.set_text("")
if self.filter and 'name' in self.filter:
self.filter.pop('name', None)
self.search_pending = reactor.callLater(0.7, self.update)
def on_search_torrents_entry_changed(self, widget):
search_string = widget.get_text().lower()
if self.search_pending and self.search_pending.active():
self.search_pending.cancel()
if not search_string:
if self.filter and 'name' in self.filter:
self.filter.pop('name', None)
self.search_pending = reactor.callLater(0.7, self.update)
return
if self.filter is None:
self.filter = {}
self.filter['name'] = search_string
self.search_pending = reactor.callLater(0.7, self.update)