Save layout button prototype.

This commit is contained in:
Ariel Zelivansky 2014-05-19 22:47:11 +03:00
parent ece4e77d58
commit eadb5cb419
3 changed files with 40 additions and 0 deletions

View File

@ -321,6 +321,10 @@ class Config(object):
"""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):
"""Replace an existing layout"""
return(self.base.replace_layout(name, layout))
def del_layout(self, layout): def del_layout(self, layout):
"""Delete a layout""" """Delete a layout"""
if self.base.layouts.has_key(layout): if self.base.layouts.has_key(layout):
@ -734,6 +738,13 @@ class ConfigBase(Borg):
self.layouts[name] = layout self.layouts[name] = layout
return(True) return(True)
def replace_layout(self, name, layout):
"""Replaces a layout with the given name"""
if not name in self.layouts:
return(False)
self.layouts[name] = layout
return(True)
def get_layout(self, layout): def get_layout(self, layout):
"""Return a layout""" """Return a layout"""
if self.layouts.has_key(layout): if self.layouts.has_key(layout):

View File

@ -3412,6 +3412,21 @@
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton" id="layoutrefreshbutton">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_layoutrefreshbutton_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -1090,6 +1090,20 @@ class PrefsEditor:
self.config.save() self.config.save()
def on_layoutrefreshbutton_clicked(self, _button):
"""Refresh the terminals status and update"""
terminator = Terminator()
current_layout = terminator.describe_layout()
guiget = self.builder.get_object
treeview = guiget('layoutlist')
selected = treeview.get_selection()
(model, rowiter) = selected.get_selected()
name = model.get_value(rowiter, 0)
if self.config.replace_layout(name, current_layout):
treeview.set_cursor(model.get_path(rowiter), focus_column=treeview.get_column(0), start_editing=False)
def on_layoutremovebutton_clicked(self, _button): def on_layoutremovebutton_clicked(self, _button):
"""Remove a layout from the list""" """Remove a layout from the list"""
guiget = self.builder.get_object guiget = self.builder.get_object