Fix saving config on exit of UI.

This commit is contained in:
Andrew Resch 2007-09-22 03:30:42 +00:00
parent cc155d9473
commit 30ed1f2d86
4 changed files with 15 additions and 11 deletions

View File

@ -61,6 +61,7 @@ class _ConfigManager:
def get_config(self, config_file, defaults=None): def get_config(self, config_file, defaults=None):
"""Get a reference to the Config object for this filename""" """Get a reference to the Config object for this filename"""
log.debug("Getting config '%s'", config_file)
# Create the config object if not already created # Create the config object if not already created
if config_file not in self.config_files.keys(): if config_file not in self.config_files.keys():
self.config_files[config_file] = Config(config_file, defaults) self.config_files[config_file] = Config(config_file, defaults)

View File

@ -83,4 +83,5 @@ class AddTorrentDialog:
result = None result = None
self.chooser.destroy() self.chooser.destroy()
del self.config
return result return result

View File

@ -60,10 +60,10 @@ DEFAULT_PREFS = {
"send_info": False, "send_info": False,
"default_load_path": None, "default_load_path": None,
"window_maximized": False, "window_maximized": False,
"window_x_pos": -1, "window_x_pos": 0,
"window_y_pos": -1, "window_y_pos": 0,
"window_width": -1, "window_width": 640,
"window_height": -1 "window_height": 480
} }
class GtkUI: class GtkUI:
@ -84,7 +84,6 @@ class GtkUI:
# Make sure gtkui.conf has at least the defaults set # Make sure gtkui.conf has at least the defaults set
config = ConfigManager("gtkui.conf", DEFAULT_PREFS) config = ConfigManager("gtkui.conf", DEFAULT_PREFS)
del config
# Initialize the main window # Initialize the main window
self.mainwindow = MainWindow() self.mainwindow = MainWindow()
@ -102,10 +101,13 @@ class GtkUI:
gtk.main() gtk.main()
log.debug("gtkui shutting down..") log.debug("gtkui shutting down..")
# Make sure the config is saved.
config.save()
del config
# Clean-up # Clean-up
del self.mainwindow del self.mainwindow
del self.signal_receiver del self.signal_receiver
del self.plugins del self.plugins
# Make sure the config file is closed and saved to disk.
deluge.configmanager.close("gtkui.conf")
del deluge.configmanager del deluge.configmanager

View File

@ -52,6 +52,7 @@ class Preferences:
self.treeview = self.glade.get_widget("treeview") self.treeview = self.glade.get_widget("treeview")
self.notebook = self.glade.get_widget("notebook") self.notebook = self.glade.get_widget("notebook")
self.core = functions.get_core() self.core = functions.get_core()
self.gtkui_config = ConfigManager("gtkui.conf")
# Setup the liststore for the categories (tab pages) # Setup the liststore for the categories (tab pages)
self.liststore = gtk.ListStore(int, str) self.liststore = gtk.ListStore(int, str)
self.treeview.set_model(self.liststore) self.treeview.set_model(self.liststore)
@ -88,7 +89,6 @@ class Preferences:
def show(self): def show(self):
self.core_config = functions.get_config(self.core) self.core_config = functions.get_config(self.core)
self.gtkui_config = ConfigManager("gtkui.conf")
# Update the preferences dialog to reflect current config settings # Update the preferences dialog to reflect current config settings
## Downloads tab ## ## Downloads tab ##