Chinaunix首页 | 论坛 | 博客
  • 博客访问: 231737
  • 博文数量: 51
  • 博客积分: 113
  • 博客等级: 民兵
  • 技术积分: 285
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-14 17:31
文章分类

全部博文(51)

文章存档

2012年(51)

分类:

2012-11-27 09:39:22

原文地址: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+

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