Merge pull request #333 from zothar/restart_command
Feature: Relaunch command option on held open after child exit
This commit is contained in:
commit
f2b656dcf1
|
@ -126,8 +126,11 @@ class Terminal(Gtk.VBox):
|
||||||
custom_encoding = None
|
custom_encoding = None
|
||||||
custom_font_size = None
|
custom_font_size = None
|
||||||
layout_command = None
|
layout_command = None
|
||||||
|
relaunch_command = None
|
||||||
directory = None
|
directory = None
|
||||||
|
|
||||||
|
is_held_open = False
|
||||||
|
|
||||||
fgcolor_active = None
|
fgcolor_active = None
|
||||||
bgcolor = None
|
bgcolor = None
|
||||||
palette_active = None
|
palette_active = None
|
||||||
|
@ -676,6 +679,8 @@ class Terminal(Gtk.VBox):
|
||||||
|
|
||||||
if self.config['exit_action'] == 'restart':
|
if self.config['exit_action'] == 'restart':
|
||||||
self.cnxids.new(self.vte, 'child-exited', self.spawn_child, True)
|
self.cnxids.new(self.vte, 'child-exited', self.spawn_child, True)
|
||||||
|
elif self.config['exit_action'] == 'hold':
|
||||||
|
self.cnxids.new(self.vte, 'child-exited', self.held_open, True)
|
||||||
elif self.config['exit_action'] in ('close', 'left'):
|
elif self.config['exit_action'] in ('close', 'left'):
|
||||||
self.cnxids.new(self.vte, 'child-exited',
|
self.cnxids.new(self.vte, 'child-exited',
|
||||||
lambda x, y: self.emit('close-term'))
|
lambda x, y: self.emit('close-term'))
|
||||||
|
@ -1426,6 +1431,10 @@ class Terminal(Gtk.VBox):
|
||||||
if cwd is not None:
|
if cwd is not None:
|
||||||
self.cwd = cwd
|
self.cwd = cwd
|
||||||
|
|
||||||
|
def held_open(self, widget=None, respawn=False, debugserver=False):
|
||||||
|
self.is_held_open = True
|
||||||
|
self.titlebar.update()
|
||||||
|
|
||||||
def spawn_child(self, widget=None, respawn=False, debugserver=False):
|
def spawn_child(self, widget=None, respawn=False, debugserver=False):
|
||||||
args = []
|
args = []
|
||||||
shell = None
|
shell = None
|
||||||
|
@ -1438,13 +1447,19 @@ class Terminal(Gtk.VBox):
|
||||||
if respawn == False:
|
if respawn == False:
|
||||||
self.vte.grab_focus()
|
self.vte.grab_focus()
|
||||||
|
|
||||||
|
self.is_held_open = False
|
||||||
|
|
||||||
options = self.config.options_get()
|
options = self.config.options_get()
|
||||||
if options and options.command:
|
if options and options.command:
|
||||||
command = options.command
|
command = options.command
|
||||||
|
self.relaunch_command = command
|
||||||
options.command = None
|
options.command = None
|
||||||
elif options and options.execute:
|
elif options and options.execute:
|
||||||
command = options.execute
|
command = options.execute
|
||||||
|
self.relaunch_command = command
|
||||||
options.execute = None
|
options.execute = None
|
||||||
|
elif self.relaunch_command:
|
||||||
|
command = self.relaunch_command
|
||||||
elif self.config['use_custom_command']:
|
elif self.config['use_custom_command']:
|
||||||
command = self.config['custom_command']
|
command = self.config['custom_command']
|
||||||
elif self.layout_command:
|
elif self.layout_command:
|
||||||
|
|
|
@ -179,6 +179,12 @@ class TerminalPopupMenu(object):
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
menu.append(Gtk.SeparatorMenuItem())
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
|
|
||||||
|
if terminal.is_held_open:
|
||||||
|
item = Gtk.MenuItem.new_with_mnemonic(_('Relaunch Command'))
|
||||||
|
item.connect('activate', lambda x: terminal.spawn_child())
|
||||||
|
menu.append(item)
|
||||||
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
|
|
||||||
item = Gtk.CheckMenuItem.new_with_mnemonic(_('Show _scrollbar'))
|
item = Gtk.CheckMenuItem.new_with_mnemonic(_('Show _scrollbar'))
|
||||||
item.set_active(terminal.scrollbar.get_property('visible'))
|
item.set_active(terminal.scrollbar.get_property('visible'))
|
||||||
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
|
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
|
||||||
|
|
|
@ -104,10 +104,15 @@ class Titlebar(Gtk.EventBox):
|
||||||
def update(self, other=None):
|
def update(self, other=None):
|
||||||
"""Update our contents"""
|
"""Update our contents"""
|
||||||
default_bg = False
|
default_bg = False
|
||||||
if self.config['title_hide_sizetext']:
|
|
||||||
self.label.set_text("%s" % self.termtext)
|
temp_heldtext_str = ''
|
||||||
else:
|
temp_sizetext_str = ''
|
||||||
self.label.set_text("%s %s" % (self.termtext, self.sizetext))
|
|
||||||
|
if self.terminal.is_held_open:
|
||||||
|
temp_heldtext_str = _('[INACTIVE: Right-Click for Relaunch option] ')
|
||||||
|
if not self.config['title_hide_sizetext']:
|
||||||
|
temp_sizetext_str = " %s" % (self.sizetext)
|
||||||
|
self.label.set_text("%s%s%s" % (temp_heldtext_str, self.termtext, temp_sizetext_str))
|
||||||
|
|
||||||
if (not self.config['title_use_system_font']) and self.config['title_font']:
|
if (not self.config['title_use_system_font']) and self.config['title_font']:
|
||||||
title_font = Pango.FontDescription(self.config['title_font'])
|
title_font = Pango.FontDescription(self.config['title_font'])
|
||||||
|
|
Loading…
Reference in New Issue