diff --git a/terminatorlib/config.py b/terminatorlib/config.py
index 03d1686d..b5363a65 100644
--- a/terminatorlib/config.py
+++ b/terminatorlib/config.py
@@ -310,6 +310,10 @@ class Config(object):
"""Get our profile"""
return(self.profile)
+ def get_profile_by_name(self, profile):
+ """Get the profile with the specified name"""
+ return(self.base.profiles[profile])
+
def set_profile(self, profile, force=False):
"""Set our profile (which usually means change it)"""
options = self.options_get()
@@ -322,9 +326,9 @@ class Config(object):
dbg('Config::set_profile: %s does not exist, creating' % profile)
self.base.profiles[profile] = copy(DEFAULTS['profiles']['default'])
- def add_profile(self, profile):
+ def add_profile(self, profile, toclone):
"""Add a new profile"""
- return(self.base.add_profile(profile))
+ return(self.base.add_profile(profile, toclone))
def del_profile(self, profile):
"""Delete a profile"""
@@ -814,11 +818,15 @@ class ConfigBase(Borg):
if plugin in self.plugins:
del self.plugins[plugin]
- def add_profile(self, profile):
+ def add_profile(self, profile, toclone):
"""Add a new profile"""
if profile in self.profiles:
return(False)
- self.profiles[profile] = copy(DEFAULTS['profiles']['default'])
+ if toclone is not None:
+ newprofile = copy(toclone)
+ else:
+ newprofile = copy(DEFAULTS['profiles']['default'])
+ self.profiles[profile] = newprofile
return(True)
def add_layout(self, name, layout):
diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade
index 67b5ed59..42616d93 100644
--- a/terminatorlib/preferences.glade
+++ b/terminatorlib/preferences.glade
@@ -1287,6 +1287,22 @@
1
+
+
+
+ False
+ False
+ 2
+
+
False
diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py
index f5055b64..58dcfc58 100755
--- a/terminatorlib/prefseditor.py
+++ b/terminatorlib/prefseditor.py
@@ -1334,22 +1334,23 @@ class PrefsEditor:
self.config['window_state'] = value
self.config.save()
- def on_profileaddbutton_clicked(self, _button):
- """Add a new profile to the list"""
+ # helper function, not a signal
+ def addprofile(self, name, toclone):
+ """Add a profile"""
guiget = self.builder.get_object
treeview = guiget('profilelist')
model = treeview.get_model()
values = [ r[0] for r in model ]
- newprofile = _('New Profile')
+ newprofile = name
if newprofile in values:
i = 1
while newprofile in values:
i = i + 1
- newprofile = '%s %d' % (_('New Profile'), i)
+ newprofile = '%s %d' % (name, i)
- if self.config.add_profile(newprofile):
+ if self.config.add_profile(newprofile, toclone):
res = model.append([newprofile, True])
if res:
path = model.get_path(res)
@@ -1358,6 +1359,10 @@ class PrefsEditor:
self.layouteditor.update_profiles()
+ def on_profileaddbutton_clicked(self, _button):
+ """Add a new profile to the list"""
+ self.addprofile(_('New Profile'), None)
+
def on_profileremovebutton_clicked(self, _button):
"""Remove a profile from the list"""
guiget = self.builder.get_object
@@ -1377,6 +1382,18 @@ class PrefsEditor:
selection.select_iter(model.get_iter_first())
self.layouteditor.update_profiles()
+ def on_profileclonebutton_clicked(self, _button):
+ """"Clone a profile and add the new one to the list"""
+ guiget = self.builder.get_object
+
+ treeview = guiget('profilelist')
+ selection = treeview.get_selection()
+ (model, rowiter) = selection.get_selected()
+ profile = model.get_value(rowiter, 0)
+
+ toclone = self.config.get_profile_by_name(profile)
+ self.addprofile(profile, toclone)
+
def on_layoutaddbutton_clicked(self, _button):
"""Add a new layout to the list"""
terminator = Terminator()