Fix showing some menuitems when disabling classic mode due to an already running daemon

This commit is contained in:
Andrew Resch 2009-07-30 23:38:14 +00:00
parent e6cf3a2fd9
commit 974b9a5f3c
2 changed files with 24 additions and 15 deletions

View File

@ -169,11 +169,7 @@ class MenuBar(component.Component):
"menuitem_addtorrent"
]
if self.config["classic_mode"]:
# We need to remove the 'quit and shutdown daemon' menu item
self.window.main_glade.get_widget("menuitem_quitdaemon").hide()
self.window.main_glade.get_widget("separatormenuitem").hide()
self.window.main_glade.get_widget("menuitem_connectionmanager").hide()
self.config.register_set_function("classic_mode", self._on_classic_mode)
client.register_event_handler("TorrentStateChangedEvent", self.on_torrentstatechanged_event)
client.register_event_handler("TorrentResumedEvent", self.on_torrentresumed_event)
@ -201,10 +197,6 @@ class MenuBar(component.Component):
# Show the Torrent menu because we're connected to a host
self.menu_torrent.show()
if not self.config["classic_mode"]:
self.window.main_glade.get_widget("separatormenuitem").show()
self.window.main_glade.get_widget("menuitem_quitdaemon").show()
def stop(self):
for widget in self.change_sensitivity:
self.window.main_glade.get_widget(widget).set_sensitive(False)
@ -459,3 +451,19 @@ class MenuBar(component.Component):
def on_menuitem_sidebar_trackers_toggled(self, widget):
self.config["sidebar_show_trackers"] = widget.get_active()
component.get("FilterTreeView").update()
def _on_classic_mode(self, key, value):
items = [
"menuitem_quitdaemon",
"separatormenuitem",
"menuitem_connectionmanager"
]
if value:
attr = "hide"
else:
attr = "show"
for item in items:
getattr(self.window.main_glade.get_widget(item), attr)()

View File

@ -117,12 +117,6 @@ class SystemTray(component.Component):
self.tray_glade.get_widget("upload-limit-image").set_from_file(
deluge.common.get_pixmap("seeding16.png"))
if self.config["classic_mode"]:
self.hide_widget_list.remove("menuitem_quitdaemon")
self.hide_widget_list.remove("separatormenuitem4")
self.tray_glade.get_widget("menuitem_quitdaemon").hide()
self.tray_glade.get_widget("separatormenuitem4").hide()
client.register_event_handler("ConfigValueChangedEvent", self.config_value_changed)
if not client.connected():
# Hide menu widgets because we're not connected to a host.
@ -135,6 +129,13 @@ class SystemTray(component.Component):
def __start(self):
if self.config["enable_system_tray"]:
if self.config["classic_mode"]:
self.hide_widget_list.remove("menuitem_quitdaemon")
self.hide_widget_list.remove("separatormenuitem4")
self.tray_glade.get_widget("menuitem_quitdaemon").hide()
self.tray_glade.get_widget("separatormenuitem4").hide()
# Show widgets in the hide list because we've connected to a host
for widget in self.hide_widget_list:
self.tray_glade.get_widget(widget).show()