From 9aab1d86433ac58767fa4c2a74ce5275b5e1fe1a Mon Sep 17 00:00:00 2001 From: "Haim Daniel hdaniel@redhat.com" <> Date: Mon, 26 Oct 2015 15:46:39 +0200 Subject: [PATCH 1/2] 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 'F2'. * edit tab title 'F2' This fixes issue: https://bugs.launchpad.net/terminator/+bug/1417747 --- doc/terminator.1 | 6 +++++ doc/terminator_config.5 | 8 +++++++ terminatorlib/config.py | 2 ++ terminatorlib/editablelabel.py | 43 +++++++++++++++++++--------------- terminatorlib/notebook.py | 3 +++ terminatorlib/prefseditor.py | 2 ++ terminatorlib/terminal.py | 14 +++++++++++ 7 files changed, 59 insertions(+), 19 deletions(-) diff --git a/doc/terminator.1 b/doc/terminator.1 index f028933e..cf0bdb78 100644 --- a/doc/terminator.1 +++ b/doc/terminator.1 @@ -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 diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index f76fc793..cc80ae62 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -286,6 +286,14 @@ Note that 1 may need to be provided as ! 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: \fBF2\fR +.TP +.B edit_terminal_title +Edit the currently active terminal's title +Default value: \fBF2\fR +.TP .B full_screen Toggle the window to a fullscreen window. Default value: \fBF11\fR diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 5323d834..b0654b9c 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -191,6 +191,8 @@ DEFAULTS = { 'insert_number' : '1', 'insert_padded' : '0', 'edit_window_title': 't', + 'edit_tab_title' : 'F2', + 'edit_terminal_title': 'F2', 'layout_launcher' : 'l', 'next_profile' : '', 'previous_profile' : '', diff --git a/terminatorlib/editablelabel.py b/terminatorlib/editablelabel.py index b5bd17ea..a76dbfc2 100644 --- a/terminatorlib/editablelabel.py +++ b/terminatorlib/editablelabel.py @@ -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,30 +70,34 @@ class EditableLabel(gtk.EventBox): """get the text from the label""" return(self._label.get_text()) + def edit(self): + """ Start editing the widget text """ + 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 == gtk.gdk._2BUTTON_PRESS: - 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 () - return(True) - return(False) + self.edit() + return True + return False def _entry_to_label (self, widget, event): # pylint: disable-msg=W0613 diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index c5228a8e..628696e3 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -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']: diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 6eed6032..3f791e72 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -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'), diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 20704855..2d2a9cf0 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -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() From 0b7b9461245ab129e25d5dc5d4f183275cab515d Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sat, 7 Nov 2015 03:27:06 +0100 Subject: [PATCH 2/2] Adjust the default shortcuts for renaming title/tab/terminal, and update docs --- doc/manual/source/gettingstarted.rst | 18 +++++++++--------- doc/terminator.1 | 12 ++++++------ doc/terminator_config.5 | 8 ++++++-- terminatorlib/config.py | 6 +++--- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/doc/manual/source/gettingstarted.rst b/doc/manual/source/gettingstarted.rst index 4de6e047..c27afd45 100644 --- a/doc/manual/source/gettingstarted.rst +++ b/doc/manual/source/gettingstarted.rst @@ -501,15 +501,15 @@ Or maybe for you it is with tabs. In Terminator you can rename three things: -+----------+---------------------------+-------------------+ -| Edit | Mouse | Default Shortcut | -+==========+===========================+===================+ -| Window | N/A | ``Alt``\ +\ ``T`` | -+----------+---------------------------+-------------------+ -| Titlebar | ``double-click`` titlebar | N/A (TBD) | -+----------+---------------------------+-------------------+ -| Tab | ``double-click`` tab | N/A (TBD) | -+----------+---------------------------+-------------------+ ++----------------+---------------------------+--------------------+ +| Edit | Mouse | Default Shortcut | ++================+===========================+====================+ +| Window title | N/A | ``Ctrl``\ +\ ``W`` | ++----------------+---------------------------+--------------------+ +| Tab title | ``double-click`` tab | ``Ctrl``\ +\ ``A`` | ++----------------+---------------------------+--------------------+ +| Terminal title | ``double-click`` titlebar | ``Ctrl``\ +\ ``X`` | ++----------------+---------------------------+--------------------+ Additionally all three can be saved/loaded from a :ref:`layout `, or the window title can be set using a diff --git a/doc/terminator.1 b/doc/terminator.1 index cf0bdb78..fbc066fb 100644 --- a/doc/terminator.1 +++ b/doc/terminator.1 @@ -221,15 +221,15 @@ 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 Alt+F2 -Rename terminal title. -.TP -.B Alt+Shift+F2 +.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. .TP diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index cc80ae62..411238a9 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -286,13 +286,17 @@ Note that 1 may need to be provided as ! 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: \fBW\fR +.TP .B edit_tab_title Edit the currently active tab's title -Default value: \fBF2\fR +Default value: \fBA\fR .TP .B edit_terminal_title Edit the currently active terminal's title -Default value: \fBF2\fR +Default value: \fBX\fR .TP .B full_screen Toggle the window to a fullscreen window. diff --git a/terminatorlib/config.py b/terminatorlib/config.py index b0654b9c..797bb94c 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -190,9 +190,9 @@ DEFAULTS = { 'broadcast_all' : 'a', 'insert_number' : '1', 'insert_padded' : '0', - 'edit_window_title': 't', - 'edit_tab_title' : 'F2', - 'edit_terminal_title': 'F2', + 'edit_window_title': 'w', + 'edit_tab_title' : 'a', + 'edit_terminal_title': 'x', 'layout_launcher' : 'l', 'next_profile' : '', 'previous_profile' : '',