[gtkada] Constraint error using Get_Text, Set_Text or Get_Chars with an GEntry Widget ...

JJ Escanellas juanjef at adinet.com.uy
Mon Oct 9 07:16:38 CEST 2000


I'm trying learn how to copy the text of an Entry Widget to another.
With GLADE I've just created Entry1 and Entry2 in Window1.
I've found that Gtk.GEntry has the Get_Text function and
the Set_Text procedure. So I used them in my project.
But I receive a Constraint Error after execution if I try something like:

window1_pkg.ads:

with Gtk.Window; use Gtk.Window;
with Gtk.Box; use Gtk.Box;
with Gtk.Container; use Gtk.Container;
with Gtk.Label; use Gtk.Label;
with Gtk.Misc; use Gtk.Misc;
with Gtk.GEntry; use Gtk.GEntry;
with Gtk.Button; use Gtk.Button;

package Window1_Pkg is

   type Window1_Record is new Gtk_Window_Record with record
      Hbox1 : Gtk_Hbox;
      Label1 : Gtk_Label;
      Entry1 : Gtk_Entry;
      Entry2 : Gtk_Entry;
   end record;
   type Window1_Access is access all Window1_Record'Class;

   procedure Gtk_New (Window1 : out Window1_Access);
   procedure Initialize (Window1 : access Window1_Record'Class);

   Window1 : Window1_Access;

window1_pkg.adb:

with Gtk.Main;use Gtk.Main;
with Glib;use Glib;
with Gtk.GEntry;use Gtk.GEntry;
with Gtk.Editable;use Gtk.Editable;
with Gtk.Text;use Gtk.Text;
with Ada.Strings.Fixed;use Ada.Strings.Fixed;
with Ada.Strings.Unbounded;use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO;use Ada.Strings.Unbounded.Text_IO;
with Ada.Text_IO;use Ada.Text_IO;

package body Window1_Pkg.Callbacks is

   --------------------------
   --  On_Window1_Destroy  --
   --------------------------

   procedure On_Window1_Destroy
     (Object : access Gtk_Window_Record) is
   begin
          Main_Quit;
   end On_Window1_Destroy;

   -------------------------
  --  On_Entry1_Changed  --
   -------------------------

   procedure On_Entry1_Changed
     (Object : access Gtk_Entry_Record) is
          texto: Unbounded_String;
   begin
          texto := To_Unbounded_String("On_Entry1_Changed...");
          Put_Line(texto);
--        texto := To_Unbounded_String(Get_Text(Window1.Entry1));
          texto := To_Unbounded_String(Get_Chars(Gtk_Editable(Window1.Entry1),Gint( 0 ),Gint( -1 ) ));
          Put_Line(texto);
   end On_Entry1_Changed;

   -------------------------
   --  On_Entry2_Changed  --
   -------------------------

   procedure On_Entry2_Changed
     (Object : access Gtk_Entry_Record) is
          texto: Unbounded_String;
   begin
          Put_Line(texto);

   end On_Entry2_Changed;

end Window1_Pkg.Callbacks;




The constraint error appears when I include Get_Text or Get_Chars or Set_Text in
the code.







More information about the gtkada mailing list