From 2e116b09eb36415c4935c950445c9ba26d861181 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 10 Mar 2010 12:52:25 +0000 Subject: [PATCH] inhibit config saving while we're loading the config into the GUI, otherwise it saves a whole bunch for no good reason. Update the LayoutEditor's idea of the layout name when it's renamed. Set the layout item command/profile to the default values if there are no stored values. Save the layout item command/profile when they change. --- terminatorlib/prefseditor.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 128c5b6f..74d4b52f 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -109,7 +109,13 @@ class PrefsEditor: self.builder.connect_signals(self) self.layouteditor.prepare() self.window.show_all() - self.set_values() + try: + self.config.inhibit_save() + self.set_values() + except Exception, e: + err('Unable to set values: %s' % e) + finally: + self.config.uninhibit_save() def on_closebutton_clicked(self, _button): """Close the window""" @@ -888,6 +894,9 @@ class PrefsEditor: if oldname == self.previous_layout_selection: self.previous_layout_selection = newtext + if oldname == self.layouteditor.layout_name: + self.layouteditor.layout_name = newtext + def on_color_scheme_combobox_changed(self, widget): """Update the fore/background colour pickers""" value = None @@ -1101,9 +1110,13 @@ class LayoutEditor: chooser.set_sensitive(True) if layout_item.has_key('command') and layout_item['command'] != '': command.set_text(layout_item['command']) + else: + command.set_text('') if layout_item.has_key('profile') and layout_item['profile'] != '': chooser.set_active(self.profile_profile_to_ids[layout_item['profile']]) + else: + chooser.set_active(0) def on_layout_profile_chooser_changed(self, widget): """A new profile has been selected for this item""" @@ -1112,12 +1125,14 @@ class LayoutEditor: profile = widget.get_active_text() layout = self.config.layout_get_config(self.layout_name) layout[self.layout_item]['profile'] = profile + self.config.save() def on_layout_profile_command_activate(self, widget): """A new command has been entered for this item""" command = widget.get_text() layout = self.config.layout_get_config(self.layout_name) layout[self.layout_item]['command'] = command + self.config.save() if __name__ == '__main__': import util