Adding feature to switch between profiles using keybindings

- adding config options
- adding prefeditor code
- adding event handlers to switch back and forth
This commit is contained in:
Peter Lind 2014-08-13 09:36:20 +02:00
parent a1264a7950
commit 16cf86d5ab
3 changed files with 50 additions and 2 deletions

View File

@ -176,7 +176,9 @@ DEFAULTS = {
'insert_number' : '', 'insert_number' : '',
'insert_padded' : '', 'insert_padded' : '',
'edit_window_title': '', 'edit_window_title': '',
'layout_launcher' : '' 'layout_launcher' : '',
'next_profile' : '',
'previous_profile' : ''
}, },
'profiles': { 'profiles': {
'default': { 'default': {

View File

@ -147,7 +147,9 @@ class PrefsEditor:
'insert_number' : 'Insert terminal number', 'insert_number' : 'Insert terminal number',
'insert_padded' : 'Insert zero padded terminal number', 'insert_padded' : 'Insert zero padded terminal number',
'edit_window_title': 'Edit window title', 'edit_window_title': 'Edit window title',
'layout_launcher' : 'Open layout launcher window' 'layout_launcher' : 'Open layout launcher window',
'next_profile' : 'Switch to next profile',
'previous_profile' : 'Switch to previous profile'
} }
def __init__ (self, term): def __init__ (self, term):

View File

@ -196,6 +196,44 @@ class Terminal(gtk.VBox):
"""Return our profile name""" """Return our profile name"""
return(self.config.profile) return(self.config.profile)
def switch_to_next_profile(self):
profilelist = self.config.list_profiles()
if len(profilelist) > 1:
next = False
first = False
for profile in profilelist:
if first == False:
first = profile
if next:
self.force_set_profile(False, profile)
return
if profile == self.get_profile():
next = True
if first:
self.force_set_profile(False, first)
def switch_to_previous_profile(self):
profilelist = self.config.list_profiles()
if len(profilelist) > 1:
last = False
for profile in profilelist:
if profile == self.get_profile():
if last:
self.force_set_profile(False, last)
return
last = profile
if last:
self.force_set_profile(False, last)
def get_cwd(self): def get_cwd(self):
"""Return our cwd""" """Return our cwd"""
return(self.terminator.pid_cwd(self.pid)) return(self.terminator.pid_cwd(self.pid))
@ -1545,6 +1583,12 @@ class Terminal(gtk.VBox):
def key_zoom_in(self): def key_zoom_in(self):
self.zoom_in() self.zoom_in()
def key_next_profile(self):
self.switch_to_next_profile()
def key_previous_profile(self):
self.switch_to_previous_profile()
def key_zoom_out(self): def key_zoom_out(self):
self.zoom_out() self.zoom_out()