diff --git a/src/gui/common/gcal-calendar-row.blp b/src/gui/common/gcal-calendar-row.blp index a95b4959bd96c12ae145c11d90bcf65f72df7ffe..a02399ffb984f60c8fe381b4ef6da8d401376b3d 100644 --- a/src/gui/common/gcal-calendar-row.blp +++ b/src/gui/common/gcal-calendar-row.blp @@ -6,6 +6,8 @@ template $GcalCalendarRow: Adw.PreferencesRow { spacing: 6; Image color_image { + accessible-role: presentation; + styles [ "calendar-color-image", ] diff --git a/src/gui/common/gcal-date-chooser.blp b/src/gui/common/gcal-date-chooser.blp index 6dc45cd06278d8251bf90584105cc0c20a1c9f57..9da7954dc6bf461190f6e42241bb91a09acb99c6 100644 --- a/src/gui/common/gcal-date-chooser.blp +++ b/src/gui/common/gcal-date-chooser.blp @@ -12,13 +12,10 @@ template $GcalDateChooser: Adw.Bin { animate: false; value: 0; wrap: true; + category: _("Month"); visible: bind $get_split_choice_visible(template.show-heading, template.split-month-year) as ; notify::value => $split_multi_choice_changed() swapped; - accessibility { - label: _("Month"); - } - layout { column: 0; row: 0; @@ -32,12 +29,9 @@ template $GcalDateChooser: Adw.Bin { max-value: 9999; animate: false; value: 0; + category: _("Year"); notify::value => $split_multi_choice_changed() swapped; - accessibility { - label: _("Year"); - } - layout { column: 1; row: 0; @@ -52,12 +46,9 @@ template $GcalDateChooser: Adw.Bin { popover: popover; animate: false; value: 0; + category: _("Month"); notify::value => $combined_multi_choice_changed() swapped; - accessibility { - label: _("Month"); - } - layout { column: 0; column-span: 2; @@ -89,10 +80,7 @@ Popover popover { max-value: bind month_choice.max-value bidirectional; animate: bind month_choice.animate bidirectional; value: bind month_choice.value bidirectional; - - accessibility { - label: _("Month"); - } + category: bind month_choice.category bidirectional; } $GcalMultiChoice { @@ -100,10 +88,7 @@ Popover popover { max-value: bind year_choice.max-value bidirectional; animate: bind year_choice.animate bidirectional; value: bind year_choice.value bidirectional; - - accessibility { - label: _("Year"); - } + category: bind year_choice.category bidirectional; } styles [ diff --git a/src/gui/event-editor/gcal-multi-choice.blp b/src/gui/event-editor/gcal-multi-choice.blp index e7b378009c77d9882968d80a8e6845295f3a1f71..da8e3799270941729b8c49a87b952969c139d505 100644 --- a/src/gui/event-editor/gcal-multi-choice.blp +++ b/src/gui/event-editor/gcal-multi-choice.blp @@ -3,11 +3,13 @@ using Gtk 4.0; template $GcalMultiChoice: Box { spacing: 6; accessible-role: spin_button; + notify::category => $set_accessibility_label() swapped; Button down_button { icon-name: "pan-start-symbolic"; clicked => $button_clicked_cb(); can-focus: false; + tooltip-text: bind $get_down_button_tooltip(template.category) as ; styles [ "back-button", @@ -53,6 +55,7 @@ template $GcalMultiChoice: Box { icon-name: "pan-end-symbolic"; clicked => $button_clicked_cb(); can-focus: false; + tooltip-text: bind $get_up_button_tooltip(template.category) as ; styles [ "circular", diff --git a/src/gui/event-editor/gcal-multi-choice.c b/src/gui/event-editor/gcal-multi-choice.c index d7008eaeaab1da5a708f92560bcd9c40cd53e6c7..f13c8fec90228adfedf250b74b556fc9f32932e3 100644 --- a/src/gui/event-editor/gcal-multi-choice.c +++ b/src/gui/event-editor/gcal-multi-choice.c @@ -24,6 +24,8 @@ #include "gcal-multi-choice.h" +#include + struct _GcalMultiChoice { GtkBox parent; @@ -40,6 +42,7 @@ struct _GcalMultiChoice gint max_value; gboolean wrap; gboolean animate; + gchar *category; GtkWidget **choices; gint n_choices; @@ -60,6 +63,7 @@ enum PROP_ANIMATE, PROP_CHOICES, PROP_POPOVER, + PROP_CATEGORY, NUM_PROPERTIES }; @@ -157,6 +161,26 @@ set_value (GcalMultiChoice *self, g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VALUE]); } +static gchar * +get_down_button_tooltip (GcalMultiChoice *self, + gchar *category) +{ + g_autofree gchar *formatted_tooltip = NULL; + + formatted_tooltip = g_strdup_printf (_("Previous %1$s"), category); + return g_steal_pointer (&formatted_tooltip); +} + +static gchar * +get_up_button_tooltip (GcalMultiChoice *self, + gchar *category) +{ + g_autofree gchar *formatted_tooltip = NULL; + + formatted_tooltip = g_strdup_printf (_("Next %1$s"), category); + return g_steal_pointer (&formatted_tooltip); +} + static void go_up (GcalMultiChoice *self) { @@ -222,6 +246,14 @@ update_sensitivity (GcalMultiChoice *self) GTK_ACCESSIBLE_RELATION_CONTROLS); } +static void +set_accessibility_label (GcalMultiChoice *self) +{ + gtk_accessible_update_property (GTK_ACCESSIBLE (self), + GTK_ACCESSIBLE_PROPERTY_LABEL, + gcal_multi_choice_get_category (self), -1); +} + static void button_clicked_cb (GtkWidget *button, GcalMultiChoice *self) @@ -405,6 +437,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 +491,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 +667,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); @@ -658,10 +702,13 @@ gcal_multi_choice_class_init (GcalMultiChoiceClass *class) gtk_widget_class_bind_template_child (widget_class, GcalMultiChoice, label1); gtk_widget_class_bind_template_child (widget_class, GcalMultiChoice, label2); + gtk_widget_class_bind_template_callback (widget_class, set_accessibility_label); gtk_widget_class_bind_template_callback (widget_class, button_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, button_toggled_cb); gtk_widget_class_bind_template_callback (widget_class, button_state_flags_changed_cb); gtk_widget_class_bind_template_callback (widget_class, key_pressed_cb); + gtk_widget_class_bind_template_callback (widget_class, get_down_button_tooltip); + gtk_widget_class_bind_template_callback (widget_class, get_up_button_tooltip); gtk_widget_class_set_css_name (widget_class, "navigator"); } @@ -860,3 +907,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 e2abfb73a1ae0f73f2bde8814f915b6c5d6ae743..20bd6b486935865e5785839f500ceadbaaa3f959 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); diff --git a/src/gui/views/gcal-month-cell.blp b/src/gui/views/gcal-month-cell.blp index d544083fb63b368e22f878b6b90950c67263aecf..4e9b740ded6e2cfd29a8d7d9642e85fb89c15443 100644 --- a/src/gui/views/gcal-month-cell.blp +++ b/src/gui/views/gcal-month-cell.blp @@ -39,6 +39,7 @@ template $GcalMonthCell: Adw.BreakpointBin { Image weather_icon { pixel-size: 16; margin-start: 12; + accessible-role: presentation; styles [ "dimmed", @@ -58,6 +59,7 @@ template $GcalMonthCell: Adw.BreakpointBin { valign: end; sensitive: false; clicked => $overflow_button_clicked_cb(template) not-swapped; + tooltip-text: _("All Events"); styles [ "flat",