diff --git a/terminatorlib/config.py b/terminatorlib/config.py index e53ff766..e2da23e2 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -225,7 +225,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): @@ -240,8 +240,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): diff --git a/terminatorlib/optionparse.py b/terminatorlib/optionparse.py index 09a67eab..3d783cef 100755 --- a/terminatorlib/optionparse.py +++ b/terminatorlib/optionparse.py @@ -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: diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 045249f4..3c5336c4 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -159,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): diff --git a/terminatorlib/terminal_popup_menu.py b/terminatorlib/terminal_popup_menu.py index bf340731..9eaddb78 100755 --- a/terminatorlib/terminal_popup_menu.py +++ b/terminatorlib/terminal_popup_menu.py @@ -172,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)