From 327de6f5cd7f77ba268e18e9379ebc08882950af Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 26 Jul 2008 08:12:34 +0000 Subject: [PATCH] Fix view options to be persistent between sessions --- deluge/ui/gtkui/gtkui.py | 5 ++++- deluge/ui/gtkui/menubar.py | 10 +++++++++- deluge/ui/gtkui/sidebar.py | 6 ++++++ deluge/ui/gtkui/statusbar.py | 5 +++++ deluge/ui/gtkui/toolbar.py | 5 +++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 09213387f..cf78d9fd8 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -97,7 +97,10 @@ DEFAULT_PREFS = { "autoadd_location": "", "choose_directory_dialog_path": deluge.common.get_default_download_dir(), "show_new_releases": True, - "signal_port": 40000 + "signal_port": 40000, + "show_sidebar": True, + "show_toolbar": True, + "show_statusbar": True } class GtkUI: diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 08dd309a2..ff0776c21 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -101,6 +101,14 @@ class MenuBar(component.Component): # Attach the torrent_menu to the Torrent file menu self.menu_torrent.set_submenu(self.torrentmenu) + # Make sure the view menuitems are showing the correct active state + self.window.main_glade.get_widget("menuitem_toolbar").set_active( + self.config["show_toolbar"]) + self.window.main_glade.get_widget("menuitem_labels").set_active( + self.config["show_sidebar"]) + self.window.main_glade.get_widget("menuitem_statusbar").set_active( + self.config["show_statusbar"]) + ### Connect Signals ### self.window.main_glade.signal_autoconnect({ ## File Menu @@ -167,7 +175,7 @@ class MenuBar(component.Component): 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() - + def start(self): for widget in self.change_sensitivity: self.window.main_glade.get_widget(widget).set_sensitive(True) diff --git a/deluge/ui/gtkui/sidebar.py b/deluge/ui/gtkui/sidebar.py index 0db5857ca..6ea22c62a 100644 --- a/deluge/ui/gtkui/sidebar.py +++ b/deluge/ui/gtkui/sidebar.py @@ -36,6 +36,7 @@ import gtk.glade import deluge.component as component import deluge.common +from deluge.configmanager import ConfigManager from deluge.log import LOG as log class SideBar(component.Component): @@ -47,6 +48,7 @@ class SideBar(component.Component): self.hpaned = glade.get_widget("hpaned") self.scrolled = glade.get_widget("scrolledwindow_sidebar") self.is_visible = True + self.config = ConfigManager("gtkui.conf") # Create the liststore # state str, str that's visible, icon @@ -90,6 +92,9 @@ class SideBar(component.Component): self.label_view.get_selection().select_iter( self.liststore.get_iter_first()) + # Hide if necessary + self.visible(self.config["show_sidebar"]) + def visible(self, visible): if visible: self.scrolled.show() @@ -98,6 +103,7 @@ class SideBar(component.Component): self.hpaned.set_position(-1) self.is_visible = visible + self.config["show_sidebar"] = visible def on_selection_changed(self, selection): try: diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index 31443ee6e..182fa7a4c 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -135,6 +135,9 @@ class StatusBar(component.Component): callback=self._on_notconnected_item_clicked) # Show the not connected status bar self.show_not_connected() + + # Hide if necessary + self.visible(self.config["show_statusbar"]) def start(self): # Add in images and labels @@ -197,6 +200,8 @@ class StatusBar(component.Component): self.statusbar.show() else: self.statusbar.hide() + + self.config["show_statusbar"] = visible def show_not_connected(self): self.hbox.pack_start( diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py index 88fea9b8c..9484a2d9e 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtkui/toolbar.py @@ -78,6 +78,9 @@ class ToolBar(component.Component): if self.config["classic_mode"]: self.window.main_glade.get_widget("toolbutton_connectionmanager").hide() + + # Hide if necessary + self.visible(self.config["show_toolbar"]) def start(self): for widget in self.change_sensitivity: @@ -94,6 +97,8 @@ class ToolBar(component.Component): else: self.toolbar.hide() + self.config["show_toolbar"] = visible + def add_toolbutton(self, callback, label=None, image=None, stock=None, tooltip=None): """Adds a toolbutton to the toolbar"""