From 42595e4a65358523ea59f83961506388fdf2a1c1 Mon Sep 17 00:00:00 2001 From: Zoey Ahmed Date: Fri, 2 Jan 2026 18:53:23 +0000 Subject: [PATCH] multi-choice: Add prop for category name This will be binded to both the accessibility label for each multi choice, as opposed to defining it in GcalDateChooser popover. Part-of: --- src/gui/event-editor/gcal-multi-choice.c | 50 ++++++++++++++++++++++++ src/gui/event-editor/gcal-multi-choice.h | 5 +++ 2 files changed, 55 insertions(+) diff --git a/src/gui/event-editor/gcal-multi-choice.c b/src/gui/event-editor/gcal-multi-choice.c index d7008eae..45b2da20 100644 --- a/src/gui/event-editor/gcal-multi-choice.c +++ b/src/gui/event-editor/gcal-multi-choice.c @@ -40,6 +40,7 @@ struct _GcalMultiChoice gint max_value; gboolean wrap; gboolean animate; + gchar *category; GtkWidget **choices; gint n_choices; @@ -60,6 +61,7 @@ enum PROP_ANIMATE, PROP_CHOICES, PROP_POPOVER, + PROP_CATEGORY, NUM_PROPERTIES }; @@ -405,6 +407,10 @@ gcal_multi_choice_get_property (GObject *object, g_value_set_object (value, self->popover); break; + case PROP_CATEGORY: + g_value_set_string (value, gcal_multi_choice_get_category (self)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -455,6 +461,10 @@ gcal_multi_choice_set_property (GObject *object, gcal_multi_choice_set_popover (self, g_value_get_object (value)); break; + case PROP_CATEGORY: + gcal_multi_choice_set_category (self, g_value_get_string (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -627,6 +637,10 @@ gcal_multi_choice_class_init (GcalMultiChoiceClass *class) g_param_spec_object ("popover", "Popover", "Popover", GTK_TYPE_POPOVER, G_PARAM_READWRITE); + properties[PROP_CATEGORY] = + g_param_spec_string ("category", "Category", "Category", + "", + G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); g_object_class_install_properties (object_class, NUM_PROPERTIES, properties); @@ -860,3 +874,39 @@ gcal_multi_choice_get_popover (GcalMultiChoice *self) return GTK_POPOVER (self->popover); } +/** + * gcal_multi_choice_set_category: + * @self: a #GcalMultiChoice + * @category: The category name + * + * Set the value of the category name + */ +void +gcal_multi_choice_set_category (GcalMultiChoice *self, + const gchar *category) +{ + g_assert (GCAL_IS_MULTI_CHOICE (self)); + + if (g_strcmp0 (self->category, category) != 0) + { + self->category = g_strdup (category ? category : ""); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CATEGORY]); + } +} + +/** + * gcal_multi_choice_get_category: + * @self: a #GcalMultiChoice + * + * Get the name of the category + * + * Returns: (transfer none): the category for the multi-choice. + */ +const gchar* +gcal_multi_choice_get_category (GcalMultiChoice *self) +{ + g_assert (GCAL_IS_MULTI_CHOICE (self)); + + return self->category ? self->category : ""; +} diff --git a/src/gui/event-editor/gcal-multi-choice.h b/src/gui/event-editor/gcal-multi-choice.h index e2abfb73..20bd6b48 100644 --- a/src/gui/event-editor/gcal-multi-choice.h +++ b/src/gui/event-editor/gcal-multi-choice.h @@ -39,6 +39,11 @@ GtkPopover* gcal_multi_choice_get_popover (GcalMultiChoic void gcal_multi_choice_set_popover (GcalMultiChoice *self, GtkWidget *popover); +const gchar* gcal_multi_choice_get_category (GcalMultiChoice *self); + +void gcal_multi_choice_set_category (GcalMultiChoice *self, + const gchar *category); + void gcal_multi_choice_set_choices (GcalMultiChoice *self, const gchar **selfs);