Miscellaneous formatting and documentation fixes
authorMatthias Clasen <mclasen@redhat.com>
Sun, 19 Feb 2023 15:09:25 +0000 (15:09 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 19 Feb 2023 15:09:25 +0000 (15:09 +0000)
gtk/gtkaccessible.c
gtk/gtkatcontext.c
gtk/gtkstack.c

index dc56e7d3b3270d8cf851537eadd216da424e7ad8..3f1619e708c9ac5693094dc0ded570c52d9d4cf1 100644 (file)
@@ -48,8 +48,8 @@
  * Also note that when an accessible object does not correspond to a widget,
  * and it has children, whose implementation you don't control,
  * it is necessary to ensure the correct shape of the a11y tree
- * by calling gtk_accessible_set_accessible_parent() and
- * updating the sibling by gtk_accessible_update_next_accessible_sibling().
+ * by calling [method@Gtk.Accessible.set_accessible_parent] and
+ * updating the sibling by [method@Gtk.Accessible.update_next_accessible_sibling].
  */
 
 #include "config.h"
@@ -135,11 +135,19 @@ gtk_accessible_get_accessible_parent (GtkAccessible *self)
 
 /**
  * gtk_accessible_set_accessible_parent:
- * @self: a `GtkAccessible`
- * @parent: the parent `GtkAccessible`
- * @next_sibling: the next accessible sibling of this `GtkAccessible`
+ * @self: an accessible object
+ * @parent: (nullable): the parent accessible object
+ * @next_sibling: (nullable): the sibling accessible object
  *
- * Sets the parent and next sibling accessible of an accessible object
+ * Sets the parent and sibling of an accessible object.
+ *
+ * This function is meant to be used by accessible implementations that are
+ * not part of the widget hierarchy, and but act as a logical bridge between
+ * widgets. For instance, if a widget creates an object that holds metadata
+ * for each child, and you want that object to implement the `GtkAccessible`
+ * interface, you will use this function to ensure that the parent of each
+ * child widget is the metadata object, and the parent of each metadata
+ * object is the container widget.
  *
  * Since: 4.10
  */
@@ -149,14 +157,16 @@ gtk_accessible_set_accessible_parent (GtkAccessible *self,
                                       GtkAccessible *next_sibling)
 {
   g_return_if_fail (GTK_IS_ACCESSIBLE (self));
+  g_return_if_fail (parent == NULL || GTK_IS_ACCESSIBLE (parent));
+  g_return_if_fail (next_sibling == NULL || GTK_IS_ACCESSIBLE (parent));
   GtkATContext *context;
 
   context = gtk_accessible_get_at_context (self);
   if (context != NULL)
-  {
-    gtk_at_context_set_accessible_parent (context, parent);
-    gtk_at_context_set_next_accessible_sibling (context, next_sibling);
-  }
+    {
+      gtk_at_context_set_accessible_parent (context, parent);
+      gtk_at_context_set_next_accessible_sibling (context, next_sibling);
+    }
 }
 
 /**
index 040bc43850c57df853d316f66933bc5e121077e1..5b25a74703e8809743691a49bf27bcd62dc3c03e 100644 (file)
@@ -476,12 +476,7 @@ gtk_at_context_set_accessible_parent (GtkATContext *self,
 {
   g_return_if_fail (GTK_IS_AT_CONTEXT (self));
   
-  if (self->accessible_parent != parent)
-    {
-      if (self->accessible_parent != NULL)
-        g_object_unref (self->accessible_parent);
-      self->accessible_parent = g_object_ref (parent);
-    }
+  g_set_object (&self->accessible_parent, parent);
 }
 
 /*< private >
@@ -513,12 +508,7 @@ gtk_at_context_set_next_accessible_sibling (GtkATContext *self,
 {
   g_return_if_fail (GTK_IS_AT_CONTEXT (self));
   
-  if (self->next_accessible_sibling != sibling)
-    {
-      if (self->next_accessible_sibling != NULL)
-        g_object_unref (self->next_accessible_sibling);
-      self->next_accessible_sibling = g_object_ref (sibling);
-    }
+  g_set_object (&self->next_accessible_sibling, sibling);
 }
 
 /*< private >
index 025bd663c7eb78363d95313ed68af00fec5faaa1..e2e070a1036dab5c2e42ea02db089999bb81cd80 100644 (file)
@@ -411,9 +411,9 @@ gtk_stack_page_set_property (GObject      *object,
     case CHILD_PROP_CHILD:
       g_set_object (&info->widget, g_value_get_object (value));
       gtk_accessible_set_accessible_parent (
-        GTK_ACCESSIBLE (info->widget),
-        GTK_ACCESSIBLE (info),
-        NULL);
+      gtk_accessible_set_accessible_parent (GTK_ACCESSIBLE (info->widget),
+                                            GTK_ACCESSIBLE (info),
+                                            NULL);
       break;
 
     case CHILD_PROP_NAME: