From 30ed1f2d86c2beda0b32b3c397ed6c8d2cefddc1 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 22 Sep 2007 03:30:42 +0000 Subject: [PATCH] Fix saving config on exit of UI. --- deluge/configmanager.py | 3 ++- deluge/ui/gtkui/addtorrentdialog.py | 1 + deluge/ui/gtkui/gtkui.py | 20 +++++++++++--------- deluge/ui/gtkui/preferences.py | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/deluge/configmanager.py b/deluge/configmanager.py index aaf87fa00..cdb8081f7 100644 --- a/deluge/configmanager.py +++ b/deluge/configmanager.py @@ -61,10 +61,11 @@ class _ConfigManager: def get_config(self, config_file, defaults=None): """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 if config_file not in self.config_files.keys(): self.config_files[config_file] = Config(config_file, defaults) - + return self.config_files[config_file] # Singleton functions diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 9966e58da..db1de8e54 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -83,4 +83,5 @@ class AddTorrentDialog: result = None self.chooser.destroy() + del self.config return result diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 20cfa05d5..d1783d1d7 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -60,10 +60,10 @@ DEFAULT_PREFS = { "send_info": False, "default_load_path": None, "window_maximized": False, - "window_x_pos": -1, - "window_y_pos": -1, - "window_width": -1, - "window_height": -1 + "window_x_pos": 0, + "window_y_pos": 0, + "window_width": 640, + "window_height": 480 } class GtkUI: @@ -84,8 +84,7 @@ class GtkUI: # Make sure gtkui.conf has at least the defaults set config = ConfigManager("gtkui.conf", DEFAULT_PREFS) - del config - + # Initialize the main window self.mainwindow = MainWindow() @@ -100,12 +99,15 @@ class GtkUI: # Start the gtk main loop gtk.main() - + log.debug("gtkui shutting down..") + + # Make sure the config is saved. + config.save() + del config + # Clean-up del self.mainwindow del self.signal_receiver del self.plugins - # Make sure the config file is closed and saved to disk. - deluge.configmanager.close("gtkui.conf") del deluge.configmanager diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index fafd81a3a..d15fd1cc5 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -52,6 +52,7 @@ class Preferences: self.treeview = self.glade.get_widget("treeview") self.notebook = self.glade.get_widget("notebook") self.core = functions.get_core() + self.gtkui_config = ConfigManager("gtkui.conf") # Setup the liststore for the categories (tab pages) self.liststore = gtk.ListStore(int, str) self.treeview.set_model(self.liststore) @@ -88,7 +89,6 @@ class Preferences: def show(self): self.core_config = functions.get_config(self.core) - self.gtkui_config = ConfigManager("gtkui.conf") # Update the preferences dialog to reflect current config settings ## Downloads tab ##