Split out the terminal widget creation code into a function so it can easily be reused

This commit is contained in:
Chris Jones 2006-11-08 18:04:07 -08:00
parent 47dd490825
commit 10c3d6ecb8
1 changed files with 24 additions and 20 deletions

View File

@ -19,6 +19,29 @@ def restore_cb(terminal):
def child_exited_cb(terminal): def child_exited_cb(terminal):
gtk.main_quit() gtk.main_quit()
def maketerm():
terminal = vte.Terminal()
if (background):
terminal.set_background_image(background)
if (transparent):
terminal.set_background_transparent(gtk.TRUE)
terminal.set_cursor_blinks(blink)
terminal.set_emulation(emulation)
terminal.set_font_from_string(font)
terminal.set_scrollback_lines(scrollback)
terminal.set_audible_bell(audible)
terminal.set_visible_bell(visible)
terminal.connect("child-exited", child_exited_cb)
terminal.connect("restore-window", restore_cb)
if (command):
# Start up the specified command.
child_pid = terminal.fork_command(command)
else:
# Start up the default command, the user's shell.
child_pid = terminal.fork_command()
terminal.show()
return (terminal)
if __name__ == '__main__': if __name__ == '__main__':
child_pid = -1; child_pid = -1;
# Defaults. # Defaults.
@ -65,26 +88,7 @@ if __name__ == '__main__':
print "Setting visible bell." print "Setting visible bell."
visible = not visible visible = not visible
window = gtk.Window() window = gtk.Window()
terminal = vte.Terminal() terminal = maketerm()
if (background):
terminal.set_background_image(background)
if (transparent):
terminal.set_background_transparent(gtk.TRUE)
terminal.set_cursor_blinks(blink)
terminal.set_emulation(emulation)
terminal.set_font_from_string(font)
terminal.set_scrollback_lines(scrollback)
terminal.set_audible_bell(audible)
terminal.set_visible_bell(visible)
terminal.connect("child-exited", child_exited_cb)
terminal.connect("restore-window", restore_cb)
if (command):
# Start up the specified command.
child_pid = terminal.fork_command(command)
else:
# Start up the default command, the user's shell.
child_pid = terminal.fork_command()
terminal.show()
scrollbar = gtk.VScrollbar() scrollbar = gtk.VScrollbar()
scrollbar.set_adjustment(terminal.get_adjustment()) scrollbar.set_adjustment(terminal.get_adjustment())