Added set_tab_title command to remotinator.
This commit is contained in:
parent
efbc0a8d0a
commit
bad7f28fe9
|
@ -46,7 +46,8 @@ COMMANDS={
|
|||
'get_window_title': [True, _('Get the title of a parent window')],
|
||||
'get_tab': [True, _('Get the UUID of a parent tab')],
|
||||
'get_tab_title': [True, _('Get the title of a parent tab')],
|
||||
'switch_profile': [True, _('Switch current terminal profile')],
|
||||
'set_tab_title': [True, _('Set the title of a parent tab')],
|
||||
'switch_profile': [True, _('Switch current terminal profile')],
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -75,6 +76,9 @@ if __name__ == '__main__':
|
|||
parser.add_argument('-p', '--profile', dest='profile', type=str, default=argparse.SUPPRESS,
|
||||
help=_('Terminal UUID for when not in env var TERMINATOR_UUID'))
|
||||
|
||||
parser.add_argument('-t', '--tab-title', dest='tab-title', type=str, default="Missing Tab Title! Use -t argument!",
|
||||
help=_('Tab name to set. Only used with "set_tab_title" command.'))
|
||||
|
||||
parser.add_argument('-v', '--version', action='version', version='%%(prog)s %s' %(APP_VERSION))
|
||||
|
||||
options = vars(parser.parse_args()) # Straight to dict
|
||||
|
|
|
@ -265,6 +265,24 @@ class DBusService(Borg, dbus.service.Object):
|
|||
if terminal in terms:
|
||||
return root_widget.get_tab_label(tab_child).get_label()
|
||||
|
||||
@dbus.service.method(BUS_NAME)
|
||||
def set_tab_title(self, uuid=None, options=dbus.Dictionary()):
|
||||
"""Set the title of a parent tab of a given terminal"""
|
||||
tab_title = options.get('tab-title')
|
||||
|
||||
maker = Factory()
|
||||
terminal = self.terminator.find_terminal_by_uuid(uuid)
|
||||
window = terminal.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.set_custom_label(tab_title, force=True)
|
||||
|
||||
@dbus.service.method(BUS_NAME)
|
||||
def switch_profile(self, uuid=None, options=dbus.Dictionary()):
|
||||
"""Switch profile of a given terminal"""
|
||||
|
@ -362,6 +380,11 @@ def get_tab_title(session, uuid, options):
|
|||
"""Call the dbus method to return the title of a tab"""
|
||||
print(session.get_tab_title(uuid))
|
||||
|
||||
@with_proxy
|
||||
def set_tab_title(session, uuid, options):
|
||||
"""Call the dbus method to set the title of a tab"""
|
||||
session.set_tab_title(uuid, options)
|
||||
|
||||
@with_proxy
|
||||
def switch_profile(session, uuid, options):
|
||||
"""Call the dbus method to return the title of a tab"""
|
||||
|
|
|
@ -583,9 +583,9 @@ class TabLabel(Gtk.HBox):
|
|||
def get_label(self):
|
||||
return self.label.get_text()
|
||||
|
||||
def set_custom_label(self, text):
|
||||
def set_custom_label(self, text, force=False):
|
||||
"""Set a permanent label as if the user had edited it"""
|
||||
self.label.set_text(text)
|
||||
self.label.set_text(text, force=force)
|
||||
self.label.set_custom()
|
||||
|
||||
def get_custom_label(self):
|
||||
|
|
Loading…
Reference in New Issue