我用 glade 创建了一个 UI。
当我运行程序时,它没有给出任何错误,但也没有显示主窗口。它只是退出。
我的完整 UI 文件位于https://paste.gnome.org/pfxz888er 完整的 C 程序位于https://paste.gnome.org/p7rxhhbk2
请告诉我我的代码是否有问题。重要的部分是:
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gprintf.h>
static void create (GtkApplication *app, gpointer user_data)
{
GtkBuilder *main_interface;
main_interface = gtk_builder_new_from_file ("/home/aj/learning/front.glade");
// gtk_builder_connect_signals (main_interface,NULL);
gtk_builder_add_callback_symbol (main_interface,
"cb_about",
G_CALLBACK(cb_about));
gtk_builder_add_callback_symbol (main_interface,
"cb_enc_mode",
G_CALLBACK(cb_enc_mode));
..... all other callbacks........
GObject *top_window;
top_window = gtk_builder_get_object (main_interface,
"top_window");
gtk_widget_show_all (GTK_WIDGET(top_window));
}
int main (int argc, char *argv[])
{
int status;
GtkApplication *app;
app = gtk_application_new ("org.aj.gui",G_APPLICATION_FLAGS_NONE);
g_signal_connect(app,"activate",G_CALLBACK(create),NULL);
status = g_application_run (G_APPLICATION(app),argc,argv);
g_object_unref (app);
return status;
}