AutoAdd plugin auto fill.
When adding new entries, the dialog is auto-filled with what's defined for the Downloads entry in the preferences. When showing errors, use the dialogs module. Added some tooltips to the dialog.
This commit is contained in:
parent
dc514d308c
commit
eb639c3722
|
@ -2,89 +2,6 @@
|
||||||
<glade-interface>
|
<glade-interface>
|
||||||
<!-- interface-requires gtk+ 2.16 -->
|
<!-- interface-requires gtk+ 2.16 -->
|
||||||
<!-- interface-naming-policy toplevel-contextual -->
|
<!-- interface-naming-policy toplevel-contextual -->
|
||||||
<widget class="GtkDialog" id="error_dialog">
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="border_width">6</property>
|
|
||||||
<property name="title" translatable="yes">AutoAdd Error</property>
|
|
||||||
<property name="resizable">False</property>
|
|
||||||
<property name="modal">True</property>
|
|
||||||
<property name="type_hint">dialog</property>
|
|
||||||
<signal name="close" handler="on_error_dialog_close"/>
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<widget class="GtkVBox" id="dialog-vbox2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<widget class="GtkHButtonBox" id="dialog-action_area2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="layout_style">end</property>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="okbutton1">
|
|
||||||
<property name="label">gtk-ok</property>
|
|
||||||
<property name="response_id">-5</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="use_action_appearance">False</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<signal name="clicked" handler="on_error_ok"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHBox" id="hbox12">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkImage" id="image7">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="stock">gtk-dialog-error</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="error_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="xalign">0.46000000834465027</property>
|
|
||||||
<property name="label" translatable="yes">Error</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>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<widget class="GtkDialog" id="options_dialog">
|
<widget class="GtkDialog" id="options_dialog">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes">Watch Folder Properties</property>
|
<property name="title" translatable="yes">Watch Folder Properties</property>
|
||||||
|
@ -196,6 +113,8 @@
|
||||||
<widget class="GtkEntry" id="path_entry">
|
<widget class="GtkEntry" id="path_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="tooltip" translatable="yes">If a .torrent file is added to this directory,
|
||||||
|
it will be added to the session.</property>
|
||||||
<property name="invisible_char">●</property>
|
<property name="invisible_char">●</property>
|
||||||
<property name="primary_icon_activatable">False</property>
|
<property name="primary_icon_activatable">False</property>
|
||||||
<property name="secondary_icon_activatable">False</property>
|
<property name="secondary_icon_activatable">False</property>
|
||||||
|
@ -212,6 +131,8 @@
|
||||||
<widget class="GtkFileChooserButton" id="path_chooser">
|
<widget class="GtkFileChooserButton" id="path_chooser">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="tooltip" translatable="yes">If a .torrent file is added to this directory,
|
||||||
|
it will be added to the session.</property>
|
||||||
<property name="action">select-folder</property>
|
<property name="action">select-folder</property>
|
||||||
<property name="title" translatable="yes">Select A Folder</property>
|
<property name="title" translatable="yes">Select A Folder</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -282,6 +203,7 @@
|
||||||
<widget class="GtkComboBox" id="OwnerCombobox">
|
<widget class="GtkComboBox" id="OwnerCombobox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="tooltip" translatable="yes">The user selected here will be the owner of the torrent.</property>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -329,6 +251,8 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip" translatable="yes">Once the torrent is added to the session,
|
||||||
|
the .torrent will be deleted.</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
<signal name="toggled" handler="on_toggle_toggled"/>
|
<signal name="toggled" handler="on_toggle_toggled"/>
|
||||||
|
@ -349,6 +273,9 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip" translatable="yes">Once the torrent is added to the session,
|
||||||
|
an extension will be appended to the .torrent
|
||||||
|
and it will remain in the same directory.</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
<property name="group">isnt_append_extension</property>
|
<property name="group">isnt_append_extension</property>
|
||||||
|
@ -396,6 +323,9 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip" translatable="yes">Once the torrent is added to the session,
|
||||||
|
the .torrent will copied to the chosen directory
|
||||||
|
and deleted from the watch folder.</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
<property name="group">isnt_append_extension</property>
|
<property name="group">isnt_append_extension</property>
|
||||||
|
@ -448,8 +378,8 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
<property name="has_tooltip">True</property>
|
<property name="has_tooltip">True</property>
|
||||||
<property name="tooltip" translatable="yes">Delete the copy of the torrent file
|
<property name="tooltip" translatable="yes">Once the torrent is deleted from the session,
|
||||||
created when the torrent is removed</property>
|
also delete the .torrent file used to add it.</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -512,6 +442,7 @@ created when the torrent is removed</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip" translatable="yes">This directory will be the download location</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
|
|
|
@ -41,6 +41,7 @@ import gtk
|
||||||
|
|
||||||
from deluge.log import getPluginLogger
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
from deluge.ui.gtkui import dialogs
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -50,6 +51,9 @@ from common import get_resource
|
||||||
|
|
||||||
log = getPluginLogger(__name__)
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
|
class IncompatibleOption(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class OptionsDialog():
|
class OptionsDialog():
|
||||||
spin_ids = ["max_download_speed", "max_upload_speed", "stop_ratio"]
|
spin_ids = ["max_download_speed", "max_upload_speed", "stop_ratio"]
|
||||||
spin_int_ids = ["max_upload_slots", "max_connections"]
|
spin_int_ids = ["max_upload_slots", "max_connections"]
|
||||||
|
@ -59,6 +63,7 @@ class OptionsDialog():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.accounts = gtk.ListStore(str)
|
self.accounts = gtk.ListStore(str)
|
||||||
self.labels = gtk.ListStore(str)
|
self.labels = gtk.ListStore(str)
|
||||||
|
self.core_config = {}
|
||||||
|
|
||||||
def show(self, options={}, watchdir_id=None):
|
def show(self, options={}, watchdir_id=None):
|
||||||
self.glade = gtk.glade.XML(get_resource("autoadd_options.glade"))
|
self.glade = gtk.glade.XML(get_resource("autoadd_options.glade"))
|
||||||
|
@ -67,14 +72,10 @@ class OptionsDialog():
|
||||||
"on_opts_apply":self.on_apply,
|
"on_opts_apply":self.on_apply,
|
||||||
"on_opts_cancel":self.on_cancel,
|
"on_opts_cancel":self.on_cancel,
|
||||||
"on_options_dialog_close":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
|
"on_toggle_toggled":self.on_toggle_toggled
|
||||||
})
|
})
|
||||||
self.dialog = self.glade.get_widget("options_dialog")
|
self.dialog = self.glade.get_widget("options_dialog")
|
||||||
self.dialog.set_transient_for(component.get("Preferences").pref_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:
|
if watchdir_id:
|
||||||
#We have an existing watchdir_id, we are editing
|
#We have an existing watchdir_id, we are editing
|
||||||
|
@ -91,7 +92,7 @@ class OptionsDialog():
|
||||||
self.dialog.run()
|
self.dialog.run()
|
||||||
|
|
||||||
def load_options(self, options):
|
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(
|
self.glade.get_widget('append_extension_toggle').set_active(
|
||||||
options.get('append_extension_toggle', False)
|
options.get('append_extension_toggle', False)
|
||||||
)
|
)
|
||||||
|
@ -149,17 +150,55 @@ class OptionsDialog():
|
||||||
self.glade.get_widget(field+"_chooser").hide()
|
self.glade.get_widget(field+"_chooser").hide()
|
||||||
self.set_sensitive()
|
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):
|
def on_accounts(accounts, owner):
|
||||||
log.debug("Got Accounts")
|
log.debug("Got Accounts")
|
||||||
selected_idx = None
|
selected_iter = None
|
||||||
for idx, account in enumerate(accounts):
|
for account in accounts:
|
||||||
iter = self.accounts.append()
|
iter = self.accounts.append()
|
||||||
self.accounts.set_value(
|
self.accounts.set_value(
|
||||||
iter, 0, account['username']
|
iter, 0, account['username']
|
||||||
)
|
)
|
||||||
if account['username'] == owner:
|
if account['username'] == owner:
|
||||||
selected_idx = idx
|
selected_iter = iter
|
||||||
self.glade.get_widget('OwnerCombobox').set_active(selected_idx)
|
self.glade.get_widget('OwnerCombobox').set_active_iter(selected_iter)
|
||||||
|
|
||||||
def on_accounts_failure(failure):
|
def on_accounts_failure(failure):
|
||||||
log.debug("Failed to get accounts!!! %s", 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)
|
client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins)
|
||||||
if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN:
|
if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN:
|
||||||
client.core.get_known_accounts().addCallback(
|
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)
|
).addErrback(on_accounts_failure)
|
||||||
else:
|
else:
|
||||||
iter = self.accounts.append()
|
iter = self.accounts.append()
|
||||||
|
@ -249,27 +288,29 @@ class OptionsDialog():
|
||||||
self.glade.get_widget('remove_at_ratio').set_sensitive(isactive)
|
self.glade.get_widget('remove_at_ratio').set_sensitive(isactive)
|
||||||
|
|
||||||
def on_apply(self, Event=None):
|
def on_apply(self, Event=None):
|
||||||
client.autoadd.set_options(
|
try:
|
||||||
str(self.watchdir_id), self.generate_opts()
|
options = self.generate_opts()
|
||||||
).addCallbacks(self.on_added, self.on_error_show)
|
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):
|
def on_error_show(self, result):
|
||||||
self.glade.get_widget('error_label').set_text(result.value.exception_msg)
|
d = dialogs.ErrorDialog(_("Error"), result.value.exception_msg, self.dialog)
|
||||||
self.err_dialog = self.glade.get_widget('error_dialog')
|
|
||||||
self.err_dialog.set_transient_for(self.dialog)
|
|
||||||
result.cleanFailure()
|
result.cleanFailure()
|
||||||
self.err_dialog.show()
|
d.run()
|
||||||
|
|
||||||
def on_added(self, result):
|
def on_added(self, result):
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
|
|
||||||
def on_error_ok(self, Event=None):
|
|
||||||
self.err_dialog.hide()
|
|
||||||
|
|
||||||
def on_add(self, Event=None):
|
def on_add(self, Event=None):
|
||||||
client.autoadd.add(
|
try:
|
||||||
self.generate_opts()
|
options = self.generate_opts()
|
||||||
).addCallbacks(self.on_added, self.on_error_show)
|
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):
|
def on_cancel(self, Event=None):
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
|
@ -314,6 +355,10 @@ class OptionsDialog():
|
||||||
for id in self.chk_ids:
|
for id in self.chk_ids:
|
||||||
options[id] = self.glade.get_widget(id).get_active()
|
options[id] = self.glade.get_widget(id).get_active()
|
||||||
options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').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
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
@ -458,7 +503,7 @@ class GtkUI(GtkPluginBase):
|
||||||
|
|
||||||
def cb_get_config(self, watchdirs):
|
def cb_get_config(self, watchdirs):
|
||||||
"""callback for on show_prefs"""
|
"""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.watchdirs = watchdirs or {}
|
||||||
self.store.clear()
|
self.store.clear()
|
||||||
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
||||||
|
|
Loading…
Reference in New Issue