AccelMapProtocol
public protocol AccelMapProtocol : ObjectProtocol
Accelerator maps are used to define runtime configurable accelerators.
Functions for manipulating them are are usually used by higher level
convenience mechanisms like GtkUIManager
and are thus considered
“low-level”. You’ll want to use them if you’re manually creating menus that
should have user-configurable accelerators.
An accelerator is uniquely defined by:
- accelerator path
- accelerator key
- accelerator modifiers
The accelerator path must consist of “<WINDOWTYPE>/Category1/Category2/…/Action”, where WINDOWTYPE should be a unique application-specific identifier that corresponds to the kind of window the accelerator is being used in, e.g. “Gimp-Image”, “Abiword-Document” or “Gnumeric-Settings”. The “Category1/…/Action” portion is most appropriately chosen by the action the accelerator triggers, i.e. for accelerators on menu items, choose the item’s menu path, e.g. “File/Save As”, “Image/View/Zoom” or “Edit/Select All”. So a full valid accelerator path may look like: “<Gimp-Toolbox>/File/Dialogs/Tool Options…”.
All accelerators are stored inside one global GtkAccelMap
that can
be obtained using gtk_accel_map_get()
. See
Monitoring changes for additional
details.
Manipulating accelerators
New accelerators can be added using gtk_accel_map_add_entry()
.
To search for specific accelerator, use gtk_accel_map_lookup_entry()
.
Modifications of existing accelerators should be done using
gtk_accel_map_change_entry()
.
In order to avoid having some accelerators changed, they can be
locked using gtk_accel_map_lock_path()
. Unlocking is done using
gtk_accel_map_unlock_path()
.
Saving and loading accelerator maps
Accelerator maps can be saved to and loaded from some external
resource. For simple saving and loading from file,
gtk_accel_map_save()
and gtk_accel_map_load()
are provided.
Saving and loading can also be done by providing file descriptor
to gtk_accel_map_save_fd()
and gtk_accel_map_load_fd()
.
Monitoring changes
GtkAccelMap
object is only useful for monitoring changes of
accelerators. By connecting to GtkAccelMap::changed
signal, one
can monitor changes of all accelerators. It is also possible to
monitor only single accelerator path by using it as a detail of
the GtkAccelMap::changed
signal.
The AccelMapProtocol
protocol exposes the methods and properties of an underlying GtkAccelMap
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see AccelMap
.
Alternatively, use AccelMapRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkAccelMap
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
accel_map_ptr
Default implementationTyped pointer to the underlying
GtkAccelMap
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkAccelMap
instance.Declaration
Swift
var accel_map_ptr: UnsafeMutablePointer<GtkAccelMap>! { get }
-
Required Initialiser for types conforming to
AccelMapProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
AccelMapSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: AccelMapSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
AccelMapSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: AccelMapSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onChanged(flags:
Extension methodhandler: ) Notifies of a change in the global accelerator map. The path is also used as the detail for the signal, so it is possible to connect to changed``
accel_path
.Note
This represents the underlyingchanged
signalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: AccelMapRef, _ accelPath: String, _ accelKey: UInt, _ accelMods: Gdk.ModifierType) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
accelPath
the path of the accelerator that changed
accelKey
the key value for the new accelerator
accelMods
the modifier mask for the new accelerator
handler
The signal handler to call Run the given callback whenever the
changed
signal is emitted -
changedSignal
Extension methodTyped
changed
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var changedSignal: AccelMapSignalName { get }