Chinaunix首页 | 论坛 | 博客
  • 博客访问: 429673
  • 博文数量: 133
  • 博客积分: 936
  • 博客等级: 准尉
  • 技术积分: 1069
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-31 15:54
文章分类

全部博文(133)

文章存档

2016年(19)

2013年(22)

2012年(92)

分类:

2012-10-17 18:28:25

原文地址:GTK+ and Glade3 GUI Programming 作者:ztguang

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

参考资料

GTK+ and Glade3 GUI Programming Tutorial (English)
http://

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+

阅读(932) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~