Merge pull request #435 from yusufgungor/master

Added set_tab_title command to remotinator.
This commit is contained in:
Matt Rose 2021-05-09 10:35:12 -04:00 committed by GitHub
commit fec99bc234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 10 deletions

View File

@ -46,7 +46,8 @@ COMMANDS={
'get_window_title': [True, _('Get the title of a parent window')], 'get_window_title': [True, _('Get the title of a parent window')],
'get_tab': [True, _('Get the UUID of a parent tab')], 'get_tab': [True, _('Get the UUID of a parent tab')],
'get_tab_title': [True, _('Get the title 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__': if __name__ == '__main__':
@ -75,6 +76,9 @@ if __name__ == '__main__':
parser.add_argument('-p', '--profile', dest='profile', type=str, default=argparse.SUPPRESS, parser.add_argument('-p', '--profile', dest='profile', type=str, default=argparse.SUPPRESS,
help=_('Terminal UUID for when not in env var TERMINATOR_UUID')) 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)) parser.add_argument('-v', '--version', action='version', version='%%(prog)s %s' %(APP_VERSION))
options = vars(parser.parse_args()) # Straight to dict options = vars(parser.parse_args()) # Straight to dict

View File

@ -265,6 +265,24 @@ class DBusService(Borg, dbus.service.Object):
if terminal in terms: if terminal in terms:
return root_widget.get_tab_label(tab_child).get_label() 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) @dbus.service.method(BUS_NAME)
def switch_profile(self, uuid=None, options=dbus.Dictionary()): def switch_profile(self, uuid=None, options=dbus.Dictionary()):
"""Switch profile of a given terminal""" """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""" """Call the dbus method to return the title of a tab"""
print(session.get_tab_title(uuid)) 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 @with_proxy
def switch_profile(session, uuid, options): def switch_profile(session, uuid, options):
"""Call the dbus method to return the title of a tab""" """Call the dbus method to return the title of a tab"""

View File

@ -583,9 +583,9 @@ class TabLabel(Gtk.HBox):
def get_label(self): def get_label(self):
return self.label.get_text() 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""" """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() self.label.set_custom()
def get_custom_label(self): def get_custom_label(self):