[gtkada] Window reference.
Paul Cass
cassp41 at yahoo.com.au
Thu May 12 04:48:05 CEST 2011
That's basically how I've done it in the past. I haven't written that much code in GTKAda but I recall searching for an alternative, and perhaps simpler solution, with no success.
Paul
Here is some code from a Sudoku program that I wrote - still unfinished :)
(part of a buttons package body)
-- the new button record is stored in an array for later access
procedure Sudoku_Number_Button_New (New_Sudoku_Number : out Sudoku_Number_Button;
Label : in Utf8_String := "";
Sudoku_Number : in Number_Choice := one) is
begin
New_Sudoku_Number := new Sudoku_Number_Button_Record;
Sudoku_Number_Buttons (Sudoku_Number) := New_Sudoku_Number; -- save for later access
Initialize
(New_Sudoku_Number => New_Sudoku_Number,
Label => Label,
Sudoku_Number => Sudoku_Number);
end Sudoku_Number_Button_New;
-- this is the function in the same package to provide access to the button record using a sudoku number (1 to 9)
function Get_Number_Button (Sudoku_Number : Number_Choice) return Sudoku_Number_Button is
-- returns access to the sudoku_number_button_record
begin
return Sudoku_Number_Buttons (Sudoku_Number); -- could be null
end Get_Number_Button;
-- and this is a procedure within a callback package that calls the function above
procedure Set_Number_Buttons_Inactive (Except_For : in Number_Choice) is
begin
For Btn in Number_Choice loop
if Btn /= Except_For then
Sudoku.Filter_Buttons.Set_Active (Get_Number_Button (Btn), False);
end if;
end loop;
end Set_Number_Buttons_Inactive;
From: Pascal <p.p14 at orange.fr>
To: gtkada at lists.adacore.com
Sent: Thursday, 12 May 2011 5:44 AM
Subject: [gtkada] Window reference.
Hello.
I've built a simple window and few widgets with Glade then generated Ada code with gate tool.
From On_Button2_Clicked procedure (Window1_Pkg.Callbacks) I want to access to an other widget present in Window1_Record (Window1_Pkg), but the window referece is created locally in main procedure (Window1) without the possibility to get it out.
So I've modified Gtk_New to store the reference and added a function Get_Window (Window1_Pkg) which return this reference.
Is it the good way to get it?
Or is there a more simple one?
See complete code in attached tgz file.
Thanks, Pascal.
http://blady.pagesperso-orange.fr
_______________________________________________
gtkada mailing list
gtkada at lists.adacore.com
http://lists.adacore.com/mailman/listinfo/gtkada
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/gtkada/attachments/20110511/e14f65c8/attachment.htm
More information about the gtkada
mailing list