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')
|
dbg('dbus disabled by command line')
|
||||||
raise ImportError
|
raise ImportError
|
||||||
from terminatorlib import ipc
|
from terminatorlib import ipc
|
||||||
|
import dbus
|
||||||
try:
|
try:
|
||||||
dbus_service = ipc.DBusService()
|
dbus_service = ipc.DBusService()
|
||||||
except ipc.DBusException:
|
except ipc.DBusException:
|
||||||
dbg('Unable to become master process, requesting a new window')
|
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()
|
sys.exit()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
dbg('dbus not imported')
|
dbg('dbus not imported')
|
||||||
|
|
|
@ -59,12 +59,16 @@ class DBusService(Borg, dbus.service.Object):
|
||||||
if not self.terminator:
|
if not self.terminator:
|
||||||
self.terminator = Terminator()
|
self.terminator = Terminator()
|
||||||
|
|
||||||
@dbus.service.method(BUS_NAME)
|
@dbus.service.method(BUS_NAME, in_signature='a{ss}')
|
||||||
def new_window(self, layout='default'):
|
def new_window(self, options=dbus.Dictionary()):
|
||||||
"""Create a new Window"""
|
"""Create a new Window"""
|
||||||
dbg('dbus method called: new_window')
|
dbg('dbus method called: new_window with parameters %s'%(options))
|
||||||
self.terminator.create_layout(layout)
|
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()
|
self.terminator.layout_done()
|
||||||
|
|
||||||
|
|
||||||
@dbus.service.method(BUS_NAME)
|
@dbus.service.method(BUS_NAME)
|
||||||
def terminal_hsplit(self, uuid=None):
|
def terminal_hsplit(self, uuid=None):
|
||||||
|
@ -124,9 +128,9 @@ def with_proxy(func):
|
||||||
return _exec
|
return _exec
|
||||||
|
|
||||||
@with_proxy
|
@with_proxy
|
||||||
def new_window(session, layout='default'):
|
def new_window(session, options):
|
||||||
"""Call the dbus method to open a new window"""
|
"""Call the dbus method to open a new window"""
|
||||||
session.new_window(layout)
|
session.new_window(options)
|
||||||
|
|
||||||
@with_proxy
|
@with_proxy
|
||||||
def terminal_hsplit(session, uuid):
|
def terminal_hsplit(session, uuid):
|
||||||
|
|
|
@ -53,26 +53,29 @@ def parse_options():
|
||||||
dest='borderless', help=_('Disable window borders'))
|
dest='borderless', help=_('Disable window borders'))
|
||||||
parser.add_option('-H', '--hidden', action='store_true', dest='hidden',
|
parser.add_option('-H', '--hidden', action='store_true', dest='hidden',
|
||||||
help=_('Hide the window at startup'))
|
help=_('Hide the window at startup'))
|
||||||
parser.add_option('-T', '--title', dest='forcedtitle', help=_('Specify a \
|
parser.add_option('-T', '--title', dest='forcedtitle',
|
||||||
title for the window'))
|
help=_('Specify a title for the window'))
|
||||||
parser.add_option('--geometry', dest='geometry', type='string', help=_('Set \
|
parser.add_option('--geometry', dest='geometry', type='string',
|
||||||
the preferred size and position of the window (see X man page)'))
|
help=_('Set the preferred size and position of the window'
|
||||||
parser.add_option('-e', '--command', dest='command', help=_('Specify a \
|
'(see X man page)'))
|
||||||
command to execute inside the terminal'))
|
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',
|
parser.add_option('-x', '--execute', dest='execute', action='callback',
|
||||||
callback=execute_cb, help=_('Use the rest of the command line as a \
|
callback=execute_cb,
|
||||||
command to execute inside the terminal, and its arguments'))
|
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',
|
parser.add_option('--working-directory', metavar='DIR',
|
||||||
dest='working_directory', help=_('Set the working directory'))
|
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 \
|
parser.add_option('-c', '--classname', dest='classname', help=_('Set a \
|
||||||
custom name (WM_CLASS) property on the window'))
|
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 \
|
parser.add_option('-i', '--icon', dest='forcedicon', help=_('Set a custom \
|
||||||
icon for the window (by file or name)'))
|
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',
|
parser.add_option('-u', '--no-dbus', action='store_true', dest='nodbus',
|
||||||
help=_('Disable DBus'))
|
help=_('Disable DBus'))
|
||||||
parser.add_option('-d', '--debug', action='count', dest='debug',
|
parser.add_option('-d', '--debug', action='count', dest='debug',
|
||||||
|
@ -82,7 +85,7 @@ icon for the window (by file or name)'))
|
||||||
parser.add_option('--debug-methods', action='store', dest='debug_methods',
|
parser.add_option('--debug-methods', action='store', dest='debug_methods',
|
||||||
help=_('Comma separated list of methods to limit debugging to'))
|
help=_('Comma separated list of methods to limit debugging to'))
|
||||||
for item in ['--sm-client-id', '--sm-config-prefix', '--screen', '-n',
|
for item in ['--sm-client-id', '--sm-config-prefix', '--screen', '-n',
|
||||||
'--no-gconf' ]:
|
'--no-gconf' ]:
|
||||||
parser.add_option(item, dest='dummy', action='store',
|
parser.add_option(item, dest='dummy', action='store',
|
||||||
help=SUPPRESS_HELP)
|
help=SUPPRESS_HELP)
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,10 @@ class Window(Container, gtk.Window):
|
||||||
|
|
||||||
options = self.config.options_get()
|
options = self.config.options_get()
|
||||||
if options:
|
if options:
|
||||||
if options.forcedtitle is not None:
|
if options.forcedtitle:
|
||||||
self.title.force_title(options.forcedtitle)
|
self.title.force_title(options.forcedtitle)
|
||||||
|
|
||||||
if options.role is not None:
|
if options.role:
|
||||||
self.set_role(options.role)
|
self.set_role(options.role)
|
||||||
|
|
||||||
if options.classname is not None:
|
if options.classname is not None:
|
||||||
|
@ -83,7 +83,7 @@ class Window(Container, gtk.Window):
|
||||||
if options.forcedicon is not None:
|
if options.forcedicon is not None:
|
||||||
icon_to_apply = options.forcedicon
|
icon_to_apply = options.forcedicon
|
||||||
|
|
||||||
if options.geometry is not None:
|
if options.geometry:
|
||||||
if not self.parse_geometry(options.geometry):
|
if not self.parse_geometry(options.geometry):
|
||||||
err('Window::__init__: Unable to parse geometry: %s' %
|
err('Window::__init__: Unable to parse geometry: %s' %
|
||||||
options.geometry)
|
options.geometry)
|
||||||
|
|
Loading…
Reference in New Issue