Package: gio

Function g-action-parse-detailed-name

Lambda List

g-action-parse-detailed-name (detailed)

Arguments

detailed -- a string with a detailed action name

Return Value

name -- a string with the action name
value -- a g-variant target value, or a null-pointer value for no target

Details

Parses a detailed action name into its separate name and target components. Detailed action names can have three formats.

The first format is used to represent an action name with no target value and consists of just an action name containing no whitespace nor the characters ':', '(' or ')'. For example: "app.action".

The second format is used to represent an action with a target value that is a non-empty string consisting only of alphanumerics, plus '-' and '.'. In that case, the action name and target value are separated by a double colon ("::"). For example: "app.action::target".

The third format is used to represent an action with any type of target value, including strings. The target value follows the action name, surrounded in parens. For example: "app.action(42)". The target value is parsed using the g-variant-parse function. If a tuple-typed value is desired, it must be specified in the same way, resulting in two sets of parens, for example: "app.action((1,2,3))". A string target can be specified this way as well: "app.action('target')". For strings, this third format must be used if * target value is empty or contains characters other than alphanumerics, '-' and '.'.

Examples

;; First format
(g-action-parse-detailed-name "app.action")
=> "app.action"
=> #.(SB-SYS:INT-SAP #X00000000)
;; Second format
(g-action-parse-detailed-name "app.action::target")
=> "app.action"
=> #.(SB-SYS:INT-SAP #X7F5B7000E8D0)
(g-variant-string
    (second (multiple-value-list
        (g-action-parse-detailed-name "app.action::target"))))
=> "target"
;; Third format
(g-action-parse-detailed-name "app.action(42)")
=> "app.action"
=> #.(SB-SYS:INT-SAP #X7F5B7000E870)
(g-variant-int32
    (second (multiple-value-list
        (g-action-parse-detailed-name "app.action(42)"))))
=> 42    
 

See also

2021-12-10