GtkWidget *terminal_create (GError **error) { GtkWidget *self = vte_terminal_new(); VtePty *self_pty = vte_pty_new(0, error); if (!self_pty){ g_free(self); return NULL; } else { GPid c_pid = 0; char *c_argv[] = { "dmesg", NULL }; vte_terminal_set_pty_object(VTE_TERMINAL(self), self_pty); c_argv[0] = getenv("SHELL"); if(g_spawn_async(getenv("HOME"), c_argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, (GSpawnChildSetupFunc) vte_pty_child_setup, (void *) self_pty, &c_pid, error)){ g_child_watch_add(c_pid, terminal_child_exited, self); } else { vte_pty_close(self_pty); g_object_unref(self_pty); g_object_unref(self); return NULL; } } vte_terminal_set_opacity(VTE_TERMINAL(self), 0); vte_terminal_set_scrollback_lines(VTE_TERMINAL(self), 255); return self; }
static VALUE rg_close(VALUE self) { vte_pty_close(_SELF(self)); return self; }
static void terminal_child_exited (GPid pid, gint status, gpointer data) { VtePty *self_pty = vte_terminal_get_pty_object(VTE_TERMINAL(data)); vte_pty_close(self_pty); gtk_widget_destroy(GTK_WIDGET(data)); g_object_unref(self_pty); }
static void vte_pty_finalize (GObject *object) { VtePty *pty = VTE_PTY (object); VtePtyPrivate *priv = pty->priv; if (priv->child_setup_data.mode == TTY_OPEN_BY_FD && priv->child_setup_data.tty.fd != -1) { /* Close the child FD */ close(priv->child_setup_data.tty.fd); } vte_pty_close(pty); /* Close the master FD */ if (priv->pty_fd != -1) { close(priv->pty_fd); } G_OBJECT_CLASS (vte_pty_parent_class)->finalize (object); }