我们可以在GTK4窗口上使用Libvte终端小部件吗?
我想在此GTK4窗口上使用libvte。但是在编译期间面对问题,以下给出的演示脚本。谁能告诉我GTK4是否支持Libvte-2.91?我在Ubuntu 22.04lts上,
$ gcc -Wall $(pkg-config --cflags gtk4 vte-2.91) gtk4App.c -o term $(pkg-config --libs gtk4 vte-2.91)
ERROR SHOW--------------
In file included from /usr/include/vte-2.91/vte/vte.h:33,
from gtk4App.c:2:
/usr/include/vte-2.91/vte/vtetypebuiltins.h:27:10: fatal error: vtetypebuiltins-gtk4.h: No such file or directory
27 | #include "vtetypebuiltins-gtk4.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
这是GTK4脚本------
#include <gtk/gtk.h>
#include <vte/vte.h>
//sudo apt install libgtk-4-dev libvte-2.91-dev
//gcc -Wall $(pkg-config --cflags gtk4 vte-2.91) gtk4App.c -o term $(pkg-config --libs gtk4 vte-2.91)
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *terminal;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
GtkWidget *grid = gtk_grid_new ();
gtk_window_set_child ((GtkWindow *)window, grid);
gtk_widget_set_vexpand(grid, TRUE);
gtk_widget_set_hexpand(grid, TRUE);
GtkWidget *scrollview1;
scrollview1 = gtk_scrolled_window_new();
gtk_grid_attach(GTK_GRID(grid), scrollview1, 0, 0, 1, 1);
terminal = vte_terminal_new();
gtk_window_set_child ((GtkWindow *)scrollview1, terminal);
gtk_widget_show (window);
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
我知道Libvte与GTK+3.0工作正常,但我想在GTK4上使用它。
I want to use libvte on this gtk4 window. But facing issue during compile, demo script given below. Can anyone tell me whether libvte-2.91 is supported with gtk4? I'm on Ubuntu 22.04LTS
$ gcc -Wall $(pkg-config --cflags gtk4 vte-2.91) gtk4App.c -o term $(pkg-config --libs gtk4 vte-2.91)
ERROR SHOW--------------
In file included from /usr/include/vte-2.91/vte/vte.h:33,
from gtk4App.c:2:
/usr/include/vte-2.91/vte/vtetypebuiltins.h:27:10: fatal error: vtetypebuiltins-gtk4.h: No such file or directory
27 | #include "vtetypebuiltins-gtk4.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
This is the gtk4 script-----
#include <gtk/gtk.h>
#include <vte/vte.h>
//sudo apt install libgtk-4-dev libvte-2.91-dev
//gcc -Wall $(pkg-config --cflags gtk4 vte-2.91) gtk4App.c -o term $(pkg-config --libs gtk4 vte-2.91)
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *terminal;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
GtkWidget *grid = gtk_grid_new ();
gtk_window_set_child ((GtkWindow *)window, grid);
gtk_widget_set_vexpand(grid, TRUE);
gtk_widget_set_hexpand(grid, TRUE);
GtkWidget *scrollview1;
scrollview1 = gtk_scrolled_window_new();
gtk_grid_attach(GTK_GRID(grid), scrollview1, 0, 0, 1, 1);
terminal = vte_terminal_new();
gtk_window_set_child ((GtkWindow *)scrollview1, terminal);
gtk_widget_show (window);
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
I know libvte working fine with gtk+3.0,,but i want to use it on gtk4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我确实将您的示例代码编译并在Ubuntu 22.04虚拟机上执行。以下是我为完成这项工作的步骤。
首先,我没有从软件包管理器中安装“ libvte-2.91-dev”库,而是去GitHub存储库获取“ VTE”库( https://github.com/gnome/vte )并克隆了代码。在运行安装步骤中指出的Meson和Ninja构建命令之前,我修改了“ Meson_options.txt”文件,以启用对“ VTE”库的“ GTK4”支持的构建,从“真实”。
然后,我介入了GitHub存储库中指出的构建方向。
我在“ ninja -c _build install”的前面添加了“ sudo”命令。否则,我相信该系统仍将提示输入密码。
执行了这些步骤后,不仅是GTK3支持的“ VTE”库,而且还建立了用于GTK4支持的“ VTE”库。因此,可以看到库进行程序执行,我运行了“ ldconfig”命令,该命令更新了库搜索路径。
然后,我将您的示例代码复制到文本文件中,将其命名为“ GTK4App.c”,然后运行“ GCC”编译器,并在您的参数值中进行以下修订版。
库“ LIBVTE-2.91-GTK4”设置与库“ Libvte-2.91”相邻。
编译样本程序后,我启动了该程序并获得了示例终端。
最后要注意的是,当我运行Meson Build命令时,有警告指出GTK4支持是实验性的。因此,请记住这一点。
我希望这为您阐明一切。
问候。
I did get your sample code to compile and executed on my Ubuntu 22.04 virtual machine. Following were the steps I performed to make that work.
First, rather than installing the "libvte-2.91-dev" library from the package manager, I went out to the Github repository for the "vte" library (https://github.com/GNOME/vte) and cloned the code. Prior to running the meson and ninja build commands as noted in the installation steps, I revised the "meson_options.txt" file to enable the building of "GTK4" support for the "vte" libraries, changing the "value" attribute from "false" to "true".
I then stepped through the build directions noted from the Github repository.
I added the "sudo" command in front of the "ninja -C _build install". Otherwise, I believe the system will still prompt for a password.
Having performed these steps, not only was the "vte" library in place for GTK3 support, but the "vte" library for GTK4 support was built as well. So that the libraries were visible for program execution, I ran the "ldconfig" command which updated the library search path.
I then copied your sample code to a text file, naming it "gtk4App.c" and then ran the "gcc" compiler with the following revision to your parameter values.
Library "libvte-2.91-gtk4" sets adjacent to library "libvte-2.91".
After compiling the sample program, I launched the program and got a sample terminal.
The last item to note that when I ran the meson build command, there was a warning noting that the GTK4 support was experimental. So please bear that in mind.
I hope that clarifies everything for you.
Regards.