Merge dbus branch
This commit is contained in:
commit
db0acc7b28
|
@ -32,6 +32,10 @@ Below are the individual sections that can exist in the config file:
|
||||||
.SH "global_config"
|
.SH "global_config"
|
||||||
These are the options Terminator currently supports in the global_config section:
|
These are the options Terminator currently supports in the global_config section:
|
||||||
.TP
|
.TP
|
||||||
|
.B dbus
|
||||||
|
Control whether or not Terminator will load its DBus server. When this server is loaded, running Terminator multiple times will cause the first Terminator process to open additional windows. If this configuration item is set to False, or the python dbus module is unavailable, running Terminator multiple times will run a separate Terminator process for each invocation.
|
||||||
|
Default value: \fBTrue\fR
|
||||||
|
.TP
|
||||||
.B focus
|
.B focus
|
||||||
Control how focus is given to terminals. 'click' means the focus only moves to a terminal after you click in it. 'sloppy' means the focus will follow the mouse pointer. 'system' means the focus will match that used by a GNOME window manager.
|
Control how focus is given to terminals. 'click' means the focus only moves to a terminal after you click in it. 'sloppy' means the focus will follow the mouse pointer. 'system' means the focus will match that used by a GNOME window manager.
|
||||||
Default value: \fBclick\fR
|
Default value: \fBclick\fR
|
||||||
|
|
20
terminator
20
terminator
|
@ -50,6 +50,26 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
OPTIONS = terminatorlib.optionparse.parse_options()
|
OPTIONS = terminatorlib.optionparse.parse_options()
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
if OPTIONS.nodbus:
|
||||||
|
dbg('dbus disabled by command line')
|
||||||
|
raise ImportError
|
||||||
|
from terminatorlib import ipc
|
||||||
|
try:
|
||||||
|
ipc.DBusService()
|
||||||
|
except ipc.DBusException:
|
||||||
|
dbg('Unable to become master process, requesting a new window')
|
||||||
|
ipc.new_window()
|
||||||
|
sys.exit()
|
||||||
|
except ImportError:
|
||||||
|
dbg('dbus not imported')
|
||||||
|
pass
|
||||||
|
|
||||||
MAKER = Factory()
|
MAKER = Factory()
|
||||||
TERMINATOR = Terminator()
|
TERMINATOR = Terminator()
|
||||||
TERMINATOR.set_origcwd(ORIGCWD)
|
TERMINATOR.set_origcwd(ORIGCWD)
|
||||||
|
|
|
@ -76,6 +76,7 @@ except ImportError:
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
'global_config': {
|
'global_config': {
|
||||||
|
'dbus' : True,
|
||||||
'focus' : 'click',
|
'focus' : 'click',
|
||||||
'handle_size' : -1,
|
'handle_size' : -1,
|
||||||
'geometry_hinting' : True,
|
'geometry_hinting' : True,
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# Terminator by Chris Jones <cmsj@tenshu.net>
|
||||||
|
# GPL v2 only
|
||||||
|
"""ipc.py - DBus server and API calls"""
|
||||||
|
|
||||||
|
import gtk
|
||||||
|
import dbus.service
|
||||||
|
from dbus.exceptions import DBusException
|
||||||
|
import dbus.glib
|
||||||
|
from borg import Borg
|
||||||
|
from terminator import Terminator
|
||||||
|
from config import Config
|
||||||
|
from util import dbg
|
||||||
|
|
||||||
|
CONFIG = Config()
|
||||||
|
if not CONFIG['dbus']:
|
||||||
|
# The config says we are not to load dbus, so pretend like we can't
|
||||||
|
dbg('dbus disabled')
|
||||||
|
raise ImportError
|
||||||
|
|
||||||
|
BUS_BASE = 'net.tenshu.Terminator'
|
||||||
|
BUS_PATH = '/net/tenshu/Terminator'
|
||||||
|
try:
|
||||||
|
# Try and include the X11 display name in the dbus bus name
|
||||||
|
DISPLAY = hex(hash(gtk.gdk.get_display())).replace('-', '_')
|
||||||
|
BUS_NAME = '%s%s' % (BUS_BASE, DISPLAY)
|
||||||
|
except:
|
||||||
|
BUS_NAME = BUS_BASE
|
||||||
|
|
||||||
|
class DBusService(Borg, dbus.service.Object):
|
||||||
|
"""DBus Server class. This is implemented as a Borg"""
|
||||||
|
bus_name = None
|
||||||
|
terminator = None
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""Class initialiser"""
|
||||||
|
Borg.__init__(self, self.__class__.__name__)
|
||||||
|
self.prepare_attributes()
|
||||||
|
dbus.service.Object.__init__(self, self.bus_name, BUS_PATH)
|
||||||
|
|
||||||
|
def prepare_attributes(self):
|
||||||
|
"""Ensure we are populated"""
|
||||||
|
if not self.bus_name:
|
||||||
|
dbg('Checking for bus name availability: %s' % BUS_NAME)
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
proxy = bus.get_object('org.freedesktop.DBus',
|
||||||
|
'/org/freedesktop/DBus')
|
||||||
|
flags = 1 | 4 # allow replacement | do not queue
|
||||||
|
if not proxy.RequestName(BUS_NAME, dbus.UInt32(flags)) in (1, 4):
|
||||||
|
dbg('bus name unavailable: %s' % BUS_NAME)
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
"Couldn't get DBus name %s: Name exists" % BUS_NAME)
|
||||||
|
self.bus_name = dbus.service.BusName(BUS_NAME,
|
||||||
|
bus=dbus.SessionBus())
|
||||||
|
if not self.terminator:
|
||||||
|
self.terminator = Terminator()
|
||||||
|
|
||||||
|
@dbus.service.method(BUS_NAME)
|
||||||
|
def new_window(self):
|
||||||
|
"""Create a new Window"""
|
||||||
|
dbg('dbus method called')
|
||||||
|
self.terminator.create_layout('default')
|
||||||
|
self.terminator.layout_done()
|
||||||
|
|
||||||
|
def with_proxy(func):
|
||||||
|
"""Decorator function to connect to the session dbus bus"""
|
||||||
|
dbg('dbus client call: %s' % func.func_name)
|
||||||
|
def _exec(*args, **argd):
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
proxy = bus.get_object(BUS_NAME, BUS_PATH)
|
||||||
|
func(proxy, *args, **argd)
|
||||||
|
return _exec
|
||||||
|
|
||||||
|
@with_proxy
|
||||||
|
def new_window(session):
|
||||||
|
"""Call the dbus method to open a new window"""
|
||||||
|
session.new_window()
|
||||||
|
|
|
@ -68,6 +68,8 @@ WM_WINDOW_ROLE property on the window')
|
||||||
parser.add_option('-l', '--layout', dest='layout', help='Select a layout')
|
parser.add_option('-l', '--layout', dest='layout', help='Select a layout')
|
||||||
parser.add_option('-p', '--profile', dest='profile', help='Use a \
|
parser.add_option('-p', '--profile', dest='profile', help='Use a \
|
||||||
different profile as the default')
|
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',
|
parser.add_option('-d', '--debug', action='count', dest='debug',
|
||||||
help='Enable debugging information (twice for debug server)')
|
help='Enable debugging information (twice for debug server)')
|
||||||
parser.add_option('--debug-classes', action='store', dest='debug_classes',
|
parser.add_option('--debug-classes', action='store', dest='debug_classes',
|
||||||
|
|
|
@ -298,7 +298,7 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTable" id="global_config_table">
|
<object class="GtkTable" id="global_config_table">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_rows">6</property>
|
<property name="n_rows">7</property>
|
||||||
<property name="n_columns">2</property>
|
<property name="n_columns">2</property>
|
||||||
<property name="column_spacing">6</property>
|
<property name="column_spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -489,6 +489,34 @@
|
||||||
<property name="x_padding">20</property>
|
<property name="x_padding">20</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label24">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">DBus server</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">6</property>
|
||||||
|
<property name="bottom_attach">7</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="dbuscheck">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_dbuscheck_toggled"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">6</property>
|
||||||
|
<property name="bottom_attach">7</property>
|
||||||
|
<property name="x_options">GTK_EXPAND</property>
|
||||||
|
<property name="y_options">GTK_EXPAND</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
|
|
|
@ -215,6 +215,9 @@ class PrefsEditor:
|
||||||
else:
|
else:
|
||||||
active = 0
|
active = 0
|
||||||
widget.set_active(active)
|
widget.set_active(active)
|
||||||
|
# DBus Server
|
||||||
|
widget = guiget('dbuscheck')
|
||||||
|
widget.set_active(self.config['dbus'])
|
||||||
|
|
||||||
## Profile tab
|
## Profile tab
|
||||||
# Populate the profile list
|
# Populate the profile list
|
||||||
|
@ -538,6 +541,11 @@ class PrefsEditor:
|
||||||
self.config['geometry_hinting'] = widget.get_active()
|
self.config['geometry_hinting'] = widget.get_active()
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
|
||||||
|
def on_dbuscheck_toggled(self, widget):
|
||||||
|
"""DBus server setting changed"""
|
||||||
|
self.config['dbus'] = widget.get_active()
|
||||||
|
self.config.save()
|
||||||
|
|
||||||
def on_winbordercheck_toggled(self, widget):
|
def on_winbordercheck_toggled(self, widget):
|
||||||
"""Window border setting changed"""
|
"""Window border setting changed"""
|
||||||
self.config['borderless'] = not widget.get_active()
|
self.config['borderless'] = not widget.get_active()
|
||||||
|
|
|
@ -1509,7 +1509,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
dbg("Terminal::key_new_window: Spawning: %s" % cmd)
|
dbg("Terminal::key_new_window: Spawning: %s" % cmd)
|
||||||
subprocess.Popen([cmd, ])
|
subprocess.Popen([cmd, '-u'])
|
||||||
|
|
||||||
def key_broadcast_off(self):
|
def key_broadcast_off(self):
|
||||||
self.set_groupsend(None, self.terminator.groupsend_type['off'])
|
self.set_groupsend(None, self.terminator.groupsend_type['off'])
|
||||||
|
|
Loading…
Reference in New Issue