N7SD logo

HOME      INDEX

Running “canvas_view_items” from testgtk via Alire


Minimal Setup: Run testgtk “GtkAda demo” – “canvas_view_items” with Alire

Date: June 28 2025
Confirmed versions:
Ubuntu: 24.04.2 LTS, Gnat: 14.2.1, Gtkada:25.0.1
PC: OMEN 17-ck2095cl, i9-13900HX, RTX-4080

canvas_view_item application screen

Setup Build Space “canvas_view_items” for “create_canvas_view_items”

testgtk sample project name: create_about
New directory name: about
~$ mkdir ada/s_testgtk
~$ cd ada/s_testgtk
~/ada/s_testgtk$ alr init canvas_view_items –bin

Alire needs some user information to initialize the crate author and maintainer,
for eventual submission to the Alire community index. This information will be
interactively requested now.
You can edit this information at any time with ‘alr config’
Enter a short description of the crate: (default: ”)

Press Enter
Using default: ”
Please enter your email address: (default: ‘example@example.com’)
Press Enter
Using default: ‘example@example.com’
Select a software license for the crate?

  1. MIT OR Apache-2.0 WITH LLVM-exception
  2. MIT
  3. Apache-2.0 WITH LLVM-exception
  4. Apache-2.0
  5. BSD-3-Clause
  6. LGPL-3.0-or-later
  7. GPL-3.0-or-later WITH GCC-exception-3.1
  8. GPL-3.0-or-later
  9. Other…

Enter your choice index (#1 is default):

Press Enter
Enter a comma (‘,’) separated list of tags to help people find your crate: (default: ”)
Press Enter
Using default: ”
Enter an optional Website URL for the crate: (default: ”)
Press Enter
Using default: ”
✓ canvas_view_items initialized successfully.

Setup gtkada Environment

~/ada/s_testgtk$ cd canvas_view_items/

~/ada/s_testgtk/canvas_view_items$ alr with gtkada

◴ Updating index… remote: Enumerating objects: 126, done.
remote: Counting objects: 100% (99/99), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 126 (delta 57), reused 77 (delta 48), pack-reused 27 (from 1)
Receiving objects: 100% (126/126), 47.03 KiB | 3.62 MiB/s, done.
Resolving deltas: 100% (61/61), completed with 17 local objects.
From https://github.com/alire-project/alire-index
4f64614..f814b95 stable-1.3.0 -> origin/stable-1.3.0
01882d3..c8f57b5 stable-1.4.0 -> origin/stable-1.4.0
Updating 4f64614..f814b95
Fast-forward
index/pr/press_utils/press_utils-1.0.0.toml | 15 +++++++++++++++
…/sparkfun_qwiic_motor_driver-0.1.0.toml | 19 +++++++++++++++++++
2 files changed, 34 insertions(+)
create mode 100644 index/pr/press_utils/press_utils-1.0.0.toml
create mode 100644 index/sp/sparkfun_qwiic_motor_driver/sparkfun_qwiic_motor_driver-0.1.0.toml
◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)… Looking for e. ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)… Looking for e. ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)… Looking for e. ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)… Looking for e. ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)… Looking for e. ◵ Solving dependencies: 0/0/0/6 (complete/partial/dupes/states)… Looking for e. Requested changes:
✓ gtkada ^25.0.1 (add)
Changes to dependency solution:

  • gtkada 25.0.1 (new)
    +📦 libgtk3 3.24.41 (new,indirect,system package)
    +📦 make 4.3.0 (new,indirect,system package)
    +📦 pkg_config 1.8.1 (new,indirect,system package)

Do you want to proceed?
[Y] Yes [N] No (default is Yes) Yes

~/ada/s_testgtk/canvas_view_items$ alr build

ⓘ Building canvas_view_items=0.1.0-dev/canvas_view_items.gpr...          
Setup
   [mkdir]        object directory for project Canvas_View_Items
   [mkdir]        exec directory for project Canvas_View_Items
Compile
   [Ada]          canvas_view_items.adb
Bind
   [gprbind]      canvas_view_items.bexch
   [Ada]          canvas_view_items.ali
Link
   [link]         canvas_view_items.adb
✓ Build finished successfully in 0.66 seconds.

Setup Source Files

~/ada/s_testgtk/canvas_view_items$ ls -al

total 44
drwxrwxr-x 8 mm mm 4096 Jun 26 11:01 .
drwxrwxr-x 6 mm mm 4096 Jun 26 11:00 ..
drwxrwxr-x 3 mm mm 4096 Jun 26 11:01 alire
-rw-rw-r– 1 mm mm 310 Jun 26 11:01 alire.toml
drwxrwxr-x 2 mm mm 4096 Jun 26 11:01 bin
-rw-rw-r– 1 mm mm 630 Jun 26 11:00 canvas_view_items.gpr
drwxrwxr-x 2 mm mm 4096 Jun 26 11:00 config
-rw-rw-r– 1 mm mm 29 Jun 26 11:00 .gitignore
drwxrwxr-x 3 mm mm 4096 Jun 26 11:01 obj
drwxrwxr-x 3 mm mm 4096 Jun 26 11:00 share
drwxrwxr-x 2 mm mm 4096 Jun 26 11:00 src

Copy 2 files from the testgtk directory into src directory.

https://github.com/AdaCore/gtkada/tree/master/testgtk

create_canvas_view_items.ads
create_canvas_view_items.adb

~/ada/s_testgtk/canvas_view_items$ cd src

~/ada/s_testgtk/canvas_view_items/src$ ls -al

total 32
drwxrwxr-x 2 mm mm 4096 Jun 26 11:05 .
drwxrwxr-x 8 mm mm 4096 Jun 26 11:01 ..
-rw-rw-r– 1 mm mm 69 Jun 26 11:00 canvas_view_items.adb
-rw-rw-r– 1 mm mm 15983 Jun 26 11:04 create_canvas_view_items.adb
-rw-rw-r– 1 mm mm 1924 Jun 26 11:04 create_canvas_view_items.ads

Edit Source File

 

canvas_view_items.adb is auto-created file

~/ada/s_testgtk/canvas_view_items/src$ cat canvas_view_items.adb

procedure Canvas_View_Items is
begin
   null;
end Canvas_View_Items;

Edit main program canvas_view_items.adb

with Gdk.Event;       --  use Gdk.Event;
--  with label;    use Label;
--  with Gdk;             use Gdk;
with Gtk.Box;         use Gtk.Box;
with Gtk.Widget;      use Gtk.Widget;
with Gtk.Main;
with Gtk.Window;      use Gtk.Window;

--  ****** Add DEFINITION ***********
with Gtk.Frame;       use Gtk.Frame;
with Create_Canvas_View_Items;
--  **********************************

procedure Canvas_View_Items is

   Win   : Gtk_Window;
   Box   : Gtk_Vbox;
   Frame1  : Gtk_Frame;  --  ****** ADD DEFINITION

   function Delete_Event_Cb
     (Self  : access Gtk_Widget_Record'Class;
      Event : Gdk.Event.Gdk_Event)
      return Boolean;

   ---------------------
   -- Delete_Event_Cb --
   ---------------------

   function Delete_Event_Cb
     (Self  : access Gtk_Widget_Record'Class;
      Event : Gdk.Event.Gdk_Event)
      return Boolean
   is
      pragma Unreferenced (Self, Event);
   begin
   --  Close all child windows before closing main loop
      Win.Destroy;
      Gtk.Main.Main_Quit;
      return True;
   end Delete_Event_Cb;

----  Main Program ---------------------
begin
   --  Initialize GtkAda.
   Gtk.Main.Init;

   --  Create a window with a size of 400x400
   Gtk_New (Win);
   Win.Set_Default_Size (400, 400);

   --  Create a box to organize vertically the contents of the window
   Gtk_New_Vbox (Box);
   Win.Add (Box);

   Gtk.Frame.Gtk_New (Frame1);
   Add (Box, Frame1);
   Create_Canvas_View_Items.Run (Frame1);   –  CALL Package.Procedure

   --  Stop the Gtk process when closing the window
   Win.On_Delete_Event (Delete_Event_Cb'Unrestricted_Access);

   --  Show the window and present it
   Win.Show_All;
   Win.Present;

   --  Start the Gtk+ main loop
   Gtk.Main.Main;
end Canvas_View_Items;

Startup GnatStudio with Alire

~/ada/s_testgtk/canvas_view_items$ alr edit

GnatStudio Openinig screen displays gpr file

Change Project File (gpr)

File canvas_view_items.gpr opens as above screen automatically.
File canvas_view_items.gpr before modification:

with "config/canvas_view_items_config.gpr";
project Canvas_View_Items is

   for Source_Dirs use ("src/", "config/");
   for Object_Dir use "obj/" & Canvas_View_Items_Config.Build_Profile;
   for Create_Missing_Dirs use "True";
   for Exec_Dir use "bin";
   for Main use ("canvas_view_items.adb");

   package Compiler is
      for Default_Switches ("Ada") use Canvas_View_Items_Config.Ada_Compiler_Switches;
   end Compiler;

   package Binder is
      for Switches ("Ada") use ("-Es"); --  Symbolic traceback
   end Binder;

   package Install is
      for Artifacts (".") use ("share");
   end Install;

end Canvas_View_Items;

Modify canvas_view_items.gpr. 

Add the following line at the next of “for Main use (“canvas_view_items.adb”);

for Source_Files use (“create_canvas_view_items.adb”, “create_canvas_view_items.ads”, “canvas_view_items.adb”);

File about.gpr after the modification

with "config/canvas_view_items_config.gpr";
project Canvas_View_Items is

   for Source_Dirs use ("src/", "config/");
   for Object_Dir use "obj/" & Canvas_View_Items_Config.Build_Profile;
   for Create_Missing_Dirs use "True";
   for Exec_Dir use "bin";
   for Main use ("canvas_view_items.adb");
   for Source_Files use
     ("create_canvas_view_items.adb", "create_canvas_view_items.ads", "canvas_view_items.adb");

   package Compiler is
      for Default_Switches ("Ada") use Canvas_View_Items_Config.Ada_Compiler_Switches;
   end Compiler;

   package Binder is
      for Switches ("Ada") use ("-Es"); --  Symbolic traceback
   end Binder;

   package Install is
      for Artifacts (".") use ("share");
   end Install;

end Canvas_View_Items;

Copy 2 files from the GitHub and move into the bin directory

https://github.com/AdaCore/gtkada/tree/master/testgtk

refresh.svg
search_and_menu.png

Build

Build all icon

Build message

gprbuild -d -P/home/mm/ada/s_testgtk/canvas_view_items/canvas_view_items.gpr -XLIBRARY_TYPE=static -XBUILD=Production -XGTK_PREFIX=/home/mm/.local/share/alire/builds/gtkada_25.0.1_d3787772/05561da954afaee17128f59bba699db2f2e4a4215317b2b818a8016192c82334/ -XOBJCFLAGS= -XLDFLAGS= -XCPPFLAGS= -XCFLAGS= -XADAFLAGS=
Compile
   [Ada]          canvas_view_items.adb
   [Ada]          create_canvas_view_items.adb
Bind
   [gprbind]      canvas_view_items.bexch
   [Ada]          canvas_view_items.ali
Link
   [link]         canvas_view_items.adb
[2025-06-26 11:48:17] process terminated successfully, elapsed time: 01.80s

Execution

Execution runs only in Terminal mode or GnatStudio without error message.
~/ada/s_testgtk/canvas_view_items/bin$ ./canvas_view_items 

canvas_view_items application