From 445f3c0123211f112cd1e7c269da5fdce17b1bf5 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 21 May 2011 16:06:46 +0100 Subject: [PATCH] Fix menu bug caused by Change Owner menuitem code The right-click torrent menu would move/jump around when the option submenu was opened with the mouse, possibly due to a conflict between glade file and append menuitem code in menubar.py. Solution was to create a menuitem entry for Change Owner in glade file and update code to add submenu to this new entry. --- deluge/ui/gtkui/glade/torrent_menu.glade | 7 +++++++ deluge/ui/gtkui/menubar.py | 19 +++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/deluge/ui/gtkui/glade/torrent_menu.glade b/deluge/ui/gtkui/glade/torrent_menu.glade index eef4f5adc..c7dfbe096 100644 --- a/deluge/ui/gtkui/glade/torrent_menu.glade +++ b/deluge/ui/gtkui/glade/torrent_menu.glade @@ -274,6 +274,13 @@ True + + + False + _Change Ownership + True + + True diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index b4b775c52..14754b06a 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -102,10 +102,6 @@ class MenuBar(component.Component): self.torrentmenu = self.torrentmenu_glade.get_widget("torrent_menu") self.menu_torrent = self.window.main_glade.get_widget("menu_torrent") - self.menuitem_change_owner = gtk.MenuItem(_("Change Ownership")) - self.torrentmenu_glade.get_widget("options_torrent_menu").append(self.menuitem_change_owner) - - # Attach the torrent_menu to the Torrent file menu self.menu_torrent.set_submenu(self.torrentmenu) @@ -209,12 +205,8 @@ class MenuBar(component.Component): # Show the Torrent menu because we're connected to a host self.menu_torrent.show() - # Hide the change owner submenu until we get the accounts back from the - # demon. - self.menuitem_change_owner.set_visible(False) - if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN: - # Get Known accounts to allow chaning ownership + # Get known accounts to allow changing ownership client.core.get_known_accounts().addCallback( self._on_known_accounts).addErrback(self._on_known_accounts_fail ) @@ -234,7 +226,6 @@ class MenuBar(component.Component): self.window.main_glade.get_widget("separatormenuitem").hide() self.window.main_glade.get_widget("menuitem_quitdaemon").hide() - def update_menu(self): selected = component.get('TorrentView').get_selected_torrents() if not selected or len(selected) == 0: @@ -531,7 +522,7 @@ class MenuBar(component.Component): if len(known_accounts) <= 1: return - self.menuitem_change_owner.set_visible(True) + self.torrentmenu_glade.get_widget("menuitem_change_owner").set_visible(True) self.change_owner_submenu = gtk.Menu() self.change_owner_submenu_items = {} @@ -549,13 +540,13 @@ class MenuBar(component.Component): self.change_owner_submenu.show_all() self.change_owner_submenu_items[None].set_active(True) self.change_owner_submenu_items[None].hide() - self.menuitem_change_owner.connect( + self.torrentmenu_glade.get_widget("menuitem_change_owner").connect( "activate", self._on_change_owner_submenu_active ) - self.menuitem_change_owner.set_submenu(self.change_owner_submenu) + self.torrentmenu_glade.get_widget("menuitem_change_owner").set_submenu(self.change_owner_submenu) def _on_known_accounts_fail(self, reason): - self.menuitem_change_owner.set_visible(False) + self.torrentmenu_glade.get_widget("menuitem_change_owner").set_visible(False) def _on_change_owner_submenu_active(self, widget): log.debug("_on_change_owner_submenu_active")