Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1676 connectés 

  FORUM HardWare.fr
  Programmation
  Ada

  [Résolut]ajout de pages nommées à un notebook avec GtkAda

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Résolut]ajout de pages nommées à un notebook avec GtkAda

n°2036042
Profil sup​primé
Posté le 15-11-2010 à 13:45:53  answer
 

Bonjour,
Je veux simplement saisir le nom du label de page pour j'ajout de page dans un notebook.
 
Voila ce que j'ai fait : Mais ça coince à l'appel de Add_Frame car je ne sais pas comment passer l'entry de ma fenêtre create_new_instrument à Add_Frame.
 

Code :
  1. with Ada.Finalization;
  2. with Gtk.Main, Gtk.Widget, Gtk.Handlers, Gtk.Enums;
  3. use Gtk.Widget;
  4. with Gtk.Window, Gtk.Frame, Gtk.Box, Gtk.Menu_Bar, Gtk.Scrolled_Window;
  5. with Gtk.Button, Gtk.Combo_Box, Gtk.Spin_Button, Gtk.Notebook;
  6. use Gtk.Window, Gtk.Frame, Gtk.Box, Gtk.Menu_Bar, Gtk.Scrolled_Window;
  7. use Gtk.Button, Gtk.Combo_Box, Gtk.Spin_Button, Gtk.Notebook;
  8. with Gtk.Label,Gtk.Menu, Gtk.Menu_Item, Gtk.Stock, Gtk.Dialog;
  9. use Gtk.Label, Gtk.Menu, Gtk.Menu_Item, Gtk.Stock, Gtk.Dialog;
  10. with Gtk.Gentry;
  11. use Gtk.Gentry;
  12.  
  13. package body Mutan.X is
  14.   type T_Main_Window is new Ada.Finalization.Controlled with
  15.      record
  16.  
  17.  
  18.         Window    : Gtk_Window;
  19.         Frame     : Gtk_Frame;
  20.         Vbox      : Gtk_Vbox;
  21.         Menu_Bar  : Gtk_Menu_Bar;
  22.         Scroll    : Gtk_Scrolled_Window;
  23.         Tools     : Gtk_Hbox;
  24.         Start     : Gtk_Button;
  25.         Stop      : Gtk_Button;
  26.         Tempo     : Gtk_Spin_Button;
  27.         LTempo     : Gtk_Label;
  28.         Orchester : Gtk_Notebook; -- insert your instrument here.
  29.  
  30.         -- menu --
  31.         File_Menu           : Gtk_Menu;
  32.         File_Item           : Gtk_Menu_Item;
  33.         Quit_Item           : Gtk_Menu_Item;
  34.         Instrument_Menu     : Gtk_Menu;
  35.         Instrument_Item     : Gtk_Menu_Item;
  36.         New_Instrument_Item : Gtk_Menu_Item;
  37.  
  38.  
  39.      end record;
  40.   package Main_Handlers is new Gtk.Handlers.User_Callback(Gtk_Widget_Record, T_Main_Window);
  41.   procedure Main_Quit(Widget : access Gtk.Widget.Gtk_Widget_Record'class; Main_Window : T_Main_Window);
  42.   procedure Create_New_Instrument(Widget : access Gtk.Widget.Gtk_Widget_Record'class; Main_Window : T_Main_Window);
  43.   procedure Initialize(Main_Window : in out T_Main_Window) is
  44.   begin
  45.  
  46.      Gtk_New(Main_Window.window);
  47.      Gtk_New(Main_Window.Frame);
  48.      Gtk_New_Vbox(Main_Window.Vbox);
  49.      Gtk_New(Main_Window.Menu_bar);
  50.      Gtk_New(Main_Window.Scroll);
  51.      Gtk_New_Hbox(Main_Window.Tools);
  52.      Gtk_New_From_stock(Main_Window.Start, Stock_Media_play);
  53.      Gtk_New_From_stock(Main_Window.Stop, Stock_Media_stop);
  54.  
  55.      Gtk_New(Main_Window.Tempo, 20.0, 300.0, 0.1);
  56.  
  57.  
  58.      Gtk_New(Main_Window.LTempo, "Tempo :" );
  59.      Gtk_New(Main_Window.Orchester);
  60.      Pack_Start(Main_Window.Tools, Main_Window.start, False, False, 0);
  61.      Pack_Start(Main_Window.Tools, Main_Window.stop, False, False, 0);
  62.      Pack_Start(Main_Window.Tools, Main_Window.Ltempo, False, False, 0);
  63.      Pack_Start(Main_Window.Tools, Main_Window.tempo, False, False, 10);
  64.  
  65.      Add_With_Viewport(Main_Window.Scroll, Main_Window.Orchester);
  66.      Pack_Start(Main_Window.Vbox, Main_Window.Menu_Bar, False, False, 0);
  67.      Pack_Start(Main_Window.Vbox, Main_Window.tools, False, False, 0);
  68.      Pack_Start(Main_Window.Vbox, Main_Window.Scroll, True, True, 0);
  69.      Add(Main_Window.Frame, Main_Window.Vbox);
  70.      Add(Main_Window.Window, Main_Window.Frame);
  71.  
  72.  
  73.      -- menu --
  74.      Gtk_New(Main_Window.File_Menu);
  75.      Gtk_New(Main_Window.File_Item, "File" );
  76.      Gtk_New(Main_Window.Quit_Item, "Quit..." );
  77.      Gtk_New(Main_Window.Instrument_Menu);
  78.      Gtk_New(Main_Window.Instrument_Item, "Instruments" );
  79.      Gtk_New(Main_Window.New_Instrument_Item, "Create new instrument..." );
  80.      Append(Main_Window.File_Menu, Main_Window.Quit_Item);
  81.      Append(Main_Window.Menu_Bar, Main_Window.File_Item);
  82.      Set_Submenu(Main_Window.File_Item, Main_Window.File_menu);
  83.      Append(Main_Window.Instrument_Menu, Main_Window.New_instrument_Item);
  84.      Append(Main_Window.Menu_Bar, Main_Window.Instrument_Item);
  85.      Set_Submenu(Main_Window.Instrument_Item, Main_Window.Instrument_menu);
  86.  
  87.      -- connecting --
  88.  
  89.      Main_Handlers.Connect(Main_Window.Window,
  90.                            "destroy",
  91.                            Main_handlers.To_Marshaller(Main_Quit'access),
  92.                            Main_Window);
  93.      Main_Handlers.Connect(Main_Window.Quit_item,
  94.                            "activate",
  95.                            Main_handlers.To_Marshaller(Main_Quit'access),
  96.                            Main_Window);
  97.      Main_Handlers.Connect(Main_Window.New_Instrument_Item,
  98.                            "activate",
  99.                            Main_handlers.To_Marshaller(Create_New_instrument'access),
  100.                            Main_Window);
  101.  
  102.      Show_All(Main_Window.Window);
  103.   end Initialize;
  104.  
  105.  
  106.   procedure Main_Quit(Widget : access Gtk.Widget.Gtk_Widget_Record'class; Main_Window : T_Main_Window) is
  107.      Dialog : Gtk_Dialog;
  108.      Yes    : Gtk_Widget;
  109.      No     : Gtk_Widget;
  110.      Help   : Gtk_Widget;
  111.   begin
  112.      loop
  113.         Gtk_New(Dialog, "Quit ?", Main_Window.Window, modal);
  114.         Yes := Add_Button(Dialog, "Yes", Gtk_Response_Yes);
  115.         No := Add_Button(Dialog, "No", Gtk_Response_No);
  116.         Help := Add_Button(Dialog, "Help", Gtk_Response_Help);
  117.         case Run(Dialog) is
  118.            when Gtk_Response_Yes    =>
  119.               Gtk.Main.Main_Quit;
  120.               exit;
  121.            when  Gtk_Response_No     =>
  122.               exit;
  123.            when Gtk_Response_Help   =>
  124.               null;
  125.            when others =>
  126.               null;
  127.         end case;
  128.         Destroy(Dialog);
  129.      end loop;
  130.      Destroy(Dialog);
  131.   end Main_Quit;
  132.  
  133.   procedure Add_Frame (Widget : access Gtk.Widget.Gtk_Widget_Record'class; Main_Window : T_Main_Window);
  134.  
  135.   procedure Create_New_Instrument(Widget : access Gtk.Widget.Gtk_Widget_Record'class; Main_Window : T_Main_Window) is
  136.      -- getting label of new instrument
  137.      Window : Gtk_Window;
  138.      Vbox   : Gtk_Vbox;
  139.      Label  : Gtk_Label;
  140.      Input  : Gtk_Entry;
  141.      Hbox   : Gtk_Hbox;
  142.      Ok     : Gtk_Button;
  143.      Cancel : Gtk_Button;
  144.      Help   : Gtk_Button;
  145.   begin
  146.      Gtk_New(Window);
  147.      Gtk_New_Vbox(Vbox);
  148.      Gtk_New(Label, "Enter name : " );
  149.      Gtk_New(Input);
  150.      Gtk_New_Hbox(Hbox);
  151.      Gtk_New_From_Stock(Ok, Stock_Ok);
  152.      Gtk_New_From_Stock(Cancel, Stock_Cancel);
  153.      Gtk_New_From_stock(Help, Stock_Help);
  154.      Pack_Start(Vbox, Label, False, False, 0);
  155.      Pack_Start(Vbox, Input, False, False, 0);
  156.      Pack_Start(Hbox, Help, True, False, 0);
  157.      Pack_Start(Hbox, Ok, True, False, 0);
  158.      Pack_Start(Hbox, Cancel, True, False, 0);
  159.      Pack_Start(Vbox, Hbox, False, False, 0);
  160.      Add(Window, vbox);
  161.      Show_All(Window);
  162.      Main_Handlers.Connect(Ok,
  163.                            "clicked",
  164.                            Main_handlers.To_Marshaller(Add_Frame'access),
  165.                            Main_Window);
  166.      Destroy(Window);
  167.   end Create_New_Instrument;
  168.  
  169.  
  170.   procedure Add_Frame (Widget : access Gtk.Widget.Gtk_Widget_Record'class; Main_Window : T_Main_Window) is
  171.  
  172.   begin
  173.      Append_Page_menu(Main_Window.orchester, Main_Frame, label, label);
  174.   end Add_Frame;
  175.  
  176.  
  177.  
  178.   procedure Xmain is
  179.   begin
  180.  
  181.      Gtk.Main.Init;
  182.      declare
  183.  
  184.         Main_Window : T_Main_Window;
  185.      begin
  186.  
  187.         Gtk.Main.Main;
  188.      end;
  189.   end Xmain;
  190.  
  191. end Mutan.X;


 
 
Quelqu'un  peut-il m'aider ?
Merci.


Message édité par Profil supprimé le 16-11-2010 à 13:56:33
mood
Publicité
Posté le 15-11-2010 à 13:45:53  profilanswer
 

n°2036086
Profil sup​primé
Posté le 15-11-2010 à 16:39:21  answer
 

Re bonjour,
En absence de solution, j'ai tenté de nommer automatiquement ma nouvelle page.
J'ai donc ajouté un page_count de type natural dans mon type T_Main_Window et j'ai écrit la procédure Add_Frame suivante..
 

Code :
  1. procedure Add_Frame (Widget : access Gtk.Widget.Gtk_Widget_Record'class; Main_Window : T_Main_Window) is
  2.  
  3.      Label : Gtk_Label;
  4.      Instrument : T_Instrument;
  5.   begin
  6.      Gtk_New(Label, "Instrument N°" & Natural'Image(Main_Window.Page_Count+1));
  7.      Main_Window.Page_Count := Main_Window.Page_Count + 1;
  8.      Append_Page_menu(Main_Window.orchester, Instrument.Main_Frame, label, label);
  9.   end Add_Frame;


 
Le problème c'est que mon paramètre Main_Window est en entrée seulement de par mon instantiation de Handlers.User_Callback.
 
Comment puis-je faire ? S'il vous plait.
Merci bien.

n°2036224
Profil sup​primé
Posté le 16-11-2010 à 11:19:04  answer
 


 
Up, Si j'avais la solution à ce problème, ça m'avancerait. Je dois mal m'y prendre, mais comment faire.


Message édité par Profil supprimé le 16-11-2010 à 11:19:24
n°2036262
breizhbugs
Posté le 16-11-2010 à 12:40:33  profilanswer
 

Bonjour,  
Peut être que si tu expliquais mieux ton problème et ce , sans une seule ligne de ADA ( :vomi: ) plus de gens te comprendrait...


---------------
Seul Google le sait...
n°2036276
Profil sup​primé
Posté le 16-11-2010 à 13:56:12  answer
 

Je sais pas, mais j'ai trouvé une solution en passant des pointeur sur les structure et non les structure elle même.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Ada

  [Résolut]ajout de pages nommées à un notebook avec GtkAda

 

Sujets relatifs
[Ada]|résolu]interuption du signal "destroy" de GtkAdaGénérer les pages plutôt que système de cache
sondage : quel type d'outil préférez-vous pour faire des pages HTML ?problème ajout d'une actualité
Détection automatique lien externe >> frameTemplate CSS , Pages associés
Cache d'un site avec potentiellement 10 milliards de pages ...Pages en double/triple et référencement
[html] afficher d'autres pages sur un siteJquerytools et Ajax (chargement pages)
Plus de sujets relatifs à : [Résolut]ajout de pages nommées à un notebook avec GtkAda


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR