Fix turning off Classic mode dialog

Fix showing the connection manager icon on the toolbar depending on classic mode setting
This commit is contained in:
Andrew Resch 2009-06-10 22:50:57 +00:00
parent e36ca0e5ba
commit 520be10e4d
2 changed files with 37 additions and 20 deletions

View File

@ -237,22 +237,30 @@ class GtkUI:
try: try:
client.start_classic_mode() client.start_classic_mode()
except deluge.error.DaemonRunningError: except deluge.error.DaemonRunningError:
response = dialogs.YesNoDialog( d = dialogs.YesNoDialog(
_("Turn off Classic Mode?"), _("Turn off Classic Mode?"),
_("It appears that a Deluge daemon process (deluged) is already running.\n\n\ _("It appears that a Deluge daemon process (deluged) is already running.\n\n\
You will either need to stop the daemon or turn off Classic Mode to continue.")).run() You will either need to stop the daemon or turn off Classic Mode to continue.")).run()
self.started_in_classic = False self.started_in_classic = False
def on_dialog_response(response):
if response != gtk.RESPONSE_YES: if response != gtk.RESPONSE_YES:
# The user does not want to turn Classic Mode off, so just quit # The user does not want to turn Classic Mode off, so just quit
reactor.stop() reactor.stop()
return return
# Turning off classic_mode # Turning off classic_mode
self.config["classic_mode"] = False self.config["classic_mode"] = False
self.__start_non_classic()
d.addCallback(on_dialog_response)
else: else:
component.start() component.start()
return return
else:
self.__start_non_classic()
def __start_non_classic(self):
# Autoconnect to a host # Autoconnect to a host
if self.config["autoconnect"]: if self.config["autoconnect"]:
for host in self.connectionmanager.config["hosts"]: for host in self.connectionmanager.config["hosts"]:

View File

@ -74,13 +74,15 @@ class ToolBar(component.Component):
"toolbutton_queue_down" "toolbutton_queue_down"
] ]
if self.config["classic_mode"]: self.config.register_set_function("classic_mode", self._on_classic_mode, True)
self.window.main_glade.get_widget("toolbutton_connectionmanager").hide()
# Hide if necessary # Hide if necessary
self.visible(self.config["show_toolbar"]) self.visible(self.config["show_toolbar"])
def start(self): def start(self):
if not self.config["classic_mode"]:
self.window.main_glade.get_widget("toolbutton_connectionmanager").show()
for widget in self.change_sensitivity: for widget in self.change_sensitivity:
self.window.main_glade.get_widget(widget).set_sensitive(True) self.window.main_glade.get_widget(widget).set_sensitive(True)
@ -176,3 +178,10 @@ class ToolBar(component.Component):
def on_toolbutton_queue_down_clicked(self, data): def on_toolbutton_queue_down_clicked(self, data):
log.debug("on_toolbutton_queue_down_clicked") log.debug("on_toolbutton_queue_down_clicked")
component.get("MenuBar").on_menuitem_queue_down_activate(data) component.get("MenuBar").on_menuitem_queue_down_activate(data)
def _on_classic_mode(self, key, value):
w = self.window.main_glade.get_widget("toolbutton_connectionmanager")
if value:
w.hide()
else:
w.show()