Fix #549 make sidebar width persistent

This commit is contained in:
Andrew Resch 2008-10-18 06:43:38 +00:00
parent 219be3f440
commit 7caf26779f
3 changed files with 13 additions and 9 deletions

View File

@ -128,7 +128,6 @@ class FilterTreeView(component.Component):
self.create_model_filter() self.create_model_filter()
#init..... #init.....
self.hpaned.set_position(170)
self.label_view.connect("button-press-event", self.on_button_press_event) self.label_view.connect("button-press-event", self.on_button_press_event)
#colors using current theme. #colors using current theme.

View File

@ -113,8 +113,9 @@ DEFAULT_PREFS = {
"show_sidebar": True, "show_sidebar": True,
"show_toolbar": True, "show_toolbar": True,
"show_statusbar": True, "show_statusbar": True,
"sidebar_show_zero":False, "sidebar_show_zero": False,
"sidebar_show_trackers":False "sidebar_show_trackers": False,
"sidebar_position": 170
} }
class GtkUI: class GtkUI:
@ -247,6 +248,8 @@ class GtkUI:
client.shutdown() client.shutdown()
except: except:
pass pass
self.config.save()
try: try:
gtk.main_quit() gtk.main_quit()
except RuntimeError: except RuntimeError:

View File

@ -51,9 +51,8 @@ class SideBar(component.Component):
glade = self.window.main_glade glade = self.window.main_glade
self.notebook = glade.get_widget("sidebar_notebook") self.notebook = glade.get_widget("sidebar_notebook")
self.hpaned = glade.get_widget("hpaned") self.hpaned = glade.get_widget("hpaned")
self.is_visible = True
self.config = ConfigManager("gtkui.conf") self.config = ConfigManager("gtkui.conf")
self.hpaned_position = self.hpaned.get_position() #self.hpaned_position = self.hpaned.get_position()
# Tabs holds references to the Tab widgets by their name # Tabs holds references to the Tab widgets by their name
self.tabs = {} self.tabs = {}
@ -61,18 +60,21 @@ class SideBar(component.Component):
# Hide if necessary # Hide if necessary
self.visible(self.config["show_sidebar"]) self.visible(self.config["show_sidebar"])
def shutdown(self):
log.debug("hpaned.position: %s", self.hpaned.get_position())
self.config["sidebar_position"] = self.hpaned.get_position()
def visible(self, visible): def visible(self, visible):
if visible: if visible:
if self.hpaned_position: if self.config["sidebar_position"]:
self.hpaned.set_position(self.hpaned_position) self.hpaned.set_position(self.config["sidebar_position"])
self.notebook.show() self.notebook.show()
else: else:
self.notebook.hide() self.notebook.hide()
# Store the position for restoring upon show() # Store the position for restoring upon show()
self.hpaned_position = self.hpaned.get_position() self.config["sidebar_position"] = self.hpaned.get_position()
self.hpaned.set_position(-1) self.hpaned.set_position(-1)
self.is_visible = visible
self.config["show_sidebar"] = visible self.config["show_sidebar"] = visible
def add_tab(self, widget, tab_name, label): def add_tab(self, widget, tab_name, label):