[gtkada] Updating a list box.

Stephen Leake stephen_leake at acm.org
Sat Aug 10 21:21:14 CEST 2002


I'm using GtkAda 1.3.12, on Windows 98.

I'm working on a database application; the database stores books I've
read. The database is MySQL, accessed via GNADE and MyODBC.

Part of one display shows all the titles by an author, using a
Gtk.List box.

Here's the code that updates the List:

      declare
         use Gtk.Widget.Widget_List;
         use Database.Title;
         use type Glib.Gint;

         List_Box_Items : Glist;
         List_Item      : Gtk.List_Item.Gtk_List_Item;
         Item_Count     : Integer := 0;
      begin
         loop
            Database.Title.Fetch
              (Author_List.Title_Table.all, Database.AuthorTitle.Title (Author_List.AuthorTitle_Table.all));

            Gtk.List_Item.Gtk_New
              (List_Item,
               Title (Author_List.Title_Table.all) & "," &
                 Interfaces.Unsigned_16'Image (Year (Author_List.Title_Table.all)));

            Append (List_Box_Items, Gtk.Widget.Gtk_Widget (List_Item));

            Item_Count := Item_Count + 1;

            begin
               Database.AuthorTitle.Next (Author_List.AuthorTitle_Table.all);
            exception
               when Database.No_Data =>
                  exit;
            end;
         end loop;

         Gtk.List.Clear_Items (Author_List.List_Box, 0, -1);
         Gtk.List.Prepend_Items (Author_List.List_Box, List_Box_Items);
         Gtk.List.Show (Author_List.List_Box);
         Ada.Text_IO.Put_Line ("Author_List.List item count: " & Integer'Image (Item_Count));
      end;


The problem is this. The first time thru this code (at application
startup), the list shows the correct titles. But the next time, no
titles show up. The list is cleared, and Item_Count is correct, but no
titles show!

I've tried Gtk.List.Append_Items; no better.

If I comment out the Clear_Items, the first items stay there; no new
items are added.

I guess I'll try Gtk.Clist, see if that's any better.
-- 
-- Stephe





More information about the gtkada mailing list