comp.lang.ada
 help / color / mirror / Atom feed
From: Gavin McCord <gavind.mccord@gmail.com>
Subject: GEntry with autocomplete
Date: Mon, 7 Mar 2022 00:06:19 -0000 (UTC)	[thread overview]
Message-ID: <t03i9r$lmj$1@dont-email.me> (raw)

I'm looking at including a GEntry with autocomplete
in some code of mine, and have created a simple example,
test.adb, which I've constructed from tutorial examples
(though from other languages, such as Python and PHP).



with Gtk.Main;
with Gtk.Window;           use Gtk.Window;
with Gtk.GEntry;           use Gtk.Gentry;
with Gtk.List_Store;       use Gtk.List_Store;
with Gtk.Tree_Model;       use Gtk.Tree_Model;
with Gtk.Entry_Completion; use Gtk.Entry_Completion;
with Gtkada.Handlers;      use Gtkada.Handlers;
with Glib;                 use Glib;

with test_cb; use test_cb;

procedure Test is
   Win          : Gtk_Window;
   Entry_1      : Gtk_GEntry;
   List_1       : Gtk_Tree_Model;
   Iter_1       : Gtk_Tree_Iter;
   Completion_1 : Gtk_Entry_Completion;
   type Word_Array is Array (1 .. 3) of String (1 .. 5);
   Words        : Word_Array;
begin
   Gtk.Main.Init;
   Gtk_New (Win);
   Win.Set_Title ("Window");
   Win.On_Delete_Event (main_del'Access);
   Win.On_Destroy (main_quit'Access);
   Win.Set_Border_Width (10);

   Words(1) := "Alpha";
   Words(2) := "Bravo";
   Words(3) := "Delta";

   Gtk_New (List_1, (0 => GType_String)); -- 0 - the first column
   for Count in 1 .. 3 loop
      List_1.Append (Iter_1);
      Set (List_1, Iter_1, 0, Words(Count));
      -- 0 The first column
   end loop;

   Gtk_New (Completion_1);
   Completion_1.Set_Model (List_1);
   Completion_1.Set_Text_Column(0);

   Gtk_New (Entry_1);
   Entry_1.Set_Completion(Completion_1);
   Win.Add (Entry_1);

   Win.Show_All;

   Gtk.Main.Main;
end Test;




Compilation fails at line 40 "Completion_1.Set_Model (List_1)"
with the error

test.adb:40:28: error: expected private type "Gtk_Tree_Model" defined at
gtk-tree_model.ads:195
test.adb:40:28: error: found type "Gtk_List_Store" defined at
gtk-list_store.ads:139

Presumably, I've missed something in translation.

Thanks for any help.

Gavin

             reply	other threads:[~2022-03-07  0:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07  0:06 Gavin McCord [this message]
2022-03-07  7:18 ` GEntry with autocomplete Dmitry A. Kazakov
2022-03-08 23:46   ` Gavin McCord
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox