Improved code for cycling through profiles
This commit is contained in:
parent
16cf86d5ab
commit
f3403d72a9
|
@ -198,41 +198,23 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
def switch_to_next_profile(self):
|
def switch_to_next_profile(self):
|
||||||
profilelist = self.config.list_profiles()
|
profilelist = self.config.list_profiles()
|
||||||
|
list_length = len(profilelist)
|
||||||
|
|
||||||
if len(profilelist) > 1:
|
if list_length > 1:
|
||||||
next = False
|
if profilelist.index(self.get_profile()) + 1 == list_length:
|
||||||
first = False
|
self.force_set_profile(False, profilelist[0])
|
||||||
|
else:
|
||||||
for profile in profilelist:
|
self.force_set_profile(False, profilelist[profilelist.index(self.get_profile()) + 1])
|
||||||
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):
|
def switch_to_previous_profile(self):
|
||||||
profilelist = self.config.list_profiles()
|
profilelist = self.config.list_profiles()
|
||||||
|
list_length = len(profilelist)
|
||||||
|
|
||||||
if len(profilelist) > 1:
|
if list_length > 1:
|
||||||
last = False
|
if profilelist.index(self.get_profile()) == 0:
|
||||||
|
self.force_set_profile(False, profilelist[list_length - 1])
|
||||||
for profile in profilelist:
|
else:
|
||||||
if profile == self.get_profile():
|
self.force_set_profile(False, profilelist[profilelist.index(self.get_profile()) - 1])
|
||||||
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"""
|
||||||
|
|
Loading…
Reference in New Issue