Merge branch from David Caro that fixes window creation via DBus to notice command line options. Closes. LP#623883
This commit is contained in:
commit
11887770e1
14
terminator
14
terminator
|
@ -62,11 +62,23 @@ if __name__ == '__main__':
|
|||
dbg('dbus disabled by command line')
|
||||
raise ImportError
|
||||
from terminatorlib import ipc
|
||||
import dbus
|
||||
try:
|
||||
dbus_service = ipc.DBusService()
|
||||
except ipc.DBusException:
|
||||
dbg('Unable to become master process, requesting a new window')
|
||||
ipc.new_window(OPTIONS.layout)
|
||||
# get rid of the None and True types so dbus can handle them (empty
|
||||
# and 'True' strings are used instead), also arrays are joined
|
||||
# (the -x argument for example)
|
||||
optionslist = {}
|
||||
for opt, val in OPTIONS.__dict__.items():
|
||||
if type(val) == type([]):
|
||||
val = ' '.join(val)
|
||||
if val == True:
|
||||
val = 'True'
|
||||
optionslist[opt] = val and '%s'%val or ''
|
||||
optionslist = dbus.Dictionary(optionslist, signature='ss')
|
||||
ipc.new_window(optionslist)
|
||||
sys.exit()
|
||||
except ImportError:
|
||||
dbg('dbus not imported')
|
||||
|
|
|
@ -59,13 +59,17 @@ class DBusService(Borg, dbus.service.Object):
|
|||
if not self.terminator:
|
||||
self.terminator = Terminator()
|
||||
|
||||
@dbus.service.method(BUS_NAME)
|
||||
def new_window(self, layout='default'):
|
||||
@dbus.service.method(BUS_NAME, in_signature='a{ss}')
|
||||
def new_window(self, options=dbus.Dictionary()):
|
||||
"""Create a new Window"""
|
||||
dbg('dbus method called: new_window')
|
||||
self.terminator.create_layout(layout)
|
||||
dbg('dbus method called: new_window with parameters %s'%(options))
|
||||
oldopts = self.terminator.config.options_get()
|
||||
oldopts.__dict__ = options
|
||||
self.terminator.config.options_set(oldopts)
|
||||
self.terminator.create_layout(oldopts.layout)
|
||||
self.terminator.layout_done()
|
||||
|
||||
|
||||
@dbus.service.method(BUS_NAME)
|
||||
def terminal_hsplit(self, uuid=None):
|
||||
"""Split a terminal horizontally, by UUID"""
|
||||
|
@ -124,9 +128,9 @@ def with_proxy(func):
|
|||
return _exec
|
||||
|
||||
@with_proxy
|
||||
def new_window(session, layout='default'):
|
||||
def new_window(session, options):
|
||||
"""Call the dbus method to open a new window"""
|
||||
session.new_window(layout)
|
||||
session.new_window(options)
|
||||
|
||||
@with_proxy
|
||||
def terminal_hsplit(session, uuid):
|
||||
|
|
|
@ -53,26 +53,29 @@ def parse_options():
|
|||
dest='borderless', help=_('Disable window borders'))
|
||||
parser.add_option('-H', '--hidden', action='store_true', dest='hidden',
|
||||
help=_('Hide the window at startup'))
|
||||
parser.add_option('-T', '--title', dest='forcedtitle', help=_('Specify a \
|
||||
title for the window'))
|
||||
parser.add_option('--geometry', dest='geometry', type='string', help=_('Set \
|
||||
the preferred size and position of the window (see X man page)'))
|
||||
parser.add_option('-e', '--command', dest='command', help=_('Specify a \
|
||||
command to execute inside the terminal'))
|
||||
parser.add_option('-T', '--title', dest='forcedtitle',
|
||||
help=_('Specify a title for the window'))
|
||||
parser.add_option('--geometry', dest='geometry', type='string',
|
||||
help=_('Set the preferred size and position of the window'
|
||||
'(see X man page)'))
|
||||
parser.add_option('-e', '--command', dest='command',
|
||||
help=_('Specify a command to execute inside the terminal'))
|
||||
parser.add_option('-x', '--execute', dest='execute', action='callback',
|
||||
callback=execute_cb, help=_('Use the rest of the command line as a \
|
||||
command to execute inside the terminal, and its arguments'))
|
||||
callback=execute_cb,
|
||||
help=_('Use the rest of the command line as a command to execute'
|
||||
'nside the terminal, and its arguments'))
|
||||
parser.add_option('--working-directory', metavar='DIR',
|
||||
dest='working_directory', help=_('Set the working directory'))
|
||||
parser.add_option('-r', '--role', dest='role', help=_('Set a custom \
|
||||
WM_WINDOW_ROLE property on the window'))
|
||||
parser.add_option('-c', '--classname', dest='classname', help=_('Set a \
|
||||
custom name (WM_CLASS) 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('-i', '--icon', dest='forcedicon', help=_('Set a custom \
|
||||
icon for the window (by file or name)'))
|
||||
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('-u', '--no-dbus', action='store_true', dest='nodbus',
|
||||
help=_('Disable DBus'))
|
||||
parser.add_option('-d', '--debug', action='count', dest='debug',
|
||||
|
|
|
@ -71,10 +71,10 @@ class Window(Container, gtk.Window):
|
|||
|
||||
options = self.config.options_get()
|
||||
if options:
|
||||
if options.forcedtitle is not None:
|
||||
if options.forcedtitle:
|
||||
self.title.force_title(options.forcedtitle)
|
||||
|
||||
if options.role is not None:
|
||||
if options.role:
|
||||
self.set_role(options.role)
|
||||
|
||||
if options.classname is not None:
|
||||
|
@ -83,7 +83,7 @@ class Window(Container, gtk.Window):
|
|||
if options.forcedicon is not None:
|
||||
icon_to_apply = options.forcedicon
|
||||
|
||||
if options.geometry is not None:
|
||||
if options.geometry:
|
||||
if not self.parse_geometry(options.geometry):
|
||||
err('Window::__init__: Unable to parse geometry: %s' %
|
||||
options.geometry)
|
||||
|
|
Loading…
Reference in New Issue