[gtk/ebassi/new-a11y: 49/63] a11y: Update GtkSeparator



commit 0fa95b749f5e61b7c25e6a8ef3d9bfae57e6af99
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Jul 13 16:26:24 2020 +0100

    a11y: Update GtkSeparator
    
    Add an accessible role, and update the orientation state.

 gtk/gtkseparator.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c
index 6a515dbf89..63ad838027 100644
--- a/gtk/gtkseparator.c
+++ b/gtk/gtkseparator.c
@@ -26,6 +26,7 @@
 
 #include "gtkseparator.h"
 
+#include "gtkaccessible.h"
 #include "gtkintl.h"
 #include "gtkorientable.h"
 #include "gtkprivate.h"
@@ -70,6 +71,24 @@ enum {
 G_DEFINE_TYPE_WITH_CODE (GtkSeparator, gtk_separator, GTK_TYPE_WIDGET,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
 
+static void
+gtk_separator_set_orientation (GtkSeparator   *self,
+                               GtkOrientation  orientation)
+{
+  if (self->orientation != orientation)
+    {
+      self->orientation = orientation;
+
+      gtk_widget_update_orientation (GTK_WIDGET (self), orientation);
+      gtk_widget_queue_resize (GTK_WIDGET (self));
+
+      gtk_accessible_update_property (GTK_ACCESSIBLE (self),
+                                      GTK_ACCESSIBLE_PROPERTY_ORIENTATION, orientation,
+                                      -1);
+
+      g_object_notify (G_OBJECT (self), "orientation");
+    }
+}
 
 static void
 gtk_separator_set_property (GObject      *object,
@@ -82,14 +101,7 @@ gtk_separator_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ORIENTATION:
-      if (separator->orientation != g_value_get_enum (value))
-        {
-          separator->orientation = g_value_get_enum (value);
-          gtk_widget_update_orientation (GTK_WIDGET (object),
-                                         separator->orientation);
-          gtk_widget_queue_resize (GTK_WIDGET (object));
-          g_object_notify_by_pspec (object, pspec);
-        }
+      gtk_separator_set_orientation (separator, g_value_get_enum (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -137,6 +149,7 @@ gtk_separator_class_init (GtkSeparatorClass *class)
   g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
 
   gtk_widget_class_set_css_name (widget_class, I_("separator"));
+  gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_SEPARATOR);
 }
 
 /**


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