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,34 +237,42 @@ 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
if response != gtk.RESPONSE_YES: def on_dialog_response(response):
# The user does not want to turn Classic Mode off, so just quit if response != gtk.RESPONSE_YES:
reactor.stop() # The user does not want to turn Classic Mode off, so just quit
return reactor.stop()
# Turning off classic_mode return
self.config["classic_mode"] = False # Turning off classic_mode
self.config["classic_mode"] = False
self.__start_non_classic()
d.addCallback(on_dialog_response)
else: else:
component.start() component.start()
return return
# Autoconnect to a host else:
if self.config["autoconnect"]: self.__start_non_classic()
for host in self.connectionmanager.config["hosts"]:
if host[0] == self.config["autoconnect_host_id"]:
def on_connect(connector):
component.start()
client.connect(*host[1:]).addCallback(on_connect)
if self.config["show_connection_manager_on_start"]: def __start_non_classic(self):
# XXX: We need to call a simulate() here, but this could be a bug in twisted # Autoconnect to a host
reactor.simulate() if self.config["autoconnect"]:
self.connectionmanager.show() for host in self.connectionmanager.config["hosts"]:
if host[0] == self.config["autoconnect_host_id"]:
def on_connect(connector):
component.start()
client.connect(*host[1:]).addCallback(on_connect)
if self.config["show_connection_manager_on_start"]:
# XXX: We need to call a simulate() here, but this could be a bug in twisted
reactor.simulate()
self.connectionmanager.show()
def __on_disconnect(self): def __on_disconnect(self):

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()