Preselect the current layout when opening Prefs window, and also save config after using the layout 'Save' button (Steve Boddy)

This commit is contained in:
Stephen Boddy 2015-07-14 23:09:05 +02:00
parent 9dadba61c4
commit 25a6da8a99
3 changed files with 12 additions and 3 deletions

View File

@ -336,7 +336,7 @@ class Config(object):
def add_layout(self, name, layout): def add_layout(self, name, layout):
"""Add a new layout""" """Add a new layout"""
return(self.base.add_layout(name, layout)) return(self.base.add_layout(name, layout))
def replace_layout(self, name, layout): def replace_layout(self, name, layout):
"""Replace an existing layout""" """Replace an existing layout"""
return(self.base.replace_layout(name, layout)) return(self.base.replace_layout(name, layout))

View File

@ -330,7 +330,12 @@ class PrefsEditor:
self.layoutiters[layout] = liststore.append([layout, editable]) self.layoutiters[layout] = liststore.append([layout, editable])
selection = widget.get_selection() selection = widget.get_selection()
selection.connect('changed', self.on_layout_selection_changed) selection.connect('changed', self.on_layout_selection_changed)
selection.select_iter(self.layoutiters['default']) terminator = Terminator()
if terminator.layoutname:
layout_to_highlight = terminator.layoutname
else:
layout_to_highlight = 'default'
selection.select_iter(self.layoutiters[layout_to_highlight])
# Now set up the selection changed handler for the layout itself # Now set up the selection changed handler for the layout itself
widget = guiget('LayoutTreeView') widget = guiget('LayoutTreeView')
selection = widget.get_selection() selection = widget.get_selection()
@ -1142,9 +1147,10 @@ class PrefsEditor:
selected = treeview.get_selection() selected = treeview.get_selection()
(model, rowiter) = selected.get_selected() (model, rowiter) = selected.get_selected()
name = model.get_value(rowiter, 0) name = model.get_value(rowiter, 0)
if self.config.replace_layout(name, current_layout): if self.config.replace_layout(name, current_layout):
treeview.set_cursor(model.get_path(rowiter), focus_column=treeview.get_column(0), start_editing=False) treeview.set_cursor(model.get_path(rowiter), focus_column=treeview.get_column(0), start_editing=False)
self.config.save()
def on_layoutremovebutton_clicked(self, _button): def on_layoutremovebutton_clicked(self, _button):
"""Remove a layout from the list""" """Remove a layout from the list"""

View File

@ -34,6 +34,7 @@ class Terminator(Borg):
debug_address = None debug_address = None
doing_layout = None doing_layout = None
layoutname = None
last_active_window = None last_active_window = None
groupsend = None groupsend = None
@ -288,6 +289,8 @@ class Terminator(Borg):
window.set_fullscreen(window.isfullscreen) window.set_fullscreen(window.isfullscreen)
window.create_layout(layout[windef]) window.create_layout(layout[windef])
self.layoutname = layoutname
def layout_done(self): def layout_done(self):
"""Layout operations have finished, record that fact""" """Layout operations have finished, record that fact"""
self.doing_layout = False self.doing_layout = False