From 8fe1ca3c55522a06dcab51a43db38cef97f3c9d8 Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Sun, 13 Jan 2008 22:56:38 -0800 Subject: [PATCH] [Terminal] Add proper handling of exit_action This makes TildaTerminal do the proper thing when the child exits, according to the exit_action member. --- tilda-terminal.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tilda-terminal.c b/tilda-terminal.c index 841b2a3..87b081a 100644 --- a/tilda-terminal.c +++ b/tilda-terminal.c @@ -92,6 +92,36 @@ launch_default_shell: return TRUE; } +/** + * Called when the child process running in the VteTerminal exits. + */ +static void +child_exited_cb (GtkWidget *widget, gpointer data) +{ + TildaTerminal *self = TILDA_TERMINAL(data); + + /* These can stay here. They don't need to go into a header because + * they are only used at this point in the code. */ + enum exit_actions { HOLD_TERMINAL_OPEN, RESTART_COMMAND, EXIT_TERMINAL }; + + /* Check the user's preference for what to do when the child terminal + * is closed. Take the appropriate action */ + switch (self->exit_action) + { + case EXIT_TERMINAL: + tilda_window_remove_term (TILDA_WINDOW(self->parent_window), self->number); + break; + case RESTART_COMMAND: + vte_terminal_feed (VTE_TERMINAL(self->vte_term), "\r\n\r\n", 4); + tilda_terminal_start_shell (self); + break; + case HOLD_TERMINAL_OPEN: + break; + default: + break; + } +} + /******************************************************************************* * All GObject stuff is below. You probably don't need to change this... ******************************************************************************/ @@ -413,7 +443,6 @@ tilda_terminal_get_property (GObject *object, case TILDA_TERMINAL_MOUSE_AUTOHIDE: g_value_set_boolean (value, self->mouse_autohide); - break; default: /* We don't have this property... */ @@ -449,8 +478,11 @@ tilda_terminal_constructor (GType type, gtk_widget_show (self->scrollbar); + /* Connect Signals */ g_signal_connect (G_OBJECT(self->vte_term), "child-exited", - G_CALLBACK(gtk_main_quit), self); + G_CALLBACK(child_exited_cb), self); + g_signal_connect (G_OBJECT(self->vte_term), "eof", + G_CALLBACK(child_exited_cb), self); tilda_terminal_start_shell (self); tilda_terminal_dbus_register_object (self); -- 2.25.1