[GTK3] Fix changing torrent ownership
The change ownership menu item was broken due to Gtk deprecation changes in commit #bcaaeac. Fixed by correctly setting the RadioMenuItem group Refactored to simplify the code Removed dead or unneeded code Fixes: https://dev.deluge-torrent.org/ticket/3610
This commit is contained in:
parent
0c1a02dcb5
commit
fa8d19335e
|
@ -578,42 +578,26 @@ class MenuBar(component.Component):
|
||||||
component.get('FilterTreeView').update()
|
component.get('FilterTreeView').update()
|
||||||
|
|
||||||
def _on_known_accounts(self, known_accounts):
|
def _on_known_accounts(self, known_accounts):
|
||||||
known_accounts_to_log = []
|
menuitem_change_owner = self.builder.get_object('menuitem_change_owner')
|
||||||
for account in known_accounts:
|
|
||||||
account_to_log = {}
|
|
||||||
for key, value in account.copy().items():
|
|
||||||
if key == 'password':
|
|
||||||
value = '*' * 10
|
|
||||||
account_to_log[key] = value
|
|
||||||
known_accounts_to_log.append(account_to_log)
|
|
||||||
log.debug('_on_known_accounts: %s', known_accounts_to_log)
|
|
||||||
if len(known_accounts) <= 1:
|
if len(known_accounts) <= 1:
|
||||||
|
menuitem_change_owner.set_visible(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.builder.get_object('menuitem_change_owner').set_visible(True)
|
self.users_menu = Gtk.Menu()
|
||||||
|
self.users_menu_items = {}
|
||||||
self.change_owner_submenu = Gtk.Menu()
|
menu_group = None
|
||||||
self.change_owner_submenu_items = {}
|
|
||||||
maingroup = Gtk.RadioMenuItem()
|
|
||||||
|
|
||||||
self.change_owner_submenu_items[None] = Gtk.RadioMenuItem(maingroup)
|
|
||||||
|
|
||||||
for account in known_accounts:
|
for account in known_accounts:
|
||||||
username = account['username']
|
username = account['username']
|
||||||
item = Gtk.RadioMenuItem.new_with_label(maingroup, username)
|
item = Gtk.RadioMenuItem.new_with_label(menu_group, username)
|
||||||
self.change_owner_submenu_items[username] = item
|
menu_group = item.get_group()
|
||||||
self.change_owner_submenu.append(item)
|
|
||||||
item.connect('toggled', self._on_change_owner_toggled, username)
|
item.connect('toggled', self._on_change_owner_toggled, username)
|
||||||
|
self.users_menu_items[username] = item
|
||||||
|
self.users_menu.append(item)
|
||||||
|
|
||||||
self.change_owner_submenu.show_all()
|
self.users_menu.show_all()
|
||||||
self.change_owner_submenu_items[None].set_active(True)
|
menuitem_change_owner.set_submenu(self.users_menu)
|
||||||
self.change_owner_submenu_items[None].hide()
|
menuitem_change_owner.set_visible(True)
|
||||||
self.builder.get_object('menuitem_change_owner').connect(
|
|
||||||
'activate', self._on_change_owner_submenu_active
|
|
||||||
)
|
|
||||||
self.builder.get_object('menuitem_change_owner').set_submenu(
|
|
||||||
self.change_owner_submenu
|
|
||||||
)
|
|
||||||
|
|
||||||
def _on_known_accounts_fail(self, reason):
|
def _on_known_accounts_fail(self, reason):
|
||||||
self.builder.get_object('menuitem_change_owner').set_visible(False)
|
self.builder.get_object('menuitem_change_owner').set_visible(False)
|
||||||
|
@ -622,13 +606,13 @@ class MenuBar(component.Component):
|
||||||
log.debug('_on_change_owner_submenu_active')
|
log.debug('_on_change_owner_submenu_active')
|
||||||
selected = component.get('TorrentView').get_selected_torrents()
|
selected = component.get('TorrentView').get_selected_torrents()
|
||||||
if len(selected) > 1:
|
if len(selected) > 1:
|
||||||
self.change_owner_submenu_items[None].set_active(True)
|
self.users_menu_items[None].set_active(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
torrent_owner = component.get('TorrentView').get_torrent_status(selected[0])[
|
torrent_owner = component.get('TorrentView').get_torrent_status(selected[0])[
|
||||||
'owner'
|
'owner'
|
||||||
]
|
]
|
||||||
for username, item in self.change_owner_submenu_items.items():
|
for username, item in self.users_menu_items.items():
|
||||||
item.set_active(username == torrent_owner)
|
item.set_active(username == torrent_owner)
|
||||||
|
|
||||||
def _on_change_owner_toggled(self, widget, username):
|
def _on_change_owner_toggled(self, widget, username):
|
||||||
|
|
|
@ -117,7 +117,6 @@ class Preferences(component.Component):
|
||||||
|
|
||||||
# Setup accounts tab lisview
|
# Setup accounts tab lisview
|
||||||
self.accounts_levels_mapping = None
|
self.accounts_levels_mapping = None
|
||||||
self.accounts_authlevel = self.builder.get_object('accounts_authlevel')
|
|
||||||
self.accounts_liststore = Gtk.ListStore(str, str, str, int)
|
self.accounts_liststore = Gtk.ListStore(str, str, str, int)
|
||||||
self.accounts_liststore.set_sort_column_id(
|
self.accounts_liststore.set_sort_column_id(
|
||||||
ACCOUNTS_USERNAME, Gtk.SortType.ASCENDING
|
ACCOUNTS_USERNAME, Gtk.SortType.ASCENDING
|
||||||
|
|
Loading…
Reference in New Issue