Ejemplo n.º 1
0
/** 
 * name: cb_eval
 * 
 * This callback function is invoked when the 'LispEdit: eval' menu option is selected.
 * If the cursor is placed after a closing parenthesis the function will look for the matching
 * opening parenthesis. If there is no matching parenthesis it will display a warning dialog box.
 *  
 * If the closing parenthesis has a matching opening parenthesis, all the characters between the parentheses
 * including the parentheses are sent to the child process running in the VTE.
 * 
 * @param menuitem GtkMenuItem.
 * @param gdata gpointer.
 * @return void
 **/
static void cb_eval(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata)
{
	if (have_vte)
    {
		doc = document_get_current();
		end_pos = sci_get_current_position(doc->editor->sci);
		if (end_pos > 0) end_pos--;
		gchar letter = sci_get_char_at(doc->editor->sci, end_pos);
		
		switch (letter)
		{ 
			case ')':	
						start_pos = sci_find_matching_brace(doc->editor->sci, end_pos);
						if (start_pos < 0)
						{
							dialogs_show_msgbox(GTK_MESSAGE_WARNING, "Found an isolated closing brace!!!");
						}
						else if (start_pos >= 0)
						{
							sci_get_text_range(doc->editor->sci, start_pos, ++end_pos, cmd_string);
							vte_terminal_feed_child(vte, "\n", strlen("\n"));
							vte_terminal_feed_child(vte, cmd_string, strlen(cmd_string));
							vte_terminal_feed_child(vte, "\n", strlen("\n"));
						}
						break;						
		}
    }
	else
	{
		show_error_message();
	}	
}
Ejemplo n.º 2
0
static void
skey_challenge_response_cb (GtkWidget *dialog,
                            int response_id,
                            SkeyData *data)
{  
  if (response_id == GTK_RESPONSE_OK)
    {
      GtkWidget *entry;
      const char *password;
      char *response;

      entry = g_object_get_data (G_OBJECT (dialog), "skey-entry");
      password = gtk_entry_get_text (GTK_ENTRY (entry));

      /* FIXME: fix skey to use g_malloc */
      response = skey (data->hash, data->seq, data->seed, password);
      if (response)
	{
          VteTerminal *vte_terminal = VTE_TERMINAL (data->screen);
          static const char newline[2] = "\n";

	  vte_terminal_feed_child (vte_terminal, response, strlen (response));
          vte_terminal_feed_child (vte_terminal, newline, strlen (newline));
	  free (response);
	}
    }

  gtk_widget_destroy (dialog);
}
Ejemplo n.º 3
0
static void
playAlgorithm (GtkWidget *widget,
		gpointer data) {

	char command[255] = "";
	GtkWidget *tty1 = g_object_get_data(data, "tty1");
	GtkWidget *mode = g_object_get_data(data, "in_mode");
	GtkWidget *bases = g_object_get_data(data, "in_bases");

	switch (gtk_combo_box_get_active(GTK_COMBO_BOX(mode)) ) {
		case 1:
			strcat(command, "bin/demo-superposition_1\r\n");
			break;
		case 3:
			sprintf(command, 
				"bin/bb84-polybase_Generation -b %s\r\n",
				gtk_entry_get_text(GTK_ENTRY(bases)));
		default:
			g_print("%i: %s\n", 
				gtk_combo_box_get_active(
					GTK_COMBO_BOX(mode)),
				gtk_combo_box_text_get_active_text(
					GTK_COMBO_BOX_TEXT(mode)));
			break;
	}

	vte_terminal_feed_child(VTE_TERMINAL(tty1), command, strlen(command));
	gtk_widget_set_sensitive(tty1, TRUE);
}
static void _terminal_write_command_with_data (GtkWidget *pWidget, gchar *cCommand, gchar *cData)
{
	gchar *cCommandLine = g_strdup_printf ("%s \"%s\"", cCommand, cData);
	vte_terminal_feed_child (VTE_TERMINAL (pWidget), cCommandLine, strlen (cCommandLine));
	g_free (cCommandLine);
	gtk_widget_grab_focus (pWidget);
}
Ejemplo n.º 5
0
void mssh_terminal_send_string(MSSHTerminal *terminal, gchar *string)
{
    if(mssh_terminal_isactive(terminal))
    {
        vte_terminal_feed_child(VTE_TERMINAL(terminal), string,
            strlen(string));
    }
}
Ejemplo n.º 6
0
void mssh_terminal_send_host(MSSHTerminal *terminal)
{
    if(mssh_terminal_isactive(terminal))
    {
        vte_terminal_feed_child(VTE_TERMINAL(terminal),
            terminal->hostname, strlen(terminal->hostname));
    }
}
Ejemplo n.º 7
0
static void toggle_changed(void *foo, void *data)
{
	char buf[1024];
	int i = (int)data;

	toggles[i].value = gtk_toggle_button_get_active(foo);

	sprintf(buf, ":eval %s=%d\n\n", toggles[i].name, toggles[i].value);
	vte_terminal_feed_child(VTE_TERMINAL(term), buf, strlen(buf));
}
Ejemplo n.º 8
0
/*
 * Class:     com_randomwalking_swt_terminal_internal_Vte
 * Method:    _vte_terminal_feed_child
 * Signature: (ILjava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_com_randomwalking_swt_terminal_internal_Vte__1vte_1terminal_1feed_1child
  (JNIEnv * env, jclass obj, jint terminal, jbyteArray data) {

	jsize datalen = (*env)->GetArrayLength(env, data);
	jbyte* cdata = (*env)->GetByteArrayElements(env, data, NULL);

	vte_terminal_feed_child(VTE_TERMINAL(terminal), (char *)cdata, datalen);

	(*env)-> ReleaseByteArrayElements(env, data, (jbyte *)cdata, 0);
}
Ejemplo n.º 9
0
static void on_terminal_feed(G_GNUC_UNUSED const MenuItem *menu_item)
{
	gdouble value = 4;

	if (dialogs_show_input_numeric(_("Feed Terminal"), _("Enter char # (0..255):"), &value,
		0, 255, 1))
	{
		char text = (char) value;
		vte_terminal_feed_child(program_terminal, &text, 1);
	}
}
Ejemplo n.º 10
0
static VALUE
rg_feed_child(VALUE self, VALUE data)
{
    glong length;

    length = RSTRING_LEN(data);

    if (length > 0) {
        vte_terminal_feed_child(_SELF(self), RSTRING_PTR(data), length);
    }

    return self;
}
Ejemplo n.º 11
0
static VALUE
term_feed_child(VALUE self, VALUE data)
{
    glong length;

    length = RSTRING_LEN(data);

    if (length > 0) {
        vte_terminal_feed_child(RVAL2TERM(self), RSTRING_PTR(data), length);
    }

    return Qnil;
}
Ejemplo n.º 12
0
void lcrt_terminal_set_connected_status(struct lcrt_terminal *lterminal)
{
    struct lcrt_window *lwindow = lterminal->parent->parent;
    debug_print("Login success\n");
    lterminal->connected =TRUE;
    debug_where();
    lcrt_terminal_set_status(lterminal, NULL, LCRT_TERMINAL_CONNECTED);
    if (lterminal->signal_connected) {
        gtk_signal_disconnect_by_func(GTK_OBJECT(lterminal->terminal),
                                      G_CALLBACK(lcrt_terminal_on_key_press_event),
                                      lterminal);
        lterminal->signal_connected = FALSE;
    }
    gtk_window_set_focus(GTK_WINDOW(lwindow->window),
             GTK_WIDGET(lterminal->terminal));
    if (lterminal->save_passwd) {
        lcrt_user_save_one(&lwindow->u_config, lwindow->current_user);
    }
    if (strlen(lterminal->user->command) != 0) {
        vte_terminal_feed_child(lterminal->terminal, lterminal->user->command, strlen(lterminal->user->command));
        vte_terminal_feed_child(lterminal->terminal, "\n", 1);
    }
}
Ejemplo n.º 13
0
static void
on_terminal_command_cb (GtkAction * action, TerminalPlugin *term_plugin)
{
	VteTerminal *term;
	gchar c;
	
	if (term_plugin->child_pid)
		term = VTE_TERMINAL (term_plugin->term);
	else
		term = VTE_TERMINAL (term_plugin->shell);
	
	/* this only works for control + letter */
	c = gtk_action_get_name (action) [strlen (gtk_action_get_name (action)) - 1] - 64;
	
	vte_terminal_feed_child (term, &c, 1);
}
Ejemplo n.º 14
0
 void terminal::insert_text(std::string i_text) {
   if ( m_terminal != NULL ) {
     vte_terminal_feed_child(m_terminal, i_text.c_str(), -1);
   }
 }
Ejemplo n.º 15
0
void termit_tab_feed_child(struct TermitTab* pTab, const gchar* data)
{
    vte_terminal_feed_child(VTE_TERMINAL(pTab->vte), data, strlen(data));
}
Ejemplo n.º 16
0
int
main(int argc, char **argv)
{
	GdkScreen *screen;
	GdkColormap *colormap;
	GtkWidget *window, *widget,*hbox = NULL, *scrollbar, *scrolled_window = NULL;
	VteTerminal *terminal;
	char *env_add[] = {
#ifdef VTE_DEBUG
		(char *) "FOO=BAR", (char *) "BOO=BIZ",
#endif
		NULL};
	const char *background = NULL;
	gboolean transparent = FALSE, audible = TRUE, blink = TRUE,
		 debug = FALSE, dingus = FALSE, dbuffer = TRUE,
		 console = FALSE, scroll = FALSE, keep = FALSE,
		 icon_title = FALSE, shell = TRUE, highlight_set = FALSE,
		 cursor_set = FALSE, reverse = FALSE, use_geometry_hints = TRUE,
		 antialias = TRUE, use_scrolled_window = FALSE,
                 show_object_notifications = FALSE;
        char *geometry = NULL;
	gint lines = 100;
	const char *message = "Launching interactive shell...\r\n";
	const char *font = NULL;
	const char *termcap = NULL;
	const char *command = NULL;
	const char *working_directory = NULL;
	const char *output_file = NULL;
        char *pty_flags_string = NULL;
        char *cursor_shape_string = NULL;
        char *scrollbar_policy_string = NULL;
	GdkColor fore, back, tint, highlight, cursor;
	const GOptionEntry options[]={
		{
			"antialias", 'A', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &antialias,
			"Disable the use of anti-aliasing", NULL
		},
		{
			"background", 'B', 0,
			G_OPTION_ARG_FILENAME, &background,
			"Specify a background image", NULL
		},
		{
			"console", 'C', 0,
			G_OPTION_ARG_NONE, &console,
			"Watch /dev/console", NULL
		},
		{
			"dingus", 'D', 0,
			G_OPTION_ARG_NONE, &dingus,
			"Highlight URLs inside the terminal", NULL
		},
		{
			"shell", 'S', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &shell,
			"Disable spawning a shell inside the terminal", NULL
		},
		{
			"transparent", 'T', 0,
			G_OPTION_ARG_NONE, &transparent,
			"Enable the use of a transparent background", NULL
		},
		{
			"double-buffer", '2', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &dbuffer,
			"Disable double-buffering", NULL
		},
		{
			"audible", 'a', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &audible,
			"Use visible, instead of audible, terminal bell",
			NULL
		},
		{
			"blink", 'b', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &blink,
			"Disable the blinking cursor", NULL
		},
		{
			"command", 'c', 0,
			G_OPTION_ARG_STRING, &command,
			"Execute a command in the terminal", NULL
		},
		{
			"debug", 'd', 0,
			G_OPTION_ARG_NONE, &debug,
			"Enable various debugging checks", NULL
		},
		{
			"font", 'f', 0,
			G_OPTION_ARG_STRING, &font,
			"Specify a font to use", NULL
		},
		{
			"geometry", 'g', 0,
			G_OPTION_ARG_STRING, &geometry,
			"Set the size (in characters) and position", "GEOMETRY"
		},
		{
			"highlight", 'h', 0,
			G_OPTION_ARG_NONE, &highlight_set,
			"Enable the cursor highlighting", NULL
		},
		{
			"icon-title", 'i', 0,
			G_OPTION_ARG_NONE, &icon_title,
			"Enable the setting of the icon title", NULL
		},
		{
			"keep", 'k', 0,
			G_OPTION_ARG_NONE, &keep,
			"Live on after the window closes", NULL
		},
		{
			"scrollback-lines", 'n', 0,
			G_OPTION_ARG_INT, &lines,
			"Specify the number of scrollback-lines", NULL
		},
		{
			"color-cursor", 'r', 0,
			G_OPTION_ARG_NONE, &cursor_set,
			"Enable a colored cursor", NULL
		},
		{
			"cursor-shape", 0, 0,
			G_OPTION_ARG_STRING, &cursor_shape_string,
			"Set cursor shape (block|underline|ibeam)", NULL
		},
		{
			"scroll-background", 's', 0,
			G_OPTION_ARG_NONE, &scroll,
			"Enable a scrolling background", NULL
		},
		{
			"termcap", 't', 0,
			G_OPTION_ARG_STRING, &termcap,
			"Specify the terminal emulation to use", NULL
		},
		{
			"working-directory", 'w', 0,
			G_OPTION_ARG_FILENAME, &working_directory,
			"Specify the initial working directory of the terminal",
			NULL
		},
		{
			"reverse", 0, 0,
			G_OPTION_ARG_NONE, &reverse,
			"Reverse foreground/background colors", NULL
		},
		{
			"no-geometry-hints", 'G', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &use_geometry_hints,
			"Allow the terminal to be resized to any dimension, not constrained to fit to an integer multiple of characters",
			NULL
		},
		{
			"scrolled-window", 'W', 0,
			G_OPTION_ARG_NONE, &use_scrolled_window,
			"Use a GtkScrolledWindow as terminal container",
			NULL
		},
		{
			"scrollbar-policy", 'P', 0,
			G_OPTION_ARG_STRING, &scrollbar_policy_string,
			"Set the policy for the vertical scroolbar in the scrolled window (always|auto|never; default:always)",
			NULL
		},
		{
			"object-notifications", 'N', 0,
			G_OPTION_ARG_NONE, &show_object_notifications,
			"Print VteTerminal object notifications",
			NULL
		},
		{
			"output-file", 0, 0,
			G_OPTION_ARG_STRING, &output_file,
			"Save terminal contents to file at exit", NULL
		},
		{
			"pty-flags", 0, 0,
			G_OPTION_ARG_STRING, &pty_flags_string,
			"PTY flags set from default|no-utmp|no-wtmp|no-lastlog|no-helper|no-fallback", NULL
		},
		{ NULL }
	};
	GOptionContext *context;
	GError *error = NULL;
        VteTerminalCursorShape cursor_shape = VTE_CURSOR_SHAPE_BLOCK;
        GtkPolicyType scrollbar_policy = GTK_POLICY_ALWAYS;
        VtePtyFlags pty_flags = VTE_PTY_DEFAULT;

	/* Have to do this early. */
	if (getenv("VTE_PROFILE_MEMORY")) {
		if (atol(getenv("VTE_PROFILE_MEMORY")) != 0) {
			g_mem_set_vtable(glib_mem_profiler_table);
		}
	}

	context = g_option_context_new (" - test VTE terminal emulation");
	g_option_context_add_main_entries (context, options, NULL);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_parse (context, &argc, &argv, &error);
	g_option_context_free (context);
	if (error != NULL) {
		g_printerr ("Failed to parse command line arguments: %s\n",
				error->message);
		g_error_free (error);
		return 1;
	}

        if (cursor_shape_string) {
                cursor_shape = parse_enum(VTE_TYPE_TERMINAL_CURSOR_SHAPE, cursor_shape_string);
                g_free(cursor_shape_string);
        }
        if (scrollbar_policy_string) {
                scrollbar_policy = parse_enum(GTK_TYPE_POLICY_TYPE, scrollbar_policy_string);
                g_free(scrollbar_policy_string);
        }
        if (pty_flags_string) {
                pty_flags |= parse_flags(VTE_TYPE_PTY_FLAGS, pty_flags_string);
                g_free(pty_flags_string);
        }

	if (!reverse) {
		back.red = back.green = back.blue = 0xffff;
		fore.red = fore.green = fore.blue = 0x0000;
	} else {
		back.red = back.green = back.blue = 0x0000;
		fore.red = fore.green = fore.blue = 0xffff;
	}

	highlight.red = highlight.green = highlight.blue = 0xc000;
	cursor.red = 0xffff;
	cursor.green = cursor.blue = 0x8000;
	tint.red = tint.green = tint.blue = 0;
	tint = back;

	gdk_window_set_debug_updates(debug);

	/* Create a window to hold the scrolling shell, and hook its
	 * delete event to the quit function.. */
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_resize_mode(GTK_CONTAINER(window),
				      GTK_RESIZE_IMMEDIATE);

	/* Set ARGB colormap */
	screen = gtk_widget_get_screen (window);
	colormap = gdk_screen_get_rgba_colormap (screen);
	if (colormap)
	    gtk_widget_set_colormap(window, colormap);

        if (use_scrolled_window) {
                scrolled_window = gtk_scrolled_window_new (NULL, NULL);
                gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
                                               GTK_POLICY_NEVER, scrollbar_policy);
                gtk_container_add(GTK_CONTAINER(window), scrolled_window);
        } else {
                /* Create a box to hold everything. */
                hbox = gtk_hbox_new(0, FALSE);
                gtk_container_add(GTK_CONTAINER(window), hbox);
        }

	/* Create the terminal widget and add it to the scrolling shell. */
	widget = vte_terminal_new();
	terminal = VTE_TERMINAL (widget);
	if (!dbuffer) {
		gtk_widget_set_double_buffered(widget, dbuffer);
	}
        g_signal_connect(terminal, "child-exited", G_CALLBACK(child_exit_cb), NULL);
        if (show_object_notifications)
                g_signal_connect(terminal, "notify", G_CALLBACK(terminal_notify_cb), NULL);
        if (use_scrolled_window) {
                gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(terminal));
        } else {
                gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
        }

	/* Connect to the "char_size_changed" signal to set geometry hints
	 * whenever the font used by the terminal is changed. */
	if (use_geometry_hints) {
		char_size_changed(widget, 0, 0, window);
		g_signal_connect(widget, "char-size-changed",
				 G_CALLBACK(char_size_changed), window);
		g_signal_connect(widget, "realize",
				 G_CALLBACK(char_size_realized), window);
	}

	/* Connect to the "window_title_changed" signal to set the main
	 * window's title. */
	g_signal_connect(widget, "window-title-changed",
			 G_CALLBACK(window_title_changed), window);
	if (icon_title) {
		g_signal_connect(widget, "icon-title-changed",
				 G_CALLBACK(icon_title_changed), window);
	}

	/* Connect to the "status-line-changed" signal. */
	g_signal_connect(widget, "status-line-changed",
			 G_CALLBACK(status_line_changed), widget);

	/* Connect to the "button-press" event. */
	g_signal_connect(widget, "button-press-event",
			 G_CALLBACK(button_pressed), widget);

	/* Connect to application request signals. */
	g_signal_connect(widget, "iconify-window",
			 G_CALLBACK(iconify_window), window);
	g_signal_connect(widget, "deiconify-window",
			 G_CALLBACK(deiconify_window), window);
	g_signal_connect(widget, "raise-window",
			 G_CALLBACK(raise_window), window);
	g_signal_connect(widget, "lower-window",
			 G_CALLBACK(lower_window), window);
	g_signal_connect(widget, "maximize-window",
			 G_CALLBACK(maximize_window), window);
	g_signal_connect(widget, "restore-window",
			 G_CALLBACK(restore_window), window);
	g_signal_connect(widget, "refresh-window",
			 G_CALLBACK(refresh_window), window);
	g_signal_connect(widget, "resize-window",
			 G_CALLBACK(resize_window), window);
	g_signal_connect(widget, "move-window",
			 G_CALLBACK(move_window), window);

	/* Connect to font tweakage. */
	g_signal_connect(widget, "increase-font-size",
			 G_CALLBACK(increase_font_size), window);
	g_signal_connect(widget, "decrease-font-size",
			 G_CALLBACK(decrease_font_size), window);

        if (!use_scrolled_window) {
                /* Create the scrollbar for the widget. */
                scrollbar = gtk_vscrollbar_new(terminal->adjustment);
                gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0);
        }

	/* Set some defaults. */
	vte_terminal_set_audible_bell(terminal, audible);
	vte_terminal_set_visible_bell(terminal, !audible);
	vte_terminal_set_cursor_blink_mode(terminal, blink ? VTE_CURSOR_BLINK_SYSTEM : VTE_CURSOR_BLINK_OFF);
	vte_terminal_set_scroll_background(terminal, scroll);
	vte_terminal_set_scroll_on_output(terminal, FALSE);
	vte_terminal_set_scroll_on_keystroke(terminal, TRUE);
	vte_terminal_set_scrollback_lines(terminal, lines);
	vte_terminal_set_mouse_autohide(terminal, TRUE);
	if (background != NULL) {
		vte_terminal_set_background_image_file(terminal,
						       background);
	}
	if (transparent) {
		vte_terminal_set_background_transparent(terminal,
							TRUE);
	}
	vte_terminal_set_background_tint_color(terminal, &tint);
	vte_terminal_set_colors(terminal, &fore, &back, NULL, 0);
	vte_terminal_set_opacity(terminal, 0xdddd);
	if (highlight_set) {
		vte_terminal_set_color_highlight(terminal,
						 &highlight);
	}
	if (cursor_set) {
		vte_terminal_set_color_cursor(terminal, &cursor);
	}
	if (termcap != NULL) {
		vte_terminal_set_emulation(terminal, termcap);
	}
        vte_terminal_set_cursor_shape(terminal, cursor_shape);

	/* Set the default font. */
	vte_terminal_set_font_from_string_full(terminal, font,
					       antialias ? VTE_ANTI_ALIAS_USE_DEFAULT : VTE_ANTI_ALIAS_FORCE_DISABLE);

	/* Match "abcdefg". */
	if (dingus) {
		int id;
		GRegex *regex;
		regex = g_regex_new (DINGUS1, 0, 0, NULL);
		id = vte_terminal_match_add_gregex(terminal, regex, 0);
		g_regex_unref (regex);
		vte_terminal_match_set_cursor_type(terminal,
						   id, GDK_GUMBY);
		regex = g_regex_new (DINGUS2, 0, 0, NULL);
		id = vte_terminal_match_add_gregex(terminal, regex, 0);
		g_regex_unref (regex);
		vte_terminal_match_set_cursor_type(terminal,
						   id, GDK_HAND1);
	}

	if (console) {
		/* Open a "console" connection. */
		int consolefd = -1, yes = 1, watch;
		GIOChannel *channel;
		consolefd = open("/dev/console", O_RDONLY | O_NOCTTY);
		if (consolefd != -1) {
			/* Assume failure. */
			console = FALSE;
#ifdef TIOCCONS
			if (ioctl(consolefd, TIOCCONS, &yes) != -1) {
				/* Set up a listener. */
				channel = g_io_channel_unix_new(consolefd);
				watch = g_io_add_watch(channel,
						       G_IO_IN,
						       read_and_feed,
						       widget);
				g_signal_connect(widget,
						 "eof",
						 G_CALLBACK(disconnect_watch),
						 GINT_TO_POINTER(watch));
				g_signal_connect(widget,
						 "child-exited",
						 G_CALLBACK(disconnect_watch),
						 GINT_TO_POINTER(watch));
				g_signal_connect(widget,
						 "realize",
						 G_CALLBACK(take_xconsole_ownership),
						 NULL);
#ifdef VTE_DEBUG
				vte_terminal_feed(terminal,
						  "Console log for ...\r\n",
						  -1);
#endif
				/* Record success. */
				console = TRUE;
			}
#endif
		} else {
			/* Bail back to normal mode. */
			g_warning(_("Could not open console.\n"));
			close(consolefd);
			console = FALSE;
		}
	}

	if (!console) {
		if (shell) {
                        GError *err = NULL;
                        char **command_argv = NULL;
                        int command_argc;
                        GPid pid = -1;

			_VTE_DEBUG_IF(VTE_DEBUG_MISC)
				vte_terminal_feed(terminal, message, -1);

                        if (command == NULL)
                                command = "/bin/sh"; // FIXMEchpe

                        if (command != NULL) {
                                if (!g_shell_parse_argv(command, &command_argc, &command_argv, &err) ||
                                    !vte_terminal_fork_command_full(terminal,
                                                                    pty_flags,
                                                                    NULL,
                                                                    command_argv,
                                                                    env_add,
                                                                    G_SPAWN_SEARCH_PATH,
                                                                    NULL, NULL,
                                                                    &pid,
                                                                    &err)) {
                                        g_warning("Failed to fork: %s\n", err->message);
                                        g_error_free(err);
                                } else {
                                        g_print("Fork succeeded, PID %d\n", pid);
                                }
                        }
                        g_strfreev(command_argv);
	#ifdef VTE_DEBUG
			if (command == NULL) {
				vte_terminal_feed_child(terminal,
							"pwd\n", -1);
			}
	#endif
		} else {
			long i;
			i = vte_terminal_forkpty(terminal,
						 env_add, working_directory,
						 TRUE, TRUE, TRUE);
			switch (i) {
			case -1:
				/* abnormal */
				g_warning("Error in vte_terminal_forkpty(): %s",
					  strerror(errno));
				break;
			case 0:
				/* child */
				for (i = 0; ; i++) {
					switch (i % 3) {
					case 0:
					case 1:
						g_print("%ld\n", i);
						break;
					case 2:
						g_printerr("%ld\n", i);
						break;
					}
					sleep(1);
				}
				_exit(0);
				break;
			default:
				g_print("Child PID is %ld (mine is %ld).\n",
					(long) i, (long) getpid());
				/* normal */
				break;
			}
		}
	}

	g_object_set_data (G_OBJECT (widget), "output_file", (gpointer) output_file);

	/* Go for it! */
	g_signal_connect(widget, "child-exited", G_CALLBACK(child_exited), window);
	g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), widget);

	add_weak_pointer(G_OBJECT(widget), &widget);
	add_weak_pointer(G_OBJECT(window), &window);

        gtk_widget_realize(widget);
        if (geometry) {
                if (!gtk_window_parse_geometry (GTK_WINDOW(window), geometry)) {
                        g_warning (_("Could not parse the geometry spec passed to --geometry"));
                }
        }

	gtk_widget_show_all(window);

	gtk_main();

	g_assert(widget == NULL);
	g_assert(window == NULL);

	if (keep) {
		while (TRUE) {
			sleep(60);
		}
	}

	return 0;
}