summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2020-08-05 18:04:34 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2020-08-25 16:36:08 +0100
commit32a1cd13c8abd3015af5923344d463eee6a6d3a5 (patch)
tree72746a77f2bbd17dfc9883240368b40727ac9fbb
parent1338dcddcb3a7174049da75c030a79cc0f50905d (diff)
downloadgtk+-32a1cd13c8abd3015af5923344d463eee6a6d3a5.tar.gz
a11y: Notify callers when an attributes set changes
We can use that information inside the ATContext.
-rw-r--r--gtk/gtkaccessibleattributeset.c37
-rw-r--r--gtk/gtkaccessibleattributesetprivate.h4
2 files changed, 35 insertions, 6 deletions
diff --git a/gtk/gtkaccessibleattributeset.c b/gtk/gtkaccessibleattributeset.c
index abdc0950ed..f49a9cf911 100644
--- a/gtk/gtkaccessibleattributeset.c
+++ b/gtk/gtkaccessibleattributeset.c
@@ -114,13 +114,26 @@ gtk_accessible_attribute_set_unref (GtkAccessibleAttributeSet *self)
*
* If you want to remove @attribute from the set, use gtk_accessible_attribute_set_remove()
* instead.
+ *
+ * Returns: %TRUE if the set was modified, and %FALSE otherwise
*/
-void
+gboolean
gtk_accessible_attribute_set_add (GtkAccessibleAttributeSet *self,
int attribute,
GtkAccessibleValue *value)
{
- g_return_if_fail (attribute >= 0 && attribute < self->n_attributes);
+ g_return_val_if_fail (attribute >= 0 && attribute < self->n_attributes, FALSE);
+
+ if (value != NULL)
+ {
+ if (gtk_accessible_value_equal (value, self->attribute_values[attribute]))
+ return FALSE;
+ }
+ else
+ {
+ if (!_gtk_bitmask_get (self->attributes_set, attribute))
+ return FALSE;
+ }
g_clear_pointer (&(self->attribute_values[attribute]), gtk_accessible_value_unref);
@@ -130,18 +143,34 @@ gtk_accessible_attribute_set_add (GtkAccessibleAttributeSet *self,
self->attribute_values[attribute] = (* self->default_func) (attribute);
self->attributes_set = _gtk_bitmask_set (self->attributes_set, attribute, TRUE);
+
+ return TRUE;
}
-void
+/*< private >
+ * gtk_accessible_attribute_set_remove:
+ * @self: a #GtkAccessibleAttributeSet
+ * @attribute: the attribute to be removed
+ *
+ * Resets the @attribute in the given #GtkAccessibleAttributeSet to its default value.
+ *
+ * Returns: %TRUE if the set was modified, and %FALSE otherwise
+ */
+gboolean
gtk_accessible_attribute_set_remove (GtkAccessibleAttributeSet *self,
int attribute)
{
- g_return_if_fail (attribute >= 0 && attribute < self->n_attributes);
+ g_return_val_if_fail (attribute >= 0 && attribute < self->n_attributes, FALSE);
+
+ if (!_gtk_bitmask_get (self->attributes_set, attribute))
+ return FALSE;
g_clear_pointer (&(self->attribute_values[attribute]), gtk_accessible_value_unref);
self->attribute_values[attribute] = (* self->default_func) (attribute);
self->attributes_set = _gtk_bitmask_set (self->attributes_set, attribute, FALSE);
+
+ return TRUE;
}
gboolean
diff --git a/gtk/gtkaccessibleattributesetprivate.h b/gtk/gtkaccessibleattributesetprivate.h
index 57a1e63e35..83694c7ede 100644
--- a/gtk/gtkaccessibleattributesetprivate.h
+++ b/gtk/gtkaccessibleattributesetprivate.h
@@ -37,10 +37,10 @@ void gtk_accessible_attribute_set_unref
gsize gtk_accessible_attribute_set_get_length (GtkAccessibleAttributeSet *self);
-void gtk_accessible_attribute_set_add (GtkAccessibleAttributeSet *self,
+gboolean gtk_accessible_attribute_set_add (GtkAccessibleAttributeSet *self,
int attribute,
GtkAccessibleValue *value);
-void gtk_accessible_attribute_set_remove (GtkAccessibleAttributeSet *self,
+gboolean gtk_accessible_attribute_set_remove (GtkAccessibleAttributeSet *self,
int state);
gboolean gtk_accessible_attribute_set_contains (GtkAccessibleAttributeSet *self,
int state);