[New Plugin] Plugin that inserts the name
This plugin inserts the name of the terminal, as determined by Terminal.get_window_title() to all open terminals. Fixes #540
This commit is contained in:
parent
1aa437d6e3
commit
3d63c91517
|
@ -0,0 +1,20 @@
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
import terminatorlib.plugin as plugin
|
||||||
|
from terminatorlib.terminator import Terminator
|
||||||
|
|
||||||
|
AVAILABLE = ['InsertTermName']
|
||||||
|
|
||||||
|
class InsertTermName(plugin.MenuItem):
|
||||||
|
capabilities = ['terminal_menu']
|
||||||
|
config = None
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
# self.connect_signals()
|
||||||
|
plugin.MenuItem.__init__(self)
|
||||||
|
|
||||||
|
def callback(self, menuitems, menu, terminal):
|
||||||
|
item = Gtk.MenuItem.new_with_label('Insert terminal name')
|
||||||
|
item.connect('activate', lambda x: terminal.emit('insert-term-name'))
|
||||||
|
menuitems.append(item)
|
||||||
|
|
|
@ -40,6 +40,7 @@ class Terminal(Gtk.VBox):
|
||||||
'close-term': (GObject.SignalFlags.RUN_LAST, None, ()),
|
'close-term': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'title-change': (GObject.SignalFlags.RUN_LAST, None,
|
'title-change': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(GObject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
|
'insert-term-name': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'enumerate': (GObject.SignalFlags.RUN_LAST, None,
|
'enumerate': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(GObject.TYPE_INT,)),
|
(GObject.TYPE_INT,)),
|
||||||
'group-tab': (GObject.SignalFlags.RUN_LAST, None, ()),
|
'group-tab': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
|
@ -126,6 +127,7 @@ class Terminal(Gtk.VBox):
|
||||||
|
|
||||||
# FIXME: Surely these should happen in Terminator::register_terminal()?
|
# FIXME: Surely these should happen in Terminator::register_terminal()?
|
||||||
self.connect('enumerate', self.terminator.do_enumerate)
|
self.connect('enumerate', self.terminator.do_enumerate)
|
||||||
|
self.connect('insert-term-name', self.terminator.do_insert_term_name)
|
||||||
self.connect('focus-in', self.terminator.focus_changed)
|
self.connect('focus-in', self.terminator.focus_changed)
|
||||||
self.connect('focus-out', self.terminator.focus_left)
|
self.connect('focus-out', self.terminator.focus_left)
|
||||||
|
|
||||||
|
|
|
@ -585,6 +585,16 @@ class Terminator(Borg):
|
||||||
idx = terminals.index(term)
|
idx = terminals.index(term)
|
||||||
term.feed(numstr.encode() % (idx + 1))
|
term.feed(numstr.encode() % (idx + 1))
|
||||||
|
|
||||||
|
def do_insert_term_name(self, widget):
|
||||||
|
terminals = []
|
||||||
|
for window in self.windows:
|
||||||
|
containers, win_terminals = enumerate_descendants(window)
|
||||||
|
terminals.extend(win_terminals)
|
||||||
|
|
||||||
|
for term in self.get_target_terms(widget):
|
||||||
|
name = term.titlebar.get_custom_string() or term.get_window_title()
|
||||||
|
term.feed(name)
|
||||||
|
|
||||||
def get_sibling_terms(self, widget):
|
def get_sibling_terms(self, widget):
|
||||||
termset = []
|
termset = []
|
||||||
for term in self.terminals:
|
for term in self.terminals:
|
||||||
|
|
Loading…
Reference in New Issue