Differences
This shows you the differences between two versions of the page.
building_gui_with_glade_3 [2012/09/15 18:19] fjfabien created by François Fabien |
building_gui_with_glade_3 [2012/12/28 11:02] (current) fjfabien [More] |
||
---|---|---|---|
Line 2: | Line 2: | ||
GTK is a popular library to build portable GUI (Graphical User Interface) written in C and an Ada binding (GTKAda) is available on Adacore Libre site. | GTK is a popular library to build portable GUI (Graphical User Interface) written in C and an Ada binding (GTKAda) is available on Adacore Libre site. | ||
+ | |||
As of 2012, there is the support of the interactive GTK builder Glade3. We describe a basic example of the different steps needed to build a "hello world" with Glade3. | As of 2012, there is the support of the interactive GTK builder Glade3. We describe a basic example of the different steps needed to build a "hello world" with Glade3. | ||
- | === Prequisite === | + | === Prerequisite === |
You must have GTKAda installed and the environnement variable GPR_PROJECT_PATH set to find the project file gtkada.gpr | You must have GTKAda installed and the environnement variable GPR_PROJECT_PATH set to find the project file gtkada.gpr | ||
For Windows, GPR_PROJECT_PATH should look like : | For Windows, GPR_PROJECT_PATH should look like : | ||
+ | |||
C:\GNAT\2012\lib\gnat;C:\GtkAda\lib\gnat (if you used the default locations) | C:\GNAT\2012\lib\gnat;C:\GtkAda\lib\gnat (if you used the default locations) | ||
Line 48: | Line 50: | ||
===== Ada code ===== | ===== Ada code ===== | ||
- | First, we declare the handler/callback that will be attached to the "destroy" signal. The callbacks must be in a package. | + | First, we declare the handler/callback that will be attached to the "destroy" signal. The callbacks must be in a package, otherwise you run into accessibility errors. |
- | The Gobject event "destroy" is handled by "Main_Quit" in XML, and "Main_Quit" is implemented by the Ada procedure Simple_Callbacks.Quit | + | |
+ | The Gobject event "destroy" is handled by "Main_Quit" in XML, and "Main_Quit" is implemented by the Ada procedure Simple_Callbacks.Quit. | ||
+ | |||
+ | The logical connection is : | ||
+ | <code> | ||
+ | signal : GTKObject.destroy => Handler name : "Main_Quit" => Ada callback : Simple_Callbacks.Quit | ||
+ | </code> | ||
=== Callback spec : simple_callbacks.ads === | === Callback spec : simple_callbacks.ads === | ||
Line 172: | Line 179: | ||
This page was adapted from codes of Pascal Pignard in [[http://blady.pagesperso-orange.fr/a_savoir.html#gtkada|Utilisation de la bibliothèque graphique GTKAda (mai 2012)]] and a post of Brian Drummond from GTKAda archives. [[http://lists.adacore.com/pipermail/gtkada/2012-September/004201.html|GtkAda builder example]] | This page was adapted from codes of Pascal Pignard in [[http://blady.pagesperso-orange.fr/a_savoir.html#gtkada|Utilisation de la bibliothèque graphique GTKAda (mai 2012)]] and a post of Brian Drummond from GTKAda archives. [[http://lists.adacore.com/pipermail/gtkada/2012-September/004201.html|GtkAda builder example]] | ||
+ | |||
+ | ===== More ===== | ||
+ | |||
+ | Complete demo programs available from [[http://sourceforge.net/projects/lorenz/files/|Sourceforge]] | ||
+ | |||
+ | * Lorenz chaotic attractor : Drawing demo with GTK timer loop. | ||
+ | * Julia set : GTK interface mixed with Ada tasking. | ||
+ | |||
+ | * For RAD, gate3 is an Ada code sketcher : you build the User Interface with glade3.8, and gate3 generates an Ada prototype that is a valid Ada code. | ||
+ |