#include <stdio.h> #include <gtk/gtk.h> static gboolean delete( GtkWidget *widget, GtkWidget *event, gpointer data ) { gtk_main_quit (); return FALSE; } int main( int argc, char **argv ) { GtkWidget *window; GtkWidget *table; GtkWidget *notebook; GtkWidget *frame; GtkWidget *label; GtkWidget *checkbutton; int i; char bufferf[32]; char bufferl[32]; /* Crée fenêtre ***********************************************************/ gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* Crée une table pour les onglets ****************************************/ table = gtk_table_new (3, 6, FALSE); gtk_container_add (GTK_CONTAINER (window), table); /* Create a new notebook, place the position of the tabs */ notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); gtk_table_attach_defaults (GTK_TABLE (table), notebook, 0, 6, 0, 1); gtk_widget_show (notebook); /* Let's append a bunch of pages to the notebook */ for (i = 0; i < 5; i++) { sprintf(bufferf, "Append Frame %d", i + 1); sprintf(bufferl, "Page %d", i + 1); frame = gtk_frame_new (bufferf); gtk_container_set_border_width (GTK_CONTAINER (frame), 10); gtk_widget_set_size_request (frame, 100, 75); gtk_widget_show (frame); label = gtk_label_new (bufferf); gtk_container_add (GTK_CONTAINER (frame), label); gtk_widget_show (label); label = gtk_label_new (bufferl); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label); } /* Now let's add a page to a specific spot */ checkbutton = gtk_check_button_new_with_label ("Check me please!"); gtk_widget_set_size_request (checkbutton, 100, 75); gtk_widget_show (checkbutton); label = gtk_label_new ("Add page"); gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), checkbutton, label, 2); /* Set what page to start at (page 4) */ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 3); /* Affiche la fenêtre *****************************************************/ gtk_widget_show (table); gtk_widget_show (window); gtk_main (); return 0; }