event-editor/multi-choice: Implement GtkAccessibleRange

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/603>
This commit is contained in:
Hari Rana
2025-06-29 08:51:17 -04:00
parent 70b9fde162
commit 2a7a4e3b30
+31 -1
View File
@@ -75,8 +75,11 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
static void gcal_multi_choice_accessible_init (GtkAccessibleInterface *iface); static void gcal_multi_choice_accessible_init (GtkAccessibleInterface *iface);
static void gcal_multi_choice_accessible_range_init (GtkAccessibleRangeInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GcalMultiChoice, gcal_multi_choice, GTK_TYPE_BOX, G_DEFINE_TYPE_WITH_CODE (GcalMultiChoice, gcal_multi_choice, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE, gcal_multi_choice_accessible_init)) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE, gcal_multi_choice_accessible_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE_RANGE, gcal_multi_choice_accessible_range_init))
/* /*
* Auxiliary methods * Auxiliary methods
@@ -115,6 +118,9 @@ apply_value (GcalMultiChoice *self,
text = get_value_string (self, self->value); text = get_value_string (self, self->value);
gtk_label_set_text (GTK_LABEL (label), text); gtk_label_set_text (GTK_LABEL (label), text);
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, text,
-1);
g_free (text); g_free (text);
if (!self->animate) if (!self->animate)
@@ -142,6 +148,12 @@ set_value (GcalMultiChoice *self,
apply_value (self, transition); apply_value (self, transition);
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, (gdouble) self->max_value,
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, (gdouble) self->min_value,
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, (gdouble) self->value,
-1);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VALUE]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VALUE]);
} }
@@ -482,6 +494,18 @@ gcal_multi_choice_accessible_get_platform_state (GtkAccessible *acc
return gtk_accessible_get_platform_state (GTK_ACCESSIBLE (self->button), state); return gtk_accessible_get_platform_state (GTK_ACCESSIBLE (self->button), state);
} }
/*
* GtkAccessibleRange overrides
*/
static gboolean
gcal_multi_choice_accessible_range_set_current_value (GtkAccessibleRange *accessible_range,
gdouble value)
{
gcal_multi_choice_set_value (GCAL_MULTI_CHOICE (accessible_range), value);
return TRUE;
}
/* /*
* Init * Init
*/ */
@@ -574,6 +598,12 @@ gcal_multi_choice_accessible_init (GtkAccessibleInterface *iface)
iface->get_platform_state = gcal_multi_choice_accessible_get_platform_state; iface->get_platform_state = gcal_multi_choice_accessible_get_platform_state;
} }
static void
gcal_multi_choice_accessible_range_init (GtkAccessibleRangeInterface *iface)
{
iface->set_current_value = gcal_multi_choice_accessible_range_set_current_value;
}
static void static void
gcal_multi_choice_init (GcalMultiChoice *self) gcal_multi_choice_init (GcalMultiChoice *self)
{ {