我是GTK的新手,我正在使用它在C中创建UI.我创建了一个启动画面,我可以在指定的秒后使用该功能关闭它g_timeout_add(100, function_to_call, NULL);.Splash屏幕效果很好.但问题是当我进一步扩展我的程序时(即)关闭启动画面后我想要另一个窗口自动显示,它不会发生.两个窗户一起打开.这是我的计划.
gboolean function_to_call(gpointer data){
gtk_quit_main();
return(FALSE);
}
int main (int argc, char *argv[]){
GtkWidget *window, *image, *another_window;
gtk_init(&argc, &argv);
.
.
.
.
.
.
.
g_timeout_add (100, function_to_call, NULL);
gtk_main ();
/*if my program is till this, splash screen closes after 1 sec . But when i try
*to define another window from here onwards and call gtk_widget_show() and gtk_main()
*again for another_ window, window and another_window both open together and window
*doesn't close after 1 sec. */
}
Run Code Online (Sandbox Code Playgroud)
任何形式的帮助都是值得赞赏的.
谢谢.
你的function_to_call没有关闭你的启动窗口,它结束了gtk_main事件循环.您不需要结束事件循环.
你想做的事情function_to_call就是隐藏(或破坏)你的启动窗口并显示你的下一个窗口(gtk_widget_hide(),gtk_widget_show()).