j'ai encore un petit souci lié à ma structure je ne dois pas voir vraiment comment ca marche.
Maintenat je l'ai compliqué un peu ainsi que ma fonction enregistrer:
voci ma structure:
voici ma fonction enregistrer:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 typedef struct { GtkWidget *textview1; GtkWidget *entry1; GtkWidget *comboboxentry1; GtkWidget *comboboxentry2; GtkWidget *comboboxentry3; } text_st;
jusque là je penses que tout va bien, il n'y a pas de problème
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
63 void on_button5_clicked(GtkButton *button,gpointer user_data) { /*déclaration des variables utiles pour récupérer la note*/ GtkTextBuffer* text_buffer=0; GtkTextIter start; GtkTextIter end; const gchar *entrer; GtkWidget* pconfirmation; gchar* buffer; text_st * p_st = user_data; const gchar *jour; const gchar *mois; const gchar *annee; /*déclaration d'un pointeur de fichier mémo*/ FILE *memo; /*On récupére ce que l'utilisateur a rentré*/ entrer=gtk_entry_get_text(GTK_ENTRY(p_st->entry1)); //On recupere le buffer et on le met dans une variable text_buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(p_st->textview1)); //On recupere l'origine du buffer gtk_text_buffer_get_start_iter(text_buffer,&start); //On recupere la fin du buffer gtk_text_buffer_get_end_iter(text_buffer,&end); /*on copie le contenu du buffer dans une variable*/ buffer = gtk_text_buffer_get_text(text_buffer, &start, &end, TRUE); /*récupéation du jour*/ jour=gtk_entry_get_text(GTK_ENTRY (GTK_BIN (p_st->comboboxentry1)->child)); /*récupération du mois*/ mois=gtk_entry_get_text(GTK_ENTRY (GTK_BIN (p_st->comboboxentry2)->child)); /*récupération de l'année*/ annee=gtk_entry_get_text(GTK_ENTRY (GTK_BIN (p_st->comboboxentry3)->child)); /*ouverture du fichier memo en écriture */ memo= fopen("calend.txt","a"); if (memo==NULL) { perror("erreur d'ouverture du fichier"); exit(0); } /*ouverture du fichier memo en écriture */ memo= fopen("calend.txt","a"); if (memo==NULL) { perror("erreur d'ouverture du fichier"); exit(0); } fprintf(memo,"BEGIN:VEVENT\n"); fprintf(memo,"SUMMARY:"); fprintf(memo,"%s\n",entrer); fprintf(memo,"DESCRIPTION:"); fprintf(memo,"%s\n",buffer); fprintf(memo,"DTSTART:"); fprintf(memo,"%s%s%sT00Z",annee,mois,jour); fclose(memo); //affichage d'une fenetre de confirmation d'enregistrement pconfirmation = gtk_message_dialog_new (NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_INFO ,GTK_BUTTONS_OK, "Votre memo a bien ete enregistre"); gtk_dialog_run(GTK_DIALOG(pconfirmation)); gtk_widget_destroy(pconfirmation); }
mon problème vient d'un bouton qui fait référence à la comboboxentry1 et comboboxentry2
voila ce que c'était avant que j'ai fais la structure:
le callback
1/ maintenant qu'il y a la structure, comment faut il le mettre?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 g_signal_connect (G_OBJECT (comboboxentry1), "changed", G_CALLBACK (on_comboboxentry1_changed), (gpointer) comboboxentry2);
comme ceci?
et voici les deux fonctions qui font référence à ces deux combobox avant la définition de la structure:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 g_signal_connect (G_OBJECT (st->comboboxentry1), "changed", G_CALLBACK (on_comboboxentry1_changed), (gpointer) st);
2/je suppose que dedans aussi ca change mais même question comment?
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 void combobox2_clear (GtkComboBox *p_combo_box) { GtkTreeModel *p_tree_model = NULL; g_return_if_fail (p_combo_box != NULL); p_tree_model = gtk_combo_box_get_model (p_combo_box); gtk_list_store_clear (GTK_LIST_STORE (p_tree_model)); } void on_comboboxentry1_changed(GtkComboBox *combobox,gpointer user_data) { int value = 0; const gchar *text = NULL; GtkComboBox * p_combo2 = user_data; /*récupération de la valeur dans la combobox1*/ text=gtk_entry_get_text(GTK_ENTRY (GTK_BIN (combobox)->child)); /*on transcrit la chaine en un nombre*/ value = (int) strtol (text, NULL,0); /* On efface le comboboxentry2 */ combobox2_clear (p_combo2); if (value==31) { gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("janvier")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("mars")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("mai")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("juillet")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("aout")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("octobre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("decembre")); } else { gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("janvier")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("fevrier")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("mars")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("avril")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("mai")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("juin")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("juillet")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("aout")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("septembre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("octobre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("novembre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_combo2), _("decembre")); } }
j'avais eu l'idée de faire peut etre comme cela
le problème c'est qu'il n'accepte pas ceci
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 void on_comboboxentry1_changed(GtkComboBox *combobox,gpointer user_data) { int value = 0; const gchar *text = NULL; text_st * p_st = user_data; /*récupération de la valeur dans la combobox1*/ text=gtk_entry_get_text(GTK_ENTRY (GTK_BIN (p_st->comboboxentry2)->child)); /*on transcrit la chaine en un nombre*/ value = (int) strtol (text, NULL,0); /* On efface le comboboxentry2 */ combobox2_clear (p_st->comboboxentry2); if (value==31) { gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("janvier")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("mars")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("mai")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("juillet")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("aout")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("octobre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("decembre")); } else { gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("janvier")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("fevrier")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("mars")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("avril")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("mai")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("juin")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("juillet")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("aout")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("septembre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("octobre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("novembre")); gtk_combo_box_append_text (GTK_COMBO_BOX (p_st->comboboxentry2), _("decembre")); } }
combobox2_clear (p_st->comboboxentry2);
mais suis je sur la piste?
je penses y etre presque mais il me faut encore de l'aide
merci beaucoup
Partager