Bonjour,

Je commence a peine avec la librairie GTK et j'ai beaucoup de mal. voila je voudrais que lorsque j'appui sur le bouton OK , mon combobox2 se rempli ...

MAis en fait ca bug quand je clique sur OK

Je vous donne mon code au cas ou...
SVP j'ai besoin d'aide, si vous connaissez de bon tutoriel en Francais ou autre je suis prenneur ... merci


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdlib.h>
#include <gtk/gtk.h>
#include <stdio.h>
 
 void copy(GtkWidget *Combo2,gpointer *Data,GList *list2)
 {
 
     list2 = g_list_append(list2, g_strdup_printf("ici ", 2)); // ajoute une chaine a le liste
     list2 = g_list_append(list2, g_strdup_printf("prout", 3)); // ajoute une chaine a le liste
     list2 = g_list_append(list2, g_strdup_printf("la bas", 4)); // ajoute une chaine a le liste
       gtk_combo_set_popdown_strings( GTK_COMBO(Combo2), list2);
 }
int main(int argc, char *argv[])
{
 
     GtkWidget *Titre, *Combo1, *Combo2,*Bouton,*Boute;
     GList *list = NULL;
     GList *list2 = NULL;
     gint i;
     char prout[50];
 
     gtk_init(&argc, &argv);
 
     Titre = gtk_dialog_new();
     gtk_window_set_title(GTK_WINDOW(Titre), "Logicel Expertise A2C - Loi SAE");
     gtk_widget_show(Titre);
     /*Pour determiner la taille*/
     gtk_widget_set_usize(GTK_WIDGET(Titre),500, 300);
 
 
     list = g_list_append(list, g_strdup_printf("2008", 1));
 
     strcpy(prout,"test");
 
 
     list2 = g_list_append(list2, g_strdup_printf(prout, 1)); // ajoute une chaine a le liste
 
     /*Permet d'init l'interface*/
     Combo1 = gtk_combo_new(); // cree une liste deroulante
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Titre)->vbox), Combo1, TRUE, TRUE, 5);
     gtk_combo_set_popdown_strings( GTK_COMBO(Combo1), list) ; // met la liste dans la conbo box
     gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Combo1)->entry), "Annee d'expiration"); // definit le texte de la conbo box
 
     gtk_widget_show(Combo1);
 
     Combo2 = gtk_combo_new(); // cree une liste deroulante
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Titre)->vbox), Combo2, TRUE, TRUE, 5);
     gtk_combo_set_popdown_strings( GTK_COMBO(Combo2), list2) ; // met la liste dans la conbo box
     gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Combo2)->entry), "Dispositif a mettre en place"); // definit le texte de la combobox
 
 
     gtk_widget_show(Combo2); 
 
     Bouton = gtk_button_new_with_label("Fermer");
     gtk_signal_connect_object(GTK_OBJECT(Bouton), "clicked", (GtkSignalFunc)gtk_exit, NULL);
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Titre)->action_area), Bouton , TRUE, TRUE, 0);
     gtk_widget_show(Bouton);
 
     gtk_main();
 
     return(0);
}