[gtk/ebassi/for-master: 9/15] a11y: Icons in buttons are presentational




commit 0af8fb1d11bc5907a1ea67152909942e59a9d85e
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Nov 12 14:53:16 2020 +0000

    a11y: Icons in buttons are presentational
    
    Buttons are described by text, and the icon child can be safely ignored.

 gtk/gtkbutton.c      | 5 ++++-
 gtk/gtkmodelbutton.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 059853106a..9e9a15a422 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -927,7 +927,10 @@ gtk_button_set_icon_name (GtkButton  *button,
 
   if (priv->child_type != ICON_CHILD || priv->child == NULL)
     {
-      GtkWidget *child = gtk_image_new_from_icon_name (icon_name);
+      GtkWidget *child = g_object_new (GTK_TYPE_IMAGE,
+                                       "accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION,
+                                       "icon-name", icon_name,
+                                       NULL);
       gtk_button_set_child (GTK_BUTTON (button), child);
       gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
       gtk_widget_remove_css_class (GTK_WIDGET (button), "text-button");
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index c6e3d04f10..9efed319aa 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -648,7 +648,10 @@ gtk_model_button_set_icon (GtkModelButton *self,
 {
   if (!self->image && icon)
     {
-      self->image = gtk_image_new_from_gicon (icon);
+      self->image = g_object_new (GTK_TYPE_IMAGE,
+                                  "accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION,
+                                  "gicon", icon,
+                                  NULL);
       gtk_widget_insert_before (self->image, GTK_WIDGET (self), self->label);
     }
   else if (self->image && !icon)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]