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

« back to all changes in this revision

Viewing changes to src/gtk-action.ads

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2008-07-31 18:10:47 UTC
  • mfrom: (1.1.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20080731181047-6m1y25zjad0p2yjr
Tags: 2.12.0-2

Correct the project files to add a Library_ALI_Dir and correct the
Library_Name.

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-2007, 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
--  <description>
 
24
--  Actions represent operations that the user can perform, along with some
 
25
--  information on how it should be presented in the interface. Each action
 
26
--  provides methods to create icons, menu items and toolbar items representing
 
27
--  itself.
 
28
--
 
29
--  As well as the callback that is called when the action gets activated, the
 
30
--  following also gets associated with the action:
 
31
--    - a name (not translated, for path lookup)
 
32
--    - a label (translated, for display)
 
33
--    - an accelerator
 
34
--    - whether label indicates a stock id
 
35
--    - a tooltip (optional, translated)
 
36
--    - a toolbar label (optional, shorter than label)
 
37
--
 
38
--  The action will also have some state information:
 
39
--    - visible (shown/hidden)
 
40
--    - sensitive (enabled/disabled)
 
41
--
 
42
--  Apart from regular actions, there are toggle actions, which can be toggled
 
43
--  between two states and radio actions, of which only one in a group can be
 
44
--  in the "active" state. Other actions can be implemented as Gtk_Action
 
45
--  subclasses.
 
46
--
 
47
--  Each action can have one or more proxy menu item, toolbar button or other
 
48
--  proxy widgets. Proxies mirror the state of the action (text label, tooltip,
 
49
--  icon, visible, sensitive, etc), and should change when the action's state
 
50
--  changes. When the proxy is activated, it should activate its action.
 
51
--  </description>
 
52
--  <c_version>2.8.17</c_version>
 
53
--  <group>Action-based menus</group>
 
54
 
 
55
with Glib.Properties;
 
56
with Gtk.Accel_Group;
 
57
with Gtk.Enums;
 
58
with Gtk.Object;
 
59
with Gtk.Widget;
 
60
with System;
 
61
 
 
62
package Gtk.Action is
 
63
 
 
64
   type Gtk_Action_Record is new Gtk.Object.Gtk_Object_Record with null record;
 
65
   type Gtk_Action is access all Gtk_Action_Record'Class;
 
66
 
 
67
   procedure Gtk_New
 
68
     (Action   : out Gtk_Action;
 
69
      Name     : String;
 
70
      Label    : String;
 
71
      Tooltip  : String := "";
 
72
      Stock_Id : String := "");
 
73
   procedure Initialize
 
74
     (Action   : access Gtk_Action_Record'Class;
 
75
      Name     : String;
 
76
      Label    : String;
 
77
      Tooltip  : String := "";
 
78
      Stock_Id : String := "");
 
79
   --  Creates a new Gtk_Action object. To add the action to a Gtk_Action_Group
 
80
   --  and set the accelerator for the action, call
 
81
   --  Gtk.Action_Group.Add_Action_With_Accel.
 
82
   --  Name must be a unique name for the action. Label is the label displayed
 
83
   --  in menu items and on buttons.
 
84
 
 
85
   function Convert (C_Object : System.Address) return Gtk_Action;
 
86
   --  Convert a C object to a Gtk_Action. The type of the C object must match,
 
87
   --  of course.
 
88
 
 
89
   function Get_Type return GType;
 
90
   --  Return the internal value associated with a Gtk_Action
 
91
 
 
92
   procedure Activate (Action : access Gtk_Action_Record);
 
93
   --  Emits the "activate" signal on the specified action, if it isn't
 
94
   --  insensitive. This gets called by the proxy widgets when they get
 
95
   --  activated.
 
96
   --  It can also be used to manually activate an action.
 
97
 
 
98
   procedure Connect_Accelerator    (Action : access Gtk_Action_Record);
 
99
   procedure Disconnect_Accelerator (Action : access Gtk_Action_Record);
 
100
   --  Installs the accelerator for Action if Action has an accel path and
 
101
   --  group. See Set_Accel_Path and Set_Accel_Group.
 
102
   --  Since multiple proxies may independently trigger the installation
 
103
   --  of the accelerator, the Action counts the number of times this
 
104
   --  function has been called and doesn't remove the accelerator until
 
105
   --  Disconnect_Accelerator has been called as many times.
 
106
 
 
107
   function Create_Icon
 
108
     (Action    : access Gtk_Action_Record;
 
109
      Icon_Size : Gtk.Enums.Gtk_Icon_Size) return Gtk.Widget.Gtk_Widget;
 
110
   --  This function is intended for use by action implementations to
 
111
   --  create icons displayed in the proxy widgets.
 
112
   --  Returns a widget that displays the icon for this action.
 
113
 
 
114
   function Create_Menu_Item
 
115
     (Action : access Gtk_Action_Record) return Gtk.Widget.Gtk_Widget;
 
116
   --  Creates a menu item widget that proxies for the given action.
 
117
 
 
118
   function Create_Tool_Item
 
119
     (Action : access Gtk_Action_Record) return Gtk.Widget.Gtk_Widget;
 
120
   --  Creates a toolbar item widget that proxies for the given action.
 
121
 
 
122
   procedure Set_Accel_Group
 
123
     (Action      : access Gtk_Action_Record;
 
124
      Accel_Group : Gtk.Accel_Group.Gtk_Accel_Group := null);
 
125
   --  Sets the Gtk_Accel_Group in which the accelerator for this action
 
126
   --  will be installed.
 
127
 
 
128
   procedure Set_Accel_Path
 
129
     (Action : access Gtk_Action_Record; Accel_Path : String);
 
130
   function Get_Accel_Path (Action : access Gtk_Action_Record) return String;
 
131
   --  Sets the accel path for this action.  All proxy widgets associated
 
132
   --  with the action will have this accel path, so that their
 
133
   --  accelerators are consistent.
 
134
 
 
135
   function Get_Name (Action : access Gtk_Action_Record) return String;
 
136
   --  Returns the name of the action.
 
137
 
 
138
   procedure Set_Sensitive
 
139
     (Action    : access Gtk_Action_Record; Sensitive : Boolean);
 
140
   function Get_Sensitive (Action : access Gtk_Action_Record) return Boolean;
 
141
   --  Returns whether the action itself is sensitive. Note that this doesn't
 
142
   --  necessarily mean effective sensitivity. See Is_Sensitive for that.
 
143
 
 
144
   function Is_Sensitive (Action : access Gtk_Action_Record) return Boolean;
 
145
   --  Returns whether the action is effectively sensitive.
 
146
   --  Returns True if teh action and its associated action group are both
 
147
   --  sensitive.
 
148
 
 
149
   procedure Set_Visible
 
150
     (Action : access Gtk_Action_Record; Visible : Boolean);
 
151
   function Get_Visible (Action : access Gtk_Action_Record) return Boolean;
 
152
   --  Returns whether the action itself is visible. Note that this doesn't
 
153
   --  necessarily mean effective visibility. See Is_Visible for that.
 
154
 
 
155
   function Is_Visible (Action : access Gtk_Action_Record) return Boolean;
 
156
   --  Returns whether the action is effectively visible.
 
157
   --  Returns True if the action and its associated action group are both
 
158
   --  visible.
 
159
 
 
160
   -------------
 
161
   -- Proxies --
 
162
   -------------
 
163
 
 
164
   procedure Connect_Proxy
 
165
     (Action : access Gtk_Action_Record;
 
166
      Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class);
 
167
   procedure Disconnect_Proxy
 
168
     (Action : access Gtk_Action_Record;
 
169
      Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class);
 
170
   --  Connects a widget to an action object as a proxy. Synchronises various
 
171
   --  properties of the action with the widget (such as label text, icon,
 
172
   --  tooltip, etc), and attaches a callback so that the action gets activated
 
173
   --  when the proxy widget does.
 
174
   --  If the widget is already connected to an action, it is disconnected
 
175
   --  first.
 
176
   --  Disconnect_Proxy does not destroy the widget.
 
177
 
 
178
   function Get_Proxies
 
179
     (Action : access Gtk_Action_Record) return Gtk.Widget.Widget_SList.GSlist;
 
180
   --  Returns the proxy widgets for an action. The returned list must not be
 
181
   --  modified
 
182
 
 
183
   procedure Block_Activate_From
 
184
     (Action : access Gtk_Action_Record;
 
185
      Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class);
 
186
   procedure Unblock_Activate_From
 
187
     (Action : access Gtk_Action_Record;
 
188
      Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class);
 
189
   --  Disables calls to the Activate function by signals on the given proxy
 
190
   --  widget. This is used to break notification loops for things like check
 
191
   --  or radio actions.
 
192
   --  This function is intended for use by action implementations.
 
193
 
 
194
   ----------------
 
195
   -- Properties --
 
196
   ----------------
 
197
 
 
198
   --  <properties>
 
199
   --  The following properties are defined for this widget. See
 
200
   --  Glib.Properties for more information on properties.
 
201
   --
 
202
   --  Name:  Action_Group_Property
 
203
   --  Type:  Object
 
204
   --  Descr: The Gtk_Action_Group this Gtk_Action is associated with, or NULL
 
205
   --        (for internal use).
 
206
   --
 
207
   --  Name:  Hide_If_Empty_Property
 
208
   --  Type:  Boolean
 
209
   --  Descr: When TRUE, empty menu proxies for this action are hidden.
 
210
   --
 
211
   --  Name:  Is_Important_Property
 
212
   --  Type:  Boolean
 
213
   --  Descr: Whether the action is considered important.
 
214
   --
 
215
   --  Name:  Label_Property
 
216
   --  Type:  String
 
217
   --  Descr: The label used for menu items and buttons
 
218
   --
 
219
   --  Name:  Name_Property
 
220
   --  Type:  String
 
221
   --  Descr: A unique name for the action.
 
222
   --
 
223
   --  Name:  Sensitive_Property
 
224
   --  Type:  Boolean
 
225
   --  Descr: Whether the action is enabled.
 
226
   --
 
227
   --  Name:  Short_Label_Property
 
228
   --  Type:  String
 
229
   --  Descr: A shorter label that may be used on toolbar buttons.
 
230
   --
 
231
   --  Name:  Stock_Id_Property
 
232
   --  Type:  String
 
233
   --  Descr: The stock icon displayed in widgets representing
 
234
   --
 
235
   --  Name:  Tooltip_Property
 
236
   --  Type:  String
 
237
   --  Descr: A tooltip for this action.
 
238
   --
 
239
   --  Name:  Visible_Property
 
240
   --  Type:  Boolean
 
241
   --  Descr: Whether the action is visible.
 
242
   --
 
243
   --  Name:  Visible_Horizontal_Property
 
244
   --  Type:  Boolean
 
245
   --  Descr: Whether the toolbar item is visible when the toolbar
 
246
   --
 
247
   --  Name:  Visible_Overflown_Property
 
248
   --  Type:  Boolean
 
249
   --  Descr: When TRUE, toolitem proxies for this action
 
250
   --
 
251
   --  Name:  Visible_Vertical_Property
 
252
   --  Type:  Boolean
 
253
   --  Descr: Whether the toolbar item is visible when the toolbar
 
254
   --
 
255
   --  </properties>
 
256
 
 
257
   Action_Group_Property       : constant Glib.Properties.Property_Object;
 
258
   Hide_If_Empty_Property      : constant Glib.Properties.Property_Boolean;
 
259
   Is_Important_Property       : constant Glib.Properties.Property_Boolean;
 
260
   Label_Property              : constant Glib.Properties.Property_String;
 
261
   Name_Property               : constant Glib.Properties.Property_String;
 
262
   Sensitive_Property          : constant Glib.Properties.Property_Boolean;
 
263
   Short_Label_Property        : constant Glib.Properties.Property_String;
 
264
   Stock_Id_Property           : constant Glib.Properties.Property_String;
 
265
   Tooltip_Property            : constant Glib.Properties.Property_String;
 
266
   Visible_Property            : constant Glib.Properties.Property_Boolean;
 
267
   Visible_Horizontal_Property : constant Glib.Properties.Property_Boolean;
 
268
   Visible_Overflown_Property  : constant Glib.Properties.Property_Boolean;
 
269
   Visible_Vertical_Property   : constant Glib.Properties.Property_Boolean;
 
270
 
 
271
   -------------
 
272
   -- Signals --
 
273
   -------------
 
274
 
 
275
   --  <signals>
 
276
   --  The following new signals are defined for this widget:
 
277
   --
 
278
   --  - "activate"
 
279
   --    procedure Handler (Action : access Gtk_Action_Record'Class);
 
280
   --    The "activate" signal is emitted when the action is activated.
 
281
   --  </signals>
 
282
 
 
283
   Signal_Activate : constant Glib.Signal_Name := "activate";
 
284
 
 
285
private
 
286
   Action_Group_Property : constant Glib.Properties.Property_Object :=
 
287
     Glib.Properties.Build ("action-group");
 
288
   Hide_If_Empty_Property : constant Glib.Properties.Property_Boolean :=
 
289
     Glib.Properties.Build ("hide-if-empty");
 
290
   Is_Important_Property : constant Glib.Properties.Property_Boolean :=
 
291
     Glib.Properties.Build ("is-important");
 
292
   Label_Property : constant Glib.Properties.Property_String :=
 
293
     Glib.Properties.Build ("label");
 
294
   Name_Property : constant Glib.Properties.Property_String :=
 
295
     Glib.Properties.Build ("name");
 
296
   Sensitive_Property : constant Glib.Properties.Property_Boolean :=
 
297
     Glib.Properties.Build ("sensitive");
 
298
   Short_Label_Property : constant Glib.Properties.Property_String :=
 
299
     Glib.Properties.Build ("short-label");
 
300
   Stock_Id_Property : constant Glib.Properties.Property_String :=
 
301
     Glib.Properties.Build ("stock-id");
 
302
   Tooltip_Property : constant Glib.Properties.Property_String :=
 
303
     Glib.Properties.Build ("tooltip");
 
304
   Visible_Property : constant Glib.Properties.Property_Boolean :=
 
305
     Glib.Properties.Build ("visible");
 
306
   Visible_Horizontal_Property : constant Glib.Properties.Property_Boolean :=
 
307
     Glib.Properties.Build ("visible-horizontal");
 
308
   Visible_Overflown_Property : constant Glib.Properties.Property_Boolean :=
 
309
     Glib.Properties.Build ("visible-overflown");
 
310
   Visible_Vertical_Property : constant Glib.Properties.Property_Boolean :=
 
311
     Glib.Properties.Build ("visible-vertical");
 
312
 
 
313
   pragma Import (C, Get_Type, "gtk_action_get_type");
 
314
end Gtk.Action;
 
315
 
 
316
--  No binding: gtk_action_get_accel_closure