Bonjour,
J'ai un petit probleme avec ma calculatrice, dont voici le code source:
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include <stdlib.h>
#include <gtk/gtk.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <string.h>
 
typedef struct _MainWindow
{
  GtkWidget *pWindow;
  GtkWidget *pEntry;
  GtkWidget *pLabel;
} MainWindow;
 
void OnQuitter (GtkObject * object, gpointer data);
 
void OnButton (GtkButton * button, gpointer data);
 
void OnResultat (GtkButton * button, gpointer data);
 
void OnEffacer (GtkButton * button, gpointer data);
 
void OnDelete (GtkButton * button, gpointer data);
 
void OnAbout (GtkMenuItem * menuitem, gpointer data);
 
 
int
main (int argc, char **argv)
{
  GtkBuilder *pBuilder = NULL;
  GError *pErr = NULL;
  MainWindow *calculatrice = NULL;
 
  gtk_init (&argc, &argv);
  calculatrice = g_new (MainWindow, 1);
 
  /* Creation d'un nouveau GtkBuilder */
  pBuilder = gtk_builder_new ();
 
  if (pBuilder != NULL)
    {
      /* Chargement du fichier xml dans pBuilder */
      gtk_builder_add_from_file (pBuilder, "calculatrice.glade", &pErr);
 
      if (pErr == NULL)
	{
	  /* Recuperation d'un pointeur sur la fenetre */
	  calculatrice->pWindow = (GtkWidget *)
	    gtk_builder_get_object (pBuilder, "window1");
 
	  /* Recuperation d'un pointeur vers le GtkEntry */
	  calculatrice->pEntry = (GtkWidget *)
	    gtk_builder_get_object (pBuilder, "entry1");
 
	  /* Connexion des signaux */
	  gtk_builder_connect_signals (pBuilder, calculatrice);
 
 
	  gtk_widget_show_all (calculatrice->pWindow);
	  gtk_main ();
	}
      else
	{
	  /* Affichage du message d'erreur de Gtk+ */
	  g_error ("%s", pErr->message);
	  g_error_free (pErr);
	}
    }
 
 
  return EXIT_SUCCESS;
}
 
 
void
OnButton (GtkButton * button, gpointer data)
{
  const gchar *sEntry = NULL;
 
  /* Recuperation du calcul en cours dans la chaine sEntry */
  sEntry = gtk_entry_get_text (GTK_ENTRY (((MainWindow *) data)->pEntry));
 
  /* Cocatenation du de sEntry, avec le label du bouton */
  sEntry = g_strdup_printf ("%s%s", sEntry, gtk_button_get_label (button));
 
  /* Mise a jour du GtkEntry */
  gtk_entry_set_text (GTK_ENTRY (((MainWindow *) data)->pEntry), sEntry);
 
 
}
 
void
OnResultat (GtkButton * button, gpointer data)
{
  FILE *f_Calcul = NULL;
  FILE *f_History = NULL;
  gchar sResultat[100] = "";
 
  /* Appel du programme Calc.bin */
  if ((f_Calcul = (FILE *) popen ("./Calc.bin", "w")) == NULL)
    {
      /* En cas d'erreur */
      fprintf (stderr, "\n\tErreur popen %d\n", errno);
      exit (2);
    }
  /* Envoi de l'expression à Calc.bin */
  fprintf (f_Calcul, "%s\n",
	   gtk_entry_get_text (GTK_ENTRY (((MainWindow *) data)->pEntry)));
 
  /* Fermeture du programme Calc.bin */
  pclose (f_Calcul);
 
  /* Recuperation du resultat dans l'historique de Calc.bin */
  if ((f_History = fopen ("history.txt", "r")) == NULL)
    {
      /* En cas d'erreur */
      fprintf (stderr,
	       "\t\nErreur, Impossible d'ouvrir le fichier \"history.txt\"\n");
      exit (3);
    }
 
  /* Parcours de l'historique jusqu'au dernier resultat */
  while (fgets (sResultat, 100, f_History) != NULL);
 
  /* On suprime le '\n', à la fin du resultat */
  sResultat[strlen (sResultat) - 1] = '\0';
 
  /* Fermeture de l'historique */
  fclose (f_History);
 
  /* Affichage du resultat contenu dans sResultat, à partir
   * du caractere '>', dans le GtkEntry
   */
  gtk_entry_set_text (GTK_ENTRY (((MainWindow *) data)->pEntry),
		      sResultat + sizeof (gchar));
}
 
void
OnDelete (GtkButton * button, gpointer data)
{
  gchar *s_tmp = NULL;
 
  /* Recuperation du texte du GtkEntry */
  const gchar *sSaisie =
    gtk_entry_get_text (GTK_ENTRY (((MainWindow *) data)->pEntry));
  if (strcmp ("", sSaisie) != 0)
    {
      /* Allocation de la memoire pour la nouvelle chaine */
      s_tmp = g_malloc (strlen (sSaisie) * sizeof (gchar));
 
      /* Copie de la saisie actuelle dans la nouvelle chaine */
      strcpy (s_tmp, sSaisie);
 
      /* On place la fin de chainede s_tmp, un caractere
       * avant la saisie actuelle 
       */
      s_tmp[strlen (sSaisie) - 1] = '\0';
 
      /* On affiche la nouvelle chaine dans le GtkEntry */
      gtk_entry_set_text (GTK_ENTRY (((MainWindow *) data)->pEntry), s_tmp);
 
      /* Liberation de la memoire allouée */
      g_free (s_tmp);
    }
}
 
void
OnEffacer (GtkButton * button, gpointer data)
{
  /* On remplace la saisie actuelle par la saisie vide "" */
  gtk_entry_set_text (GTK_ENTRY (((MainWindow *) data)->pEntry), "");
}
 
void
OnAbout (GtkMenuItem * menuitem, gpointer data)
{
  GtkWidget *pMessage = NULL;
 
  pMessage =
    gtk_message_dialog_new (GTK_WINDOW ((((MainWindow *) data)->pWindow)),
			    GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
			    GTK_BUTTONS_OK, "BisonCalc-v0.2");
 
  /* Affichage de la boite de dialog "A propos de.." */
  gtk_widget_show_all (pMessage);
 
  /* Lancement de la boite de dialog */
  gtk_dialog_run (GTK_DIALOG (pMessage));
  gtk_widget_destroy (pMessage);
}
 
void
OnEffacer (GtkButton * button, gpointer data)
{
  /* On remplace la saisie actuelle par la saisie vide "" */
  gtk_entry_set_text (GTK_ENTRY (((MainWindow *) data)->pEntry), "");
}
 
void
OnAbout (GtkMenuItem * menuitem, gpointer data)
{
  GtkWidget *pMessage = NULL;
 
  pMessage =
    gtk_message_dialog_new (GTK_WINDOW ((((MainWindow *) data)->pWindow)),
			    GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
			    GTK_BUTTONS_OK, "BisonCalc-v0.2");
 
  /* Affichage de la boite de dialog "A propos de.." */
  gtk_widget_show_all (pMessage);
 
  /* Lancement de la boite de dialog */
  gtk_dialog_run (GTK_DIALOG (pMessage));
  gtk_widget_destroy (pMessage);
}
 
void
OnQuitter (GtkObject * object, gpointer data)
{
  /* Liberation de la memoire allouée
   * pour (MainWindow*) calculatrice
   */
  g_free ((void *) data);
 
  /* Arret de la boucle evennementielle */
  gtk_main_quit ();
}
et le fichier glade:
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
<?xml version="1.0"?>
<interface>
  <requires lib="gtk+" version="2.16"/>
  <!-- interface-naming-policy project-wide -->
  <object class="GtkWindow" id="window1">
    <property name="border_width">5</property>
    <signal name="destroy" handler="OnQuitter"/>
    <child>
      <object class="GtkTable" id="table1">
        <property name="visible">True</property>
        <property name="n_rows">10</property>
        <property name="n_columns">11</property>
        <child>
          <object class="GtkEntry" id="entry1">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="has_frame">False</property>
            <property name="invisible_char">&#x25CF;</property>
            <property name="width_chars">9</property>
          </object>
          <packing>
            <property name="right_attach">11</property>
            <property name="top_attach">2</property>
            <property name="bottom_attach">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkFrame" id="frame1">
            <property name="visible">True</property>
            <property name="label_xalign">0</property>
            <property name="shadow_type">none</property>
            <child>
              <object class="GtkAlignment" id="alignment1">
                <property name="visible">True</property>
                <property name="left_padding">12</property>
                <child>
                  <object class="GtkTable" id="table2">
                    <property name="visible">True</property>
                    <property name="n_rows">4</property>
                    <property name="n_columns">5</property>
                    <child>
                      <object class="GtkButton" id="chiffre7">
                        <property name="label" translatable="yes">7</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre8">
                        <property name="label" translatable="yes">8</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre9">
                        <property name="label" translatable="yes">9</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">2</property>
                        <property name="right_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button4">
                        <property name="label" translatable="yes">/</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">3</property>
                        <property name="right_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre4">
                        <property name="label" translatable="yes">4</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre5">
                        <property name="label" translatable="yes">5</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre6">
                        <property name="label" translatable="yes">6</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">2</property>
                        <property name="right_attach">3</property>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button8">
                        <property name="label" translatable="yes">-</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">3</property>
                        <property name="right_attach">4</property>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre1">
                        <property name="label" translatable="yes">1</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre2">
                        <property name="label" translatable="yes">2</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre3">
                        <property name="label" translatable="yes">3</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">2</property>
                        <property name="right_attach">3</property>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button12">
                        <property name="label" translatable="yes">*</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">3</property>
                        <property name="right_attach">4</property>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="chiffre0">
                        <property name="label" translatable="yes">0</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button14">
                        <property name="label" translatable="yes">.</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button16">
                        <property name="label" translatable="yes">+</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">3</property>
                        <property name="right_attach">4</property>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="delete">
                        <property name="label" translatable="yes">&#x2190;</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnDelete"/>
                      </object>
                      <packing>
                        <property name="left_attach">2</property>
                        <property name="right_attach">3</property>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="egal">
                        <property name="label" translatable="yes">=</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnResultat"/>
                      </object>
                      <packing>
                        <property name="left_attach">4</property>
                        <property name="right_attach">5</property>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="clear">
                        <property name="label" translatable="yes">CE</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnEffacer"/>
                      </object>
                      <packing>
                        <property name="left_attach">4</property>
                        <property name="right_attach">5</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                  </object>
                </child>
              </object>
            </child>
            <child type="label">
              <object class="GtkLabel" id="label1">
                <property name="visible">True</property>
                <property name="xpad">11</property>
                <property name="label" translatable="yes">&lt;b&gt;Basique&lt;/b&gt;</property>
                <property name="use_markup">True</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="right_attach">7</property>
            <property name="top_attach">4</property>
            <property name="bottom_attach">10</property>
            <property name="x_options">GTK_FILL</property>
          </packing>
        </child>
        <child>
          <object class="GtkFrame" id="frame2">
            <property name="visible">True</property>
            <property name="label_xalign">0</property>
            <property name="shadow_type">none</property>
            <child>
              <object class="GtkAlignment" id="alignment2">
                <property name="visible">True</property>
                <property name="left_padding">12</property>
                <child>
                  <object class="GtkTable" id="table3">
                    <property name="visible">True</property>
                    <property name="n_rows">4</property>
                    <property name="n_columns">2</property>
                    <child>
                      <object class="GtkButton" id="button17">
                        <property name="label" translatable="yes">(</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                    </child>
                    <child>
                      <object class="GtkButton" id="button18">
                        <property name="label" translatable="yes">)</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <signal name="clicked" handler="OnButton"/>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button19">
                        <property name="label" translatable="yes">sin</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                      </object>
                      <packing>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button20">
                        <property name="label" translatable="yes">cos</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button21">
                        <property name="label" translatable="yes">tan</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                      </object>
                      <packing>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button22">
                        <property name="label" translatable="yes">x^y</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button23">
                        <property name="label" translatable="yes">pi</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                      </object>
                      <packing>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkButton" id="button24">
                        <property name="label" translatable="yes">log</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                  </object>
                </child>
              </object>
            </child>
            <child type="label">
              <object class="GtkLabel" id="label2">
                <property name="visible">True</property>
                <property name="xpad">10</property>
                <property name="label" translatable="yes">&lt;b&gt;Scientifique&lt;/b&gt;</property>
                <property name="use_markup">True</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="left_attach">8</property>
            <property name="right_attach">11</property>
            <property name="top_attach">4</property>
            <property name="bottom_attach">10</property>
          </packing>
        </child>
        <child>
          <object class="GtkMenuBar" id="menubar1">
            <property name="visible">True</property>
            <child>
              <object class="GtkMenuItem" id="menuitem1">
                <property name="visible">True</property>
                <property name="label" translatable="yes">_Fichier</property>
                <property name="use_underline">True</property>
                <child type="submenu">
                  <object class="GtkMenu" id="menu1">
                    <property name="visible">True</property>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem1">
                        <property name="label">gtk-new</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem2">
                        <property name="label">gtk-open</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem3">
                        <property name="label">gtk-save</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem4">
                        <property name="label">gtk-save-as</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
                        <property name="visible">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem5">
                        <property name="label">gtk-quit</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                        <signal name="activate" handler="OnQuitter"/>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </child>
            <child>
              <object class="GtkMenuItem" id="menuitem2">
                <property name="visible">True</property>
                <property name="label" translatable="yes">&#xC9;_dition</property>
                <property name="use_underline">True</property>
                <child type="submenu">
                  <object class="GtkMenu" id="menu2">
                    <property name="visible">True</property>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem6">
                        <property name="label">gtk-cut</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem7">
                        <property name="label">gtk-copy</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem8">
                        <property name="label">gtk-paste</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem9">
                        <property name="label">gtk-delete</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </child>
            <child>
              <object class="GtkMenuItem" id="menuitem3">
                <property name="visible">True</property>
                <property name="label" translatable="yes">_Affichage</property>
                <property name="use_underline">True</property>
              </object>
            </child>
            <child>
              <object class="GtkMenuItem" id="menuitem4">
                <property name="visible">True</property>
                <property name="label" translatable="yes">Aid_e</property>
                <property name="use_underline">True</property>
                <child type="submenu">
                  <object class="GtkMenu" id="menu3">
                    <property name="visible">True</property>
                    <child>
                      <object class="GtkImageMenuItem" id="imagemenuitem10">
                        <property name="label">gtk-about</property>
                        <property name="visible">True</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                        <signal name="activate" handler="OnAbout"/>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="right_attach">11</property>
          </packing>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
      </object>
    </child>
  </object>
</interface>
La compilation se passe sans probleme, mais lors de l'éxécution, si je saisi une chaine, et que je clique environ 7 fois sur la touche "←" (delete), le programme se ferme avec le message d'erreur suivant:
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
[artificier@smoothie glade]$./calculatrice
*** glibc detected *** ./calculatrice: free(): invalid next size (fast): 0x09c2af70 ***
======= Backtrace: =========
/lib/i686/libc.so.6[0xb76f6f34]
/lib/i686/libc.so.6(cfree+0x96)[0xb76f8f36]
/usr/lib/libglib-2.0.so.0(g_free+0x36)[0xb781f416]
/usr/lib/libgobject-2.0.so.0(g_cclosure_marshal_VOID__VOID+0x90)[0xb78bde70]
======= Memory map: ========
08048000-0804a000 r-xp 00000000 08:07 485210     /home/artificier/Programmation/glade/calculatrice
0804a000-0804b000 rw-p 00001000 08:07 485210     /home/artificier/Programmation/glade/calculatrice
09a56000-09c48000 rw-p 09a56000 00:00 0          [heap]
b6d00000-b6d21000 rw-p b6d00000 00:00 0 
b6d21000-b6e00000 ---p b6d21000 00:00 0 
b6e78000-b6e85000 r-xp 00000000 08:06 97055      /lib/libgcc_s-4.3.2.so.1
b6e85000-b6e86000 rw-p 0000c000 08:06 97055      /lib/libgcc_s-4.3.2.so.1
b6ea5000-b6ea6000 r-xp 00000000 08:06 19002      /usr/lib/gtk-2.0/2.10.0/immodules/im-cedilla.so
b6ea6000-b6ea7000 r--p 00000000 08:06 19002      /usr/lib/gtk-2.0/2.10.0/immodules/im-cedilla.so
b6ea7000-b6ea8000 rw-p 00001000 08:06 19002      /usr/lib/gtk-2.0/2.10.0/immodules/im-cedilla.so
b6ea8000-b6f34000 r--p 00000000 08:06 55454      /usr/share/fonts/TTF/dejavu/DejaVuSans-Bold.ttf
b6f34000-b6fcc000 r--p 00000000 08:06 55458      /usr/share/fonts/TTF/dejavu/DejaVuSans.ttf
b6fcc000-b6fce000 r-xp 00000000 08:06 28279      /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
b6fce000-b6fcf000 r--p 00001000 08:06 28279      /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
b6fcf000-b6fd0000 rw-p 00002000 08:06 28279      /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
b6fd0000-b6fd6000 r--s 00000000 08:06 105538     /var/cache/fontconfig/20b58f14c9b581391d79ea335a81488a-x86.cache-2
b6fd6000-b6fd9000 r--s 00000000 08:06 105550     /var/cache/fontconfig/c59da4255e67c0866a9890836123dfcc-x86.cache-2
b6fd9000-b6fdc000 r--s 00000000 08:06 105555     /var/cache/fontconfig/e6845615947634e89d319e77806483ba-x86.cache-2
b6fdc000-b6fe2000 r--s 00000000 08:06 105551     /var/cache/fontconfig/d4b6e1db2c46a3b281c413657cd2bc49-x86.cache-2
b6fe2000-b6fe5000 r--s 00000000 08:06 105545     /var/cache/fontconfig/87f5e051180a7a75f16eb6fe7dbd3749-x86.cache-2
b6fe5000-b6feb000 r--s 00000000 08:06 105549     /var/cache/fontconfig/b79f3aaa7d385a141ab53ec885cc22a8-x86.cache-2
b6feb000-b6fee000 r--s 00000000 08:06 105543     /var/cache/fontconfig/5d999c1bbe32f61af008974facb58b71-x86.cache-2
b6fee000-b6ff5000 r--s 00000000 08:06 105544     /var/cache/fontconfig/79aeb4e90a401e55ec91db207072ba77-x86.cache-2
b6ff5000-b7002000 r--s 00000000 08:06 105546     /var/cache/fontconfig/8d4af663993b81a124ee82e610bb31f9-x86.cache-2
b7002000-b7042000 r--s 00000000 08:06 105537     /var/cache/fontconfig/17090aa38d5c6f09fb8c5c354938f1d7-x86.cache-2
b7042000-b7047000 r-xp 00000000 08:06 22253      /usr/lib/libogg.so.0.5.3
b7047000-b7048000 r--p 00004000 08:06 22253      /usr/lib/libogg.so.0.5.3
b7048000-b7049000 rw-p 00005000 08:06 22253      /usr/lib/libogg.so.0.5.3
b7049000-b7066000 r-xp 00000000 08:06 22534      /usr/lib/libvorbis.so.0.4.0
b7066000-b7067000 r--p 0001c000 08:06 22534      /usr/lib/libvorbis.so.0.4.0
b7067000-b7075000 rw-p 0001d000 08:06 22534      /usr/lib/libvorbis.so.0.4.0
b7075000-b707d000 r-xp 00000000 08:06 22141      /usr/lib/libltdl.so.7.2.0
b707d000-b707e000 r--p 00007000 08:06 22141      /usr/lib/libltdl.so.7.2.0
b707e000-b707f000 rw-p 00008000 08:06 22141      /usr/lib/libltdl.so.7.2.0
b707f000-b7086000 r-xp 00000000 08:06 22538      /usr/lib/libvorbisfile.so.3.2.0
b7086000-b7087000 r--p 00006000 08:06 22538      /usr/lib/libvorbisfile.so.3.2.0
b7087000-b7088000 rw-p 00007000 08:06 22538      /usr/lib/libvorbisfile.so.3.2.0
b7088000-b70a3000 r-xp 00000000 08:06 21282      /usr/lib/libcanberra.so.0.1.4
b70a3000-b70a4000 r--p 0001a000 08:06 21282      /usr/lib/libcanberra.so.0.1.4
b70a4000-b70a5000 rw-p 0001b000 08:06 21282      /usr/lib/libcanberra.so.0.1.4
b70a5000-b70b9000 r-xp 00000000 08:06 96913      /lib/i686/libpthread-2.9.so
b70b9000-b70ba000 r--p 00013000 08:06 96913      /lib/i686/libpthread-2.9.so
b70ba000-b70bb000 rw-p 00014000 08:06 96913      /lib/i686/libpthread-2.9.so
b70bb000-b70bd000 rw-p b70bb000 00:00 0 
b70bd000-b70e0000 r--p 00000000 08:06 82840      /usr/share/locale/fr/LC_MESSAGES/libc.mo
b70e0000-b710e000 r-xp 00000000 08:06 158279     /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so
b710e000-b710f000 r--p 0002d000 08:06 158279     /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so
b710f000-b7110000 rw-p 0002e000 08:06 158279     /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so
b7110000-b7138000 r--p 00000000 08:06 82458      /usr/share/locale/fr/LC_MESSAGES/gtk20-properties.mo
b7138000-b7142000 r-xp 00000000 08:06 97080      /lib/libnss_files-2.9.so
b7142000-b7143000 r--p 00009000 08:06 97080      /lib/libnss_files-2.9.so
b7143000-b7144000 rw-p 0000a000 08:06 97080      /lib/libnss_files-2.9.so
b7144000-b7163000 r--s 00000000 08:06 21051      /var/cache/fontconfig/df311e82a1a24c41a75c2c930223552e-x86.cache-2
b7163000-b7176000 r--p 00000000 08:06 82459      /usr/share/locale/fr/LC_MESSAGES/gtk20.mo
b7176000-b71b5000 r--p 00000000 08:06 77798      /usr/share/locale/UTF-8/LC_CTYPE
b71b5000-b7299000 r--p 00000000 08:06 77797      /usr/share/locale/UTF-8/LC_COLLATE
b7299000-b729c000 rw-p b7299000 00:00 0 
b729c000-b72a1000 r-xp 00000000 08:06 21096      /usr/lib/libXdmcp.so.6.0.0
b72a1000-b72a2000 r--p 00004000 08:06 21096      /usr/lib/libXdmcp.so.6.0.0
b72a2000-b72a3000 rw-p 00005000 08:06 21096      /usr/lib/libXdmcp.so.6.0.0
b72a3000-b72a5000 r-xp 00000000 08:06 21085      /usr/lib/libXau.so.6.0.0
b72a5000-b72a6000 r--p 00001000 08:06 21085      /usr/lib/libXau.so.6.0.0
b72a6000-b72a7000 rw-p 00002000 08:06 21085      /usr/lib/libXau.so.6.0.0
b72a7000-b72c3000 r-xp 00000000 08:06 22615      /usr/lib/libxcb.so.1.1.0
b72c3000-b72c4000 r--p 0001b000 08:06 22615      /usr/lib/libxcb.so.1.1.0
b72c4000-b72c5000 rw-p 0001c000 08:06 22615      /usr/lib/libxcb.so.1.1.0
b72c5000-b72f6000 r-xp 00000000 08:06 97101      /lib/libpcre.so.0.0.1
b72f6000-b72f7000 r--p 00030000 08:06 97101      /lib/libpcre.so.0.0.1
b72f7000-b72f8000 rw-p 00031000 08:06 97101      /lib/libpcre.so.0.0.1
b72f8000-b72fa000 r-xp 00000000 08:06 97045      /lib/libdl-2.9.so
b72fa000-b72fb000 r--p 00001000 08:06 97045      /lib/libdl-2.9.so
b72fb000-b72fc000 rw-p 00002000 08:06 97045      /lib/libdl-2.9.so
b72fc000-b72fd000 rw-p b72fc000 00:00 0 
b72fd000-b7449000 r-xp 00000000 08:06 22623      /usr/lib/libxml2.so.2.7.3
b7449000-b744a000 ---p 0014c000 08:06 22623      /usr/lib/libxml2.so.2.7.3
b744a000-b744e000 r--p 0014c000 08:06 22623      /usr/lib/libxml2.so.2.7.3
b744e000-b744f000 rw-p 00150000 08:06 22623      /usr/lib/libxml2.so.2.7.3
b744f000-b7450000 rw-p b744f000 00:00 0 
b7450000-b7463000 r-xp 00000000 08:06 97148      /lib/libz.so.1.2.3
b7463000-b7464000 rw-p 00012000 08:06 97148      /lib/libz.so.1.2.3
b7464000-b748e000 r-xp 00000000 08:06 22326      /usr/lib/libpng12.so.0.35.0
b748e000-b748f000 r--p 00029000 08:06 22326      /usr/lib/libpng12.so.0.35.0
b748f000-b7490000 rw-p 0002a000 08:06 22326      /usr/lib/libpng12.so.0.35.0
b7490000-b74d9000 r-xp 00000000 08:06 22312      /usr/lib/libpixman-1.so.0.14.0
b74d9000-b74db000 r--p 00048000 08:06 22312      /usr/lib/libpixman-1.so.0.14.0
b74db000-b74dc000 rw-p 0004a000 08:06 22312      /usr/lib/libpixman-1.so.0.14.0
b74dc000-b74e4000 r-xp 00000000 08:06 21118      /usr/lib/libXrender.so.1.3.0
b74e4000-b74e5000 rw-p 00007000 08:06 21118      /usr/lib/libXrender.so.1.3.0
b74e5000-b74e6000 rw-p b74e5000 00:00 0 
b74e6000-b74e8000 r-xp 00000000 08:06 21094      /usr/lib/libXdamage.so.1.1.0
b74e8000-b74e9000 rw-p 00001000 08:06 21094      /usr/lib/libXdamage.so.1.1.0
b74e9000-b74f9000 r-xp 00000000 08:06 21098      /usr/lib/libXext.so.6.4.0
b74f9000-b74fa000 r--p 0000f000 08:06 21098      /usr/lib/libXext.so.6.4.0
b74fa000-b74fb000 rw-p 00010000 08:06 21098      /usr/lib/libXext.so.6.4.0
b74fb000-b74fd000 r-xp 00000000 08:06 21090      /usr/lib/libXcomposite.so.1.0.0
b74fd000-b74fe000 rw-p 00001000 08:06 21090      /usr/lib/libXcomposite.so.1.0.0
b74fe000-b7507000 r-xp 00000000 08:06 21092      /usr/lib/libXcursor.so.1.0.2
b7507000-b7508000 rw-p 00008000 08:06 21092      /usr/lib/libXcursor.so.1.0.2
b7508000-b750f000 r-xp 00000000 08:06 21116      /usr/lib/libXrandr.so.2.2.0
b750f000-b7510000 r--p 00006000 08:06 21116      /usr/lib/libXrandr.so.2.2.0
b7510000-b7511000 rw-p 00007000 08:06 21116      /usr/lib/libXrandr.so.2.2.0
b7511000-b7512000 rw-p b7511000 00:00 0 
b7512000-b751b000 r-xp 00000000 08:06 21106      /usr/lib/libXi.so.6.0.0
b751b000-b751c000 r--p 00008000 08:06 21106      /usr/lib/libXi.so.6.0.0
b751c000-b751d000 rw-p 00009000 08:06 21106      /usr/lib/libXi.so.6.0.0
b751d000-b751f000 r-xp 00000000 08:06 21108      /usr/lib/libXinerama.so.1.0.0
b751f000-b7520000 rw-p 00001000 08:06 21108      /usr/lib/libXinerama.so.1.0.0
b7520000-b7544000 r-xp 00000000 08:06 96911      /lib/i686/libm-2.9.so
b7544000-b7545000 r--p 00023000 08:06 96911      /lib/i686/libm-2.9.so
b7545000-b7546000 rw-p 00024000 08:06 96911      /lib/i686/libm-2.9.so
b7546000-b7683000 r-xp 00000000 08:06 21082      /usr/lib/libX11.so.6.2.0
b7683000-b7684000 r--p 0013c000 08:06 21082      /usr/lib/libX11.so.6.2.0
b7684000-b7687000 rw-p 0013d000 08:06 21082      /usr/lib/libX11.so.6.2.0
b7687000-b768b000 r-xp 00000000 08:06 21100      /usr/lib/libAbandon
Le bouton en question appelle la fonction OnDelete.
De plus, pour cette fonction, j'ai l'impression de m'etre un peu cassé la tete pour rien
Je pense, qu'il doit y avoir beaucoup plus simple...


Donc, ben si vous avez une petite idée...
Merci