Commit 459c4f29 authored by Matthias Clasen's avatar Matthias Clasen

property action: Add state hints

We have this information in the param specs,
we might as well pass it on to give consumers
a chance to present meaningful UIs for these
actions.
parent 4e00fdea
Pipeline #87309 passed with stages
in 14 minutes and 16 seconds
......@@ -158,6 +158,29 @@ g_property_action_get_state_type (GAction *action)
static GVariant *
g_property_action_get_state_hint (GAction *action)
{
GPropertyAction *paction = G_PROPERTY_ACTION (action);
if (paction->pspec->value_type == G_TYPE_INT)
{
GParamSpecInt *pspec = (GParamSpecInt *)paction->pspec;
return g_variant_new ("(ii)", pspec->minimum, pspec->maximum);
}
else if (paction->pspec->value_type == G_TYPE_UINT)
{
GParamSpecUInt *pspec = (GParamSpecUInt *)paction->pspec;
return g_variant_new ("(uu)", pspec->minimum, pspec->maximum);
}
else if (paction->pspec->value_type == G_TYPE_FLOAT)
{
GParamSpecFloat *pspec = (GParamSpecFloat *)paction->pspec;
return g_variant_new ("(dd)", (double)pspec->minimum, (double)pspec->maximum);
}
else if (paction->pspec->value_type == G_TYPE_DOUBLE)
{
GParamSpecDouble *pspec = (GParamSpecDouble *)paction->pspec;
return g_variant_new ("(dd)", pspec->minimum, pspec->maximum);
}
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment