~ubuntu-branches/ubuntu/intrepid/libgtkada2/intrepid

« back to all changes in this revision

Viewing changes to src/gtk-toggle_action.adb

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-08-11 09:46:51 UTC
  • mfrom: (6.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20080811094651-9mjd6acwa98ffw5c
Tags: 2.12.0-2ubuntu1
Add lpia to supported architectures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-----------------------------------------------------------------------
 
2
--              GtkAda - Ada95 binding for Gtk+/Gnome                --
 
3
--                                                                   --
 
4
--                 Copyright (C) 2006-2008, AdaCore                  --
 
5
--                                                                   --
 
6
-- This library is free software; you can redistribute it and/or     --
 
7
-- modify it under the terms of the GNU General Public               --
 
8
-- License as published by the Free Software Foundation; either      --
 
9
-- version 2 of the License, or (at your option) any later version.  --
 
10
--                                                                   --
 
11
-- This library is distributed in the hope that it will be useful,   --
 
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of    --
 
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --
 
14
-- General Public License for more details.                          --
 
15
--                                                                   --
 
16
-- You should have received a copy of the GNU General Public         --
 
17
-- License along with this library; if not, write to the             --
 
18
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --
 
19
-- Boston, MA 02111-1307, USA.                                       --
 
20
--                                                                   --
 
21
-----------------------------------------------------------------------
 
22
 
 
23
with Gtkada.Bindings;      use Gtkada.Bindings;
 
24
with Interfaces.C.Strings; use Interfaces.C.Strings;
 
25
 
 
26
with Glib.Type_Conversion_Hooks;
 
27
 
 
28
package body Gtk.Toggle_Action is
 
29
 
 
30
   package Type_Conversion is new Glib.Type_Conversion_Hooks.Hook_Registrator
 
31
     (Get_Type'Access, Gtk_Toggle_Action_Record);
 
32
   pragma Warnings (Off, Type_Conversion);
 
33
 
 
34
   ----------------
 
35
   -- Get_Active --
 
36
   ----------------
 
37
 
 
38
   function Get_Active
 
39
     (Action : access Gtk_Toggle_Action_Record) return Boolean
 
40
   is
 
41
      function Internal (Action : System.Address) return Gboolean;
 
42
      pragma Import (C, Internal, "gtk_toggle_action_get_active");
 
43
   begin
 
44
      return Boolean'Val (Internal (Get_Object (Action)));
 
45
   end Get_Active;
 
46
 
 
47
   -----------------------
 
48
   -- Get_Draw_As_Radio --
 
49
   -----------------------
 
50
 
 
51
   function Get_Draw_As_Radio
 
52
     (Action : access Gtk_Toggle_Action_Record) return Boolean
 
53
   is
 
54
      function Internal (Action : System.Address) return Gboolean;
 
55
      pragma Import (C, Internal, "gtk_toggle_action_get_draw_as_radio");
 
56
   begin
 
57
      return Boolean'Val (Internal (Get_Object (Action)));
 
58
   end Get_Draw_As_Radio;
 
59
 
 
60
   -------------
 
61
   -- Gtk_New --
 
62
   -------------
 
63
 
 
64
   procedure Gtk_New
 
65
     (Action   : out Gtk_Toggle_Action;
 
66
      Name     : String;
 
67
      Label    : String := "";
 
68
      Tooltip  : String := "";
 
69
      Stock_Id : String := "")
 
70
   is
 
71
   begin
 
72
      Action := new Gtk_Toggle_Action_Record;
 
73
      Initialize (Action, Name, Label, Tooltip, Stock_Id);
 
74
   end Gtk_New;
 
75
 
 
76
   ----------------
 
77
   -- Initialize --
 
78
   ----------------
 
79
 
 
80
   procedure Initialize
 
81
     (Action   : access Gtk_Toggle_Action_Record'Class;
 
82
      Name     : String;
 
83
      Label    : String := "";
 
84
      Tooltip  : String := "";
 
85
      Stock_Id : String := "")
 
86
   is
 
87
      function Internal
 
88
        (Name     : String;
 
89
         Label    : chars_ptr;
 
90
         Tooltip  : chars_ptr;
 
91
         Stock_Id : chars_ptr)
 
92
         return System.Address;
 
93
      pragma Import (C, Internal, "gtk_toggle_action_new");
 
94
      L : chars_ptr := String_Or_Null (Label);
 
95
      T : chars_ptr := String_Or_Null (Tooltip);
 
96
      S : chars_ptr := String_Or_Null (Stock_Id);
 
97
   begin
 
98
      Set_Object (Action, Internal (Name & ASCII.NUL, L, T, S));
 
99
      Free (L);
 
100
      Free (T);
 
101
      Free (S);
 
102
   end Initialize;
 
103
 
 
104
   ----------------
 
105
   -- Set_Active --
 
106
   ----------------
 
107
 
 
108
   procedure Set_Active
 
109
     (Action    : access Gtk_Toggle_Action_Record;
 
110
      Is_Active : Boolean)
 
111
   is
 
112
      procedure Internal (Action : System.Address; Is_Active : Gboolean);
 
113
      pragma Import (C, Internal, "gtk_toggle_action_set_active");
 
114
   begin
 
115
      Internal (Get_Object (Action), Boolean'Pos (Is_Active));
 
116
   end Set_Active;
 
117
 
 
118
   -----------------------
 
119
   -- Set_Draw_As_Radio --
 
120
   -----------------------
 
121
 
 
122
   procedure Set_Draw_As_Radio
 
123
     (Action        : access Gtk_Toggle_Action_Record;
 
124
      Draw_As_Radio : Boolean)
 
125
   is
 
126
      procedure Internal (Action : System.Address; Draw_As_Radio : Gboolean);
 
127
      pragma Import (C, Internal, "gtk_toggle_action_set_draw_as_radio");
 
128
   begin
 
129
      Internal (Get_Object (Action), Boolean'Pos (Draw_As_Radio));
 
130
   end Set_Draw_As_Radio;
 
131
 
 
132
   -------------
 
133
   -- Toggled --
 
134
   -------------
 
135
 
 
136
   procedure Toggled (Action : access Gtk_Toggle_Action_Record) is
 
137
      procedure Internal (Action : System.Address);
 
138
      pragma Import (C, Internal, "gtk_toggle_action_toggled");
 
139
   begin
 
140
      Internal (Get_Object (Action));
 
141
   end Toggled;
 
142
 
 
143
end Gtk.Toggle_Action;