Merge branch from David Caro that fixes window creation via DBus to notice command line options. Closes. LP#623883

This commit is contained in:
Chris Jones 2012-10-18 16:03:58 -07:00
commit 11887770e1
4 changed files with 43 additions and 24 deletions

View File

@ -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')

View File

@ -59,12 +59,16 @@ 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):
@ -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):

View File

@ -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',
@ -82,7 +85,7 @@ icon for the window (by file or name)'))
parser.add_option('--debug-methods', action='store', dest='debug_methods',
help=_('Comma separated list of methods to limit debugging to'))
for item in ['--sm-client-id', '--sm-config-prefix', '--screen', '-n',
'--no-gconf' ]:
'--no-gconf' ]:
parser.add_option(item, dest='dummy', action='store',
help=SUPPRESS_HELP)

View File

@ -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)