2006-11-10 05:18:31 +00:00
|
|
|
#!/usr/bin/python
|
2007-07-28 01:33:48 +00:00
|
|
|
# Terminator - multiple gnome terminals in one window
|
2008-02-08 10:20:48 +00:00
|
|
|
# Copyright (C) 2006-2008 cmsj@tenshu.net
|
2007-07-28 01:33:48 +00:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, version 2 only.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
2008-02-12 22:06:19 +00:00
|
|
|
"""Terminator by Chris Jones <cmsj@tenshu.net>"""
|
2007-12-27 17:44:38 +00:00
|
|
|
|
2008-01-03 08:10:39 +00:00
|
|
|
# import standard python libs
|
2008-07-16 23:43:55 +00:00
|
|
|
import os, sys
|
2008-02-12 13:49:36 +00:00
|
|
|
from optparse import OptionParser
|
2008-01-03 08:10:39 +00:00
|
|
|
|
2008-07-16 23:43:55 +00:00
|
|
|
from terminatorlib.version import APP_NAME, APP_VERSION
|
2008-06-18 13:02:10 +00:00
|
|
|
|
2008-04-09 07:11:51 +00:00
|
|
|
try:
|
|
|
|
import gettext
|
|
|
|
gettext.install (APP_NAME)
|
2008-07-16 23:43:55 +00:00
|
|
|
except ImportError:
|
2008-06-18 13:02:10 +00:00
|
|
|
import __builtin__
|
2008-07-16 23:54:21 +00:00
|
|
|
def dummytrans (text):
|
|
|
|
"""A _ function for systems without gettext. Effectively a NOOP"""
|
2008-04-09 07:11:51 +00:00
|
|
|
return text
|
2008-07-16 23:54:21 +00:00
|
|
|
__builtin__.__dict__['_'] = dummytrans
|
2008-01-03 08:10:39 +00:00
|
|
|
|
2008-06-28 20:20:49 +00:00
|
|
|
from terminatorlib.config import dbg, err, debug
|
|
|
|
import terminatorlib.config
|
2008-05-22 14:37:59 +00:00
|
|
|
|
2008-01-03 08:10:39 +00:00
|
|
|
try:
|
2008-07-02 09:16:52 +00:00
|
|
|
import pygtk
|
|
|
|
pygtk.require ("2.0")
|
|
|
|
|
2008-02-26 00:25:01 +00:00
|
|
|
import gobject, gtk, pango
|
2008-07-16 23:54:21 +00:00
|
|
|
except ImportError:
|
2008-06-18 13:02:10 +00:00
|
|
|
err (_("You need to install the python bindings for " \
|
|
|
|
"gobject, gtk and pango to run Terminator."))
|
|
|
|
sys.exit(1)
|
2008-06-09 13:15:30 +00:00
|
|
|
|
2008-06-26 23:24:52 +00:00
|
|
|
from terminatorlib.terminator import Terminator
|
2008-06-17 10:15:28 +00:00
|
|
|
|
2007-07-29 02:06:52 +00:00
|
|
|
if __name__ == '__main__':
|
2008-02-25 09:50:06 +00:00
|
|
|
def execute_cb (option, opt, value, parser):
|
2008-07-16 23:54:21 +00:00
|
|
|
"""Callback for use in parsing Terminator command line options"""
|
2008-02-25 09:50:06 +00:00
|
|
|
assert value is None
|
|
|
|
value = []
|
|
|
|
while parser.rargs:
|
|
|
|
arg = parser.rargs[0]
|
|
|
|
value.append (arg)
|
|
|
|
del (parser.rargs[0])
|
|
|
|
setattr(parser.values, option.dest, value)
|
|
|
|
|
2008-06-15 10:15:45 +00:00
|
|
|
def profile_cb (option, opt, value, parser):
|
2008-07-16 23:54:21 +00:00
|
|
|
"""Callback for handling the profile name"""
|
2008-06-15 10:15:45 +00:00
|
|
|
assert value is None
|
|
|
|
value = ''
|
|
|
|
while parser.rargs:
|
|
|
|
arg = parser.rargs[0]
|
|
|
|
if arg[0] != '-':
|
|
|
|
if len (value) > 0:
|
2008-07-16 23:43:55 +00:00
|
|
|
value = '%s %s' % (value, arg)
|
2008-06-15 10:15:45 +00:00
|
|
|
else:
|
2008-07-16 23:43:55 +00:00
|
|
|
value = '%s' % arg
|
2008-06-15 10:15:45 +00:00
|
|
|
del (parser.rargs[0])
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
setattr (parser.values, option.dest, value)
|
|
|
|
|
2008-02-12 13:49:36 +00:00
|
|
|
usage = "usage: %prog [options]"
|
|
|
|
parser = OptionParser (usage)
|
2008-07-16 23:43:55 +00:00
|
|
|
parser.add_option ("-v", "--version", action="store_true", dest="version",
|
|
|
|
help="Display program version")
|
|
|
|
parser.add_option ("-d", "--debug", action="store_true", dest="debug",
|
|
|
|
help="Enable debugging information")
|
|
|
|
parser.add_option ("-m", "--maximise", action="store_true", dest="maximise",
|
|
|
|
help="Open the %s window maximised" % APP_NAME.capitalize())
|
|
|
|
parser.add_option ("-f", "--fullscreen", action="store_true", dest="fullscreen",
|
|
|
|
help="Set the window into fullscreen mode")
|
|
|
|
parser.add_option ("-b", "--borderless", action="store_true", dest="borderless",
|
|
|
|
help="Turn off the window's borders")
|
|
|
|
parser.add_option ("-n", "--no-gconf", dest="no_gconf", action="store_true",
|
|
|
|
help="ignore gnome-terminal gconf settings")
|
|
|
|
parser.add_option ("-p", "--profile", dest="profile", action="callback",
|
|
|
|
callback=profile_cb, help="Specify a GNOME Terminal profile to emulate")
|
|
|
|
parser.add_option ("-e", "--command", dest="command",
|
|
|
|
help="Execute the argument to this option inside the terminal")
|
|
|
|
parser.add_option ("-x", "--execute", dest="execute", action="callback",
|
|
|
|
callback=execute_cb, help="Execute the remainder of the command line inside the terminal")
|
2008-02-12 13:49:36 +00:00
|
|
|
|
|
|
|
(options, args) = parser.parse_args ()
|
|
|
|
if len (args) != 0:
|
|
|
|
parser.error("Expecting zero additional arguments, found: %d"%len (args))
|
2008-07-16 23:43:55 +00:00
|
|
|
|
2008-07-08 18:38:51 +00:00
|
|
|
if options.no_gconf and options.profile:
|
2008-07-16 23:43:55 +00:00
|
|
|
parser.error("using --no-gconf and defining a profile at the same time does not make sense")
|
2008-02-12 13:49:36 +00:00
|
|
|
|
2008-03-29 01:40:49 +00:00
|
|
|
if options.version:
|
2008-07-16 23:43:55 +00:00
|
|
|
print "%s %s" % (APP_NAME, APP_VERSION)
|
2008-03-29 01:40:49 +00:00
|
|
|
sys.exit (0)
|
2008-07-16 23:43:55 +00:00
|
|
|
|
2008-06-28 20:20:49 +00:00
|
|
|
if options.debug:
|
|
|
|
terminatorlib.config.debug = True
|
2008-03-29 01:40:49 +00:00
|
|
|
|
2008-02-12 22:06:19 +00:00
|
|
|
command = []
|
|
|
|
if (options.command):
|
|
|
|
command.append (options.command)
|
|
|
|
if (options.execute):
|
|
|
|
command = options.execute
|
2008-07-16 23:43:55 +00:00
|
|
|
|
2008-05-29 12:25:46 +00:00
|
|
|
if gtk.gdk.display_get_default() == None:
|
2008-06-16 23:10:54 +00:00
|
|
|
err (_("You need to run terminator in an X environment. " \
|
|
|
|
"Make sure DISPLAY is properly set"))
|
2008-05-29 12:25:46 +00:00
|
|
|
sys.exit(1)
|
2008-06-13 00:28:29 +00:00
|
|
|
|
2008-06-17 00:58:41 +00:00
|
|
|
try:
|
|
|
|
open (os.path.expanduser ('~/.config/terminator/config'))
|
2008-07-16 23:43:55 +00:00
|
|
|
except IOError:
|
2008-06-17 00:58:41 +00:00
|
|
|
try:
|
|
|
|
open (os.path.expanduser ('~/.terminatorrc'))
|
|
|
|
error = gtk.MessageDialog (None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
|
|
|
|
('''You have a configuration file:
|
|
|
|
|
|
|
|
~/.terminatorrc.
|
|
|
|
|
|
|
|
Please be aware that this file needs to be moved to:
|
|
|
|
|
|
|
|
~/.config/terminator/config.
|
|
|
|
|
|
|
|
See the following bug report for more details:
|
|
|
|
|
|
|
|
https://bugs.launchpad.net/bugs/238070'''))
|
|
|
|
error.run ()
|
|
|
|
error.destroy ()
|
2008-07-16 23:43:55 +00:00
|
|
|
except IOError:
|
2008-06-17 00:58:41 +00:00
|
|
|
pass
|
|
|
|
|
2008-06-18 17:30:47 +00:00
|
|
|
dbg ('profile_cb: settled on profile: "%s"'%options.profile)
|
2008-07-16 23:43:55 +00:00
|
|
|
term = Terminator (options.profile, command, options.fullscreen, options.maximise,
|
|
|
|
options.borderless, options.no_gconf)
|
2008-01-05 01:05:41 +00:00
|
|
|
|
2006-11-10 05:18:31 +00:00
|
|
|
gtk.main ()
|
|
|
|
|