(trunk-1683) Merge feature branch for tab/terminal title editing from Haim Daniel

This commit is contained in:
Stephen Boddy 2015-12-01 00:57:18 +01:00
parent 9115b62928
commit 295f884c6d
7 changed files with 66 additions and 22 deletions

View File

@ -221,8 +221,14 @@ Decrease font size. \fBNote:\fP This may require you to press shift, depending o
.B Ctrl+Zero (0)
Restore font size to original setting.
.TP
.B Alt+T
Rename titlebar.
.B Ctrl+W
Rename window title.
.TP
.B Ctrl+A
Rename tab title.
.TP
.B Ctrl+X
Rename terminal title.
.TP
.B Super+1
Insert terminal number, i.e. 1 to 12.

View File

@ -286,6 +286,18 @@ 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_window_title
Edit the current active window's title
Default value: \fB<Ctrl>W\fR
.TP
.B edit_tab_title
Edit the currently active tab's title
Default value: \fB<Ctrl>A\fR
.TP
.B edit_terminal_title
Edit the currently active terminal's title
Default value: \fB<Ctrl>X\fR
.TP
.B full_screen
Toggle the window to a fullscreen window.
Default value: \fBF11\fR

View File

@ -192,7 +192,9 @@ DEFAULTS = {
'broadcast_all' : '<Alt>a',
'insert_number' : '<Super>1',
'insert_padded' : '<Super>0',
'edit_window_title': '<Alt>t',
'edit_window_title': '<Control>w',
'edit_tab_title' : '<Control>a',
'edit_terminal_title': '<Control>x',
'layout_launcher' : '<Alt>l',
'next_profile' : '',
'previous_profile' : '',

View File

@ -25,7 +25,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
@ -67,30 +68,34 @@ class EditableLabel(Gtk.EventBox):
"""get the text from the label"""
return(self._label.get_text())
def edit(self):
""" Start editing the widget text """
if self._entry:
return False
self.remove (self._label)
self._entry = Gtk.Entry ()
self._entry.set_text (self._label.get_text ())
self._entry.show ()
self.add (self._entry)
sig = self._entry.connect ("focus-out-event", self._entry_to_label)
self._entry_handler_id.append(sig)
sig = self._entry.connect ("activate", self._on_entry_activated)
self._entry_handler_id.append(sig)
sig = self._entry.connect ("key-press-event",
self._on_entry_keypress)
self._entry_handler_id.append(sig)
sig = self._entry.connect("button-press-event",
self._on_entry_buttonpress)
self._entry_handler_id.append(sig)
self._entry.grab_focus ()
def _on_click_text(self, widget, event):
# pylint: disable-msg=W0613
"""event handling text edition"""
if event.button != 1:
return False
if event.type == Gdk.EventType._2BUTTON_PRESS:
if self._entry:
return False
self.remove (self._label)
self._entry = Gtk.Entry ()
self._entry.set_text (self._label.get_text ())
self._entry.show ()
self.add (self._entry)
sig = self._entry.connect ("focus-out-event", self._entry_to_label)
self._entry_handler_id.append(sig)
sig = self._entry.connect ("activate", self._on_entry_activated)
self._entry_handler_id.append(sig)
sig = self._entry.connect ("key-press-event",
self._on_entry_keypress)
self._entry_handler_id.append(sig)
sig = self._entry.connect("button-press-event",
self._on_entry_buttonpress)
self._entry_handler_id.append(sig)
self._entry.grab_focus ()
self.edit()
return(True)
return(False)

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

@ -147,6 +147,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

@ -1884,6 +1884,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()