2008-08-29 18:22:16 +00:00
|
|
|
#!/usr/bin/env python
|
2007-07-28 01:33:48 +00:00
|
|
|
# Terminator - multiple gnome terminals in one window
|
2010-01-04 23:56:28 +00:00
|
|
|
# Copyright (C) 2006-2010 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
|
2008-09-03 23:52:04 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
|
|
|
# USA
|
2007-07-28 01:33:48 +00:00
|
|
|
|
2008-02-12 22:06:19 +00:00
|
|
|
"""Terminator by Chris Jones <cmsj@tenshu.net>"""
|
2007-12-27 17:44:38 +00:00
|
|
|
|
2010-01-04 12:57:14 +00:00
|
|
|
import sys
|
2010-01-29 23:52:21 +00:00
|
|
|
import os
|
|
|
|
ORIGCWD = os.getcwd()
|
2008-05-22 14:37:59 +00:00
|
|
|
|
2010-01-04 23:52:57 +00:00
|
|
|
# Check we have simple basics like Gtk+ and a valid $DISPLAY
|
2008-01-03 08:10:39 +00:00
|
|
|
try:
|
2010-01-04 23:52:57 +00:00
|
|
|
import pygtk
|
|
|
|
pygtk.require ("2.0")
|
2010-01-05 09:24:44 +00:00
|
|
|
# pylint: disable-msg=W0611
|
|
|
|
import gtk, pango, gobject
|
2010-01-04 23:52:57 +00:00
|
|
|
|
|
|
|
if gtk.gdk.display_get_default() == None:
|
|
|
|
print('You need to run terminator in an X environment. ' \
|
|
|
|
'Make sure $DISPLAY is properly set')
|
|
|
|
sys.exit(1)
|
2008-07-02 09:16:52 +00:00
|
|
|
|
2008-07-16 23:54:21 +00:00
|
|
|
except ImportError:
|
2010-01-04 23:52:57 +00:00
|
|
|
print('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
|
|
|
|
2010-01-04 23:52:57 +00:00
|
|
|
import terminatorlib.optionparse
|
2010-01-11 20:11:35 +00:00
|
|
|
from terminatorlib.terminator import Terminator
|
2010-01-04 23:52:57 +00:00
|
|
|
from terminatorlib.factory import Factory
|
|
|
|
from terminatorlib.version import APP_NAME, APP_VERSION
|
2010-02-01 12:11:44 +00:00
|
|
|
from terminatorlib.util import dbg, err
|
2008-06-17 10:15:28 +00:00
|
|
|
|
2007-07-29 02:06:52 +00:00
|
|
|
if __name__ == '__main__':
|
2010-01-04 23:52:57 +00:00
|
|
|
dbg ("%s starting up, version %s" % (APP_NAME, APP_VERSION))
|
|
|
|
|
|
|
|
OPTIONS = terminatorlib.optionparse.parse_options()
|
2008-06-15 10:15:45 +00:00
|
|
|
|
2010-07-21 22:17:34 +00:00
|
|
|
# Attempt to import our dbus server. If one exists already we will just
|
|
|
|
# connect to that and ask for a new window. If not, we will create one and
|
|
|
|
# continue. Failure to import dbus, or the global config option "dbus"
|
|
|
|
# being False will cause us to continue without the dbus server and open a
|
|
|
|
# window.
|
|
|
|
try:
|
2010-07-22 12:59:06 +00:00
|
|
|
if OPTIONS.nodbus:
|
|
|
|
dbg('dbus disabled by command line')
|
|
|
|
raise ImportError
|
2010-07-21 22:17:34 +00:00
|
|
|
from terminatorlib import ipc
|
|
|
|
try:
|
|
|
|
ipc.DBusService()
|
|
|
|
except ipc.DBusException:
|
2010-07-22 08:24:47 +00:00
|
|
|
dbg('Unable to become master process, requesting a new window')
|
2010-11-29 20:46:49 +00:00
|
|
|
ipc.new_window(OPTIONS.layout)
|
2010-07-21 22:17:34 +00:00
|
|
|
sys.exit()
|
|
|
|
except ImportError:
|
2010-07-22 08:24:47 +00:00
|
|
|
dbg('dbus not imported')
|
2010-07-21 22:17:34 +00:00
|
|
|
pass
|
|
|
|
|
2010-01-04 23:52:57 +00:00
|
|
|
MAKER = Factory()
|
|
|
|
TERMINATOR = Terminator()
|
2010-04-18 08:49:32 +00:00
|
|
|
TERMINATOR.set_origcwd(ORIGCWD)
|
2010-01-11 23:46:18 +00:00
|
|
|
TERMINATOR.reconfigure()
|
2010-02-05 00:16:24 +00:00
|
|
|
try:
|
2010-06-15 14:19:05 +00:00
|
|
|
dbg('Creating a terminal with layout: %s' % OPTIONS.layout)
|
2010-02-05 00:16:24 +00:00
|
|
|
TERMINATOR.create_layout(OPTIONS.layout)
|
|
|
|
except (KeyError,ValueError), ex:
|
|
|
|
err('layout creation failed, creating a window ("%s")' % ex)
|
|
|
|
TERMINATOR.new_window()
|
2010-04-05 23:05:20 +00:00
|
|
|
TERMINATOR.layout_done()
|
2008-07-16 23:43:55 +00:00
|
|
|
|
2010-01-14 13:15:05 +00:00
|
|
|
if OPTIONS.debug > 2:
|
2010-01-04 23:52:57 +00:00
|
|
|
import terminatorlib.debugserver as debugserver
|
|
|
|
# pylint: disable-msg=W0611
|
|
|
|
import threading
|
2008-02-12 13:49:36 +00:00
|
|
|
|
2010-01-04 23:52:57 +00:00
|
|
|
gtk.gdk.threads_init()
|
|
|
|
(DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals())
|
2010-03-19 22:16:08 +00:00
|
|
|
TERMINATOR.debug_address = DEBUGSVR.server_address
|
2008-07-16 23:43:55 +00:00
|
|
|
|
2008-06-17 00:58:41 +00:00
|
|
|
try:
|
2010-01-04 23:52:57 +00:00
|
|
|
gtk.main()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
2006-11-10 05:18:31 +00:00
|
|
|
|