Merge branch 'master' into pieces-progress-bar

This commit is contained in:
Pedro Algarvio 2011-05-28 21:59:20 +01:00
commit c13eade81c
5 changed files with 109 additions and 121 deletions

View File

@ -2,89 +2,6 @@
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- 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">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Watch Folder Properties</property>
@ -196,6 +113,8 @@
<widget class="GtkEntry" id="path_entry">
<property name="visible">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="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
@ -212,6 +131,8 @@
<widget class="GtkFileChooserButton" id="path_chooser">
<property name="visible">True</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="title" translatable="yes">Select A Folder</property>
</widget>
@ -282,6 +203,7 @@
<widget class="GtkComboBox" id="OwnerCombobox">
<property name="visible">True</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>
</child>
</widget>
@ -329,6 +251,8 @@
<property name="visible">True</property>
<property name="can_focus">True</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="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle_toggled"/>
@ -349,6 +273,9 @@
<property name="visible">True</property>
<property name="can_focus">True</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="draw_indicator">True</property>
<property name="group">isnt_append_extension</property>
@ -396,6 +323,9 @@
<property name="visible">True</property>
<property name="can_focus">True</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="draw_indicator">True</property>
<property name="group">isnt_append_extension</property>
@ -448,8 +378,8 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Delete the copy of the torrent file
created when the torrent is removed</property>
<property name="tooltip" translatable="yes">Once the torrent is deleted from the session,
also delete the .torrent file used to add it.</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
</widget>
@ -512,6 +442,7 @@ created when the torrent is removed</property>
<property name="visible">True</property>
<property name="can_focus">True</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_underline">True</property>
<property name="draw_indicator">True</property>

View File

@ -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():

View File

@ -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)

View File

@ -37,7 +37,7 @@
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_addtorrent_activate"/>
<accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<accelerator key="O" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<child internal-child="image">
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
@ -57,7 +57,7 @@
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_createtorrent_activate"/>
<accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<accelerator key="N" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<child internal-child="image">
<widget class="GtkImage" id="image2">
<property name="visible">True</property>
@ -82,7 +82,7 @@
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_quitdaemon_activate"/>
<accelerator key="Q" modifiers="GDK_SHIFT_MASK|GDK_CONTROL_MASK" signal="activate"/>
<accelerator key="Q" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
<child internal-child="image">
<widget class="GtkImage" id="image3">
<property name="visible">True</property>
@ -134,7 +134,7 @@
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_menuitem_preferences_activate"/>
<accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<accelerator key="P" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
@ -147,7 +147,7 @@
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menuitem_connectionmanager_activate"/>
<accelerator key="M" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<accelerator key="M" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<child internal-child="image">
<widget class="GtkImage" id="image4">
<property name="visible">True</property>
@ -2986,6 +2986,7 @@
<property name="action">select-folder</property>
<property name="local_only">False</property>
<property name="title" translatable="yes">Select A Folder</property>
<signal name="file_set" handler="on_move_completed_file_set"/>
</widget>
<packing>
<property name="expand">False</property>
@ -3076,6 +3077,7 @@
<property name="tooltip" translatable="yes">If checked this torrent won't be shared among trackers, DHT nodes, etc...</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>
@ -3091,6 +3093,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>
@ -3113,7 +3116,7 @@ distribution negatively in the swarm. It should be
used sparingly.</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_chk_sequential_download_toggled"/>
<signal name="toggled" handler="on_chk_toggled"/>
</widget>
<packing>
<property name="expand">True</property>
@ -3130,7 +3133,7 @@ used sparingly.</property>
<property name="tooltip" translatable="yes">Torrent is shared between other Deluge users or not.</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_chk_shared_toggled"/>
<signal name="toggled" handler="on_chk_toggled"/>
</widget>
<packing>
<property name="expand">True</property>

View File

@ -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)