summaryrefslogtreecommitdiffstats
path: root/deluge/ui/gtkui/menubar.py
diff options
context:
space:
mode:
Diffstat (limited to 'deluge/ui/gtkui/menubar.py')
-rw-r--r--deluge/ui/gtkui/menubar.py105
1 files changed, 66 insertions, 39 deletions
diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py
index 1bf0cbfe7..a08ce972c 100644
--- a/deluge/ui/gtkui/menubar.py
+++ b/deluge/ui/gtkui/menubar.py
@@ -38,15 +38,15 @@ class MenuBar(component.Component):
self.builder = gtk.Builder()
# Get the torrent menu from the gtk builder file
self.builder.add_from_file(deluge.common.resource_filename(
- 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.ui')
+ 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.ui'),
))
# Get the torrent options menu from the gtk builder file
self.builder.add_from_file(deluge.common.resource_filename(
- 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.options.ui')
+ 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.options.ui'),
))
# Get the torrent queue menu from the gtk builder file
self.builder.add_from_file(deluge.common.resource_filename(
- 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.queue.ui')
+ 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.queue.ui'),
))
# Attach queue torrent menu
@@ -59,8 +59,10 @@ class MenuBar(component.Component):
self.builder.get_object('download-limit-image').set_from_file(deluge.common.get_pixmap('downloading16.png'))
self.builder.get_object('upload-limit-image').set_from_file(deluge.common.get_pixmap('seeding16.png'))
- for menuitem in ('menuitem_down_speed', 'menuitem_up_speed',
- 'menuitem_max_connections', 'menuitem_upload_slots'):
+ for menuitem in (
+ 'menuitem_down_speed', 'menuitem_up_speed',
+ 'menuitem_max_connections', 'menuitem_upload_slots',
+ ):
submenu = gtk.Menu()
item = gtk.MenuItem(_('Set Unlimited'))
item.set_name(menuitem)
@@ -115,7 +117,7 @@ class MenuBar(component.Component):
self.builder.connect_signals(self)
self.change_sensitivity = [
- 'menuitem_addtorrent'
+ 'menuitem_addtorrent',
]
def start(self):
@@ -125,7 +127,7 @@ class MenuBar(component.Component):
# Only show open_folder menuitem and separator if connected to a localhost daemon.
localhost_items = [
'menuitem_open_folder',
- 'separator4'
+ 'separator4',
]
if client.is_localhost():
for widget in localhost_items:
@@ -146,7 +148,8 @@ class MenuBar(component.Component):
if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN:
# Get known accounts to allow changing ownership
client.core.get_known_accounts().addCallback(
- self._on_known_accounts).addErrback(self._on_known_accounts_fail)
+ self._on_known_accounts,
+ ).addErrback(self._on_known_accounts_fail)
client.register_event_handler('TorrentStateChangedEvent', self.on_torrentstatechanged_event)
client.register_event_handler('TorrentResumedEvent', self.on_torrentresumed_event)
@@ -232,24 +235,28 @@ class MenuBar(component.Component):
def on_menuitem_pause_activate(self, data=None):
log.debug('on_menuitem_pause_activate')
client.core.pause_torrent(
- component.get('TorrentView').get_selected_torrents())
+ component.get('TorrentView').get_selected_torrents(),
+ )
def on_menuitem_resume_activate(self, data=None):
log.debug('on_menuitem_resume_activate')
client.core.resume_torrent(
- component.get('TorrentView').get_selected_torrents())
+ component.get('TorrentView').get_selected_torrents(),
+ )
def on_menuitem_updatetracker_activate(self, data=None):
log.debug('on_menuitem_updatetracker_activate')
client.core.force_reannounce(
- component.get('TorrentView').get_selected_torrents())
+ component.get('TorrentView').get_selected_torrents(),
+ )
def on_menuitem_edittrackers_activate(self, data=None):
log.debug('on_menuitem_edittrackers_activate')
from deluge.ui.gtkui.edittrackersdialog import EditTrackersDialog
dialog = EditTrackersDialog(
component.get('TorrentView').get_selected_torrent(),
- self.mainwindow.window)
+ self.mainwindow.window,
+ )
dialog.run()
def on_menuitem_remove_activate(self, data=None):
@@ -262,7 +269,8 @@ class MenuBar(component.Component):
def on_menuitem_recheck_activate(self, data=None):
log.debug('on_menuitem_recheck_activate')
client.core.force_recheck(
- component.get('TorrentView').get_selected_torrents())
+ component.get('TorrentView').get_selected_torrents(),
+ )
def on_menuitem_open_folder_activate(self, data=None):
log.debug('on_menuitem_open_folder')
@@ -273,19 +281,21 @@ class MenuBar(component.Component):
deluge.common.show_file(path, timestamp=timestamp)
for torrent_id in component.get('TorrentView').get_selected_torrents():
component.get('SessionProxy').get_torrent_status(
- torrent_id, ['download_location', 'files']).addCallback(_on_torrent_status)
+ torrent_id, ['download_location', 'files'],
+ ).addCallback(_on_torrent_status)
def on_menuitem_move_activate(self, data=None):
log.debug('on_menuitem_move_activate')
component.get('SessionProxy').get_torrent_status(
component.get('TorrentView').get_selected_torrent(),
- ['download_location']).addCallback(self.show_move_storage_dialog)
+ ['download_location'],
+ ).addCallback(self.show_move_storage_dialog)
def show_move_storage_dialog(self, status):
log.debug('show_move_storage_dialog')
builder = gtk.Builder()
builder.add_from_file(deluge.common.resource_filename(
- 'deluge.ui.gtkui', os.path.join('glade', 'move_storage_dialog.ui')
+ 'deluge.ui.gtkui', os.path.join('glade', 'move_storage_dialog.ui'),
))
# Keep it referenced:
# https://bugzilla.gnome.org/show_bug.cgi?id=546802
@@ -308,11 +318,13 @@ class MenuBar(component.Component):
on_core_result(None)
if response_id == gtk.RESPONSE_OK:
- log.debug('Moving torrents to %s',
- self.move_storage_path_chooser.get_text())
+ log.debug(
+ 'Moving torrents to %s',
+ self.move_storage_path_chooser.get_text(),
+ )
path = self.move_storage_path_chooser.get_text()
client.core.move_storage(
- component.get('TorrentView').get_selected_torrents(), path
+ component.get('TorrentView').get_selected_torrents(), path,
).addCallback(on_core_result)
self.move_storage_dialog.connect('response', on_dialog_response_event)
@@ -371,7 +383,7 @@ class MenuBar(component.Component):
'menuitem_down_speed': 'max_download_speed',
'menuitem_up_speed': 'max_upload_speed',
'menuitem_max_connections': 'max_connections',
- 'menuitem_upload_slots': 'max_upload_slots'
+ 'menuitem_upload_slots': 'max_upload_slots',
}
if widget.get_name() in funcs:
torrent_ids = component.get('TorrentView').get_selected_torrents()
@@ -384,19 +396,27 @@ class MenuBar(component.Component):
'menuitem_up_speed': ['max_upload_speed', 'max_upload_speed'],
'menuitem_max_connections': ['max_connections', 'max_connections_global'],
'menuitem_upload_slots': ['max_upload_slots', 'max_upload_slots_global'],
- 'menuitem_stop_seed_at_ratio': ['stop_ratio', 'stop_seed_ratio']
+ 'menuitem_stop_seed_at_ratio': ['stop_ratio', 'stop_seed_ratio'],
}
other_dialog_info = {
- 'menuitem_down_speed': [_('Download Speed Limit'), _('Set the maximum download speed'),
- _('KiB/s'), 'downloading.svg'],
- 'menuitem_up_speed': [_('Upload Speed Limit'), _('Set the maximum upload speed'),
- _('KiB/s'), 'seeding.svg'],
- 'menuitem_max_connections': [_('Incoming Connections'), _('Set the maximum incoming connections'),
- '', gtk.STOCK_NETWORK],
- 'menuitem_upload_slots': [_('Peer Upload Slots'), _('Set the maximum upload slots'),
- '', gtk.STOCK_SORT_ASCENDING],
- 'menuitem_stop_seed_at_ratio': [_('Stop Seed At Ratio'), 'Stop torrent seeding at ratio', '', None]
+ 'menuitem_down_speed': [
+ _('Download Speed Limit'), _('Set the maximum download speed'),
+ _('KiB/s'), 'downloading.svg',
+ ],
+ 'menuitem_up_speed': [
+ _('Upload Speed Limit'), _('Set the maximum upload speed'),
+ _('KiB/s'), 'seeding.svg',
+ ],
+ 'menuitem_max_connections': [
+ _('Incoming Connections'), _('Set the maximum incoming connections'),
+ '', gtk.STOCK_NETWORK,
+ ],
+ 'menuitem_upload_slots': [
+ _('Peer Upload Slots'), _('Set the maximum upload slots'),
+ '', gtk.STOCK_SORT_ASCENDING,
+ ],
+ 'menuitem_stop_seed_at_ratio': [_('Stop Seed At Ratio'), 'Stop torrent seeding at ratio', '', None],
}
core_key = status_map[widget.get_name()][0]
@@ -429,16 +449,22 @@ class MenuBar(component.Component):
d.addCallback(_on_torrent_status)
def on_menuitem_set_automanaged_on(self, widget):
- client.core.set_torrent_options(component.get('TorrentView').get_selected_torrents(),
- {'auto_managed': True})
+ client.core.set_torrent_options(
+ component.get('TorrentView').get_selected_torrents(),
+ {'auto_managed': True},
+ )
def on_menuitem_set_automanaged_off(self, widget):
- client.core.set_torrent_options(component.get('TorrentView').get_selected_torrents(),
- {'auto_managed': False})
+ client.core.set_torrent_options(
+ component.get('TorrentView').get_selected_torrents(),
+ {'auto_managed': False},
+ )
def on_menuitem_set_stop_seed_at_ratio_disable(self, widget):
- client.core.set_torrent_options(component.get('TorrentView').get_selected_torrents(),
- {'stop_at_ratio': False})
+ client.core.set_torrent_options(
+ component.get('TorrentView').get_selected_torrents(),
+ {'stop_at_ratio': False},
+ )
def on_menuitem_sidebar_zero_toggled(self, widget):
self.config['sidebar_show_zero'] = widget.get_active()
@@ -484,7 +510,7 @@ class MenuBar(component.Component):
self.change_owner_submenu_items[None].set_active(True)
self.change_owner_submenu_items[None].hide()
self.builder.get_object('menuitem_change_owner').connect(
- 'activate', self._on_change_owner_submenu_active
+ 'activate', self._on_change_owner_submenu_active,
)
self.builder.get_object('menuitem_change_owner').set_submenu(self.change_owner_submenu)
@@ -518,7 +544,8 @@ class MenuBar(component.Component):
ErrorDialog(
_('Ownership Change Error'),
_('There was an error while trying changing ownership.'),
- self.mainwindow.window, details=failure.value.logable()
+ self.mainwindow.window, details=failure.value.logable(),
).run()
client.core.set_torrent_options(
- update_torrents, {'owner': username}).addErrback(failed_change_owner)
+ update_torrents, {'owner': username},
+ ).addErrback(failed_change_owner)