IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GTK+ Discussion :

[Ada] frame manquent après un callback


Sujet :

GTK+

  1. #1
    Invité
    Invité(e)
    Par défaut [Ada] frame manquent après un callback
    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 :
    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;
    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
    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;
    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
     
    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.
    Dernière modification par liberforce ; 30/11/2017 à 18h49. Motif: Ajout d'un tag pour le langage

  2. #2
    Invité
    Invité(e)
    Par défaut
    Re, alors, ça a été rapide, c'était un peu le fouillis et j'ai ranger, en rangeant j'ai arranger la chose.

    j'ai fait une procédure de plus que je peux appeler distinctement de ma procédure d'initialisation précédente pour initialiser la surface comme je souhaite.

    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
     
       procedure Initialize(S  : in out Surface_Access;
                            As_Drums : in boolean) is
       begin
          if As_Drums then
     
             S := new drums_Type;
             Gtk_New(S.Main_Frame, "Drums");
     
          else
     
             S := new Synthetizer_Type;
             Gtk_New(S.Main_Frame, "Synth");
     
          end if;
       end Initialize;

    Que j'appelle dans le callback du check_button au lieu de rappeler l'initialisation précédente.

    Désolé encore pour le dérangement, je ne travaille jamais suffisamment.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Upload de fichier côté serveur après traitement callback
    Par FoxDeltaSierra dans le forum ASP.NET
    Réponses: 0
    Dernier message: 04/10/2010, 11h05
  2. retourner une variable après un callback de button
    Par roubas dans le forum Interfaces Graphiques
    Réponses: 5
    Dernier message: 19/06/2009, 20h38
  3. Réponses: 1
    Dernier message: 26/12/2007, 13h06
  4. [Framesets] Recharger tous les frames aprés un login
    Par Invité dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 30/05/2007, 10h14
  5. Réponses: 1
    Dernier message: 14/05/2007, 12h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo