我花了很多时间尝试使用gtk + 3.22来构建Visual Studio 2015.最后我建立了它,但是小GUI程序无法初始化gtk。错误如下所示:
gtk+_gtk_test.exe:15980): Gtk-WARNING **: Could not find the icon 'window-minimize-symbolic-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
http://icon-theme.freedesktop.org/releases
(gtk+_gtk_test.exe:15980): GLib-GObject-WARNING **: cannot register existing type 'PangoCairoFont'
(gtk+_gtk_test.exe:15980): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed
(gtk+_gtk_test.exe:15980): Glib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
存在第一个警告,因为可执行文件无法找到图标文件。我已经想出了如何解决这个问题。但是,我无法修复第二个警告。这是我的第一个gtk +项目。当我调试代码时,由于存在PangoCairoWin32Font类型,似乎PangoCairoFont类型失败。
这里有什么问题?感谢您的建议。
该计划的源代码:
#include <gtk/gtk.h>
void hello(GtkWidget *widget, gpointer data)
{
g_print("Hello, World\n");
}
gint delete_event(GtkWidget *widget, GdkEvent event, gpointer data)
{
/* when this fucntion returns FALSE, the delete-event
signal becomes a destroy signal*/
return FALSE;
}
void end_program(GtkWidget *widget, gpointer data)
{
/* End the main loop */
gtk_main_quit();
}
int main(int argc, char **argv)
{
GtkWindow *window;
GtkButton *button;
/* initialize Gtk+ */
gtk_init(&argc, &argv);
/* create window, set default height and width to 200px */
window = g_object_new(GTK_TYPE_WINDOW,
"default-height", 200,
"default-width", 200,
"border-width", 12,
"title", "GtkHello",
NULL);
/* add signal handlers for window */
g_signal_connect(window, "delete-event", G_CALLBACK(delete_event),
NULL);
g_signal_connect(window,
"destroy", G_CALLBACK(end_program),
NULL);
/* create button */
button = g_object_new(GTK_TYPE_BUTTON,
"label", "_Hello, World!\nClick here.",
"use-underline", TRUE,
NULL);
g_signal_connect(button,
"clicked", G_CALLBACK(hello),
NULL);
g_signal_connect_swapped(button,
"clicked", G_CALLBACK(gtk_widget_destroy),
window);
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(button));
gtk_widget_show_all(GTK_WIDGET(window));
/* start main loop */
gtk_main();
return 0;
}
答案 0 :(得分:0)