红联Linux门户
Linux帮助

询问高手 GTK+ 里的一个困扰我很长时间的问题

发布时间:2007-06-22 10:14:10来源:红联作者:shaochong888
今天写的GTK+的程序,程序如下:
1 #include
2
3 gint x = 50;
4 gint y = 50;
5
6 void move_button( GtkWidget * widget, GtkWidget * fixed )
7 {
8 x = ( x + 30 ) % 300;
9 y = ( y + 50 ) % 300;
10 gtk_fixed_move( GTK_FIXED( fixed ), widget, x, y );
11 }
12
13
14 int main( int argc, char * argv[] )
15 {
16 GtkWidget * window;
17 GtkWidget * fixed;
18 GtkWidget * button;
19
20 gtk_init( & argc, & argv );
21
22 window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
23 gtk_window_set_title( GTK_WINDOW(window) , "fixed container" );
24
25 gtk_signal_connect( GTK_OBJECT( window ), "destory",
26 GTK_SIGNAL_FUNC( gtk_main_quit ) , NULL );
27
28 gtk_container_set_border_width( GTK_CONTAINER(window), 10 );
29
30 fixed = gtk_fixed_new();
31 gtk_container_add( GTK_CONTAINER( window ), fixed );
32 gtk_widget_show( fixed );
33 int i ;
34
35
36
37 for ( i = 1; i <= 3; i++ )
38 {
39 button = gtk_button_new_with_label( "press me" );
40 gtk_signal_connect( "GTK_OBJECT( button )", "clicked",
41 GTK_SIGNAL_FUNC( move_button ), fixed );
42
43 gtk_fixed_put( GTK_FIXED( fixed ), button, i * 50, i * 50 );
44 gtk_widget_show( button );
45
46 }
47
48 gtk_widget_show( window );
49
50 gtk_main();
51 return 0;
52 }

编译的时候总是报gtk4.c: In function `main':
gtk4.c:41: warning: passing arg 1 of `gtk_signal_connect' from incompatible pointer type

然后运行报错
Gtk-WARNING **: gtk_signal_connect(): could not find signal "destory" in the `GtkWindow' class ancestry
段错误


还有我的很多程序如果有 gtk_signal_connect( GTK_OBJECT( window ), "destory",
GTK_SIGNAL_FUNC( gtk_main_quit ) , NULL );

的语句 运行结果都是 Gtk-WARNING **: gtk_signal_connect(): could not find signal "destory" in the `GtkWindow' class ancestry
段错误
第一次发贴子,希望大家能帮助我


我的LINUX系统是 redhat linux enterprise 3 内核是 2.4.21-32.el



还望大家给与帮助,谢谢
文章评论

共有 1 条评论

  1. yangLinux 于 2007-07-26 14:35:59发表:

    g_signal_connect( GTK_OBJECT( window ), "destory",G_CALLBACK( gtk_main_quit ) , NULL );