* Re: GtkAda and the Tree_Store Widget
2003-09-05 6:57 GtkAda and the Tree_Store Widget Adam Puleo
2003-09-05 8:52 ` Preben Randhol
@ 2003-09-08 5:56 ` max1
1 sibling, 0 replies; 4+ messages in thread
From: max1 @ 2003-09-08 5:56 UTC (permalink / raw)
Adam Puleo wrote:
> I'm trying to use the Tree_Store widget in GtkAda 2.2.0 but nothing shows up
Try this:
with Glib;
with Gtk.Box;
with Gtk.Main;
with Gtk.Enums;
with Gtk.Widget;
with Gtk.Window;
with Gtk.Button;
with Gtk.Tree_View;
with Gtk.Tree_Store;
with Gtk.Tree_Model;
with Gtk.Tree_View_Column;
with Gtk.Scrolled_Window;
with Gtk.Cell_Renderer_Text;
procedure Gtk_Test is
use type Glib.Gint;
Box : Gtk.Box.Gtk_Box;
Window : Gtk.Window.Gtk_Window;
Scroll : Gtk.Scrolled_Window.Gtk_Scrolled_Window;
Button : Gtk.Button.Gtk_Button;
Store : Gtk.Tree_Store.Gtk_Tree_Store;
View : Gtk.Tree_View.Gtk_Tree_View;
Parent : Gtk.Tree_Model.Gtk_Tree_Iter := Gtk.Tree_Model.Null_Iter;
Iter : Gtk.Tree_Model.Gtk_Tree_Iter;
Types : Glib.GType_Array (0 .. 0);
Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column;
Render : Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text;
Ignore : Glib.Gint;
begin
Gtk.Main.Init;
Gtk.Window.Gtk_New (Window);
Gtk.Box.Gtk_New_Vbox (Box);
Gtk.Button.Gtk_New (Button, "Hello World");
Gtk.Box.Pack_Start (Box, Button, False, False);
Gtk.Scrolled_Window.Gtk_New (Scroll);
Gtk.Scrolled_Window.Set_Border_Width (Scroll, 5);
Gtk.Scrolled_Window.Set_Policy
(Scroll,
Gtk.Enums.Policy_Automatic,
Gtk.Enums.Policy_Automatic);
Gtk.Box.Pack_Start (Box, Scroll);
Types (0) := Glib.GType_String;
Gtk.Tree_Store.Gtk_New (Store, Types);
for I in 1 .. 1000 loop
Iter := Gtk.Tree_Model.Null_Iter;
Gtk.Tree_Store.Append (Store, Iter, Parent);
Gtk.Tree_Store.Set (Store, Iter, 0,
Gtk.Tree_Model.To_String (Gtk.Tree_Store.Get_Path (
Store, Iter)));
end loop;
Gtk.Tree_View.Gtk_New (View, Store);
Gtk.Cell_Renderer_Text.Gtk_New (Render);
for I in 1 .. Glib.Gint'(18) loop
Gtk.Tree_View_Column.Gtk_New (Column);
Gtk.Tree_View_Column.Pack_Start (Column, Render, True);
Gtk.Tree_View_Column.Add_Attribute (Column, Render, "text", 0);
Ignore := Gtk.Tree_View.Append_Column (View, Column);
end loop;
Gtk.Scrolled_Window.Add (Scroll, View);
Gtk.Window.Add (Window, Box);
Gtk.Scrolled_Window.Show (Scroll);
Gtk.Button.Show (Button);
Gtk.Tree_View.Show (View);
Gtk.Box.Show (Box);
Gtk.Window.Show (Window);
Gtk.Main.Main;
end Gtk_Test;
^ permalink raw reply [flat|nested] 4+ messages in thread