1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <gtk/gtk.h>
gint
main(int argc, char* argv[]) {
gtk_init (&argc, &argv);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (window, 400, 400);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
GtkWidget *box = gtk_vbox_new (FALSE, 4);
GtkWidget *button = gtk_button_new_with_label ("test button");
GtkWidget *textview = gtk_text_view_new ();
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
gtk_box_pack_start (GTK_BOX (box), textview, TRUE, TRUE, 4);
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show_all (window);
/* Force le focus sur textview si ce n'est pas le cas */
if (!gtk_widget_is_focus (textview))
gtk_widget_grab_focus (textview);
gtk_main ();
return 0;
} |
Partager