Store the command line options in Config rather than overwriting parts of it, and passing them around

This commit is contained in:
Chris Jones 2010-01-11 20:56:30 +00:00
parent 96ad941267
commit adfaf600fa
4 changed files with 44 additions and 27 deletions

View File

@ -50,8 +50,7 @@ if __name__ == '__main__':
MAKER = Factory() MAKER = Factory()
TERMINATOR = Terminator() TERMINATOR = Terminator()
WINDOW = MAKER.make('Window', geometry=OPTIONS.geometry, WINDOW = MAKER.make('Window')
forcedtitle=OPTIONS.forcedtitle, role=OPTIONS.role)
TERMINAL = MAKER.make('Terminal') TERMINAL = MAKER.make('Terminal')
WINDOW.add(TERMINAL) WINDOW.add(TERMINAL)

View File

@ -237,6 +237,14 @@ class Config(object):
"""Cause ConfigBase to save our config to file""" """Cause ConfigBase to save our config to file"""
return(self.base.save()) return(self.base.save())
def options_set(self, options):
"""Set the command line options"""
self.base.command_line_options = options
def options_get(self):
"""Get the command line options"""
return(self.base.command_line_options)
def plugin_get(self, pluginname, key): def plugin_get(self, pluginname, key):
"""Get a plugin config value""" """Get a plugin config value"""
return(self.base.get_item(key, plugin=pluginname)) return(self.base.get_item(key, plugin=pluginname))
@ -262,6 +270,7 @@ class ConfigBase(Borg):
keybindings = None keybindings = None
plugins = None plugins = None
layouts = None layouts = None
command_line_options = None
def __init__(self): def __init__(self):
"""Class initialiser""" """Class initialiser"""

View File

@ -91,18 +91,7 @@ WM_WINDOW_ROLE property on the window')
options.working_directory) options.working_directory)
sys.exit(1) sys.exit(1)
if options.maximise: configobj.options_set(options)
configobj['window_state'] = 'maximise'
if options.fullscreen:
configobj['window_state'] = 'fullscreen'
if options.borderless:
configobj['borderless'] = True
if options.hidden:
configobj['window_state'] = 'hidden'
# FIXME: Map all the other bits of options to configobj # FIXME: Map all the other bits of options to configobj
if util.DEBUG == True: if util.DEBUG == True:

View File

@ -35,7 +35,7 @@ class Window(Container, gtk.Window):
zoom_data = None zoom_data = None
term_zoomed = gobject.property(type=bool, default=False) term_zoomed = gobject.property(type=bool, default=False)
def __init__(self, geometry=None, forcedtitle=None, role=None): def __init__(self):
"""Class initialiser""" """Class initialiser"""
self.terminator = Terminator() self.terminator = Terminator()
self.terminator.register_window(self) self.terminator.register_window(self)
@ -53,15 +53,19 @@ class Window(Container, gtk.Window):
self.title = WindowTitle(self) self.title = WindowTitle(self)
self.title.update() self.title.update()
if forcedtitle is not None:
self.title.force_title(forcedtitle)
if role is not None: options = self.config.options_get()
self.set_role(role) if options:
if options.forcedtitle is not None:
self.title.force_title(options.forcedtitle)
if geometry is not None: if options.role is not None:
if not self.parse_geometry(geometry): self.set_role(options.role)
err('Window::__init__: Unable to parse geometry: %s' % geometry)
if options.geometry is not None:
if not self.parse_geometry(options.geometry):
err('Window::__init__: Unable to parse geometry: %s' %
options.geometry)
def register_callbacks(self): def register_callbacks(self):
"""Connect the GTK+ signals we care about""" """Connect the GTK+ signals we care about"""
@ -87,14 +91,30 @@ class Window(Container, gtk.Window):
def apply_config(self): def apply_config(self):
"""Apply various configuration options""" """Apply various configuration options"""
self.set_fullscreen(self.config['window_state'] == 'fullscreen') options = self.config.options_get()
self.set_maximised(self.config['window_state'] == 'maximise') maximise = self.config['window_state'] == 'maximise'
self.set_borderless(self.config['borderless']) fullscreen = self.config['window_state'] == 'fullscreen'
hidden = self.config['window_state'] == 'hidden'
borderless = self.config['borderless']
if options:
if options.maximise:
maximise = True
if options.fullscreen:
fullscreen = True
if options.hidden:
hidden = True
if options.borderless:
borderless = True
self.set_fullscreen(fullscreen)
self.set_maximised(maximise)
self.set_borderless(borderless)
self.set_real_transparency() self.set_real_transparency()
if self.hidebound: if self.hidebound:
self.set_hidden(self.config['window_state'] == 'hidden') self.set_hidden(hidden)
else: else:
self.set_iconified(self.config['window_state'] == 'hidden') self.set_iconified(hidden)
def apply_icon(self): def apply_icon(self):
"""Set the window icon""" """Set the window icon"""