tching pao | voic mon code et j'aimerais savoir comment je fais pour recupere la valeur de tous les GTK_Entry, GTK_RadioButton et des GTK_CheckButton lorsque je clique sur le Boutton CALCUL ?
Et aussi comment faire pour lorsque je ferme la 2eme fenetre la 1ere ne se ferme aussi ?
Code :
- #include <stdlib.h>
- #include <gtk/gtk.h>
- static GtkWidget *win = NULL;
- void Calcul(GtkWidget *winBtn,gpointer data);
- int main (int argc, char *argv[])
- {
- // GtkWidget *win = NULL;
-
- /* Initialize GTK+ */
- gtk_init (&argc, &argv);
- /* Create the main window */
- win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_container_set_border_width (GTK_CONTAINER (win), 1);
- gtk_window_set_default_size(GTK_WINDOW (win),320,200);
- gtk_window_set_title (GTK_WINDOW (win), "INTERCLUB" );
- gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
- //gtk_widget_realize (win); // A QUOI CA SERT ???
- g_signal_connect (win, "destroy", gtk_main_quit, NULL);
-
- GtkWidget *winVBox = gtk_vbox_new(TRUE, 0);
- gtk_container_add(GTK_CONTAINER(win), winVBox);
-
- GtkWidget *winTable_1;
- winTable_1 = gtk_table_new(14,15,FALSE);
- gtk_box_pack_start(GTK_BOX(winVBox), winTable_1, TRUE, FALSE, 0);
-
-
- /* equipe */
- GtkWidget *winLabel_NageursDoublants;
- winLabel_NageursDoublants = gtk_label_new("Nageurs\ndoublants" );
- gtk_table_attach(GTK_TABLE(winTable_1), winLabel_NageursDoublants, 0, 1 , 0 , 1,GTK_EXPAND, GTK_EXPAND,0,0);
-
- GtkWidget *winCheck_NageursDoublants[10];
- for(gint i=0 ; i < 10 ; ++i) {
- winCheck_NageursDoublants[i] = gtk_check_button_new();
- gtk_table_attach(GTK_TABLE(winTable_1), winCheck_NageursDoublants[i], 0, 1 , i+1 , i+2,GTK_EXPAND, GTK_EXPAND,0,0);
- }
-
-
- GtkWidget *winLabel_Nageurs;
- winLabel_Nageurs = gtk_label_new("Nageurs" );
- gtk_table_attach(GTK_TABLE(winTable_1), winLabel_Nageurs, 1, 2 , 0 , 1,GTK_EXPAND, GTK_EXPAND,0,0);
-
- GtkWidget *winLabel_Nages[13];
- winLabel_Nages[0] = gtk_label_new("50 NL" );
- winLabel_Nages[1] = gtk_label_new("100 NL" );
- winLabel_Nages[2] = gtk_label_new("200 NL" );
- winLabel_Nages[3] = gtk_label_new("400 NL" );
- winLabel_Nages[4] = gtk_label_new("1500 NL" );
- winLabel_Nages[5] = gtk_label_new("100 DOS" );
- winLabel_Nages[6] = gtk_label_new("200 DOS" );
- winLabel_Nages[7] = gtk_label_new("100 BR" );
- winLabel_Nages[8] = gtk_label_new("200 BR" );
- winLabel_Nages[9] = gtk_label_new("100 PAP" );
- winLabel_Nages[10] = gtk_label_new("200 PAP" );
- winLabel_Nages[11] = gtk_label_new("200 4N" );
- winLabel_Nages[12] = gtk_label_new("400 4N" );
- for(gint i=0 ; i < 13 ; ++i) {
- gtk_table_attach(GTK_TABLE(winTable_1), winLabel_Nages[i], i+2, i+3 , 0 , 1, GTK_EXPAND, GTK_EXPAND,1,2);
- }
-
- GtkWidget *winEntry_Equipe[11][14];
- for(gint i=0 ; i < 10 ; ++i) {
- winEntry_Equipe[i][0] = gtk_entry_new();
- gtk_entry_set_width_chars (GTK_ENTRY(winEntry_Equipe[i][0]), 20);
- gtk_table_attach(GTK_TABLE(winTable_1), winEntry_Equipe[i][0], 1 , 2, i+1, i+2 ,GTK_EXPAND, GTK_EXPAND,1,2 );
- }
- for(gint i=0 ; i < 10 ; ++i) {
- for(gint j=1 ; j < 14 ; ++j) {
- winEntry_Equipe[i][j] = gtk_entry_new_with_max_length(7);
- gtk_entry_set_width_chars (GTK_ENTRY(winEntry_Equipe[i][j]), 7);
- gtk_table_attach(GTK_TABLE(winTable_1), winEntry_Equipe[i][j],j+1 , j+2, i+1, i+2 ,GTK_EXPAND, GTK_EXPAND,1,2);
- }
- }
-
- GtkWidget *winLabel_Relais[3];
- winLabel_Relais[0] = gtk_label_new("RELAIS" );
- winLabel_Relais[1] = gtk_label_new("10x100 NL" );
- winLabel_Relais[2] = gtk_label_new("4x100 4N" );
- gtk_table_attach_defaults(GTK_TABLE(winTable_1), winLabel_Relais[0],1 ,2 ,12 ,14 );
- gtk_table_attach_defaults(GTK_TABLE(winTable_1), winLabel_Relais[1],2 ,3 ,12 ,13 );
- gtk_table_attach_defaults(GTK_TABLE(winTable_1), winLabel_Relais[2],2 ,3 ,13 ,14 );
- GtkWidget *winEntry_Relais[2];
- winEntry_Relais[0] = gtk_entry_new_with_max_length(7);
- winEntry_Relais[1] = gtk_entry_new_with_max_length(7);
- gtk_entry_set_width_chars (GTK_ENTRY(winEntry_Relais[0]), 7);
- gtk_entry_set_width_chars (GTK_ENTRY(winEntry_Relais[1]), 7);
- gtk_table_attach(GTK_TABLE(winTable_1), winEntry_Relais[0],3 , 4, 12, 13 ,GTK_EXPAND, GTK_EXPAND,1,1);
- gtk_table_attach(GTK_TABLE(winTable_1), winEntry_Relais[1],3 , 4, 13, 14 ,GTK_EXPAND, GTK_EXPAND,1,1);
-
- GtkWidget *winLabel_Sexe;
- winLabel_Sexe = gtk_label_new("Sexe de l'equipe" );
- gtk_table_attach_defaults(GTK_TABLE(winTable_1), winLabel_Sexe,5 ,7 ,12 ,14 );
-
- GtkWidget *winRadio_Sexe1;
- GtkWidget *winRadio_Sexe2;
-
- winRadio_Sexe1 = gtk_radio_button_new_with_label(NULL, "Homme" );
- gtk_table_attach_defaults(GTK_TABLE(winTable_1), winRadio_Sexe1 ,7 ,8 ,12 ,13 );
-
- winRadio_Sexe2 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (winRadio_Sexe1), "Femme" );
- gtk_table_attach_defaults(GTK_TABLE(winTable_1), winRadio_Sexe2 ,7 ,8 ,13 ,14 );
-
- GtkWidget *winButtonCalcul;
- winButtonCalcul = gtk_button_new_with_label("CALCUL" );
- gtk_table_attach_defaults(GTK_TABLE(winTable_1), winButtonCalcul ,13 ,15 ,12 ,14 );
- g_signal_connect(G_OBJECT(winButtonCalcul), "clicked", G_CALLBACK(Calcul), (GtkWidget*) winVBox);
-
- /* Enter the main loop */
- gtk_widget_show_all (win);
- gtk_main ();
- return 0;
- }
- void Calcul(GtkWidget *winBtn,gpointer data)
- {
- GtkWidget *winRes = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_position (GTK_WINDOW (winRes), GTK_WIN_POS_CENTER);
- gtk_window_set_default_size(GTK_WINDOW (winRes),320,200);
- gtk_window_set_title (GTK_WINDOW (winRes), "RESULTATS" );
- g_signal_connect (winRes, "destroy", gtk_main_quit, NULL);
-
- GtkWidget *winTable_2 = gtk_table_new(14,15,FALSE);
- gtk_container_add(GTK_CONTAINER(winRes), winTable_2);
-
- gtk_widget_show_all(winRes);
- }
|
Message édité par tching pao le 24-10-2004 à 15:36:33
|