Rework the Remove Torrent Dialog and change client.remove_torrent() to

only having the option of removing data, not torrent file.  Deleting the 
torrent file was deleting the torrent file in the Copy Torrentfile 
folder and this is not desirable.
This commit is contained in:
Andrew Resch 2008-11-26 09:11:18 +00:00
parent e11b7adeff
commit c6422b53df
13 changed files with 826 additions and 969 deletions

View File

@ -432,10 +432,10 @@ class Core(
# Run the plugin hooks for 'post_torrent_add'
self.plugins.run_post_torrent_add(torrent_id)
def export_remove_torrent(self, torrent_ids, remove_torrent, remove_data):
def export_remove_torrent(self, torrent_ids, remove_data):
log.debug("Removing torrent %s from the core.", torrent_ids)
for torrent_id in torrent_ids:
if self.torrents.remove(torrent_id, remove_torrent, remove_data):
if self.torrents.remove(torrent_id, remove_data):
# Run the plugin hooks for 'post_torrent_remove'
self.plugins.run_post_torrent_remove(torrent_id)

View File

@ -421,30 +421,15 @@ class TorrentManager(component.Component):
return filedump
def remove(self, torrent_id, remove_torrent=False, remove_data=False):
def remove(self, torrent_id, remove_data=False):
"""Remove a torrent from the manager"""
try:
# Remove from libtorrent session
option = 0
# Remove data if set
if remove_data:
option = 1
self.session.remove_torrent(self.torrents[torrent_id].handle,
option)
1 if remove_data else 0)
except (RuntimeError, KeyError), e:
log.warning("Error removing torrent: %s", e)
return False
# Remove the .torrent file if requested
if remove_torrent:
try:
torrent_file = os.path.join(
self.config["torrentfiles_location"],
self.torrents[torrent_id].filename)
os.remove(torrent_file)
except Exception, e:
log.warning("Unable to remove .torrent file: %s", e)
# Remove the .fastresume if it exists
self.torrents[torrent_id].delete_fastresume()

View File

@ -12,8 +12,6 @@ class Command(BaseCommand):
aliases = ['del']
option_list = BaseCommand.option_list + (
make_option('--remove_torrent', action='store_true', default=False,
help="remove the torrent's file"),
make_option('--remove_data', action='store_true', default=False,
help="remove the torrent's data"),
)
@ -22,7 +20,7 @@ class Command(BaseCommand):
try:
args = mapping.to_ids(args)
torrents = match_torrents(args)
client.remove_torrent(torrents, options['remove_torrent'], options['remove_data'])
client.remove_torrent(torrents, options['remove_data'])
except Exception, msg:
print template.ERROR(str(msg))

File diff suppressed because it is too large Load Diff

View File

@ -1,56 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.0 on Sun Feb 17 13:32:23 2008 -->
<!--Generated with glade3 3.4.5 on Wed Nov 26 00:35:55 2008 -->
<glade-interface>
<widget class="GtkDialog" id="remove_torrent_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Remove Torrent?</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<property name="deletable">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkVBox" id="vbox1">
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
<property name="spacing">10</property>
<child>
<widget class="GtkHBox" id="hbox1">
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">10</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="stock">gtk-dialog-warning</property>
<property name="icon_size">6</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_title">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;big&gt;&lt;b&gt;Are you sure you want to remove the selected torrent?&lt;/b&gt;&lt;/big&gt;</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<property name="stock">gtk-dialog-warning</property>
<property name="icon_size">6</property>
</widget>
<packing>
<property name="expand">False</property>
@ -58,99 +34,23 @@
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<widget class="GtkLabel" id="label_title">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;big&gt;&lt;b&gt;Are you sure you want to remove the selected torrent?&lt;/b&gt;&lt;/big&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="left_padding">15</property>
<child>
<widget class="GtkHBox" id="hbox_torrentfile">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
<child>
<widget class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="stock">gtk-dialog-warning</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_torrentfile_warning">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;i&gt;The associated .torrent will be deleted!&lt;/i&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="left_padding">15</property>
<child>
<widget class="GtkHBox" id="hbox_data">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
<child>
<widget class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="stock">gtk-dialog-warning</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_data_warning">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;i&gt;The downloaded data will be deleted!&lt;/i&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
@ -163,25 +63,38 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="no">gtk-cancel</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_button_cancel_clicked"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_data">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label">Remove Torrent and Data</property>
<property name="response_id">2</property>
<signal name="clicked" handler="on_button_data_clicked"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_ok">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Remove Selected Torrent</property>
<property name="response_id">0</property>
<property name="label" translatable="yes">Remove Torrent</property>
<property name="response_id">1</property>
<signal name="clicked" handler="on_button_ok_clicked"/>
</widget>
<packing>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</widget>

View File

@ -151,6 +151,7 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Remove Torrent</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menuitem_remove_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image9">
<property name="visible">True</property>
@ -201,46 +202,6 @@
</widget>
</child>
</widget>
<widget class="GtkMenu" id="remove_torrent_menu">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkMenuItem" id="menuitem_remove_session">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">From Session</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menuitem_remove_session_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem_remove_torrentfile">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">.. And Delete Torrent File</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menuitem_remove_torrentfile_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem_remove_data">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">.. And Delete Downloaded Files</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menuitem_remove_data_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem_remove_both">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">.. And Delete All Files</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menuitem_remove_both_activate"/>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="options_torrent_menu">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -331,7 +292,7 @@
<widget class="GtkImageMenuItem" id="menuitem_queue_up">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="no">gtk-go-up</property>
<property name="label">gtk-go-up</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_menuitem_queue_up_activate"/>
@ -341,7 +302,7 @@
<widget class="GtkImageMenuItem" id="menuitem_queue_down">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="no">gtk-go-down</property>
<property name="label">gtk-go-down</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_menuitem_queue_down_activate"/>

View File

@ -49,10 +49,6 @@ class MenuBar(component.Component):
pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/torrent_menu.glade"))
# Attach remove torrent menu
self.torrentmenu_glade.get_widget("menuitem_remove").set_submenu(
self.torrentmenu_glade.get_widget("remove_torrent_menu"))
self.torrentmenu_glade.get_widget("menuitem_queue").set_submenu(
self.torrentmenu_glade.get_widget("queue_torrent_menu"))
@ -147,15 +143,8 @@ class MenuBar(component.Component):
self.on_menuitem_updatetracker_activate,
"on_menuitem_edittrackers_activate": \
self.on_menuitem_edittrackers_activate,
"on_menuitem_remove_session_activate": \
self.on_menuitem_remove_session_activate,
"on_menuitem_remove_torrentfile_activate": \
self.on_menuitem_remove_torrentfile_activate,
"on_menuitem_remove_data_activate": \
self.on_menuitem_remove_data_activate,
"on_menuitem_remove_both_activate": \
self.on_menuitem_remove_both_activate,
"on_menuitem_remove_activate": \
self.on_menuitem_remove_activate,
"on_menuitem_recheck_activate": self.on_menuitem_recheck_activate,
"on_menuitem_open_folder_activate": self.on_menuitem_open_folder_activate,
"on_menuitem_move_activate": self.on_menuitem_move_activate,
@ -287,33 +276,10 @@ class MenuBar(component.Component):
component.get("MainWindow").window)
dialog.run()
def on_menuitem_remove_session_activate(self, data=None):
log.debug("on_menuitem_remove_session_activate")
def on_menuitem_remove_activate(self, data=None):
log.debug("on_menuitem_remove_activate")
from removetorrentdialog import RemoveTorrentDialog
RemoveTorrentDialog(
component.get("TorrentView").get_selected_torrents()).run()
def on_menuitem_remove_torrentfile_activate(self, data=None):
log.debug("on_menuitem_remove_torrentfile_activate")
from removetorrentdialog import RemoveTorrentDialog
RemoveTorrentDialog(
component.get("TorrentView").get_selected_torrents(),
remove_torrentfile=True).run()
def on_menuitem_remove_data_activate(self, data=None):
log.debug("on_menuitem_remove_data_activate")
from removetorrentdialog import RemoveTorrentDialog
RemoveTorrentDialog(
component.get("TorrentView").get_selected_torrents(),
remove_data=True).run()
def on_menuitem_remove_both_activate(self, data=None):
log.debug("on_menuitem_remove_both_activate")
from removetorrentdialog import RemoveTorrentDialog
RemoveTorrentDialog(
component.get("TorrentView").get_selected_torrents(),
remove_torrentfile=True,
remove_data=True).run()
RemoveTorrentDialog(component.get("TorrentView").get_selected_torrents()).run()
def on_menuitem_recheck_activate(self, data=None):
log.debug("on_menuitem_recheck_activate")

View File

@ -1,7 +1,7 @@
#
# removetorrentdialog.py
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -22,62 +22,72 @@
# Boston, MA 02110-1301, USA.
#
import gtk, gtk.glade
import pkg_resources
import deluge.common
from deluge.ui.client import aclient as client
import deluge.component as component
from deluge.log import LOG as log
import deluge.ui.gtkui.common as common
class RemoveTorrentDialog:
def __init__(self, torrent_ids, remove_torrentfile=False, remove_data=False):
self.torrent_ids = torrent_ids
self.remove_torrentfile = remove_torrentfile
self.remove_data = remove_data
class RemoveTorrentDialog(object):
"""
This class is used to create and show a Remove Torrent Dialog.
self.glade = gtk.glade.XML(
:param torrent_ids: a list of torrent_ids to remove
:raises TypeError: if :param:`torrent_id` is not a sequence type
:raises ValueError: if :param:`torrent_id` contains no torrent_ids or is None
"""
def __init__(self, torrent_ids):
if type(torrent_ids) != list and type(torrent_ids) != tuple:
raise TypeError("requires a list of torrent_ids")
if not torrent_ids:
raise ValueError("requires a list of torrent_ids")
self.__torrent_ids = torrent_ids
glade = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/remove_torrent_dialog.glade"))
self.dialog = self.glade.get_widget("remove_torrent_dialog")
self.dialog.set_icon(common.get_logo(32))
self.dialog.set_transient_for(component.get("MainWindow").window)
self.__dialog = glade.get_widget("remove_torrent_dialog")
self.__dialog.set_transient_for(component.get("MainWindow").window)
self.__dialog.set_title("")
self.glade.signal_autoconnect({
"on_button_ok_clicked": self.on_button_ok_clicked,
"on_button_cancel_clicked": self.on_button_cancel_clicked
})
if len(self.torrent_ids) > 1:
if len(self.__torrent_ids) > 1:
# We need to pluralize the dialog
self.dialog.set_title("Remove Torrents?")
self.glade.get_widget("label_title").set_markup(
_("<big><b>Are you sure you want to remove the selected torrents?</b></big>"))
self.glade.get_widget("button_ok").set_label(_("Remove Selected Torrents"))
label_title = glade.get_widget("label_title")
button_ok = glade.get_widget("button_ok")
button_data = glade.get_widget("button_data")
if self.remove_torrentfile or self.remove_data:
self.glade.get_widget("hseparator1").show()
if self.remove_torrentfile:
self.glade.get_widget("hbox_torrentfile").show()
if self.remove_data:
self.glade.get_widget("hbox_data").show()
def pluralize_torrents(text):
plural_torrent = _("Torrents")
return text.replace("torrent", plural_torrent.lower()).replace("Torrent", plural_torrent)
def run(self):
if self.torrent_ids == None or self.torrent_ids == []:
self.dialog.destroy()
return
self.dialog.show()
label_title.set_markup(pluralize_torrents(label_title.get_label()))
button_ok.set_label(pluralize_torrents(button_ok.get_label()))
button_data.set_label(pluralize_torrents(button_data.get_label()))
def on_button_ok_clicked(self, widget):
client.remove_torrent(
self.torrent_ids, self.remove_torrentfile, self.remove_data)
def __remove_torrents(self, remove_data):
client.remove_torrent(self.__torrent_ids, remove_data)
# Unselect all to avoid issues with the selection changed event
component.get("TorrentView").treeview.get_selection().unselect_all()
self.dialog.destroy()
def on_button_cancel_clicked(self, widget):
self.dialog.destroy()
def run(self):
"""
Shows the dialog and awaits for user input. The user can select to
remove the torrent(s) from the session with or without their data.
"""
# Response IDs from the buttons
RESPONSE_SESSION = 1
RESPONSE_DATA = 2
response = self.__dialog.run()
if response == RESPONSE_SESSION:
self.__remove_torrents(False)
elif response == RESPONSE_DATA:
self.__remove_torrents(True)
self.__dialog.destroy()

View File

@ -63,11 +63,6 @@ class ToolBar(component.Component):
"toolbutton_queue_down"
]
# Set the Remove Torrent toolbuttons drop-down menu
tb_remove = self.window.main_glade.get_widget("toolbutton_remove")
tb_remove.set_menu(
component.get("MenuBar").torrentmenu_glade.get_widget("remove_torrent_menu"))
if self.config["classic_mode"]:
self.window.main_glade.get_widget("toolbutton_connectionmanager").hide()
@ -142,7 +137,7 @@ class ToolBar(component.Component):
def on_toolbutton_remove_clicked(self, data):
log.debug("on_toolbutton_remove_clicked")
# Use the menubar's callbacks
component.get("MenuBar").on_menuitem_remove_session_activate(data)
component.get("MenuBar").on_menuitem_remove_activate(data)
def on_toolbutton_pause_clicked(self, data):
log.debug("on_toolbutton_pause_clicked")

View File

@ -404,7 +404,7 @@ class CommandRemove(Command):
return
try:
torrents = self.match_torrents(cmd[1:])
client.remove_torrent(torrents, False, False)
client.remove_torrent(torrents, False)
except Exception, msg:
print "*** Error:", str(msg), "\n"
@ -500,4 +500,3 @@ class NullUI:
print
print "Thanks."

View File

@ -192,7 +192,7 @@ class torrent_delete:
vars = web.input(data_also = None, torrent_also = None)
data_also = bool(vars.data_also)
torrent_also = bool(vars.torrent_also)
proxy.remove_torrent(torrent_ids, torrent_also, data_also)
proxy.remove_torrent(torrent_ids, data_also)
do_redirect()
route("/torrent/delete/(.*)",torrent_delete)
@ -487,7 +487,3 @@ class gettext:
web.header("Content-Type", "text/javascript")
print render.gettext()
route("/gettext.js", gettext)

View File

@ -10,7 +10,7 @@ Copyright:
Object: Deluge.UI
The object that manages
The object that manages
Example:
Deluge.Grid.initialize();
@ -21,11 +21,11 @@ Deluge.UI = {
this.torrents = {};
this.torrentIds = [];
Deluge.Client = new JSON.RPC('/json/rpc');
var theme = Cookie.read('theme');
if (theme) this.setTheme(theme);
else this.setTheme('classic');
this.bound = {
onUpdate: this.onUpdate.bindWithEvent(this),
onResize: this.onResize.bindWithEvent(this),
@ -38,32 +38,32 @@ Deluge.UI = {
if (this.vbox) this.vbox.calculatePositions();
}.bindWithEvent(this));
},
/*
Property: loadUI
A method to load the UI after a delayed period of time until
mooui has been fixed to allow a refresh of the widgets to gather
the new style information.
Example:
Deluge.UI.loadUI();
*/
loadUI: function() {
this.vbox = new Widgets.VBox('page', {expand: true});
this.toolbar = new Deluge.Widgets.Toolbar();
this.addWindow = new Deluge.Widgets.AddWindow();
this.createWindow = new Deluge.Widgets.CreateTorrent();
if (Browser.Engine.name != 'trident') {
this.prefsWindow = new Deluge.Widgets.PreferencesWindow();
}
this.statusbar = new Deluge.Widgets.StatusBar();
this.labels = new Deluge.Widgets.Labels()
this.details = new Deluge.Widgets.Details()
this.initializeGrid()
this.split_horz = new Widgets.SplitPane('top', this.labels, this.grid, {
pane1: {min: 180},
pane2: {min: 100, expand: true}
@ -74,36 +74,36 @@ Deluge.UI = {
pane1: {min: 100, expand: true},
pane2: {min: 200}
});
this.vbox.addBox(this.toolbar, {fixed: true});
this.vbox.addBox(this.splitVert);
this.vbox.addBox(this.statusbar, {fixed: true});
this.vbox.calculatePositions();
this.details.expand()
this.toolbar.addEvent('buttonClick', this.bound.onToolbarClick);
this.details.addEvent('filesAction', this.bound.onFilesAction);
this.labels.addEvent('filterChanged', this.bound.onFilterChanged);
details.addEvent('resize', function(e) {
this.details.expand();
}.bindWithEvent(this));
this.initialized = true;
window.addEvent('resize', this.bound.onResize);
Deluge.UI.update();
this.overlay = $('overlay').dispose();
},
/*
Property: initializeGrid
Initializes the Deluge torrent grid.
Example:
Deluge.UI.initializeGrid();
*/
initializeGrid: function() {
this.grid = new Deluge.Widgets.TorrentGrid('torrents')
var menu = new Widgets.PopupMenu()
menu.add(Deluge.Menus.Torrents);
menu.addEvent('action', function(e) {
@ -117,7 +117,7 @@ Deluge.UI = {
menu.torrent_id = e.row_id
menu.show(e)
}.bindWithEvent(this))
this.grid.addEvent('selectedChanged', function(e) {
if ($chk(this.grid.selectedRow)) {
this.details.update(this.grid.selectedRow.id);
@ -126,16 +126,16 @@ Deluge.UI = {
}
}.bindWithEvent(this))
},
/*
Property: setTheme
Change the theme of the AJAX UI by unloading the current stylesheet
and reloading a different one.
Arguments:
name: the name of the theme to be switched too.
Example:
Deluge.UI.setTheme('white');
*/
@ -163,12 +163,12 @@ Deluge.UI = {
}.periodical(50, this);
};
},
/*
Property: run
Start the Deluge UI polling the server to get the updated torrent
information.
Example:
Deluge.UI.run();
*/
@ -177,12 +177,12 @@ Deluge.UI = {
this.running = this.update.periodical(2000, this);
}
},
/*
Property: stop
Stop the Deluge UI polling the server to get the updated torrent
information.
Example:
Deluge.UI.stop();
*/
@ -192,18 +192,18 @@ Deluge.UI = {
this.running = false;
}
},
/*
Property: update
The function that is called to perform the update to the UI.
Example:
Deluge.UI.update();
*/
update: function() {
filter = {};
if (!this.initialized) return;
var type = this.labels.filterType, name = this.labels.filterName
var type = this.labels.filterType, name = this.labels.filterName
if (type && !(type == 'state' && name == 'All')) {
filter[this.labels.filterType] = this.labels.filterName;
}
@ -211,14 +211,14 @@ Deluge.UI = {
onSuccess: this.bound.onUpdate
});
},
/*
Property: onUpdate
Event handler for when the update data is returned from the server.
Arguments:
data - The data returned from the server
Example:
Deluge.Client.update_ui(Deluge.Keys.Grid, filter, {
onSuccess: this.onUpdate.bindWithEvent(this)
@ -234,7 +234,7 @@ Deluge.UI = {
})
this.grid.updateTorrents(this.torrents);
this.statusbar.update(this.stats);
if ($chk(this.grid.selectedRow)) {
this.details.update(this.grid.selectedRow.id);
} else {
@ -242,14 +242,14 @@ Deluge.UI = {
}
this.labels.update(this.filters);
},
/*
Property: onFilesAction
Event handler for when a torrents file priorities have been changed.
Arguments:
e - The event args
Example:
details.addEvent('filesAction', this.onFilesAction.bindWithEvent(this));
*/
@ -265,63 +265,63 @@ Deluge.UI = {
Deluge.Client.set_torrent_file_priorities(event.torrentId, priorities, {
onSuccess: function(response) {
this.details.update(event.torrentId)
}.bindWithEvent(this)
}.bindWithEvent(this)
})
}.bindWithEvent(this)
})
},
/*
Property: onResize
Event handler for when the page is resized
Arguments:
e - The event args
Example:
window.addEvent('resize', this.onResize.bindWithEvent(this));
*/
onResize: function(e) {
this.vbox.calculatePositions();
},
/*
Property: onToolbarClick
Event handler for when a list item is clicked
Arguments:
e - The event args
Example:
toolbar.addEvent('buttonClick', this.onToolbarClick.bindWithEvent(this));
*/
onToolbarClick: function(e) {
this.torrentAction(e.action);
},
/*
Property: onFilterChanged
Event handler for when a filter is changed in the sidebar.
Arguments:
e - The event args
Example:
labels.addEvent('filterChanged', this.onFilterChanged.bindWithEvent(this));
*/
onFilterChanged: function(e) {
this.update();
},
/*
Property: torrentAction
Peform either a global action or and action on selected torrents
and then update the UI after performing the action.
Arguments:
action - The action to perform
value - The value accompanying the action, if there is one.
Example:
Deluge.UI.torrentAction('resume');
*/
@ -396,7 +396,7 @@ Deluge.UI = {
removeTorrent = true;
removeFiles = true;
}
client.remove_torrent(torrentIds, removeTorrent, removeFiles);
client.remove_torrent(torrentIds, removeFiles);
break;
case 'preferences':
this.prefsWindow.show();

View File

@ -230,7 +230,7 @@ class TestIntegration(TestWebUiBase):
#delete all, nice use case for refactoring delete..
torrent_ids = proxy.get_session_state()
for torrent in torrent_ids:
proxy.remove_torrent([torrent], False, False)
proxy.remove_torrent([torrent], False)
torrent_ids = proxy.get_session_state()
self.assertEqual(torrent_ids, [])
@ -411,4 +411,3 @@ elif False:
else:
unittest.main()