Bonjour,
J'ai dans un notebook des frames contenant une check_button qui permet de changer le contenu d'une box qui peut donc contenir soit une frame nommée Synth soit une frame nommé Drums.
A l'initialisation pas de problème, mais lors du callback du check_button la frame contenu dans la box est bien supprimé mais la nouvelle n'est pas ajouter.
Avec GtkAda, j'ai fait ceci :
les types :
La procédure d'initialisation :
Code ada : 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 type Surface_Type is tagged record Main_Vbox : Gtk.Box.Gtk_Vbox; Main_Frame : Gtk_Frame; end record; type Surface_Access is access all Surface_Type'Class; type Interface_Type is tagged record Main_Frame : Gtk_Frame; Label : Gtk.Label.Gtk_Label; Main_Vbox : Gtk.Box.Gtk_Vbox; Hbox : Gtk.Box.Gtk_HBox; Check_Is_Drums : Gtk.Check_Button.Gtk_Check_Button; Surface_box : Gtk_vbox; Channel_Combo_Box : Gtk_Combo_Box; Surface : Surface_Access; Is_Drums : Boolean := False; Channel : Channel_Type := 0; Eq : Control_Unit_Access; InsFx_1 : Control_Unit_Access; InsFx_2 : Control_Unit_Access; end record; type Interface_Access is access all Interface_Type'Class;
Le callback du check_button :
Code ada : 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 procedure Initialize(Surface : in Interface_Access; As_Drums : in boolean) is begin Text_Io.Put_Line("Initialize surface..."); Text_Io.Put_Line("TOTO 2.1"); Gtk.Check_Button.Gtk_New(Surface.Check_Is_Drums, "Set as drums"); if As_Drums then Surface.Is_Drums := True; Surface.surface := new drums_Type; Gtk_New(Surface.Surface.Main_Frame, "Drums"); Set_Active(Surface.Check_Is_Drums, True); else Surface.Is_Drums := False; Surface.surface := new Synthetizer_Type; Gtk_New(Surface.Surface.Main_Frame, "Synth"); Set_Active(Surface.Check_Is_Drums, False); end if; Gtk.Box.Gtk_New_Vbox(Surface.Main_Vbox); Gtk.Box.Gtk_New_Hbox(Surface.Hbox); Gtk.Box.Gtk_New_Vbox(Surface.Surface_Box); Text_Io.Put_Line("TOTO 2.3"); Gtk_New_Text(Surface.Channel_Combo_box); for I in 1..16 loop insert_Text(Surface.Channel_Combo_box, Glib.Gint(I-1), "Channel" & Positive'Image(I)); end loop; Set_Active(Surface.Channel_Combo_box, Glib.Gint(Surface.Channel)); Text_Io.Put_Line("TOTO 2.4"); Gtk.Box.Pack_Start(Surface.Surface_box, Surface.Surface.Main_Frame, False, False, 0); Gtk.Box.Pack_Start(Surface.Hbox, Surface.Check_Is_Drums, False, False, 0); Gtk.Box.Pack_Start(Surface.Hbox, Surface.Channel_Combo_box, False, False, 0); Gtk.Box.Pack_Start(Surface.Main_Vbox, Surface.Hbox, False, False, 0); Gtk.Box.Pack_Start(Surface.Main_Vbox, Surface.Surface_box, False, False, 0); Text_Io.Put_Line("Init Timbre..."); Text_Io.Put_Line("TOTO 2.5"); Interfaces_Handlers.Connect(Surface.Check_Is_Drums, "toggled", Interfaces_handlers.To_Marshaller(Set_To_Active'access), Surface); Text_Io.Put_Line("TOTO 2.6"); Interfaces_Handlers.Connect(Surface.Channel_Combo_Box, "changed", Interfaces_handlers.To_Marshaller(Set_Timbre_Channel'access), surface); Text_Io.Put_Line("TOTO 2.7"); Gtk_New(Surface.Main_Frame); Add(Surface.Main_Frame, Surface.Main_Vbox); Text_Io.Put_Line("TOTO 2.8"); Show_All(Surface.Main_Frame); Text_Io.Put_Line("TOTO 2.9"); end Initialize;
Code ada : 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 procedure Set_To_Active(Widget : access Gtk.Widget.Gtk_Widget_Record'class; Surface : Interface_access) is Child_Widget : Gtk_Widget; begin Child_Widget := Gtk.Box.Get_Child(Surface.Surface_Box, 0); if Child_Widget /= null then Remove(Surface.Surface_box, Child_Widget); end if; case Gtk.Check_Button.Get_Active(Surface.Check_Is_Drums) is when True => Initialize(Surface, True); when False => Initialize(Surface, False); end case; end Set_To_Active;
Ce qui donne ceci en image : Pièce jointe 139057
Si vous pouviez me dépatouiller du problème, si vous pouvez, merci.
Partager