Merge pull request #487 from mattrose/issue-466
add bg_img and bg_img_all commands to remotinator
This commit is contained in:
commit
f7f47f4f5e
|
@ -47,6 +47,8 @@ COMMANDS={
|
||||||
'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')],
|
||||||
'set_tab_title': [True, _('Set the title of a parent tab')],
|
'set_tab_title': [True, _('Set the title of a parent tab')],
|
||||||
|
'bg_img': [True, _('Set the background image')],
|
||||||
|
'bg_img_all': [False, _('Set the background image for all terminals')],
|
||||||
'switch_profile': [True, _('Switch current terminal profile')],
|
'switch_profile': [True, _('Switch current terminal profile')],
|
||||||
'switch_profile_all': [False, _('Switch profile of all currently running terminals')],
|
'switch_profile_all': [False, _('Switch profile of all currently running terminals')],
|
||||||
}
|
}
|
||||||
|
@ -75,10 +77,13 @@ if __name__ == '__main__':
|
||||||
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('-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=_('Profile name to switch to'))
|
||||||
|
|
||||||
|
parser.add_argument('-f', '--file', dest='file', type=str, default=argparse.SUPPRESS,
|
||||||
|
help=_('File to pass to command'))
|
||||||
|
|
||||||
parser.add_argument('-x', '--execute', dest='execute', type=str, default=argparse.SUPPRESS,
|
parser.add_argument('-x', '--execute', dest='execute', type=str, default=argparse.SUPPRESS,
|
||||||
help=_('Terminal UUID for when not in env var TERMINATOR_UUID'))
|
help=_('Command to run in new terminal'))
|
||||||
|
|
||||||
parser.add_argument('-t', '--tab-title', dest='tab-title', type=str, default="Missing Tab Title! Use -t argument!",
|
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.'))
|
help=_('Tab name to set. Only used with "set_tab_title" command.'))
|
||||||
|
|
|
@ -124,6 +124,15 @@ class DBusService(Borg, dbus.service.Object):
|
||||||
"""Create a new tab"""
|
"""Create a new tab"""
|
||||||
return self.new_terminal(uuid, 'tab')
|
return self.new_terminal(uuid, 'tab')
|
||||||
|
|
||||||
|
@dbus.service.method(BUS_NAME)
|
||||||
|
def bg_img_all (self,options=dbus.Dictionary()):
|
||||||
|
for terminal in self.terminator.terminals:
|
||||||
|
terminal.set_background_image(options.get('file'))
|
||||||
|
|
||||||
|
@dbus.service.method(BUS_NAME)
|
||||||
|
def bg_img(self,uuid=None,options=dbus.Dictionary()):
|
||||||
|
self.terminator.find_terminal_by_uuid(uuid).set_background_image(options.get('file'))
|
||||||
|
|
||||||
@dbus.service.method(BUS_NAME)
|
@dbus.service.method(BUS_NAME)
|
||||||
def hsplit(self, uuid=None,options=None):
|
def hsplit(self, uuid=None,options=None):
|
||||||
"""Split a terminal horizontally, by UUID"""
|
"""Split a terminal horizontally, by UUID"""
|
||||||
|
@ -202,7 +211,7 @@ class DBusService(Borg, dbus.service.Object):
|
||||||
return new_terminal_set[0]
|
return new_terminal_set[0]
|
||||||
|
|
||||||
def new_terminal(self, uuid, type):
|
def new_terminal(self, uuid, type):
|
||||||
"""Split a terminal horizontally or vertically, by UUID"""
|
"""Split a terminal horizontally o?r vertically, by UUID"""
|
||||||
dbg('dbus method called: %s' % type)
|
dbg('dbus method called: %s' % type)
|
||||||
if not uuid:
|
if not uuid:
|
||||||
return "ERROR: No UUID specified"
|
return "ERROR: No UUID specified"
|
||||||
|
@ -422,3 +431,11 @@ def switch_profile(session, uuid, options):
|
||||||
def switch_profile_all(session,options):
|
def switch_profile_all(session,options):
|
||||||
"""Call the dbus method to return the title of a tab"""
|
"""Call the dbus method to return the title of a tab"""
|
||||||
session.switch_profile_all(options)
|
session.switch_profile_all(options)
|
||||||
|
|
||||||
|
@with_proxy
|
||||||
|
def bg_img_all(session,options):
|
||||||
|
session.bg_img_all(options)
|
||||||
|
|
||||||
|
@with_proxy
|
||||||
|
def bg_img(session,uuid,options):
|
||||||
|
session.bg_img(uuid,options)
|
||||||
|
|
|
@ -203,6 +203,16 @@ class Terminal(Gtk.VBox):
|
||||||
self.reconfigure()
|
self.reconfigure()
|
||||||
self.vte.set_size(80, 24)
|
self.vte.set_size(80, 24)
|
||||||
|
|
||||||
|
def set_background_image(self,image):
|
||||||
|
try:
|
||||||
|
self.background_image = GdkPixbuf.Pixbuf.new_from_file(image)
|
||||||
|
self.vte.set_clear_background(False)
|
||||||
|
self.vte.connect("draw",self.background_draw)
|
||||||
|
except Exception as e:
|
||||||
|
self.background_image = None
|
||||||
|
self.vte.set_clear_background(True)
|
||||||
|
err('error loading background image: %s, %s' % (type(e).__name__,e))
|
||||||
|
|
||||||
def get_vte(self):
|
def get_vte(self):
|
||||||
"""This simply returns the vte widget we are using"""
|
"""This simply returns the vte widget we are using"""
|
||||||
return(self.vte)
|
return(self.vte)
|
||||||
|
|
Loading…
Reference in New Issue