文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>gtk-窗口消息与按钮

gtk-窗口消息与按钮

时间:2010-04-13  来源:cj_gameboy

#include <gtk/gtk.h>
void hello(GtkWidget *window, gpointer data){
 g_print("Hello world\n");
}

gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data){
  g_print("delete event occurred\n");
  return TRUE;
}

void destroy(GtkWidget *window, 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);
  g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL);
  g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
  gtk_container_set_border_width(GTK_CONTAINER(window), 10);
  button=gtk_button_new_with_label("HELLO World");
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(hello), NULL);
  g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), window);
  gtk_container_add(GTK_CONTAINER(window), button);
  gtk_widget_show(button);
  gtk_widget_show(window);

  gtk_main();
  return 0;
}


cc sem.c -o sem `pkg-config --cflags --libs gtk+-2.0`


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载