Add support for terminal and tab edit title key binding.

Currently the only way of changing either active terminal title or active tab
title is by mouse clicking on them.

The suggested fix adds support for keybinding for each action, thus providing
a potential productivity increase from user's perspective.

The suggested default key layouts are:
* edit terminal title '<Alt>F2'.
* edit tab title '<Alt><Shift>F2'

This fixes issue: https://bugs.launchpad.net/terminator/+bug/1417747
This commit is contained in:
Haim Daniel hdaniel@redhat.com 2015-10-26 15:46:39 +02:00
parent 454a82a8cb
commit 9aab1d8643
7 changed files with 59 additions and 19 deletions

View File

@ -224,6 +224,12 @@ Restore font size to original setting.
.B Alt+T
Rename titlebar.
.TP
.B Alt+F2
Rename terminal title.
.TP
.B Alt+Shift+F2
Rename tab title.
.TP
.B Super+1
Insert terminal number, i.e. 1 to 12.
.TP

View File

@ -286,6 +286,14 @@ Note that <Alt><Shift>1 may need to be provided as <Alt>! or similar,
depending on your keyboard layout.
Default value: \fBUnbound\fR
.TP
.B edit_tab_title
Edit the currently active tab's title
Default value: \fB<Alt><Shift>F2\fR
.TP
.B edit_terminal_title
Edit the currently active terminal's title
Default value: \fB<Alt>F2\fR
.TP
.B full_screen
Toggle the window to a fullscreen window.
Default value: \fBF11\fR

View File

@ -191,6 +191,8 @@ DEFAULTS = {
'insert_number' : '<Super>1',
'insert_padded' : '<Super>0',
'edit_window_title': '<Alt>t',
'edit_tab_title' : '<Alt><Shift>F2',
'edit_terminal_title': '<Alt>F2',
'layout_launcher' : '<Alt>l',
'next_profile' : '',
'previous_profile' : '',

View File

@ -26,7 +26,8 @@ class EditableLabel(gtk.EventBox):
# pylint: disable-msg=R0904
"""
An eventbox that partialy emulate a gtk.Label
On double-click, the label is editable, entering an empty will revert back to automatic text
On double-click or key binding the label is editable, entering an empty
will revert back to automatic text
"""
_label = None
_ebox = None
@ -69,12 +70,8 @@ class EditableLabel(gtk.EventBox):
"""get the text from the label"""
return(self._label.get_text())
def _on_click_text(self, widget, event):
# pylint: disable-msg=W0613
"""event handling text edition"""
if event.button != 1:
return False
if event.type == gtk.gdk._2BUTTON_PRESS:
def edit(self):
""" Start editing the widget text """
self.remove(self._label)
self._entry = gtk.Entry()
self._entry.set_text(self._label.get_text())
@ -91,8 +88,16 @@ class EditableLabel(gtk.EventBox):
self._on_entry_buttonpress)
self._entry_handler_id.append(sig)
self._entry.grab_focus()
return(True)
return(False)
def _on_click_text(self, widget, event):
# pylint: disable-msg=W0613
"""event handling text edition"""
if event.button != 1:
return False
if event.type == gtk.gdk._2BUTTON_PRESS:
self.edit()
return True
return False
def _entry_to_label (self, widget, event):
# pylint: disable-msg=W0613

View File

@ -536,6 +536,9 @@ class TabLabel(gtk.HBox):
else:
return(None)
def edit(self):
self.label.edit()
def update_button(self):
"""Update the state of our close button"""
if not self.config['close_button_on_tab']:

View File

@ -148,6 +148,8 @@ class PrefsEditor:
'insert_number' : _('Insert terminal number'),
'insert_padded' : _('Insert padded terminal number'),
'edit_window_title': _('Edit window title'),
'edit_terminal_title': _('Edit terminal title'),
'edit_tab_title' : _('Edit tab title'),
'layout_launcher' : _('Open layout launcher window'),
'next_profile' : _('Switch to next profile'),
'previous_profile' : _('Switch to previous profile'),

View File

@ -1836,6 +1836,20 @@ class Terminal(gtk.VBox):
dialog.destroy()
return
def key_edit_tab_title(self):
window = self.get_toplevel()
if not window.is_child_notebook():
return
notebook = window.get_children()[0]
n_page = notebook.get_current_page()
page = notebook.get_nth_page(n_page)
label = notebook.get_tab_label(page)
label.edit()
def key_edit_terminal_title(self):
self.titlebar.label.edit()
def key_layout_launcher(self):
LAYOUTLAUNCHER=LayoutLauncher()