GTK+ and Glade3 GUI Programming
参考资料
GTK+ and Glade3 GUI Programming Tutorial (English)
http://www.micahcarrick.com/gtk-glade-tutorial-part-1.html
GTK+ and Glade3 GUI Programming Tutorial (Chinese)
http://blog.csdn.net/xbwee/article/details/4032652
Say Hello to Glade
http://www.cppblog.com/len/archive/2008/03/27/45548.html
Creating GtkTreeView with Glade-3, part 1
http://tadeboro.blogspot.com/2009/04/creatin-gtktreeview-with-glade-3.html
Creating GtkTreeView with Glade-3, part 2
http://tadeboro.blogspot.com/2009/04/creating-gtktreeview-with-glade-3-part.html
问题总结
练习Say Hello to Glade
//Say Hello to Glade
//编译后执行出现下面错误
[kang@Gala glade]$ ./t
(t:2209): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed
//解决办法:
//在Glade界面窗口修改window的窗口名称与程序代码window=glade_xml_get_widget(gxml,"test")中保持一致,即可成功执行
回调函数和系统调用重名
//程序
[kang@Gala glade]$ cat test.c
#include <gtk/gtk.h>
#include <glade/glade.h>
void close(GtkWidget *window, gpointer data)
{
gtk_main_quit();
}
int main(int argc, char* argv[])
{
GladeXML *gxml;
GtkWidget *window;
gtk_init(&argc,&argv);
gxml=glade_xml_new("login.glade",NULL,NULL);
window=glade_xml_get_widget(gxml,"login");
g_object_unref(G_OBJECT(gxml));
g_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(close),NULL);
gtk_widget_show(window);
gtk_main();
return 0;
}
//编译正常
[kang@Gala glade]$ gcc -o log test.c `pkg-config --cflags --libs gtk+-2.0 libglade-2.0` -g
//运行出错
[kang@Gala glade]$ ./log
(log:2659): Gtk-CRITICAL **: gtk_main_quit: assertion `main_loops != NULL' failed
(log:2659): Gtk-CRITICAL **: gtk_main_quit: assertion `main_loops != NULL' failed
................................................................
(log:2659): Gtk-CRITICAL **: gtk_main_quit: assertion `main_loops != NULL' failed
(log:2659): Gtk-CRITICAL **: gtk_main_quit: assertion `main_loops != NULL' failed
//问题处理
由于close是linux系统调用函数,改成closeApp或其他,程序即可正常执行。