Store the command line options in Config rather than overwriting parts of it, and passing them around
This commit is contained in:
parent
96ad941267
commit
adfaf600fa
@ -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)
|
||||
|
@ -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"""
|
||||
|
@ -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:
|
||||
|
@ -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"""
|
||||
|
Loading…
Reference in New Issue
Block a user