Improved code for cycling through profiles

This commit is contained in:
Peter Lind 2014-08-13 18:52:59 +02:00
parent 16cf86d5ab
commit f3403d72a9
1 changed files with 12 additions and 30 deletions

View File

@ -198,41 +198,23 @@ class Terminal(gtk.VBox):
def switch_to_next_profile(self):
profilelist = self.config.list_profiles()
list_length = len(profilelist)
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)
if list_length > 1:
if profilelist.index(self.get_profile()) + 1 == list_length:
self.force_set_profile(False, profilelist[0])
else:
self.force_set_profile(False, profilelist[profilelist.index(self.get_profile()) + 1])
def switch_to_previous_profile(self):
profilelist = self.config.list_profiles()
list_length = len(profilelist)
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)
if list_length > 1:
if profilelist.index(self.get_profile()) == 0:
self.force_set_profile(False, profilelist[list_length - 1])
else:
self.force_set_profile(False, profilelist[profilelist.index(self.get_profile()) - 1])
def get_cwd(self):
"""Return our cwd"""