1
-----------------------------------------------------------------------
2
-- GtkAda - Ada95 binding for Gtk+/Gnome --
4
-- Copyright (C) 2006-2007, AdaCore --
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. --
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. --
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. --
21
-----------------------------------------------------------------------
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
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)
34
-- - whether label indicates a stock id
35
-- - a tooltip (optional, translated)
36
-- - a toolbar label (optional, shorter than label)
38
-- The action will also have some state information:
39
-- - visible (shown/hidden)
40
-- - sensitive (enabled/disabled)
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
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.
52
-- <c_version>2.8.17</c_version>
53
-- <group>Action-based menus</group>
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;
68
(Action : out Gtk_Action;
71
Tooltip : String := "";
72
Stock_Id : String := "");
74
(Action : access Gtk_Action_Record'Class;
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.
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,
89
function Get_Type return GType;
90
-- Return the internal value associated with a Gtk_Action
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
96
-- It can also be used to manually activate an action.
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.
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.
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.
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.
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.
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.
135
function Get_Name (Action : access Gtk_Action_Record) return String;
136
-- Returns the name of the action.
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.
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
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.
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
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
176
-- Disconnect_Proxy does not destroy the widget.
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
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
192
-- This function is intended for use by action implementations.
199
-- The following properties are defined for this widget. See
200
-- Glib.Properties for more information on properties.
202
-- Name: Action_Group_Property
204
-- Descr: The Gtk_Action_Group this Gtk_Action is associated with, or NULL
205
-- (for internal use).
207
-- Name: Hide_If_Empty_Property
209
-- Descr: When TRUE, empty menu proxies for this action are hidden.
211
-- Name: Is_Important_Property
213
-- Descr: Whether the action is considered important.
215
-- Name: Label_Property
217
-- Descr: The label used for menu items and buttons
219
-- Name: Name_Property
221
-- Descr: A unique name for the action.
223
-- Name: Sensitive_Property
225
-- Descr: Whether the action is enabled.
227
-- Name: Short_Label_Property
229
-- Descr: A shorter label that may be used on toolbar buttons.
231
-- Name: Stock_Id_Property
233
-- Descr: The stock icon displayed in widgets representing
235
-- Name: Tooltip_Property
237
-- Descr: A tooltip for this action.
239
-- Name: Visible_Property
241
-- Descr: Whether the action is visible.
243
-- Name: Visible_Horizontal_Property
245
-- Descr: Whether the toolbar item is visible when the toolbar
247
-- Name: Visible_Overflown_Property
249
-- Descr: When TRUE, toolitem proxies for this action
251
-- Name: Visible_Vertical_Property
253
-- Descr: Whether the toolbar item is visible when the toolbar
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;
276
-- The following new signals are defined for this widget:
279
-- procedure Handler (Action : access Gtk_Action_Record'Class);
280
-- The "activate" signal is emitted when the action is activated.
283
Signal_Activate : constant Glib.Signal_Name := "activate";
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");
313
pragma Import (C, Get_Type, "gtk_action_get_type");
316
-- No binding: gtk_action_get_accel_closure