[glib/prop-action-state-hints] property action: Add state hints
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/prop-action-state-hints] property action: Add state hints
- Date: Mon, 10 Jun 2019 00:03:59 +0000 (UTC)
commit 459c4f296af01fb8fac2adc5befd9b7d2d617a5b
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 10 00:01:57 2019 +0000
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.
gio/gpropertyaction.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/gio/gpropertyaction.c b/gio/gpropertyaction.c
index c1ce813ae..9ce9ab52e 100644
--- a/gio/gpropertyaction.c
+++ b/gio/gpropertyaction.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]