Make the terminal context menu list available profiles and switch between them

This commit is contained in:
Chris Jones 2009-12-26 20:09:16 +00:00
parent 2a56e328ac
commit ee81bd4f76
3 changed files with 32 additions and 1 deletions

View File

@ -198,8 +198,10 @@ class Config(object):
def set_profile(self, profile):
"""Set our profile (which usually means change it)"""
dbg('Config::set_profile: Changing profile to %s' % profile)
self.profile = profile
if not self.base.profiles.has_key(profile):
dbg('Config::set_profile: %s does not exist, creating' % profile)
self.base.profiles[profile] = copy(DEFAULTS['profiles']['default'])
def del_profile(self, profile):

View File

@ -135,6 +135,15 @@ class Terminal(gtk.VBox):
if self.config['http_proxy'] and self.config['http_proxy'] != '':
os.putenv('http_proxy', self.config['http_proxy'])
def set_profile(self, widget, profile):
"""Set our profile"""
self.config.set_profile(profile)
self.reconfigure()
def get_profile(self):
"""Return our profile name"""
return(self.config.profile)
def close(self):
"""Close ourselves"""
dbg('Terminal::close: emitting close-term')

View File

@ -10,6 +10,7 @@ from version import APP_NAME
from translation import _
from encoding import TerminatorEncoding
from util import err
from config import Config
import plugin
class TerminalPopupMenu(object):
@ -130,10 +131,29 @@ class TerminalPopupMenu(object):
item.set_sensitive(False)
menu.append(item)
item = gtk.MenuItem(_('Profiles'))
submenu = gtk.Menu()
item.set_submenu(submenu)
menu.append(item)
config = Config()
current = terminal.get_profile()
group = None
for profile in config.list_profiles():
item = gtk.RadioMenuItem(group, profile.capitalize())
item.connect('activate', terminal.set_profile, profile)
if profile == current:
item.set_active(True)
submenu.append(item)
submenu.append(gtk.MenuItem())
item = gtk.MenuItem(_('Ed_it profile'))
item.connect('activate', lambda x:
terminal.terminator.edit_profile(terminal))
menu.append(item)
submenu.append(item)
self.add_encoding_items(menu)