From 3e98ef5f89a94a28e9562521aa9acf248ac789de Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Wed, 21 Nov 2012 22:25:10 -0500 Subject: [PATCH] Add quit dialog when changing classic mode. Don't change visibility of connection manager when changing classic mode. --- deluge/ui/gtkui/menubar.py | 26 ++++---------------------- deluge/ui/gtkui/preferences.py | 16 ++++++++++++++++ deluge/ui/gtkui/toolbar.py | 12 +----------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index e6e9284e9..214c4b7cb 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -169,8 +169,6 @@ class MenuBar(component.Component): "menuitem_addtorrent" ] - self.config.register_set_function("classic_mode", self._on_classic_mode, True) - client.register_event_handler("TorrentStateChangedEvent", self.on_torrentstatechanged_event) client.register_event_handler("TorrentResumedEvent", self.on_torrentresumed_event) client.register_event_handler("SessionPausedEvent", self.on_sessionpaused_event) @@ -194,9 +192,10 @@ class MenuBar(component.Component): for widget in non_remote_items: self.torrentmenu_glade.get_widget(widget).set_no_show_all(False) - if not self.config["classic_mode"]: - self.window.main_glade.get_widget("separatormenuitem").show() - self.window.main_glade.get_widget("menuitem_quitdaemon").show() + self.window.main_glade.get_widget("separatormenuitem").set_visible(not self.config["classic_mode"]) + self.window.main_glade.get_widget("menuitem_quitdaemon").set_visible(not self.config["classic_mode"]) + self.window.main_glade.get_widget("menuitem_connectionmanager").set_visible(not self.config["classic_mode"]) + # Show the Torrent menu because we're connected to a host self.menu_torrent.show() @@ -460,20 +459,3 @@ 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" - ] - - for item in items: - w = self.window.main_glade.get_widget(item) - if value: - w.hide() - else: - if client.connected() or item is "menuitem_connectionmanager": - w.show() - else: - w.hide() diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 712cbd62d..aa00ead32 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -751,6 +751,22 @@ class Preferences(component.Component): # Re-show the dialog to make sure everything has been updated self.show() + if client.is_classicmode() != new_gtkui_config["classic_mode"]: + dialog = gtk.MessageDialog( + flags=gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, + type=gtk.MESSAGE_QUESTION, + buttons=gtk.BUTTONS_YES_NO, + message_format=_("You must restart the deluge UI to change classic mode. Quit now?") + ) + result = dialog.run() + if result == gtk.RESPONSE_YES: + shutdown_daemon = (not client.is_classicmode() and + client.connected() and + client.is_localhost()) + component.get("MainWindow").quit(shutdown=shutdown_daemon) + dialog.destroy() + + def hide(self): self.glade.get_widget("port_img").hide() self.pref_dialog.hide() diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py index 81b0c3e8e..5261da516 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtkui/toolbar.py @@ -74,14 +74,11 @@ class ToolBar(component.Component): "toolbutton_queue_down" ] - self.config.register_set_function("classic_mode", self._on_classic_mode, True) - # Hide if necessary self.visible(self.config["show_toolbar"]) def start(self): - if not self.config["classic_mode"]: - self.window.main_glade.get_widget("toolbutton_connectionmanager").show() + self.window.main_glade.get_widget("toolbutton_connectionmanager").set_visible(not self.config["classic_mode"]) for widget in self.change_sensitivity: self.window.main_glade.get_widget(widget).set_sensitive(True) @@ -178,10 +175,3 @@ class ToolBar(component.Component): def on_toolbutton_queue_down_clicked(self, data): log.debug("on_toolbutton_queue_down_clicked") 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()