Merged with trunk

This commit is contained in:
Peter Bjørn Jørgensen 2010-05-17 22:50:03 +02:00
commit 2ef3964b39
5 changed files with 61 additions and 15 deletions

View File

@ -229,7 +229,7 @@ class Config(object):
def __init__(self, profile='default'):
self.base = ConfigBase()
self.profile = profile
self.set_profile(profile)
self.inhibited = False
def __getitem__(self, key):
@ -244,8 +244,12 @@ class Config(object):
"""Get our profile"""
return(self.profile)
def set_profile(self, profile):
def set_profile(self, profile, force=False):
"""Set our profile (which usually means change it)"""
options = self.options_get()
if not force and options and options.profile and profile == 'default':
dbg('overriding default profile to %s' % options.profile)
profile = options.profile
dbg('Config::set_profile: Changing profile to %s' % profile)
self.profile = profile
if not self.base.profiles.has_key(profile):
@ -259,10 +263,16 @@ class Config(object):
def del_profile(self, profile):
"""Delete a profile"""
if profile == self.profile:
# FIXME: We should solve this problem by updating terminals when we
# remove a profile
err('Config::del_profile: Deleting in-use profile %s.' % profile)
self.set_profile('default')
if self.base.profiles.has_key(profile):
del(self.base.profiles[profile])
options = self.options_get()
if options and options.profile == profile:
options.profile = None
self.options_set(options)
def rename_profile(self, profile, newname):
"""Rename a profile"""
@ -600,6 +610,10 @@ class ConfigBase(Borg):
def get_item(self, key, profile='default', plugin=None):
"""Look up a configuration item"""
if not self.profiles.has_key(profile):
# Hitting this generally implies a bug
profile = 'default'
if self.global_config.has_key(key):
dbg('ConfigBase::get_item: %s found in globals: %s' %
(key, self.global_config[key]))

View File

@ -66,6 +66,8 @@ command to execute inside the terminal, and its arguments')
parser.add_option('-r', '--role', dest='role', help='Set a custom \
WM_WINDOW_ROLE property on the window')
parser.add_option('-l', '--layout', dest='layout', help='Select a layout')
parser.add_option('-p', '--profile', dest='profile', help='Use a \
different profile as the default')
parser.add_option('-d', '--debug', action='count', dest='debug',
help='Enable debugging information (twice for debug server)')
parser.add_option('--debug-classes', action='store', dest='debug_classes',
@ -73,7 +75,7 @@ WM_WINDOW_ROLE property on the window')
parser.add_option('--debug-methods', action='store', dest='debug_methods',
help='Comma separated list of methods to limit debugging to')
for item in ['--sm-client-id', '--sm-config-prefix', '--screen', '-n',
'--no-gconf', '-p', '--profile' ]:
'--no-gconf' ]:
parser.add_option(item, dest='dummy', action='store',
help=SUPPRESS_HELP)
@ -113,6 +115,9 @@ WM_WINDOW_ROLE property on the window')
if options.layout is None:
options.layout = 'default'
if options.profile and options.profile not in configobj.list_profiles():
options.profile = None
configobj.options_set(options)
if util.DEBUG == True:

View File

@ -105,6 +105,7 @@ class Terminal(gtk.VBox):
self.terminator = Terminator()
self.terminator.register_terminal(self)
# FIXME: Surely these should happen in Terminator::register_terminal()?
self.connect('enumerate', self.terminator.do_enumerate)
self.connect('focus-in', self.terminator.focus_changed)
@ -158,10 +159,14 @@ 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):
def force_set_profile(self, widget, profile):
"""Forcibly set our profile"""
self.set_profile(widget, profile, True)
def set_profile(self, _widget, profile, force=False):
"""Set our profile"""
if profile != self.config.get_profile():
self.config.set_profile(profile)
self.config.set_profile(profile, force)
self.reconfigure()
def get_profile(self):

View File

@ -19,11 +19,13 @@ class TerminalPopupMenu(object):
"""Class implementing the Terminal context menu"""
terminal = None
terminator = None
config = None
def __init__(self, terminal):
"""Class initialiser"""
self.terminal = terminal
self.terminator = Terminator()
self.config = Config()
def show(self, widget, event=None):
"""Display the context menu"""
@ -34,6 +36,8 @@ class TerminalPopupMenu(object):
button = None
time = None
self.config.set_profile(terminal.get_profile())
if event:
url = terminal.check_for_url(event)
button = event.button
@ -135,6 +139,14 @@ class TerminalPopupMenu(object):
menu.append(gtk.MenuItem())
if self.config['show_titlebar'] == False:
item = gtk.MenuItem(_('Grouping'))
submenu = self.terminal.populate_group_menu()
submenu.show_all()
item.set_submenu(submenu)
menu.append(item)
menu.append(gtk.MenuItem())
item = gtk.CheckMenuItem(_('Show _scrollbar'))
item.set_active(terminal.scrollbar.get_property('visible'))
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
@ -144,8 +156,7 @@ class TerminalPopupMenu(object):
item.connect('activate', lambda x: PrefsEditor(self.terminal))
menu.append(item)
config = Config()
profilelist = config.list_profiles()
profilelist = self.config.list_profiles()
if len(profilelist) > 1:
item = gtk.MenuItem(_('Profiles'))
@ -161,7 +172,7 @@ class TerminalPopupMenu(object):
item = gtk.RadioMenuItem(group, profile.capitalize())
if profile == current:
item.set_active(True)
item.connect('activate', terminal.set_profile, profile)
item.connect('activate', terminal.force_set_profile, profile)
submenu.append(item)
self.add_encoding_items(menu)

View File

@ -150,21 +150,30 @@ class Titlebar(gtk.EventBox):
color = term.get_style().bg[gtk.STATE_NORMAL]
else:
color = gtk.gdk.color_parse(title_bg)
self.set_size_request(-1, 2)
self.label.hide()
else:
self.set_size_request(-1, -1)
self.label.show()
self.update_visibility()
self.ebox.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(group_bg))
self.set_from_icon_name(icon, gtk.ICON_SIZE_MENU)
def update_visibility(self):
"""Make the titlebar be visible or not"""
if not self.get_desired_visibility():
dbg('hiding titlebar')
self.hide()
self.label.hide()
else:
dbg('showing titlebar')
self.show()
self.label.show()
def get_desired_visibility(self):
"""Returns True if the titlebar is supposed to be visible. False if
not"""
if self.editing() == True:
if self.editing() == True or self.terminal.group:
dbg('implicit desired visibility')
return(True)
else:
dbg('configured visibility: %s' % self.config['show_titlebar'])
return(self.config['show_titlebar'])
def set_from_icon_name(self, name, size = gtk.ICON_SIZE_MENU):
@ -195,10 +204,11 @@ class Titlebar(gtk.EventBox):
self.grouplabel.show()
else:
self.grouplabel.hide()
self.update_visibility()
def on_clicked(self, widget, event):
"""Handle a click on the label"""
self.set_size_request(-1, -1)
self.show()
self.label.show()
self.emit('clicked')
@ -214,6 +224,7 @@ class Titlebar(gtk.EventBox):
"""Create a new group"""
self.groupentry.show()
self.groupentry.grab_focus()
self.update_visibility()
def groupentry_cancel(self, widget, event):
"""Hide the group name entry"""