Session support now tests ok with xsm. Note change of default #! line, and addition of dummy arguments to OptionParser. If we move gnome init earlier we can avoid the latter.
This commit is contained in:
parent
0f5c6b361b
commit
035b15b6d9
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/env python
|
||||||
# Terminator - multiple gnome terminals in one window
|
# Terminator - multiple gnome terminals in one window
|
||||||
# Copyright (C) 2006-2008 cmsj@tenshu.net
|
# Copyright (C) 2006-2008 cmsj@tenshu.net
|
||||||
#
|
#
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
# import standard python libs
|
# import standard python libs
|
||||||
import os, sys
|
import os, sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser, SUPPRESS_HELP
|
||||||
|
|
||||||
from terminatorlib.version import APP_NAME, APP_VERSION
|
from terminatorlib.version import APP_NAME, APP_VERSION
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ if __name__ == '__main__':
|
||||||
help="Execute the argument to this option inside the terminal")
|
help="Execute the argument to this option 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="Execute the remainder of the command line inside the terminal")
|
callback=execute_cb, help="Execute the remainder of the command line inside the terminal")
|
||||||
|
for opt in ['--sm-client-id', '--sm-config-prefix', '--screen']:
|
||||||
|
parser.add_option (opt, dest="dummy", action="store", help=SUPPRESS_HELP)
|
||||||
|
|
||||||
(options, args) = parser.parse_args ()
|
(options, args) = parser.parse_args ()
|
||||||
if len (args) != 0:
|
if len (args) != 0:
|
||||||
|
|
|
@ -197,6 +197,7 @@ class Terminator:
|
||||||
self.window.set_title (APP_NAME.capitalize())
|
self.window.set_title (APP_NAME.capitalize())
|
||||||
|
|
||||||
if self._geometry is not None:
|
if self._geometry is not None:
|
||||||
|
dbg("Geometry=%s" % self._geometry)
|
||||||
if not self.window.parse_geometry(self._geometry):
|
if not self.window.parse_geometry(self._geometry):
|
||||||
err(_("Invalid geometry string %s") % repr(self._geometry))
|
err(_("Invalid geometry string %s") % repr(self._geometry))
|
||||||
|
|
||||||
|
@ -241,13 +242,14 @@ class Terminator:
|
||||||
term.spawn_child ()
|
term.spawn_child ()
|
||||||
self.save_yourself ()
|
self.save_yourself ()
|
||||||
|
|
||||||
def die(self):
|
def die(self, *args):
|
||||||
gtk.main_quit ()
|
gtk.main_quit ()
|
||||||
|
|
||||||
def save_yourself (self):
|
def save_yourself (self, *args):
|
||||||
""" Save as much of our state as possible for the X session manager """
|
""" Save as much of our state as possible for the X session manager """
|
||||||
dbg("Saving session for xsm")
|
dbg("Saving session for xsm")
|
||||||
args = []
|
args = [sys.argv[0],
|
||||||
|
("--geometry=%dx%d" % self.window.get_size()) + ("+%d+%d" % self.window.get_position())]
|
||||||
drop_next_arg = False
|
drop_next_arg = False
|
||||||
geompatt = re.compile(r'^--geometry(=.+)?')
|
geompatt = re.compile(r'^--geometry(=.+)?')
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
|
@ -259,22 +261,25 @@ class Terminator:
|
||||||
args.append(arg)
|
args.append(arg)
|
||||||
drop_next_arg = False
|
drop_next_arg = False
|
||||||
|
|
||||||
cmd = [sys.executable, sys.argv[0]]
|
# We can't set an interpreter because Gnome unconditionally spams it with
|
||||||
# pygtk docs suggest the session manager protocol handles this for us.
|
# --sm-foo-bar arguments before our own argument list. *mutter*
|
||||||
cmd.append(("--geometry=%dx%d" % self.window.get_size()) + ("+%d+%d" % self.window.get_position()))
|
# So, hopefully your #! line is correct. If not, we could write out
|
||||||
cmd += args
|
# a shell script with the interpreter name etc.
|
||||||
dbg("Session restart command: %s in %s" % (repr(cmd), self.start_cwd))
|
|
||||||
|
|
||||||
c = self.gnome_client
|
c = self.gnome_client
|
||||||
|
c.set_program(sys.argv[0])
|
||||||
|
dbg("Session restart command: %s with args %s in %s" % (sys.argv[0], repr(args), self.start_cwd))
|
||||||
|
|
||||||
c.set_restart_style(gnome.ui.RESTART_IF_RUNNING)
|
c.set_restart_style(gnome.ui.RESTART_IF_RUNNING)
|
||||||
c.set_current_directory(self.start_cwd)
|
c.set_current_directory(self.start_cwd)
|
||||||
try:
|
try:
|
||||||
c.set_restart_command(cmd)
|
c.set_restart_command(args)
|
||||||
except TypeError:
|
c.set_clone_command(args)
|
||||||
|
except (TypeError,AttributeError):
|
||||||
# Apparantly needed for some Fedora systems
|
# Apparantly needed for some Fedora systems
|
||||||
# see http://trac.nicfit.net/mesk/ticket/137
|
# see http://trac.nicfit.net/mesk/ticket/137
|
||||||
#
|
dbg("Gnome bindings have weird set_clone/restart_command")
|
||||||
c.set_restart_command(len(cmd), cmd)
|
c.set_restart_command(len(args), args)
|
||||||
|
c.set_clone_command(len(args), args)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def maximize (self):
|
def maximize (self):
|
||||||
|
|
Loading…
Reference in New Issue