Advertisement
thecplusplusguy

GTK+ tutorial 11

Jun 27th, 2012
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 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. #include <string>
  5.  
  6. int main(int argc, char* argv[])
  7. {
  8.     gtk_init(&argc, &argv);
  9.     GtkWidget *window, *notebook, *label, *label2;
  10.     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  11.     g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
  12.  
  13.     notebook = gtk_notebook_new();
  14.     gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);
  15.     for(int i = 0; i < 5; i += 1)
  16.     {
  17.         std::string s = "This is just a test of the notebook.\nIn this example you can learn it.%nThis is the page ";
  18.         s += static_cast<char>(49+i);
  19.         label = gtk_label_new(s.c_str());
  20.  
  21.         s = "Page ";
  22.         s += static_cast<char>(49+i);
  23.         label2 = gtk_label_new(s.c_str());
  24.  
  25.         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), label, label2);
  26.     }
  27.     gtk_container_add(GTK_CONTAINER(window), notebook);
  28.  
  29.  
  30.     gtk_widget_show_all(window);
  31.     gtk_main();
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement