概述
Fedora环境下Gtk+开发环境配置
————————————————————————————————
1、安装必要组建:(在root权限下)yum install gtk2 gtk2-devel gtk2-devel-docs
2、可能还需要组建(可选,不行再装):yum install gnome-devel gnome-devel-docs
3、编写测试程序:
#include
<
gtk
/
gtk.h
>
void hello(GtkWidget * widget,gpointer data)
{
g_print( " Hello Ubuntu!n " );
}
gint delete_event(GtkWidget * widget,GdkEvent * event ,gpointer data)
{
g_print ( " delete event occurredn " );
return (TRUE);
}
void destroy(GtkWidget * widget,gpointer data)
{
gtk_main_quit();
}
int main( int argc, char * argv[] )
{
GtkWidget * window;
GtkWidget * button;
gtk_init ( & argc, & argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT(window), " delete_event " ,GTK_SIGNAL_FUNC(delete_event),NULL);
gtk_signal_connect (GTK_OBJECT (window), " destroy " ,GTK_SIGNAL_FUNC (destroy), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10 );
button = gtk_button_new_with_label ( " Hello Ubuntu! " );
gtk_signal_connect (GTK_OBJECT (button), " clicked " ,GTK_SIGNAL_FUNC (hello), NULL);
gtk_signal_connect_object (GTK_OBJECT (button), " clicked " ,GTK_SIGNAL_FUNC (gtk_widget_destroy),GTK_OBJECT (window));
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window); /* 显示一个窗口 */
gtk_main(); /* 进入主循环 */
return ( 0 );
}
void hello(GtkWidget * widget,gpointer data)
{
g_print( " Hello Ubuntu!n " );
}
gint delete_event(GtkWidget * widget,GdkEvent * event ,gpointer data)
{
g_print ( " delete event occurredn " );
return (TRUE);
}
void destroy(GtkWidget * widget,gpointer data)
{
gtk_main_quit();
}
int main( int argc, char * argv[] )
{
GtkWidget * window;
GtkWidget * button;
gtk_init ( & argc, & argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT(window), " delete_event " ,GTK_SIGNAL_FUNC(delete_event),NULL);
gtk_signal_connect (GTK_OBJECT (window), " destroy " ,GTK_SIGNAL_FUNC (destroy), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10 );
button = gtk_button_new_with_label ( " Hello Ubuntu! " );
gtk_signal_connect (GTK_OBJECT (button), " clicked " ,GTK_SIGNAL_FUNC (hello), NULL);
gtk_signal_connect_object (GTK_OBJECT (button), " clicked " ,GTK_SIGNAL_FUNC (gtk_widget_destroy),GTK_OBJECT (window));
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window); /* 显示一个窗口 */
gtk_main(); /* 进入主循环 */
return ( 0 );
}
4、编译程序:
终端命令:
$
gcc `pkg
-
config
--
cflags
--
libs gtk
+-
2.0
` gtktest.c
-
o gtktest
$ . / gtktest
$ . / gtktest
转载于:https://www.cnblogs.com/watsonlong/archive/2011/04/06/2006989.html
最后
以上就是爱撒娇宝马为你收集整理的Fedora环境下Gtk+开发环境配置的全部内容,希望文章能够帮你解决Fedora环境下Gtk+开发环境配置所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复