Merge pull request #435 from yusufgungor/master
Added set_tab_title command to remotinator.
This commit is contained in:
commit
fec99bc234
@ -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
|
||||
|
@ -56,14 +56,14 @@ class DBusService(Borg, dbus.service.Object):
|
||||
except Exception as e:
|
||||
err('Unable to connect to DBUS Server, proceeding as standalone')
|
||||
raise ImportError
|
||||
proxy = bus.get_object('org.freedesktop.DBus',
|
||||
proxy = bus.get_object('org.freedesktop.DBus',
|
||||
'/org/freedesktop/DBus')
|
||||
flags = 1 | 4 # allow replacement | do not queue
|
||||
if not proxy.RequestName(BUS_NAME, dbus.UInt32(flags)) in (1, 4):
|
||||
dbg('bus name unavailable: %s' % BUS_NAME)
|
||||
raise dbus.exceptions.DBusException(
|
||||
"Couldn't get DBus name %s: Name exists" % BUS_NAME)
|
||||
self.bus_name = dbus.service.BusName(BUS_NAME,
|
||||
self.bus_name = dbus.service.BusName(BUS_NAME,
|
||||
bus=dbus.SessionBus())
|
||||
if not self.bus_path:
|
||||
self.bus_path = BUS_PATH
|
||||
@ -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"""
|
||||
|
@ -202,7 +202,7 @@ class Notebook(Container, Gtk.Notebook):
|
||||
"""Remove a widget from the container"""
|
||||
page_num = self.page_num(widget)
|
||||
if page_num == -1:
|
||||
err('%s not found in Notebook. Actual parent is: %s' %
|
||||
err('%s not found in Notebook. Actual parent is: %s' %
|
||||
(widget, widget.get_parent()))
|
||||
return(False)
|
||||
self.remove_page(page_num)
|
||||
@ -410,7 +410,7 @@ class Notebook(Container, Gtk.Notebook):
|
||||
if not label:
|
||||
err('Notebook::update_tab_label_text: %s not found' % widget)
|
||||
return
|
||||
|
||||
|
||||
label.set_label(text)
|
||||
|
||||
def hoover(self):
|
||||
@ -474,7 +474,7 @@ class Notebook(Container, Gtk.Notebook):
|
||||
"""Prime a single idle tab switch signal, using the most recent set of params"""
|
||||
tabs_last_active_term = self.last_active_term.get(self.get_nth_page(page_num), None)
|
||||
data = {'tabs_last_active_term':tabs_last_active_term}
|
||||
|
||||
|
||||
self.pending_on_tab_switch_args = (notebook, page, page_num, data)
|
||||
if self.pending_on_tab_switch == True:
|
||||
return
|
||||
@ -507,7 +507,7 @@ class Notebook(Container, Gtk.Notebook):
|
||||
return False
|
||||
|
||||
event_widget = Gtk.get_event_widget(event)
|
||||
|
||||
|
||||
if event_widget == None or \
|
||||
event_widget == child or \
|
||||
event_widget.is_ancestor(child):
|
||||
@ -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):
|
||||
@ -615,7 +615,7 @@ class TabLabel(Gtk.HBox):
|
||||
if not self.icon:
|
||||
self.icon = Gio.ThemedIcon.new_with_default_fallbacks("window-close-symbolic")
|
||||
self.icon = Gtk.Image.new_from_gicon(self.icon, Gtk.IconSize.MENU)
|
||||
|
||||
|
||||
self.button.set_focus_on_click(False)
|
||||
self.button.set_relief(Gtk.ReliefStyle.NONE)
|
||||
# style = Gtk.RcStyle() # FIXME FOR GTK3 how to do it there? actually do we really want to override the theme?
|
||||
|
Loading…
Reference in New Issue
Block a user