Fix view options to be persistent between sessions

This commit is contained in:
Andrew Resch 2008-07-26 08:12:34 +00:00
commit 327de6f5cd
5 changed files with 29 additions and 2 deletions

View file

@ -97,7 +97,10 @@ DEFAULT_PREFS = {
"autoadd_location": "", "autoadd_location": "",
"choose_directory_dialog_path": deluge.common.get_default_download_dir(), "choose_directory_dialog_path": deluge.common.get_default_download_dir(),
"show_new_releases": True, "show_new_releases": True,
"signal_port": 40000 "signal_port": 40000,
"show_sidebar": True,
"show_toolbar": True,
"show_statusbar": True
} }
class GtkUI: class GtkUI:

View file

@ -101,6 +101,14 @@ class MenuBar(component.Component):
# Attach the torrent_menu to the Torrent file menu # Attach the torrent_menu to the Torrent file menu
self.menu_torrent.set_submenu(self.torrentmenu) 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 ### ### Connect Signals ###
self.window.main_glade.signal_autoconnect({ self.window.main_glade.signal_autoconnect({
## File Menu ## 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("menuitem_quitdaemon").hide()
self.window.main_glade.get_widget("separatormenuitem").hide() self.window.main_glade.get_widget("separatormenuitem").hide()
self.window.main_glade.get_widget("menuitem_connectionmanager").hide() self.window.main_glade.get_widget("menuitem_connectionmanager").hide()
def start(self): def start(self):
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)

View file

@ -36,6 +36,7 @@ import gtk.glade
import deluge.component as component import deluge.component as component
import deluge.common import deluge.common
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log from deluge.log import LOG as log
class SideBar(component.Component): class SideBar(component.Component):
@ -47,6 +48,7 @@ class SideBar(component.Component):
self.hpaned = glade.get_widget("hpaned") self.hpaned = glade.get_widget("hpaned")
self.scrolled = glade.get_widget("scrolledwindow_sidebar") self.scrolled = glade.get_widget("scrolledwindow_sidebar")
self.is_visible = True self.is_visible = True
self.config = ConfigManager("gtkui.conf")
# Create the liststore # Create the liststore
# state str, str that's visible, icon # state str, str that's visible, icon
@ -90,6 +92,9 @@ class SideBar(component.Component):
self.label_view.get_selection().select_iter( self.label_view.get_selection().select_iter(
self.liststore.get_iter_first()) self.liststore.get_iter_first())
# Hide if necessary
self.visible(self.config["show_sidebar"])
def visible(self, visible): def visible(self, visible):
if visible: if visible:
self.scrolled.show() self.scrolled.show()
@ -98,6 +103,7 @@ class SideBar(component.Component):
self.hpaned.set_position(-1) self.hpaned.set_position(-1)
self.is_visible = visible self.is_visible = visible
self.config["show_sidebar"] = visible
def on_selection_changed(self, selection): def on_selection_changed(self, selection):
try: try:

View file

@ -135,6 +135,9 @@ class StatusBar(component.Component):
callback=self._on_notconnected_item_clicked) callback=self._on_notconnected_item_clicked)
# Show the not connected status bar # Show the not connected status bar
self.show_not_connected() self.show_not_connected()
# Hide if necessary
self.visible(self.config["show_statusbar"])
def start(self): def start(self):
# Add in images and labels # Add in images and labels
@ -197,6 +200,8 @@ class StatusBar(component.Component):
self.statusbar.show() self.statusbar.show()
else: else:
self.statusbar.hide() self.statusbar.hide()
self.config["show_statusbar"] = visible
def show_not_connected(self): def show_not_connected(self):
self.hbox.pack_start( self.hbox.pack_start(

View file

@ -78,6 +78,9 @@ class ToolBar(component.Component):
if self.config["classic_mode"]: if self.config["classic_mode"]:
self.window.main_glade.get_widget("toolbutton_connectionmanager").hide() self.window.main_glade.get_widget("toolbutton_connectionmanager").hide()
# Hide if necessary
self.visible(self.config["show_toolbar"])
def start(self): def start(self):
for widget in self.change_sensitivity: for widget in self.change_sensitivity:
@ -94,6 +97,8 @@ class ToolBar(component.Component):
else: else:
self.toolbar.hide() self.toolbar.hide()
self.config["show_toolbar"] = visible
def add_toolbutton(self, callback, label=None, image=None, stock=None, def add_toolbutton(self, callback, label=None, image=None, stock=None,
tooltip=None): tooltip=None):
"""Adds a toolbutton to the toolbar""" """Adds a toolbutton to the toolbar"""