我在网上找到了一个用C语言写的程序,我正在试着为它实现一个图标。我找遍了所有的地方,但是没有找到一个合适的答案。
#include <vte/vte.h>
static void
child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data)
{
if (!terminal) return;
if (pid == -1) gtk_main_quit();
}
int
main(int argc, char *argv[])
{
GtkWidget *window, *terminal;
/* Initialise GTK, the window and the terminal */
gtk_init(&argc, &argv);
terminal = vte_terminal_new();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "myterm");
/* Start a new shell */
gchar **envp = g_get_environ();
gchar **command = (gchar *[]){g_strdup(g_environ_getenv(envp, "SHELL")), NULL };
g_strfreev(envp);
vte_terminal_spawn_async(VTE_TERMINAL(terminal),
VTE_PTY_DEFAULT,
NULL, /* working directory */
command, /* command */
NULL, /* environment */
0, /* spawn flags */
NULL, NULL, /* child setup */
NULL, /* child pid */
-1, /* timeout */
NULL, /* cancellable */
child_ready, /* callback */
NULL); /* user_data */
/* Connect some signals */
g_signal_connect(window, "delete-event", gtk_main_quit, NULL);
g_signal_connect(terminal, "child-exited", gtk_main_quit, NULL);
vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), 0);
vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), FALSE);
vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE);
vte_terminal_set_mouse_autohide(VTE_TERMINAL(terminal), TRUE);
/* Put widgets together and run the main loop */
gtk_container_add(GTK_CONTAINER(window), terminal);
gtk_widget_show_all(window);
gtk_main();
}
我在网上找到了一个用C语言写的程序,我正在试着为它实现一个图标。我找遍了所有的地方,但是没有找到一个合适的答案。
1条答案
按热度按时间thigvfpy1#
你需要像这样在窗口上设置图标: