diff --git a/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade b/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade index 8e69ba9a6..ea7167e9d 100644 --- a/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade +++ b/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade @@ -2,89 +2,6 @@ - - False - 6 - AutoAdd Error - False - True - dialog - - - - True - False - - - True - False - end - - - gtk-ok - -5 - True - True - True - False - False - True - - - - False - False - 0 - - - - - False - True - end - 0 - - - - - True - False - - - True - False - gtk-dialog-error - - - False - True - 0 - - - - - True - False - 0.46000000834465027 - Error - True - - - False - False - 1 - - - - - True - True - 2 - - - - - False Watch Folder Properties @@ -196,6 +113,8 @@ True True + If a .torrent file is added to this directory, +it will be added to the session. False False @@ -212,6 +131,8 @@ True False + If a .torrent file is added to this directory, +it will be added to the session. select-folder Select A Folder @@ -282,6 +203,7 @@ True False + The user selected here will be the owner of the torrent. @@ -329,6 +251,8 @@ True True False + Once the torrent is added to the session, +the .torrent will be deleted. False True @@ -349,6 +273,9 @@ True True False + Once the torrent is added to the session, +an extension will be appended to the .torrent +and it will remain in the same directory. False True isnt_append_extension @@ -396,6 +323,9 @@ True True False + Once the torrent is added to the session, +the .torrent will copied to the chosen directory +and deleted from the watch folder. False True isnt_append_extension @@ -448,8 +378,8 @@ True False True - Delete the copy of the torrent file -created when the torrent is removed + Once the torrent is deleted from the session, +also delete the .torrent file used to add it. False True @@ -512,6 +442,7 @@ created when the torrent is removed True True False + This directory will be the download location False True True diff --git a/deluge/plugins/autoadd/autoadd/gtkui.py b/deluge/plugins/autoadd/autoadd/gtkui.py index 25d3eea9b..e32d37ff6 100644 --- a/deluge/plugins/autoadd/autoadd/gtkui.py +++ b/deluge/plugins/autoadd/autoadd/gtkui.py @@ -41,6 +41,7 @@ import gtk from deluge.log import getPluginLogger from deluge.ui.client import client +from deluge.ui.gtkui import dialogs from deluge.plugins.pluginbase import GtkPluginBase import deluge.component as component import deluge.common @@ -50,6 +51,9 @@ from common import get_resource log = getPluginLogger(__name__) +class IncompatibleOption(Exception): + pass + class OptionsDialog(): spin_ids = ["max_download_speed", "max_upload_speed", "stop_ratio"] spin_int_ids = ["max_upload_slots", "max_connections"] @@ -59,6 +63,7 @@ class OptionsDialog(): def __init__(self): self.accounts = gtk.ListStore(str) self.labels = gtk.ListStore(str) + self.core_config = {} def show(self, options={}, watchdir_id=None): self.glade = gtk.glade.XML(get_resource("autoadd_options.glade")) @@ -67,14 +72,10 @@ class OptionsDialog(): "on_opts_apply":self.on_apply, "on_opts_cancel":self.on_cancel, "on_options_dialog_close":self.on_cancel, - "on_error_ok":self.on_error_ok, - "on_error_dialog_close":self.on_error_ok, "on_toggle_toggled":self.on_toggle_toggled }) self.dialog = self.glade.get_widget("options_dialog") self.dialog.set_transient_for(component.get("Preferences").pref_dialog) - self.err_dialog = self.glade.get_widget("error_dialog") - self.err_dialog.set_transient_for(self.dialog) if watchdir_id: #We have an existing watchdir_id, we are editing @@ -91,7 +92,7 @@ class OptionsDialog(): self.dialog.run() def load_options(self, options): - self.glade.get_widget('enabled').set_active(options.get('enabled', False)) + self.glade.get_widget('enabled').set_active(options.get('enabled', True)) self.glade.get_widget('append_extension_toggle').set_active( options.get('append_extension_toggle', False) ) @@ -149,17 +150,55 @@ class OptionsDialog(): self.glade.get_widget(field+"_chooser").hide() self.set_sensitive() + def on_core_config(config): + if client.is_localhost(): + self.glade.get_widget('download_location_chooser').set_current_folder( + options.get('download_location', config["download_location"]) + ) + if options.get('move_completed_toggle', config["move_completed"]): + self.glade.get_widget('move_completed_toggle').set_active(True) + self.glade.get_widget('move_completed_path_chooser').set_current_folder( + options.get('move_completed_path', config["move_completed_path"]) + ) + if options.get('copy_torrent_toggle', config["copy_torrent_file"]): + self.glade.get_widget('copy_torrent_toggle').set_active(True) + self.glade.get_widget('copy_torrent_chooser').set_current_folder( + options.get('copy_torrent', config["torrentfiles_location"]) + ) + else: + self.glade.get_widget('download_location_entry').set_text( + options.get('download_location', config["download_location"]) + ) + if options.get('move_completed_toggle', config["move_completed"]): + self.glade.get_widget('move_completed_toggle').set_active( + options.get('move_completed_toggle', False) + ) + self.glade.get_widget('move_completed_path_entry').set_text( + options.get('move_completed_path', config["move_completed_path"]) + ) + if options.get('copy_torrent_toggle', config["copy_torrent_file"]): + self.glade.get_widget('copy_torrent_toggle').set_active(True) + self.glade.get_widget('copy_torrent_entry').set_text( + options.get('copy_torrent', config["torrentfiles_location"]) + ) + + if options.get('delete_copy_torrent_toggle', config["del_copy_torrent_file"]): + self.glade.get_widget('delete_copy_torrent_toggle').set_active(True) + + if not options: + client.core.get_config().addCallback(on_core_config) + def on_accounts(accounts, owner): log.debug("Got Accounts") - selected_idx = None - for idx, account in enumerate(accounts): + selected_iter = None + for account in accounts: iter = self.accounts.append() self.accounts.set_value( iter, 0, account['username'] ) if account['username'] == owner: - selected_idx = idx - self.glade.get_widget('OwnerCombobox').set_active(selected_idx) + selected_iter = iter + self.glade.get_widget('OwnerCombobox').set_active_iter(selected_iter) def on_accounts_failure(failure): log.debug("Failed to get accounts!!! %s", failure) @@ -190,7 +229,7 @@ class OptionsDialog(): client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins) if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN: client.core.get_known_accounts().addCallback( - on_accounts, options.get('owner', 'localclient') + on_accounts, options.get('owner', client.get_auth_user()) ).addErrback(on_accounts_failure) else: iter = self.accounts.append() @@ -249,27 +288,29 @@ class OptionsDialog(): self.glade.get_widget('remove_at_ratio').set_sensitive(isactive) def on_apply(self, Event=None): - client.autoadd.set_options( - str(self.watchdir_id), self.generate_opts() - ).addCallbacks(self.on_added, self.on_error_show) + try: + options = self.generate_opts() + client.autoadd.set_options( + str(self.watchdir_id), options + ).addCallbacks(self.on_added, self.on_error_show) + except IncompatibleOption, err: + dialogs.ErrorDialog(_("Incompatible Option"), str(err), self.dialog).run() + def on_error_show(self, result): - self.glade.get_widget('error_label').set_text(result.value.exception_msg) - self.err_dialog = self.glade.get_widget('error_dialog') - self.err_dialog.set_transient_for(self.dialog) + d = dialogs.ErrorDialog(_("Error"), result.value.exception_msg, self.dialog) result.cleanFailure() - self.err_dialog.show() + d.run() def on_added(self, result): self.dialog.destroy() - def on_error_ok(self, Event=None): - self.err_dialog.hide() - def on_add(self, Event=None): - client.autoadd.add( - self.generate_opts() - ).addCallbacks(self.on_added, self.on_error_show) + try: + options = self.generate_opts() + client.autoadd.add(options).addCallbacks(self.on_added, self.on_error_show) + except IncompatibleOption, err: + dialogs.ErrorDialog(_("Incompatible Option"), str(err), self.dialog).run() def on_cancel(self, Event=None): self.dialog.destroy() @@ -314,6 +355,10 @@ class OptionsDialog(): for id in self.chk_ids: options[id] = self.glade.get_widget(id).get_active() options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active() + + if options['copy_torrent_toggle'] and options['path'] == options['copy_torrent']: + raise IncompatibleOption(_("\"Watch Folder\" directory and \"Copy of .torrent" + " files to\" directory cannot be the same!")) return options @@ -458,7 +503,7 @@ class GtkUI(GtkPluginBase): def cb_get_config(self, watchdirs): """callback for on show_prefs""" - log.debug("Got whatchdirs from core: %s", watchdirs) + log.trace("Got whatchdirs from core: %s", watchdirs) self.watchdirs = watchdirs or {} self.store.clear() for watchdir_id, watchdir in self.watchdirs.iteritems(): diff --git a/deluge/ui/gtkui/dialogs.py b/deluge/ui/gtkui/dialogs.py index 805398bd7..ead22f349 100644 --- a/deluge/ui/gtkui/dialogs.py +++ b/deluge/ui/gtkui/dialogs.py @@ -36,6 +36,7 @@ import gtk from twisted.internet import defer +from deluge.ui.gtkui import common import deluge.component as component @@ -58,6 +59,8 @@ class BaseDialog(gtk.Dialog): flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR, buttons=buttons) + self.set_icon(common.get_deluge_icon()) + self.connect("delete-event", self._on_delete_event) self.connect("response", self._on_response) diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index 7c7a2125a..8beb2ed36 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -37,7 +37,7 @@ True False - + True @@ -57,7 +57,7 @@ True False - + True @@ -82,7 +82,7 @@ True False - + True @@ -134,7 +134,7 @@ True True - + @@ -147,7 +147,7 @@ True False - + True @@ -2986,6 +2986,7 @@ select-folder False Select A Folder + False @@ -3076,6 +3077,7 @@ If checked this torrent won't be shared among trackers, DHT nodes, etc... False True + False @@ -3091,6 +3093,7 @@ False False True + False @@ -3113,7 +3116,7 @@ distribution negatively in the swarm. It should be used sparingly. False True - + True @@ -3130,7 +3133,7 @@ used sparingly. Torrent is shared between other Deluge users or not. False True - + True diff --git a/deluge/ui/gtkui/options_tab.py b/deluge/ui/gtkui/options_tab.py index 7d61870cf..4360ec76a 100644 --- a/deluge/ui/gtkui/options_tab.py +++ b/deluge/ui/gtkui/options_tab.py @@ -72,10 +72,9 @@ class OptionsTab(Tab): "on_button_edit_trackers_clicked": self._on_button_edit_trackers_clicked, "on_chk_move_completed_toggled": self._on_chk_move_completed_toggled, "on_chk_stop_at_ratio_toggled": self._on_chk_stop_at_ratio_toggled, - "on_chk_shared_toggled": self._on_chk_shared_toggled, + "on_chk_toggled": self._on_chk_toggled, "on_spin_value_changed": self._on_spin_value_changed, - "on_chk_sequential_download_toggled": \ - self._on_chk_sequential_download_toggled + "on_move_completed_file_set": self._on_move_completed_file_set }) def start(self): @@ -85,6 +84,9 @@ class OptionsTab(Tab): else: self.filechooser_move_completed.hide() self.entry_move_completed.show() + self.entry_move_completed.connect( + "changed", self._on_entry_move_completed_changed + ) def stop(self): pass @@ -278,7 +280,7 @@ class OptionsTab(Tab): if not self.button_apply.is_sensitive(): self.button_apply.set_sensitive(True) - def _on_chk_shared_toggled(self, widget): + def _on_chk_toggled(self, widget): if not self.button_apply.is_sensitive(): self.button_apply.set_sensitive(True) @@ -286,6 +288,10 @@ class OptionsTab(Tab): if not self.button_apply.is_sensitive(): self.button_apply.set_sensitive(True) - def _on_chk_sequential_download_toggled(self, widget): + def _on_move_completed_file_set(self, widget): + if not self.button_apply.is_sensitive(): + self.button_apply.set_sensitive(True) + + def _on_entry_move_completed_changed(self, widget): if not self.button_apply.is_sensitive(): self.button_apply.set_sensitive(True)