Merged with trunk
This commit is contained in:
commit
2ef3964b39
@ -229,7 +229,7 @@ class Config(object):
|
|||||||
|
|
||||||
def __init__(self, profile='default'):
|
def __init__(self, profile='default'):
|
||||||
self.base = ConfigBase()
|
self.base = ConfigBase()
|
||||||
self.profile = profile
|
self.set_profile(profile)
|
||||||
self.inhibited = False
|
self.inhibited = False
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
@ -244,8 +244,12 @@ class Config(object):
|
|||||||
"""Get our profile"""
|
"""Get our profile"""
|
||||||
return(self.profile)
|
return(self.profile)
|
||||||
|
|
||||||
def set_profile(self, profile):
|
def set_profile(self, profile, force=False):
|
||||||
"""Set our profile (which usually means change it)"""
|
"""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)
|
dbg('Config::set_profile: Changing profile to %s' % profile)
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
if not self.base.profiles.has_key(profile):
|
if not self.base.profiles.has_key(profile):
|
||||||
@ -259,10 +263,16 @@ class Config(object):
|
|||||||
def del_profile(self, profile):
|
def del_profile(self, profile):
|
||||||
"""Delete a profile"""
|
"""Delete a profile"""
|
||||||
if profile == self.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)
|
err('Config::del_profile: Deleting in-use profile %s.' % profile)
|
||||||
self.set_profile('default')
|
self.set_profile('default')
|
||||||
if self.base.profiles.has_key(profile):
|
if self.base.profiles.has_key(profile):
|
||||||
del(self.base.profiles[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):
|
def rename_profile(self, profile, newname):
|
||||||
"""Rename a profile"""
|
"""Rename a profile"""
|
||||||
@ -600,6 +610,10 @@ class ConfigBase(Borg):
|
|||||||
|
|
||||||
def get_item(self, key, profile='default', plugin=None):
|
def get_item(self, key, profile='default', plugin=None):
|
||||||
"""Look up a configuration item"""
|
"""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):
|
if self.global_config.has_key(key):
|
||||||
dbg('ConfigBase::get_item: %s found in globals: %s' %
|
dbg('ConfigBase::get_item: %s found in globals: %s' %
|
||||||
(key, self.global_config[key]))
|
(key, self.global_config[key]))
|
||||||
|
@ -66,6 +66,8 @@ command to execute inside the terminal, and its arguments')
|
|||||||
parser.add_option('-r', '--role', dest='role', help='Set a custom \
|
parser.add_option('-r', '--role', dest='role', help='Set a custom \
|
||||||
WM_WINDOW_ROLE property on the window')
|
WM_WINDOW_ROLE property on the window')
|
||||||
parser.add_option('-l', '--layout', dest='layout', help='Select a layout')
|
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',
|
parser.add_option('-d', '--debug', action='count', dest='debug',
|
||||||
help='Enable debugging information (twice for debug server)')
|
help='Enable debugging information (twice for debug server)')
|
||||||
parser.add_option('--debug-classes', action='store', dest='debug_classes',
|
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',
|
parser.add_option('--debug-methods', action='store', dest='debug_methods',
|
||||||
help='Comma separated list of methods to limit debugging to')
|
help='Comma separated list of methods to limit debugging to')
|
||||||
for item in ['--sm-client-id', '--sm-config-prefix', '--screen', '-n',
|
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',
|
parser.add_option(item, dest='dummy', action='store',
|
||||||
help=SUPPRESS_HELP)
|
help=SUPPRESS_HELP)
|
||||||
|
|
||||||
@ -113,6 +115,9 @@ WM_WINDOW_ROLE property on the window')
|
|||||||
if options.layout is None:
|
if options.layout is None:
|
||||||
options.layout = 'default'
|
options.layout = 'default'
|
||||||
|
|
||||||
|
if options.profile and options.profile not in configobj.list_profiles():
|
||||||
|
options.profile = None
|
||||||
|
|
||||||
configobj.options_set(options)
|
configobj.options_set(options)
|
||||||
|
|
||||||
if util.DEBUG == True:
|
if util.DEBUG == True:
|
||||||
|
@ -105,6 +105,7 @@ class Terminal(gtk.VBox):
|
|||||||
self.terminator = Terminator()
|
self.terminator = Terminator()
|
||||||
self.terminator.register_terminal(self)
|
self.terminator.register_terminal(self)
|
||||||
|
|
||||||
|
# FIXME: Surely these should happen in Terminator::register_terminal()?
|
||||||
self.connect('enumerate', self.terminator.do_enumerate)
|
self.connect('enumerate', self.terminator.do_enumerate)
|
||||||
self.connect('focus-in', self.terminator.focus_changed)
|
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'] != '':
|
if self.config['http_proxy'] and self.config['http_proxy'] != '':
|
||||||
os.putenv('http_proxy', 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"""
|
"""Set our profile"""
|
||||||
if profile != self.config.get_profile():
|
if profile != self.config.get_profile():
|
||||||
self.config.set_profile(profile)
|
self.config.set_profile(profile, force)
|
||||||
self.reconfigure()
|
self.reconfigure()
|
||||||
|
|
||||||
def get_profile(self):
|
def get_profile(self):
|
||||||
|
@ -19,11 +19,13 @@ class TerminalPopupMenu(object):
|
|||||||
"""Class implementing the Terminal context menu"""
|
"""Class implementing the Terminal context menu"""
|
||||||
terminal = None
|
terminal = None
|
||||||
terminator = None
|
terminator = None
|
||||||
|
config = None
|
||||||
|
|
||||||
def __init__(self, terminal):
|
def __init__(self, terminal):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
self.terminal = terminal
|
self.terminal = terminal
|
||||||
self.terminator = Terminator()
|
self.terminator = Terminator()
|
||||||
|
self.config = Config()
|
||||||
|
|
||||||
def show(self, widget, event=None):
|
def show(self, widget, event=None):
|
||||||
"""Display the context menu"""
|
"""Display the context menu"""
|
||||||
@ -34,6 +36,8 @@ class TerminalPopupMenu(object):
|
|||||||
button = None
|
button = None
|
||||||
time = None
|
time = None
|
||||||
|
|
||||||
|
self.config.set_profile(terminal.get_profile())
|
||||||
|
|
||||||
if event:
|
if event:
|
||||||
url = terminal.check_for_url(event)
|
url = terminal.check_for_url(event)
|
||||||
button = event.button
|
button = event.button
|
||||||
@ -135,6 +139,14 @@ class TerminalPopupMenu(object):
|
|||||||
|
|
||||||
menu.append(gtk.MenuItem())
|
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 = gtk.CheckMenuItem(_('Show _scrollbar'))
|
||||||
item.set_active(terminal.scrollbar.get_property('visible'))
|
item.set_active(terminal.scrollbar.get_property('visible'))
|
||||||
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
|
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
|
||||||
@ -144,8 +156,7 @@ class TerminalPopupMenu(object):
|
|||||||
item.connect('activate', lambda x: PrefsEditor(self.terminal))
|
item.connect('activate', lambda x: PrefsEditor(self.terminal))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
config = Config()
|
profilelist = self.config.list_profiles()
|
||||||
profilelist = config.list_profiles()
|
|
||||||
|
|
||||||
if len(profilelist) > 1:
|
if len(profilelist) > 1:
|
||||||
item = gtk.MenuItem(_('Profiles'))
|
item = gtk.MenuItem(_('Profiles'))
|
||||||
@ -161,7 +172,7 @@ class TerminalPopupMenu(object):
|
|||||||
item = gtk.RadioMenuItem(group, profile.capitalize())
|
item = gtk.RadioMenuItem(group, profile.capitalize())
|
||||||
if profile == current:
|
if profile == current:
|
||||||
item.set_active(True)
|
item.set_active(True)
|
||||||
item.connect('activate', terminal.set_profile, profile)
|
item.connect('activate', terminal.force_set_profile, profile)
|
||||||
submenu.append(item)
|
submenu.append(item)
|
||||||
|
|
||||||
self.add_encoding_items(menu)
|
self.add_encoding_items(menu)
|
||||||
|
@ -150,21 +150,30 @@ class Titlebar(gtk.EventBox):
|
|||||||
color = term.get_style().bg[gtk.STATE_NORMAL]
|
color = term.get_style().bg[gtk.STATE_NORMAL]
|
||||||
else:
|
else:
|
||||||
color = gtk.gdk.color_parse(title_bg)
|
color = gtk.gdk.color_parse(title_bg)
|
||||||
self.set_size_request(-1, 2)
|
self.update_visibility()
|
||||||
self.label.hide()
|
|
||||||
else:
|
|
||||||
self.set_size_request(-1, -1)
|
|
||||||
self.label.show()
|
|
||||||
self.ebox.modify_bg(gtk.STATE_NORMAL,
|
self.ebox.modify_bg(gtk.STATE_NORMAL,
|
||||||
gtk.gdk.color_parse(group_bg))
|
gtk.gdk.color_parse(group_bg))
|
||||||
self.set_from_icon_name(icon, gtk.ICON_SIZE_MENU)
|
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):
|
def get_desired_visibility(self):
|
||||||
"""Returns True if the titlebar is supposed to be visible. False if
|
"""Returns True if the titlebar is supposed to be visible. False if
|
||||||
not"""
|
not"""
|
||||||
if self.editing() == True:
|
if self.editing() == True or self.terminal.group:
|
||||||
|
dbg('implicit desired visibility')
|
||||||
return(True)
|
return(True)
|
||||||
else:
|
else:
|
||||||
|
dbg('configured visibility: %s' % self.config['show_titlebar'])
|
||||||
return(self.config['show_titlebar'])
|
return(self.config['show_titlebar'])
|
||||||
|
|
||||||
def set_from_icon_name(self, name, size = gtk.ICON_SIZE_MENU):
|
def set_from_icon_name(self, name, size = gtk.ICON_SIZE_MENU):
|
||||||
@ -195,10 +204,11 @@ class Titlebar(gtk.EventBox):
|
|||||||
self.grouplabel.show()
|
self.grouplabel.show()
|
||||||
else:
|
else:
|
||||||
self.grouplabel.hide()
|
self.grouplabel.hide()
|
||||||
|
self.update_visibility()
|
||||||
|
|
||||||
def on_clicked(self, widget, event):
|
def on_clicked(self, widget, event):
|
||||||
"""Handle a click on the label"""
|
"""Handle a click on the label"""
|
||||||
self.set_size_request(-1, -1)
|
self.show()
|
||||||
self.label.show()
|
self.label.show()
|
||||||
self.emit('clicked')
|
self.emit('clicked')
|
||||||
|
|
||||||
@ -214,6 +224,7 @@ class Titlebar(gtk.EventBox):
|
|||||||
"""Create a new group"""
|
"""Create a new group"""
|
||||||
self.groupentry.show()
|
self.groupentry.show()
|
||||||
self.groupentry.grab_focus()
|
self.groupentry.grab_focus()
|
||||||
|
self.update_visibility()
|
||||||
|
|
||||||
def groupentry_cancel(self, widget, event):
|
def groupentry_cancel(self, widget, event):
|
||||||
"""Hide the group name entry"""
|
"""Hide the group name entry"""
|
||||||
|
Loading…
Reference in New Issue
Block a user