Nicer default groupname generation, and it all works as expected now

This commit is contained in:
Stephen Boddy 2012-10-24 15:19:58 +02:00
parent 183914c7dc
commit af549969ed
1 changed files with 14 additions and 8 deletions

View File

@ -6,6 +6,7 @@
import gtk import gtk
import gobject import gobject
import random import random
import itertools
from version import APP_NAME from version import APP_NAME
from util import dbg from util import dbg
@ -237,15 +238,20 @@ class Titlebar(gtk.EventBox):
if self.terminal.group: if self.terminal.group:
self.groupentry.set_text(self.terminal.group) self.groupentry.set_text(self.terminal.group)
else: else:
defaultgroups=set(['Alpha','Beta','Gamma','Delta','Epsilon','Zeta','Eta', defaultmembers=['Alpha','Beta','Gamma','Delta','Epsilon','Zeta','Eta',
'Theta','Iota','Kappa','Lambda','Mu','Nu','Xi', 'Theta','Iota','Kappa','Lambda','Mu','Nu','Xi',
'Omnicron','Pi','Rho','Sigma','Tau','Upsilon','Phi', 'Omnicron','Pi','Rho','Sigma','Tau','Upsilon','Phi',
'Chi','Psi','Omega']) 'Chi','Psi','Omega']
currentgroups=set(self.terminator.groups) currentgroups=set(self.terminator.groups)
freegroups = list(defaultgroups-currentgroups) for i in range(1,4):
random.shuffle(freegroups) defaultgroups=set(map(''.join, list(itertools.product(defaultmembers,repeat=i))))
if self.groupentry.get_text()=='' and freegroups: freegroups = list(defaultgroups-currentgroups)
self.groupentry.set_text(freegroups.pop()) if freegroups:
random.shuffle(freegroups)
self.groupentry.set_text(freegroups.pop())
break
else:
self.groupentry.set_text('')
self.groupentry.show() self.groupentry.show()
self.grouplabel.hide() self.grouplabel.hide()
self.groupentry.grab_focus() self.groupentry.grab_focus()