From adfaf600faa2def91597cf078963d4bf594446d1 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 11 Jan 2010 20:56:30 +0000 Subject: [PATCH] Store the command line options in Config rather than overwriting parts of it, and passing them around --- terminator | 3 +-- terminatorlib/config.py | 9 +++++++ terminatorlib/optionparse.py | 13 +--------- terminatorlib/window.py | 46 ++++++++++++++++++++++++++---------- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/terminator b/terminator index 631d0c3e..ab5e694f 100755 --- a/terminator +++ b/terminator @@ -50,8 +50,7 @@ if __name__ == '__main__': MAKER = Factory() TERMINATOR = Terminator() - WINDOW = MAKER.make('Window', geometry=OPTIONS.geometry, - forcedtitle=OPTIONS.forcedtitle, role=OPTIONS.role) + WINDOW = MAKER.make('Window') TERMINAL = MAKER.make('Terminal') WINDOW.add(TERMINAL) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 9cd11261..14adcb85 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -237,6 +237,14 @@ class Config(object): """Cause ConfigBase to save our config to file""" 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): """Get a plugin config value""" return(self.base.get_item(key, plugin=pluginname)) @@ -262,6 +270,7 @@ class ConfigBase(Borg): keybindings = None plugins = None layouts = None + command_line_options = None def __init__(self): """Class initialiser""" diff --git a/terminatorlib/optionparse.py b/terminatorlib/optionparse.py index 513cb740..c49575ba 100755 --- a/terminatorlib/optionparse.py +++ b/terminatorlib/optionparse.py @@ -91,18 +91,7 @@ WM_WINDOW_ROLE property on the window') options.working_directory) sys.exit(1) - if options.maximise: - configobj['window_state'] = 'maximise' - - if options.fullscreen: - configobj['window_state'] = 'fullscreen' - - if options.borderless: - configobj['borderless'] = True - - if options.hidden: - configobj['window_state'] = 'hidden' - + configobj.options_set(options) # FIXME: Map all the other bits of options to configobj if util.DEBUG == True: diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 663303db..6b631b5c 100755 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -35,7 +35,7 @@ class Window(Container, gtk.Window): zoom_data = None term_zoomed = gobject.property(type=bool, default=False) - def __init__(self, geometry=None, forcedtitle=None, role=None): + def __init__(self): """Class initialiser""" self.terminator = Terminator() self.terminator.register_window(self) @@ -53,15 +53,19 @@ class Window(Container, gtk.Window): self.title = WindowTitle(self) self.title.update() - if forcedtitle is not None: - self.title.force_title(forcedtitle) - if role is not None: - self.set_role(role) + options = self.config.options_get() + if options: + if options.forcedtitle is not None: + self.title.force_title(options.forcedtitle) - if geometry is not None: - if not self.parse_geometry(geometry): - err('Window::__init__: Unable to parse geometry: %s' % geometry) + if options.role is not None: + self.set_role(options.role) + + 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): """Connect the GTK+ signals we care about""" @@ -87,14 +91,30 @@ class Window(Container, gtk.Window): def apply_config(self): """Apply various configuration options""" - self.set_fullscreen(self.config['window_state'] == 'fullscreen') - self.set_maximised(self.config['window_state'] == 'maximise') - self.set_borderless(self.config['borderless']) + options = self.config.options_get() + maximise = self.config['window_state'] == 'maximise' + 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() if self.hidebound: - self.set_hidden(self.config['window_state'] == 'hidden') + self.set_hidden(hidden) else: - self.set_iconified(self.config['window_state'] == 'hidden') + self.set_iconified(hidden) def apply_icon(self): """Set the window icon"""