summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2025-04-01 16:24:14 +0200
committerColomban Wendling <[email protected]>2025-04-02 19:54:40 +0200
commita8e36f3bfe154237b00853e2804a50afe5531f30 (patch)
treefba848193643df9a95fa7345e31507399eff12c7
parent419c26c13a2ec822cc1005694da96737d1ebb78c (diff)
downloadcaja-a8e36f3bfe154237b00853e2804a50afe5531f30.tar.bz2
caja-a8e36f3bfe154237b00853e2804a50afe5531f30.tar.xz
eel-labeled-image: Implement a11y for button types
Add accessible implementation for EelLabeledImageButton, EelLabeledImageCheckButton, EelLabeledImageToggleButton and EelLabeledImageRadioButton. The implementation is actually the same as the one for EelLabeledImage which already handles the button cases, this just plugs in the right bits for those other types to use it properly. This fixes accessibility of the emblem selector in the file properties window as well as the groups in the "property borwser" (the "Backgrounds & Emblems" window).
-rw-r--r--eel/eel-labeled-image.c94
1 files changed, 91 insertions, 3 deletions
diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c
index 865bcc3e..91ba7cae 100644
--- a/eel/eel-labeled-image.c
+++ b/eel/eel-labeled-image.c
@@ -90,6 +90,9 @@ static GType eel_labeled_image_toggle_button_get_type (void);
/* GtkWidgetClass methods */
static GType eel_labeled_image_accessible_get_type (void);
+static GType eel_labeled_image_button_accessible_get_type (void);
+static GType eel_labeled_image_toggle_button_accessible_get_type (void);
+static GType eel_labeled_image_radio_button_accessible_get_type (void);
/* Private EelLabeledImage methods */
static EelDimensions labeled_image_get_image_dimensions (const EelLabeledImage *labeled_image);
@@ -2268,9 +2271,94 @@ eel_labeled_image_accessible_init (EelLabeledImageAccessible *accessible)
{
}
+/* Actual accessible implementations for Button, CheckButton, ToggleButton and
+ * RadioButton are the same as EelLabeledImageAccessible, which handles those
+ * cases as well. We have different objects just to inherit from the correct
+ * GTK accessible parent. CheckButton and ToggleButton accessible objects
+ * share the same type as GTK uses the same there. */
+
static void
eel_labeled_image_button_class_init (GtkWidgetClass *klass)
{
+ gtk_widget_class_set_accessible_type (klass, eel_labeled_image_button_accessible_get_type ());
+}
+
+static void
+eel_labeled_image_toggle_button_class_init (GtkWidgetClass *klass)
+{
+ gtk_widget_class_set_accessible_type (klass, eel_labeled_image_toggle_button_accessible_get_type ());
+}
+
+static void
+eel_labeled_image_radio_button_class_init (GtkWidgetClass *klass)
+{
+ gtk_widget_class_set_accessible_type (klass, eel_labeled_image_radio_button_accessible_get_type ());
+}
+
+typedef GtkButtonAccessible EelLabeledImageButtonAccessible;
+typedef GtkButtonAccessibleClass EelLabeledImageButtonAccessibleClass;
+
+G_DEFINE_TYPE_WITH_CODE (EelLabeledImageButtonAccessible,
+ eel_labeled_image_button_accessible,
+ GTK_TYPE_BUTTON_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE,
+ eel_labeled_image_accessible_image_interface_init));
+
+static void
+eel_labeled_image_button_accessible_class_init (EelLabeledImageButtonAccessibleClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
+
+ atk_class->get_name = eel_labeled_image_accessible_get_name;
+}
+
+static void
+eel_labeled_image_button_accessible_init (EelLabeledImageButtonAccessible *obj)
+{
+}
+
+typedef GtkToggleButtonAccessible EelLabeledImageToggleButtonAccessible;
+typedef GtkToggleButtonAccessibleClass EelLabeledImageToggleButtonAccessibleClass;
+
+G_DEFINE_TYPE_WITH_CODE (EelLabeledImageToggleButtonAccessible,
+ eel_labeled_image_toggle_button_accessible,
+ GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE,
+ eel_labeled_image_accessible_image_interface_init));
+
+static void
+eel_labeled_image_toggle_button_accessible_class_init (EelLabeledImageToggleButtonAccessibleClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
+
+ atk_class->get_name = eel_labeled_image_accessible_get_name;
+}
+
+static void
+eel_labeled_image_toggle_button_accessible_init (EelLabeledImageToggleButtonAccessible *obj)
+{
+}
+
+typedef GtkRadioButtonAccessible EelLabeledImageRadioButtonAccessible;
+typedef GtkRadioButtonAccessibleClass EelLabeledImageRadioButtonAccessibleClass;
+
+G_DEFINE_TYPE_WITH_CODE (EelLabeledImageRadioButtonAccessible,
+ eel_labeled_image_radio_button_accessible,
+ GTK_TYPE_RADIO_BUTTON_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE,
+ eel_labeled_image_accessible_image_interface_init));
+
+static void
+eel_labeled_image_radio_button_accessible_class_init (EelLabeledImageRadioButtonAccessibleClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
+
+ atk_class->get_name = eel_labeled_image_accessible_get_name;
+}
+
+static void
+eel_labeled_image_radio_button_accessible_init (EelLabeledImageRadioButtonAccessible *obj)
+{
}
static GType
@@ -2314,7 +2402,7 @@ eel_labeled_image_check_button_get_type (void)
sizeof (GtkCheckButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) eel_labeled_image_button_class_init,
+ (GClassInitFunc) eel_labeled_image_toggle_button_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkCheckButton),
@@ -2343,7 +2431,7 @@ eel_labeled_image_toggle_button_get_type (void)
sizeof (GtkToggleButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) eel_labeled_image_button_class_init,
+ (GClassInitFunc) eel_labeled_image_toggle_button_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkToggleButton),
@@ -2372,7 +2460,7 @@ eel_labeled_image_radio_button_get_type (void)
sizeof (GtkRadioButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) eel_labeled_image_button_class_init,
+ (GClassInitFunc) eel_labeled_image_radio_button_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkRadioButton),