GTK+ and Glade3 GUI Programming

http://www.cnblogs.com/gala/archive/2011/10/14/2211121.html

参考资料

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
#include

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或其他,程序即可正常执行。



分类: GTK+

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(923) | 评论(0) | 转发(4) |
给主人留下些什么吧!~~
评论热议
posted @ 2016-03-30 10:33  张同光  阅读(207)  评论(0编辑  收藏  举报