Advertisement
thecplusplusguy

GTK+ tutorial 5

Jun 27th, 2012
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. //http://www.youtube.com/user/thecplusplusguy
  2. //Thanks for the typed in code to Tapit85
  3. #include <gtk/gtk.h>
  4.  
  5. int main(int argc, char* argv[])
  6. {
  7.     gtk_init(&argc, &argv);
  8.     GtkWidget *window, *label, *button, *table;
  9.     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  10.     g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
  11.  
  12.     table = gtk_table_new(2, 2, 0); //rows, columns, honogenous
  13.     button = gtk_button_new_with_mnemonic("_Button");
  14.     label = gtk_label_new("Hello World");
  15.     gtk_table_attach(GTK_TABLE(table), label, 0,1,0,1, GTK_FILL, GTK_FILL, 0,0);
  16.     gtk_table_attach(GTK_TABLE(table), button, 1,2,0,1, GTK_FILL, GTK_FILL, 0,0);
  17.  
  18.     button = gtk_button_new_with_mnemonic("_Button 2");
  19.     label = gtk_label_new("Hello World 2");
  20.     gtk_table_attach(GTK_TABLE(table), label, 0,1,1,2, GTK_FILL, GTK_FILL, 0,0);
  21.     gtk_table_attach(GTK_TABLE(table), button, 1,2,1,2, GTK_FILL, GTK_FILL, 0,0);
  22.    
  23.     gtk_container_add(GTK_CONTAINER(window), table);
  24.  
  25.     gtk_widget_show_all(window);
  26.     gtk_main();
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement