当前位置: 技术问答>linux和unix
有关GTK_TEXT(text)->vadj的问题
来源: 互联网 发布时间:2015-09-22
本文导语: 我用GTK+写了一个linux下的图形界面小程序,但是编译的时间报错,请高手给指点一下吧。我已经找了好长时间也没找到答案。 源代码: #include #include gint delete_event(GtkWidget * window ,gpointer data) { gtk_main_quit...
我用GTK+写了一个linux下的图形界面小程序,但是编译的时间报错,请高手给指点一下吧。我已经找了好长时间也没找到答案。
源代码:
#include
#include
gint delete_event(GtkWidget * window ,gpointer data)
{
gtk_main_quit();
return FALSE;
}
int main(int argc ,char * argv[])
{
GtkWidget * window;
GtkWidget * box;
GtkWidget * text;
GtkWidget * table;
GtkWidget * hscroll;
GtkWidget * vscroll;
gtk_init(&argc,&argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(delete_event),NULL);
gtk_window_set_title(GTK_WINDOW(window),"Editor");
gtk_container_set_border_width(GTK_CONTAINER(window),400);
box=gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(window),box);
gtk_widget_show(box);
table=gtk_table_new(2,2,FALSE);
gtk_box_pack_start(GTK_BOX(box),table,TRUE,TRUE,0);
gtk_widget_show(table);
text=gtk_text_new(NULL,NULL);
gtk_table_attach(GTK_TABLE(table),text,0,1,0,1,GTK_SHRINK|GTK_FILL|GTK_EXPAND,GTK_EXPAND|GTK_FILL|GTK_SHRINK,0,0);
gtk_widget_show(text);
hscroll=gtk_hscrollbar_new(GTK_TEXT(text)->hadj);
gtk_table_attach(GTK_TABLE(table),hscroll,0,1,1,2,GTK_EXPAND|GTK_FILL|GTK_SHRINK,GTK_FILL,0,0);
gtk_widget_show(hscroll);
vscroll=gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
gtk_table_attach(GTK_TABLE(table),vscroll,1,2,0,1,GTK_FILL,GTK_SHRINK|GTK_FILL|GTK_EXPAND,0,0);
gtk_widget_show(vscroll);
gtk_show(window);
gtk_main();
return 0;
}
使用如下命令编译: gcc Editor.c -o Editor `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
提示信息:
Editor.c: In function `main':
Editor.c:31: warning: assignment makes pointer from integer without a cast
Editor.c:35: invalid type argument of `->'
Editor.c:39: invalid type argument of `->'
Editor.c:46:2: warning: no newline at end of file
我实在是找不出该如何解决来,请高手指点。我是在红帽9下编译的。
源代码:
#include
#include
gint delete_event(GtkWidget * window ,gpointer data)
{
gtk_main_quit();
return FALSE;
}
int main(int argc ,char * argv[])
{
GtkWidget * window;
GtkWidget * box;
GtkWidget * text;
GtkWidget * table;
GtkWidget * hscroll;
GtkWidget * vscroll;
gtk_init(&argc,&argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(delete_event),NULL);
gtk_window_set_title(GTK_WINDOW(window),"Editor");
gtk_container_set_border_width(GTK_CONTAINER(window),400);
box=gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(window),box);
gtk_widget_show(box);
table=gtk_table_new(2,2,FALSE);
gtk_box_pack_start(GTK_BOX(box),table,TRUE,TRUE,0);
gtk_widget_show(table);
text=gtk_text_new(NULL,NULL);
gtk_table_attach(GTK_TABLE(table),text,0,1,0,1,GTK_SHRINK|GTK_FILL|GTK_EXPAND,GTK_EXPAND|GTK_FILL|GTK_SHRINK,0,0);
gtk_widget_show(text);
hscroll=gtk_hscrollbar_new(GTK_TEXT(text)->hadj);
gtk_table_attach(GTK_TABLE(table),hscroll,0,1,1,2,GTK_EXPAND|GTK_FILL|GTK_SHRINK,GTK_FILL,0,0);
gtk_widget_show(hscroll);
vscroll=gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
gtk_table_attach(GTK_TABLE(table),vscroll,1,2,0,1,GTK_FILL,GTK_SHRINK|GTK_FILL|GTK_EXPAND,0,0);
gtk_widget_show(vscroll);
gtk_show(window);
gtk_main();
return 0;
}
使用如下命令编译: gcc Editor.c -o Editor `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
提示信息:
Editor.c: In function `main':
Editor.c:31: warning: assignment makes pointer from integer without a cast
Editor.c:35: invalid type argument of `->'
Editor.c:39: invalid type argument of `->'
Editor.c:46:2: warning: no newline at end of file
我实在是找不出该如何解决来,请高手指点。我是在红帽9下编译的。
|
加我的QQ嘛,95384015