MichiB
(Michael Buzgaru)
1
After more than 3 weeks where I read all documentations of the following:
GSimpleAction
GactionMap
Gaction
GSimpleActionGroup
GactionGroup
I realized that I have no clue how to work with the following 3 Funcions:
g_simple_action_set_state_hint()
g_action_get_state_hint()
g_action_group_get_action_state_hint()
Could someone please give me an example code with g_simple_action_set_state_hint()
Function?
1 Like
ebassi
(Emmanuele Bassi)
2
The “state hint” is used for inspecting an action; if you call g_action_get_state_hint()
on an action, you will get:
-
NULL
, meaning: the action is not stateful
- a
GVariant
with the possible values of the state
For instance, if your stateful GSimpleAction
has these possible values:
- ‘hi’
- ‘hello’
- ‘goodbye’
- ‘adieu’
then you will have to create a GVariant
for a tuple of strings with all possible values:
g_simple_action_set_state_hint (action,
g_variant_new ("(ssss)", "hi", "hello", "goodbye", "adieu"));
If your action can accept a range of integer values between 1 and 10, you will need to create a GVariant
with the range:
g_simple_action_set_state_hint (action,
g_variant_new ("(ii)", 1, 10));
And so on, and so forth.
As the documentation states, this is merely a hint.
1 Like
MichiB
(Michael Buzgaru)
3
You saved my Day. Something similar I have already, but never thought that I can some how to set them like in your example.
Thank you for your time.
system
(system)
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.