mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 09:16:17 +01:00
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.
This commit is contained in:
parent
4e00fdea9b
commit
459c4f296a
@ -158,6 +158,29 @@ g_property_action_get_state_type (GAction *action)
|
|||||||
static GVariant *
|
static GVariant *
|
||||||
g_property_action_get_state_hint (GAction *action)
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user