File: table_test.adb

package info (click to toggle)
libgtkada 2.24.4dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,208 kB
  • ctags: 1,676
  • sloc: ada: 119,686; ansic: 4,719; sh: 3,003; makefile: 690; xml: 338; perl: 70
file content (79 lines) | stat: -rw-r--r-- 2,037 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
with Table; use Table;
with Gtk.Window, Gtk.Button, Gtk.Table, Gtk.Main;
use  Gtk.Window, Gtk.Button, Gtk.Table;

procedure Table_Test is
   Window : Gtk_Window;
   Button : Gtk_Button;
   Table  : Gtk_Table;

begin
   Gtk.Main.Init;

   --  Create a new window
   Gtk_New (Window);

   --  Set the window title
   Set_Title (Window, "Table");

   --  Set a handler for delete_event that immediately
   --  exits GTK.

   Return_Handlers.Connect
     (Window,
      "delete_event",
      Return_Handlers.To_Marshaller (Delete_Event'Access));

   --  Sets the border width of the window.
   Set_Border_Width (Window, 20);

   --  Create a 2x2 table
   Gtk_New (Table, 2, 2, True);

   --  Put the table in the main window
   Add (Window, Table);

   --  Create first button
   Gtk_New (Button, "button 1");

   --  When the button is clicked, we call the "callback" function
   --  with a pointer to "button 1" as its argument

   Handlers.Connect
     (Button, "clicked", Handlers.To_Marshaller (Callback'Access),
      new String'("button 1"));

   --  Insert button 1 into the upper left quadrant of the table
   Attach_Defaults (Table, Button, 0, 1, 0, 1);

   --  Create second button

   Gtk_New (Button, "button 2");

   --  When the button is clicked, we call the "callback" function
   --  with a pointer to "button 2" as its argument
   Handlers.Connect
     (Button, "clicked",
      Handlers.To_Marshaller (Callback'Access), new String'("button 2"));

   --  Insert button 2 into the upper right quadrant of the table
   Attach_Defaults (Table, Button, 1, 2, 0, 1);

   --  Create "Quit" button
   Gtk_New (Button, "Quit");

   --  When the button is clicked, we call the "Quit" function
   --  and the program exits

   Handlers.Connect
     (Button, "clicked", Handlers.To_Marshaller (Quit'Access),
      new String'("Button Pressed"));

   --  Insert the quit button into the both
   --  lower quadrants of the table
   Attach_Defaults (Table, Button, 0, 2, 1, 2);

   Show_All (Window);

   Gtk.Main.Main;
end Table_Test;