528
by Thomas Hurst
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. |
1 |
#!/usr/bin/env python
|
34
by Chris Jones
Add the tedious legal stuff |
2 |
# Terminator - multiple gnome terminals in one window
|
775.1.231
by Chris Jones
hey look it's 2010 already |
3 |
# Copyright (C) 2006-2010 cmsj@tenshu.net
|
34
by Chris Jones
Add the tedious legal stuff |
4 |
#
|
5 |
# This program is free software; you can redistribute it and/or modify
|
|
6 |
# it under the terms of the GNU General Public License as published by
|
|
7 |
# the Free Software Foundation, version 2 only.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
536
by Chris Jones
fix some pylint stuff |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
17 |
# USA
|
|
34
by Chris Jones
Add the tedious legal stuff |
18 |
|
189
by Chris Jones
Add necessary changes for supporting -x as well as -e. Basically makes all commands stored as arrays |
19 |
"""Terminator by Chris Jones <cmsj@tenshu.net>"""
|
105.1.1
by Thomas Meire
Added support for a Terminator in fullscreen state. |
20 |
|
775.1.221
by Chris Jones
prepare for this main terminator script to work with epicrefactor |
21 |
import sys |
847
by Chris Jones
Fix up the startup cwd tracking so self-spawning works in non-absolute paths, and handle the key_new_window => key_new_terminator switch |
22 |
import os |
23 |
ORIGCWD = os.getcwd() |
|
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
24 |
|
25 |
# Check we have simple basics like Gtk+ and a valid $DISPLAY
|
|
118.1.1
by Thomas Meire
Display a translatable error when an import fails. When importing the VTE-bindings fails, the error is shown in a |
26 |
try: |
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
27 |
import pygtk |
28 |
pygtk.require ("2.0") |
|
775.1.235
by Chris Jones
There was a reason we imported these three, I just forgot it until now. It's a rough test that we have sufficient dependencies to run. |
29 |
# pylint: disable-msg=W0611
|
30 |
import gtk, pango, gobject |
|
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
31 |
|
32 |
if gtk.gdk.display_get_default() == None: |
|
33 |
print('You need to run terminator in an X environment. ' \ |
|
34 |
'Make sure $DISPLAY is properly set') |
|
35 |
sys.exit(1) |
|
36 |
||
452
by Chris Jones
Apply some fixups from pylint |
37 |
except ImportError: |
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
38 |
print('You need to install the python bindings for ' \ |
39 |
'gobject, gtk and pango to run Terminator.') |
|
40 |
sys.exit(1) |
|
320
by Emmanuel Bretelle
Adding XDG support closes LP#238070 |
41 |
|
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
42 |
import terminatorlib.optionparse |
775.1.280
by Chris Jones
Clear up pyflakes errata and switch newterminator to terminator |
43 |
from terminatorlib.terminator import Terminator |
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
44 |
from terminatorlib.factory import Factory |
45 |
from terminatorlib.version import APP_NAME, APP_VERSION |
|
855
by Chris Jones
First run at layout loading, creating, enumerating and saving. It sucks and works poorly at the moment, but here it is |
46 |
from terminatorlib.util import dbg, err |
349
by Chris Jones
Make sure we retain focus when zooming/unzooming |
47 |
|
1
by Chris Jones
Start work on a very simple port of multi-gnome-terminal to gtk2 and python. |
48 |
if __name__ == '__main__': |
1246
by Chris Jones
Add dbus mechanism to obtain a list of terminals |
49 |
dbus_service = None |
50 |
||
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
51 |
dbg ("%s starting up, version %s" % (APP_NAME, APP_VERSION)) |
52 |
||
53 |
OPTIONS = terminatorlib.optionparse.parse_options() |
|
54 |
||
1078.2.1
by Chris Jones
Land a modified and extended patch from Andrea Corbellini that adds a dbus server and a new default behaviour to use the dbus server to make terminator processes singletons |
55 |
# Attempt to import our dbus server. If one exists already we will just
|
56 |
# connect to that and ask for a new window. If not, we will create one and
|
|
57 |
# continue. Failure to import dbus, or the global config option "dbus"
|
|
58 |
# being False will cause us to continue without the dbus server and open a
|
|
59 |
# window.
|
|
60 |
try: |
|
1078.2.3
by Chris Jones
Allow disabling of dbus from the command line, and make use of that when spawning a new terminator process |
61 |
if OPTIONS.nodbus: |
62 |
dbg('dbus disabled by command line') |
|
63 |
raise ImportError |
|
1078.2.1
by Chris Jones
Land a modified and extended patch from Andrea Corbellini that adds a dbus server and a new default behaviour to use the dbus server to make terminator processes singletons |
64 |
from terminatorlib import ipc |
65 |
try: |
|
1246
by Chris Jones
Add dbus mechanism to obtain a list of terminals |
66 |
dbus_service = ipc.DBusService() |
1078.2.1
by Chris Jones
Land a modified and extended patch from Andrea Corbellini that adds a dbus server and a new default behaviour to use the dbus server to make terminator processes singletons |
67 |
except ipc.DBusException: |
1078.2.2
by Chris Jones
Add debugging and hash the X11 display (suggestion from Andrea) |
68 |
dbg('Unable to become master process, requesting a new window') |
1155
by Chris Jones
When creating a new window via dbus, pass on the layout request if there is one |
69 |
ipc.new_window(OPTIONS.layout) |
1078.2.1
by Chris Jones
Land a modified and extended patch from Andrea Corbellini that adds a dbus server and a new default behaviour to use the dbus server to make terminator processes singletons |
70 |
sys.exit() |
71 |
except ImportError: |
|
1078.2.2
by Chris Jones
Add debugging and hash the X11 display (suggestion from Andrea) |
72 |
dbg('dbus not imported') |
1078.2.1
by Chris Jones
Land a modified and extended patch from Andrea Corbellini that adds a dbus server and a new default behaviour to use the dbus server to make terminator processes singletons |
73 |
pass
|
74 |
||
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
75 |
MAKER = Factory() |
76 |
TERMINATOR = Terminator() |
|
1009
by Chris Jones
Apply some policy to the original cwd we inherit - if it's / then our parent process is probably some kind of app launcher, so we'll try to be helpful and make our cwd be ~ |
77 |
TERMINATOR.set_origcwd(ORIGCWD) |
1246
by Chris Jones
Add dbus mechanism to obtain a list of terminals |
78 |
TERMINATOR.set_dbus_data(dbus_service) |
775.1.282
by Chris Jones
Fix up handle_size to work properly |
79 |
TERMINATOR.reconfigure() |
862
by Chris Jones
Undo my madness |
80 |
try: |
1035
by Chris Jones
Add some more debugging to layout creation |
81 |
dbg('Creating a terminal with layout: %s' % OPTIONS.layout) |
862
by Chris Jones
Undo my madness |
82 |
TERMINATOR.create_layout(OPTIONS.layout) |
83 |
except (KeyError,ValueError), ex: |
|
84 |
err('layout creation failed, creating a window ("%s")' % ex) |
|
85 |
TERMINATOR.new_window() |
|
966
by Chris Jones
finally: is not py2.4 compatible |
86 |
TERMINATOR.layout_done() |
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
87 |
|
775.1.291
by Chris Jones
-d now automatically infers the Class::method in dbg(), and -d additionally adds a trailing (filename:line) item. debugserver is now moved to -ddd |
88 |
if OPTIONS.debug > 2: |
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
89 |
import terminatorlib.debugserver as debugserver |
90 |
# pylint: disable-msg=W0611
|
|
91 |
import threading |
|
92 |
||
93 |
gtk.gdk.threads_init() |
|
94 |
(DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals()) |
|
931
by Chris Jones
Attach the debug server to the context menu |
95 |
TERMINATOR.debug_address = DEBUGSVR.server_address |
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
96 |
|
348
by Chris Jones
Add a warning about terminatorrc moving |
97 |
try: |
775.1.230
by Chris Jones
Remove option parsing code now that is in its own module, and generally refactor/reformat |
98 |
gtk.main() |
99 |
except KeyboardInterrupt: |
|
100 |
pass
|
|
457.1.1
by Chris James
Quake mode |
101 |