forked from AuroraMiddleware/gtk
a11y: Consolidate the attributes container
While we have split the various attributes for convenience, there's no reason why we should have specialised data types for the attributes container object.
This commit is contained in:
parent
1124f2507d
commit
732578eb53
249
gtk/gtkaccessibleattributeset.c
Normal file
249
gtk/gtkaccessibleattributeset.c
Normal file
@ -0,0 +1,249 @@
|
||||
/* gtkaccessibleattributeset.c: Accessible attribute containt
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkaccessibleattributesetprivate.h"
|
||||
|
||||
#include "gtkbitmaskprivate.h"
|
||||
#include "gtkenums.h"
|
||||
|
||||
struct _GtkAccessibleAttributeSet
|
||||
{
|
||||
gsize n_attributes;
|
||||
|
||||
GtkAccessibleAttributeDefaultFunc default_func;
|
||||
|
||||
GtkBitmask *attributes_set;
|
||||
|
||||
char **attribute_names;
|
||||
GtkAccessibleValue **attribute_values;
|
||||
};
|
||||
|
||||
static GtkAccessibleAttributeSet *
|
||||
gtk_accessible_attribute_set_init (GtkAccessibleAttributeSet *self,
|
||||
gsize n_attributes,
|
||||
const char **attribute_names,
|
||||
GtkAccessibleAttributeDefaultFunc default_func)
|
||||
{
|
||||
self->n_attributes = n_attributes;
|
||||
self->default_func = default_func;
|
||||
self->attribute_names = g_new (char *, n_attributes);
|
||||
self->attribute_values = g_new (GtkAccessibleValue *, n_attributes);
|
||||
self->attributes_set = _gtk_bitmask_new ();
|
||||
|
||||
/* Initialize all attribute values, so we can always get the full attribute */
|
||||
for (int i = 0; i < self->n_attributes; i++)
|
||||
{
|
||||
self->attribute_names[i] = g_strdup (attribute_names[i]);
|
||||
self->attribute_values[i] = (* self->default_func) (i);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkAccessibleAttributeSet *
|
||||
gtk_accessible_attribute_set_new (gsize n_attributes,
|
||||
const char **attribute_names,
|
||||
GtkAccessibleAttributeDefaultFunc default_func)
|
||||
{
|
||||
GtkAccessibleAttributeSet *set = g_rc_box_new0 (GtkAccessibleAttributeSet);
|
||||
|
||||
return gtk_accessible_attribute_set_init (set, n_attributes, attribute_names, default_func);
|
||||
}
|
||||
|
||||
GtkAccessibleAttributeSet *
|
||||
gtk_accessible_attribute_set_ref (GtkAccessibleAttributeSet *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
return g_rc_box_acquire (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accessible_attribute_set_free (gpointer data)
|
||||
{
|
||||
GtkAccessibleAttributeSet *self = data;
|
||||
|
||||
for (int i = 0; i < self->n_attributes; i++)
|
||||
{
|
||||
g_free (self->attribute_names[i]);
|
||||
|
||||
if (self->attribute_values[i] != NULL)
|
||||
gtk_accessible_value_unref (self->attribute_values[i]);
|
||||
}
|
||||
|
||||
g_free (self->attribute_names);
|
||||
g_free (self->attribute_values);
|
||||
|
||||
_gtk_bitmask_free (self->attributes_set);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_attribute_set_unref (GtkAccessibleAttributeSet *self)
|
||||
{
|
||||
g_rc_box_release_full (self, gtk_accessible_attribute_set_free);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_attribute_set_add:
|
||||
* @self: a #GtkAccessibleAttributeSet
|
||||
* @attribute: the attribute to set
|
||||
* @value: (nullable): a #GtkAccessibleValue
|
||||
*
|
||||
* Adds @attribute to the attributes set, and sets its value.
|
||||
*
|
||||
* If @value is %NULL, the @attribute is reset to its default value.
|
||||
*
|
||||
* If you want to remove @attribute from the set, use gtk_accessible_attribute_set_remove()
|
||||
* instead.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_attribute_set_add (GtkAccessibleAttributeSet *self,
|
||||
int attribute,
|
||||
GtkAccessibleValue *value)
|
||||
{
|
||||
g_return_if_fail (attribute >= 0 && attribute < self->n_attributes);
|
||||
|
||||
g_clear_pointer (&(self->attribute_values[attribute]), gtk_accessible_value_unref);
|
||||
|
||||
if (value != NULL)
|
||||
self->attribute_values[attribute] = gtk_accessible_value_ref (value);
|
||||
else
|
||||
self->attribute_values[attribute] = (* self->default_func) (attribute);
|
||||
|
||||
self->attributes_set = _gtk_bitmask_set (self->attributes_set, attribute, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_attribute_set_remove (GtkAccessibleAttributeSet *self,
|
||||
int attribute)
|
||||
{
|
||||
g_return_if_fail (attribute >= 0 && attribute < self->n_attributes);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_accessible_attribute_set_contains (GtkAccessibleAttributeSet *self,
|
||||
int attribute)
|
||||
{
|
||||
g_return_val_if_fail (attribute >= 0 && attribute < self->n_attributes, FALSE);
|
||||
|
||||
return _gtk_bitmask_get (self->attributes_set, attribute);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_attribute_set_get_value:
|
||||
* @self: a #GtkAccessibleAttributeSet
|
||||
* @attribute: the attribute to retrieve
|
||||
*
|
||||
* Retrieves the value of the given @attribute in the set.
|
||||
*
|
||||
* Returns: (transfer none): the value for the attribute
|
||||
*/
|
||||
GtkAccessibleValue *
|
||||
gtk_accessible_attribute_set_get_value (GtkAccessibleAttributeSet *self,
|
||||
int attribute)
|
||||
{
|
||||
g_return_val_if_fail (attribute >= 0 && attribute < self->n_attributes, NULL);
|
||||
|
||||
return self->attribute_values[attribute];
|
||||
}
|
||||
|
||||
gsize
|
||||
gtk_accessible_attribute_set_get_length (GtkAccessibleAttributeSet *self)
|
||||
{
|
||||
return self->n_attributes;
|
||||
}
|
||||
|
||||
guint
|
||||
gtk_accessible_attribute_set_get_changed (GtkAccessibleAttributeSet *self)
|
||||
{
|
||||
guint changed = 0;
|
||||
|
||||
for (gsize i = 0; i < self->n_attributes; i++)
|
||||
{
|
||||
if (gtk_accessible_attribute_set_contains (self, i))
|
||||
changed |= (1 << i);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_attribute_set_print:
|
||||
* @self: a #GtkAccessibleAttributeSet
|
||||
* @only_set: %TRUE if only the set attributes should be printed
|
||||
* @buffer: a #GString
|
||||
*
|
||||
* Prints the contents of the #GtkAccessibleAttributeSet into @buffer.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_attribute_set_print (GtkAccessibleAttributeSet *self,
|
||||
gboolean only_set,
|
||||
GString *buffer)
|
||||
{
|
||||
if (only_set && _gtk_bitmask_is_empty (self->attributes_set))
|
||||
{
|
||||
g_string_append (buffer, "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append (buffer, "{\n");
|
||||
|
||||
for (gsize i = 0; i < self->n_attributes; i++)
|
||||
{
|
||||
if (only_set && !_gtk_bitmask_get (self->attributes_set, i))
|
||||
continue;
|
||||
|
||||
g_string_append (buffer, " ");
|
||||
g_string_append (buffer, self->attribute_names[i]);
|
||||
g_string_append (buffer, ": ");
|
||||
|
||||
gtk_accessible_value_print (self->attribute_values[i], buffer);
|
||||
|
||||
g_string_append (buffer, ",\n");
|
||||
}
|
||||
|
||||
g_string_append (buffer, "}");
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_attribute_set_to_string:
|
||||
* @self: a #GtkAccessibleAttributeSet
|
||||
*
|
||||
* Prints the contents of a #GtkAccessibleAttributeSet into a string.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated string with the contents
|
||||
* of the #GtkAccessibleAttributeSet
|
||||
*/
|
||||
char *
|
||||
gtk_accessible_attribute_set_to_string (GtkAccessibleAttributeSet *self)
|
||||
{
|
||||
GString *buf = g_string_new (NULL);
|
||||
|
||||
gtk_accessible_attribute_set_print (self, TRUE, buf);
|
||||
|
||||
return g_string_free (buf, FALSE);
|
||||
}
|
57
gtk/gtkaccessibleattributesetprivate.h
Normal file
57
gtk/gtkaccessibleattributesetprivate.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* gtkaccessibleattributesetprivate.h: Accessible attribute container
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtkaccessibleprivate.h"
|
||||
#include "gtkaccessiblevalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkAccessibleAttributeSet GtkAccessibleAttributeSet;
|
||||
|
||||
typedef GtkAccessibleValue *(* GtkAccessibleAttributeDefaultFunc) (int attribute);
|
||||
|
||||
GtkAccessibleAttributeSet * gtk_accessible_attribute_set_new (gsize n_attributes,
|
||||
const char **attr_names,
|
||||
GtkAccessibleAttributeDefaultFunc default_func);
|
||||
GtkAccessibleAttributeSet * gtk_accessible_attribute_set_ref (GtkAccessibleAttributeSet *self);
|
||||
void gtk_accessible_attribute_set_unref (GtkAccessibleAttributeSet *self);
|
||||
|
||||
gsize gtk_accessible_attribute_set_get_length (GtkAccessibleAttributeSet *self);
|
||||
|
||||
void gtk_accessible_attribute_set_add (GtkAccessibleAttributeSet *self,
|
||||
int attribute,
|
||||
GtkAccessibleValue *value);
|
||||
void gtk_accessible_attribute_set_remove (GtkAccessibleAttributeSet *self,
|
||||
int state);
|
||||
gboolean gtk_accessible_attribute_set_contains (GtkAccessibleAttributeSet *self,
|
||||
int state);
|
||||
GtkAccessibleValue * gtk_accessible_attribute_set_get_value (GtkAccessibleAttributeSet *self,
|
||||
int state);
|
||||
|
||||
guint gtk_accessible_attribute_set_get_changed (GtkAccessibleAttributeSet *self);
|
||||
|
||||
void gtk_accessible_attribute_set_print (GtkAccessibleAttributeSet *self,
|
||||
gboolean only_set,
|
||||
GString *string);
|
||||
char * gtk_accessible_attribute_set_to_string (GtkAccessibleAttributeSet *self);
|
||||
|
||||
G_END_DECLS
|
@ -1,218 +0,0 @@
|
||||
/* gtkaccessiblepropertyset.c: Accessible properties
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkaccessiblepropertysetprivate.h"
|
||||
|
||||
#include "gtkbitmaskprivate.h"
|
||||
#include "gtkenums.h"
|
||||
|
||||
/* Keep in sync with GtkAccessibleProperty in gtkenums.h */
|
||||
#define LAST_PROPERTY GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT
|
||||
|
||||
struct _GtkAccessiblePropertySet
|
||||
{
|
||||
GtkBitmask *property_set;
|
||||
|
||||
GtkAccessibleValue **property_values;
|
||||
};
|
||||
|
||||
static GtkAccessiblePropertySet *
|
||||
gtk_accessible_property_set_init (GtkAccessiblePropertySet *self)
|
||||
{
|
||||
self->property_set = _gtk_bitmask_new ();
|
||||
self->property_values = g_new (GtkAccessibleValue *, LAST_PROPERTY);
|
||||
|
||||
/* Initialize all property values, so we can always get the full set */
|
||||
for (int i = 0; i < LAST_PROPERTY; i++)
|
||||
self->property_values[i] = gtk_accessible_value_get_default_for_property (i);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkAccessiblePropertySet *
|
||||
gtk_accessible_property_set_new (void)
|
||||
{
|
||||
GtkAccessiblePropertySet *set = g_rc_box_new0 (GtkAccessiblePropertySet);
|
||||
|
||||
return gtk_accessible_property_set_init (set);
|
||||
}
|
||||
|
||||
GtkAccessiblePropertySet *
|
||||
gtk_accessible_property_set_ref (GtkAccessiblePropertySet *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
return g_rc_box_acquire (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accessible_property_set_free (gpointer data)
|
||||
{
|
||||
GtkAccessiblePropertySet *self = data;
|
||||
|
||||
for (int i = 0; i < LAST_PROPERTY; i++)
|
||||
{
|
||||
if (self->property_values[i] != NULL)
|
||||
gtk_accessible_value_unref (self->property_values[i]);
|
||||
}
|
||||
|
||||
g_free (self->property_values);
|
||||
|
||||
_gtk_bitmask_free (self->property_set);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_property_set_unref (GtkAccessiblePropertySet *self)
|
||||
{
|
||||
g_rc_box_release_full (self, gtk_accessible_property_set_free);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_property_set_add (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property,
|
||||
GtkAccessibleValue *value)
|
||||
{
|
||||
g_return_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
|
||||
property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT);
|
||||
|
||||
if (gtk_accessible_property_set_contains (self, property))
|
||||
gtk_accessible_value_unref (self->property_values[property]);
|
||||
else
|
||||
self->property_set = _gtk_bitmask_set (self->property_set, property, TRUE);
|
||||
|
||||
self->property_values[property] = gtk_accessible_value_ref (value);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_property_set_remove (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property)
|
||||
{
|
||||
g_return_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
|
||||
property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT);
|
||||
|
||||
if (gtk_accessible_property_set_contains (self, property))
|
||||
{
|
||||
g_clear_pointer (&(self->property_values[property]), gtk_accessible_value_unref);
|
||||
self->property_set = _gtk_bitmask_set (self->property_set, property, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_accessible_property_set_contains (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property)
|
||||
{
|
||||
g_return_val_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
|
||||
property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
|
||||
FALSE);
|
||||
|
||||
return _gtk_bitmask_get (self->property_set, property);
|
||||
}
|
||||
|
||||
GtkAccessibleValue *
|
||||
gtk_accessible_property_set_get_value (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property)
|
||||
{
|
||||
g_return_val_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
|
||||
property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
|
||||
NULL);
|
||||
|
||||
return self->property_values[property];
|
||||
}
|
||||
|
||||
static const char *property_names[] = {
|
||||
[GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE] = "autocomplete",
|
||||
[GTK_ACCESSIBLE_PROPERTY_DESCRIPTION] = "description",
|
||||
[GTK_ACCESSIBLE_PROPERTY_HAS_POPUP] = "haspopup",
|
||||
[GTK_ACCESSIBLE_PROPERTY_KEY_SHORTCUTS] = "keyshortcuts",
|
||||
[GTK_ACCESSIBLE_PROPERTY_LABEL] = "label",
|
||||
[GTK_ACCESSIBLE_PROPERTY_LEVEL] = "level",
|
||||
[GTK_ACCESSIBLE_PROPERTY_MODAL] = "modal",
|
||||
[GTK_ACCESSIBLE_PROPERTY_MULTI_LINE] = "multiline",
|
||||
[GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE] = "multiselectable",
|
||||
[GTK_ACCESSIBLE_PROPERTY_ORIENTATION] = "orientation",
|
||||
[GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER] = "placeholder",
|
||||
[GTK_ACCESSIBLE_PROPERTY_READ_ONLY] = "readonly",
|
||||
[GTK_ACCESSIBLE_PROPERTY_REQUIRED] = "required",
|
||||
[GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION] = "roledescription",
|
||||
[GTK_ACCESSIBLE_PROPERTY_SORT] = "sort",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_MAX] = "valuemax",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_MIN] = "valuemin",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_NOW] = "valuenow",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT] = "valuetext",
|
||||
};
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_property_set_print:
|
||||
* @self: a #GtkAccessiblePropertySet
|
||||
* @only_set: %TRUE if only the set properties should be printed
|
||||
* @buffer: a #GString
|
||||
*
|
||||
* Prints the contents of the #GtkAccessiblePropertySet into @buffer.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_property_set_print (GtkAccessiblePropertySet *self,
|
||||
gboolean only_set,
|
||||
GString *buffer)
|
||||
{
|
||||
if (only_set && _gtk_bitmask_is_empty (self->property_set))
|
||||
{
|
||||
g_string_append (buffer, "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append (buffer, "{\n");
|
||||
|
||||
for (int i = 0; i < G_N_ELEMENTS (property_names); i++)
|
||||
{
|
||||
if (only_set && !_gtk_bitmask_get (self->property_set, i))
|
||||
continue;
|
||||
|
||||
g_string_append (buffer, " ");
|
||||
g_string_append (buffer, property_names[i]);
|
||||
g_string_append (buffer, ": ");
|
||||
|
||||
gtk_accessible_value_print (self->property_values[i], buffer);
|
||||
|
||||
g_string_append (buffer, ",\n");
|
||||
}
|
||||
|
||||
g_string_append (buffer, "}");
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_property_set_to_string:
|
||||
* @self: a #GtkAccessiblePropertySet
|
||||
*
|
||||
* Prints the contents of a #GtkAccessiblePropertySet into a string.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated string with the contents
|
||||
* of the #GtkAccessiblePropertySet
|
||||
*/
|
||||
char *
|
||||
gtk_accessible_property_set_to_string (GtkAccessiblePropertySet *self)
|
||||
{
|
||||
GString *buf = g_string_new (NULL);
|
||||
|
||||
gtk_accessible_property_set_print (self, TRUE, buf);
|
||||
|
||||
return g_string_free (buf, FALSE);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/* gtkaccessiblepropertysetprivate.h: Accessible property set
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtkaccessibleprivate.h"
|
||||
#include "gtkaccessiblevalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkAccessiblePropertySet GtkAccessiblePropertySet;
|
||||
|
||||
GtkAccessiblePropertySet * gtk_accessible_property_set_new (void);
|
||||
GtkAccessiblePropertySet * gtk_accessible_property_set_ref (GtkAccessiblePropertySet *self);
|
||||
void gtk_accessible_property_set_unref (GtkAccessiblePropertySet *self);
|
||||
|
||||
void gtk_accessible_property_set_add (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property,
|
||||
GtkAccessibleValue *value);
|
||||
void gtk_accessible_property_set_remove (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property);
|
||||
gboolean gtk_accessible_property_set_contains (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property);
|
||||
GtkAccessibleValue * gtk_accessible_property_set_get_value (GtkAccessiblePropertySet *self,
|
||||
GtkAccessibleProperty property);
|
||||
|
||||
void gtk_accessible_property_set_print (GtkAccessiblePropertySet *self,
|
||||
gboolean only_set,
|
||||
GString *string);
|
||||
char * gtk_accessible_property_set_to_string (GtkAccessiblePropertySet *self);
|
||||
|
||||
G_END_DECLS
|
@ -1,217 +0,0 @@
|
||||
/* gtkaccessiblerelationset.c: Accessible relation set
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkaccessiblerelationsetprivate.h"
|
||||
|
||||
#include "gtkbitmaskprivate.h"
|
||||
#include "gtkenums.h"
|
||||
|
||||
/* Keep in sync with GtkAccessibleRelation in gtkenums.h */
|
||||
#define LAST_RELATION GTK_ACCESSIBLE_RELATION_SET_SIZE
|
||||
|
||||
struct _GtkAccessibleRelationSet
|
||||
{
|
||||
GtkBitmask *relation_set;
|
||||
|
||||
GtkAccessibleValue **relation_values;
|
||||
};
|
||||
|
||||
static GtkAccessibleRelationSet *
|
||||
gtk_accessible_relation_set_init (GtkAccessibleRelationSet *self)
|
||||
{
|
||||
self->relation_set = _gtk_bitmask_new ();
|
||||
self->relation_values = g_new (GtkAccessibleValue *, LAST_RELATION);
|
||||
|
||||
/* Initialize all relation values, so we can always get the full set */
|
||||
for (int i = 0; i < LAST_RELATION; i++)
|
||||
self->relation_values[i] = gtk_accessible_value_get_default_for_relation (i);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkAccessibleRelationSet *
|
||||
gtk_accessible_relation_set_new (void)
|
||||
{
|
||||
GtkAccessibleRelationSet *set = g_rc_box_new0 (GtkAccessibleRelationSet);
|
||||
|
||||
return gtk_accessible_relation_set_init (set);
|
||||
}
|
||||
|
||||
GtkAccessibleRelationSet *
|
||||
gtk_accessible_relation_set_ref (GtkAccessibleRelationSet *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
return g_rc_box_acquire (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accessible_relation_set_free (gpointer data)
|
||||
{
|
||||
GtkAccessibleRelationSet *self = data;
|
||||
|
||||
for (int i = 0; i < LAST_RELATION; i++)
|
||||
{
|
||||
if (self->relation_values[i] != NULL)
|
||||
gtk_accessible_value_unref (self->relation_values[i]);
|
||||
}
|
||||
|
||||
g_free (self->relation_values);
|
||||
|
||||
_gtk_bitmask_free (self->relation_set);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_relation_set_unref (GtkAccessibleRelationSet *self)
|
||||
{
|
||||
g_rc_box_release_full (self, gtk_accessible_relation_set_free);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_relation_set_add (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation relation,
|
||||
GtkAccessibleValue *value)
|
||||
{
|
||||
g_return_if_fail (relation >= GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT &&
|
||||
relation <= GTK_ACCESSIBLE_RELATION_SET_SIZE);
|
||||
|
||||
if (gtk_accessible_relation_set_contains (self, relation))
|
||||
gtk_accessible_value_unref (self->relation_values[relation]);
|
||||
else
|
||||
self->relation_set = _gtk_bitmask_set (self->relation_set, relation, TRUE);
|
||||
|
||||
self->relation_values[relation] = gtk_accessible_value_ref (value);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_relation_set_remove (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation relation)
|
||||
{
|
||||
g_return_if_fail (relation >= GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT &&
|
||||
relation <= GTK_ACCESSIBLE_RELATION_SET_SIZE);
|
||||
|
||||
if (gtk_accessible_relation_set_contains (self, relation))
|
||||
{
|
||||
g_clear_pointer (&(self->relation_values[relation]), gtk_accessible_value_unref);
|
||||
self->relation_set = _gtk_bitmask_set (self->relation_set, relation, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_accessible_relation_set_contains (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation relation)
|
||||
{
|
||||
g_return_val_if_fail (relation >= GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT &&
|
||||
relation <= GTK_ACCESSIBLE_RELATION_SET_SIZE,
|
||||
FALSE);
|
||||
|
||||
return _gtk_bitmask_get (self->relation_set, relation);
|
||||
}
|
||||
|
||||
GtkAccessibleValue *
|
||||
gtk_accessible_relation_set_get_value (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation relation)
|
||||
{
|
||||
g_return_val_if_fail (relation >= GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT &&
|
||||
relation <= GTK_ACCESSIBLE_RELATION_SET_SIZE,
|
||||
NULL);
|
||||
|
||||
return self->relation_values[relation];
|
||||
}
|
||||
|
||||
static const char *relation_names[] = {
|
||||
[GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT] = "activedescendant",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_COUNT] = "colcount",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_INDEX] = "colindex",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_INDEX_TEXT] = "colindextext",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_SPAN] = "colspan",
|
||||
[GTK_ACCESSIBLE_RELATION_CONTROLS] = "controls",
|
||||
[GTK_ACCESSIBLE_RELATION_DESCRIBED_BY] = "describedby",
|
||||
[GTK_ACCESSIBLE_RELATION_DETAILS] = "details",
|
||||
[GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE] = "errormessage",
|
||||
[GTK_ACCESSIBLE_RELATION_FLOW_TO] = "flowto",
|
||||
[GTK_ACCESSIBLE_RELATION_LABELLED_BY] = "labelledby",
|
||||
[GTK_ACCESSIBLE_RELATION_OWNS] = "owns",
|
||||
[GTK_ACCESSIBLE_RELATION_POS_IN_SET] = "posinset",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_COUNT] = "rowcount",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_INDEX] = "rowindex",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_INDEX_TEXT] = "rowindextext",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_SPAN] = "rowspan",
|
||||
[GTK_ACCESSIBLE_RELATION_SET_SIZE] = "setsize",
|
||||
};
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_relation_set_print:
|
||||
* @self: a #GtkAccessibleRelationSet
|
||||
* @only_set: %TRUE if only the set relations should be printed
|
||||
* @buffer: a #GString
|
||||
*
|
||||
* Prints the contents of the #GtkAccessibleRelationSet into @buffer.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_relation_set_print (GtkAccessibleRelationSet *self,
|
||||
gboolean only_set,
|
||||
GString *buffer)
|
||||
{
|
||||
if (only_set && _gtk_bitmask_is_empty (self->relation_set))
|
||||
{
|
||||
g_string_append (buffer, "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append (buffer, "{\n");
|
||||
|
||||
for (int i = 0; i < G_N_ELEMENTS (relation_names); i++)
|
||||
{
|
||||
if (only_set && !_gtk_bitmask_get (self->relation_set, i))
|
||||
continue;
|
||||
|
||||
g_string_append (buffer, " ");
|
||||
g_string_append (buffer, relation_names[i]);
|
||||
g_string_append (buffer, ": ");
|
||||
|
||||
gtk_accessible_value_print (self->relation_values[i], buffer);
|
||||
|
||||
g_string_append (buffer, ",\n");
|
||||
}
|
||||
|
||||
g_string_append (buffer, "}");
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_relation_set_to_string:
|
||||
* @self: a #GtkAccessibleRelationSet
|
||||
*
|
||||
* Prints the contents of a #GtkAccessibleRelationSet into a string.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated string with the contents
|
||||
* of the #GtkAccessibleRelationSet
|
||||
*/
|
||||
char *
|
||||
gtk_accessible_relation_set_to_string (GtkAccessibleRelationSet *self)
|
||||
{
|
||||
GString *buf = g_string_new (NULL);
|
||||
|
||||
gtk_accessible_relation_set_print (self, TRUE, buf);
|
||||
|
||||
return g_string_free (buf, FALSE);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/* gtkaccessiblerelationsetprivate.h: Accessible relations set
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtkaccessibleprivate.h"
|
||||
#include "gtkaccessiblevalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkAccessibleRelationSet GtkAccessibleRelationSet;
|
||||
|
||||
GtkAccessibleRelationSet * gtk_accessible_relation_set_new (void);
|
||||
GtkAccessibleRelationSet * gtk_accessible_relation_set_ref (GtkAccessibleRelationSet *self);
|
||||
void gtk_accessible_relation_set_unref (GtkAccessibleRelationSet *self);
|
||||
|
||||
void gtk_accessible_relation_set_add (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation state,
|
||||
GtkAccessibleValue *value);
|
||||
void gtk_accessible_relation_set_remove (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation state);
|
||||
gboolean gtk_accessible_relation_set_contains (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation state);
|
||||
GtkAccessibleValue * gtk_accessible_relation_set_get_value (GtkAccessibleRelationSet *self,
|
||||
GtkAccessibleRelation state);
|
||||
|
||||
void gtk_accessible_relation_set_print (GtkAccessibleRelationSet *self,
|
||||
gboolean only_set,
|
||||
GString *string);
|
||||
char * gtk_accessible_relation_set_to_string (GtkAccessibleRelationSet *self);
|
||||
|
||||
G_END_DECLS
|
@ -1,207 +0,0 @@
|
||||
/* gtkaccessiblestateset.c: Accessible state
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkaccessiblestatesetprivate.h"
|
||||
|
||||
#include "gtkbitmaskprivate.h"
|
||||
#include "gtkenums.h"
|
||||
|
||||
/* Keep in sync with GtkAccessibleState in gtkenums.h */
|
||||
#define LAST_STATE GTK_ACCESSIBLE_STATE_SELECTED
|
||||
|
||||
struct _GtkAccessibleStateSet
|
||||
{
|
||||
GtkBitmask *states_set;
|
||||
|
||||
GtkAccessibleValue **state_values;
|
||||
};
|
||||
|
||||
static GtkAccessibleStateSet *
|
||||
gtk_accessible_state_set_init (GtkAccessibleStateSet *self)
|
||||
{
|
||||
self->states_set = _gtk_bitmask_new ();
|
||||
self->state_values = g_new (GtkAccessibleValue*, LAST_STATE);
|
||||
|
||||
/* Initialize all state values, so we can always get the full state */
|
||||
for (int i = 0; i < LAST_STATE; i++)
|
||||
self->state_values[i] = gtk_accessible_value_get_default_for_state (i);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkAccessibleStateSet *
|
||||
gtk_accessible_state_set_new (void)
|
||||
{
|
||||
GtkAccessibleStateSet *set = g_rc_box_new0 (GtkAccessibleStateSet);
|
||||
|
||||
return gtk_accessible_state_set_init (set);
|
||||
}
|
||||
|
||||
GtkAccessibleStateSet *
|
||||
gtk_accessible_state_set_ref (GtkAccessibleStateSet *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
return g_rc_box_acquire (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accessible_state_set_free (gpointer data)
|
||||
{
|
||||
GtkAccessibleStateSet *self = data;
|
||||
|
||||
for (int i = 0; i < LAST_STATE; i++)
|
||||
{
|
||||
if (self->state_values[i] != NULL)
|
||||
gtk_accessible_value_unref (self->state_values[i]);
|
||||
}
|
||||
|
||||
g_free (self->state_values);
|
||||
|
||||
_gtk_bitmask_free (self->states_set);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_state_set_unref (GtkAccessibleStateSet *self)
|
||||
{
|
||||
g_rc_box_release_full (self, gtk_accessible_state_set_free);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_state_set_add (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state,
|
||||
GtkAccessibleValue *value)
|
||||
{
|
||||
g_return_if_fail (state >= GTK_ACCESSIBLE_STATE_BUSY &&
|
||||
state <= GTK_ACCESSIBLE_STATE_SELECTED);
|
||||
|
||||
if (gtk_accessible_state_set_contains (self, state))
|
||||
gtk_accessible_value_unref (self->state_values[state]);
|
||||
else
|
||||
self->states_set = _gtk_bitmask_set (self->states_set, state, TRUE);
|
||||
|
||||
self->state_values[state] = gtk_accessible_value_ref (value);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_accessible_state_set_remove (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state)
|
||||
{
|
||||
g_return_if_fail (state >= GTK_ACCESSIBLE_STATE_BUSY &&
|
||||
state <= GTK_ACCESSIBLE_STATE_SELECTED);
|
||||
|
||||
if (gtk_accessible_state_set_contains (self, state))
|
||||
{
|
||||
g_clear_pointer (&(self->state_values[state]), gtk_accessible_value_unref);
|
||||
self->states_set = _gtk_bitmask_set (self->states_set, state, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_accessible_state_set_contains (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state)
|
||||
{
|
||||
g_return_val_if_fail (state >= GTK_ACCESSIBLE_STATE_BUSY &&
|
||||
state <= GTK_ACCESSIBLE_STATE_SELECTED,
|
||||
FALSE);
|
||||
|
||||
return _gtk_bitmask_get (self->states_set, state);
|
||||
}
|
||||
|
||||
GtkAccessibleValue *
|
||||
gtk_accessible_state_set_get_value (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state)
|
||||
{
|
||||
g_return_val_if_fail (state >= GTK_ACCESSIBLE_STATE_BUSY &&
|
||||
state <= GTK_ACCESSIBLE_STATE_SELECTED,
|
||||
NULL);
|
||||
|
||||
return self->state_values[state];
|
||||
}
|
||||
|
||||
static const char *state_names[] = {
|
||||
[GTK_ACCESSIBLE_STATE_BUSY] = "busy",
|
||||
[GTK_ACCESSIBLE_STATE_CHECKED] = "checked",
|
||||
[GTK_ACCESSIBLE_STATE_DISABLED] = "disabled",
|
||||
[GTK_ACCESSIBLE_STATE_EXPANDED] = "expanded",
|
||||
[GTK_ACCESSIBLE_STATE_HIDDEN] = "hidden",
|
||||
[GTK_ACCESSIBLE_STATE_INVALID] = "invalid",
|
||||
[GTK_ACCESSIBLE_STATE_PRESSED] = "pressed",
|
||||
[GTK_ACCESSIBLE_STATE_SELECTED] = "selected",
|
||||
};
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_state_set_print:
|
||||
* @self: a #GtkAccessibleStateSet
|
||||
* @only_set: %TRUE if only the set states should be printed
|
||||
* @buffer: a #GString
|
||||
*
|
||||
* Prints the contents of the #GtkAccessibleStateSet into @buffer.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_state_set_print (GtkAccessibleStateSet *self,
|
||||
gboolean only_set,
|
||||
GString *buffer)
|
||||
{
|
||||
if (only_set && _gtk_bitmask_is_empty (self->states_set))
|
||||
{
|
||||
g_string_append (buffer, "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append (buffer, "{\n");
|
||||
|
||||
for (int i = 0; i < G_N_ELEMENTS (state_names); i++)
|
||||
{
|
||||
if (only_set && !_gtk_bitmask_get (self->states_set, i))
|
||||
continue;
|
||||
|
||||
g_string_append (buffer, " ");
|
||||
g_string_append (buffer, state_names[i]);
|
||||
g_string_append (buffer, ": ");
|
||||
|
||||
gtk_accessible_value_print (self->state_values[i], buffer);
|
||||
|
||||
g_string_append (buffer, ",\n");
|
||||
}
|
||||
|
||||
g_string_append (buffer, "}");
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_state_set_to_string:
|
||||
* @self: a #GtkAccessibleStateSet
|
||||
*
|
||||
* Prints the contents of a #GtkAccessibleStateSet into a string.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated string with the contents
|
||||
* of the #GtkAccessibleStateSet
|
||||
*/
|
||||
char *
|
||||
gtk_accessible_state_set_to_string (GtkAccessibleStateSet *self)
|
||||
{
|
||||
GString *buf = g_string_new (NULL);
|
||||
|
||||
gtk_accessible_state_set_print (self, TRUE, buf);
|
||||
|
||||
return g_string_free (buf, FALSE);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/* gtkaccessiblestatesetprivate.h: Accessible state container
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtkaccessibleprivate.h"
|
||||
#include "gtkaccessiblevalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkAccessibleStateSet GtkAccessibleStateSet;
|
||||
|
||||
GtkAccessibleStateSet * gtk_accessible_state_set_new (void);
|
||||
GtkAccessibleStateSet * gtk_accessible_state_set_ref (GtkAccessibleStateSet *self);
|
||||
void gtk_accessible_state_set_unref (GtkAccessibleStateSet *self);
|
||||
|
||||
void gtk_accessible_state_set_add (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state,
|
||||
GtkAccessibleValue *value);
|
||||
void gtk_accessible_state_set_remove (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state);
|
||||
gboolean gtk_accessible_state_set_contains (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state);
|
||||
GtkAccessibleValue * gtk_accessible_state_set_get_value (GtkAccessibleStateSet *self,
|
||||
GtkAccessibleState state);
|
||||
|
||||
void gtk_accessible_state_set_print (GtkAccessibleStateSet *self,
|
||||
gboolean only_set,
|
||||
GString *string);
|
||||
char * gtk_accessible_state_set_to_string (GtkAccessibleStateSet *self);
|
||||
|
||||
G_END_DECLS
|
@ -56,9 +56,9 @@ gtk_at_context_finalize (GObject *gobject)
|
||||
{
|
||||
GtkATContext *self = GTK_AT_CONTEXT (gobject);
|
||||
|
||||
gtk_accessible_property_set_unref (self->properties);
|
||||
gtk_accessible_relation_set_unref (self->relations);
|
||||
gtk_accessible_state_set_unref (self->states);
|
||||
gtk_accessible_attribute_set_unref (self->properties);
|
||||
gtk_accessible_attribute_set_unref (self->relations);
|
||||
gtk_accessible_attribute_set_unref (self->states);
|
||||
|
||||
G_OBJECT_CLASS (gtk_at_context_parent_class)->finalize (gobject);
|
||||
}
|
||||
@ -114,9 +114,9 @@ gtk_at_context_real_state_change (GtkATContext *self,
|
||||
GtkAccessibleStateChange changed_states,
|
||||
GtkAccessiblePropertyChange changed_properties,
|
||||
GtkAccessibleRelationChange changed_relations,
|
||||
GtkAccessibleStateSet *states,
|
||||
GtkAccessiblePropertySet *properties,
|
||||
GtkAccessibleRelationSet *relations)
|
||||
GtkAccessibleAttributeSet *states,
|
||||
GtkAccessibleAttributeSet *properties,
|
||||
GtkAccessibleAttributeSet *relations)
|
||||
{
|
||||
}
|
||||
|
||||
@ -166,14 +166,81 @@ gtk_at_context_class_init (GtkATContextClass *klass)
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, obj_props);
|
||||
}
|
||||
|
||||
#define N_PROPERTIES (GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT + 1)
|
||||
#define N_RELATIONS (GTK_ACCESSIBLE_RELATION_SET_SIZE + 1)
|
||||
#define N_STATES (GTK_ACCESSIBLE_STATE_SELECTED + 1)
|
||||
|
||||
static const char *property_attrs[] = {
|
||||
[GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE] = "autocomplete",
|
||||
[GTK_ACCESSIBLE_PROPERTY_DESCRIPTION] = "description",
|
||||
[GTK_ACCESSIBLE_PROPERTY_HAS_POPUP] = "haspopup",
|
||||
[GTK_ACCESSIBLE_PROPERTY_KEY_SHORTCUTS] = "keyshortcuts",
|
||||
[GTK_ACCESSIBLE_PROPERTY_LABEL] = "label",
|
||||
[GTK_ACCESSIBLE_PROPERTY_LEVEL] = "level",
|
||||
[GTK_ACCESSIBLE_PROPERTY_MODAL] = "modal",
|
||||
[GTK_ACCESSIBLE_PROPERTY_MULTI_LINE] = "multiline",
|
||||
[GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE] = "multiselectable",
|
||||
[GTK_ACCESSIBLE_PROPERTY_ORIENTATION] = "orientation",
|
||||
[GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER] = "placeholder",
|
||||
[GTK_ACCESSIBLE_PROPERTY_READ_ONLY] = "readonly",
|
||||
[GTK_ACCESSIBLE_PROPERTY_REQUIRED] = "required",
|
||||
[GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION] = "roledescription",
|
||||
[GTK_ACCESSIBLE_PROPERTY_SORT] = "sort",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_MAX] = "valuemax",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_MIN] = "valuemin",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_NOW] = "valuenow",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT] = "valuetext",
|
||||
};
|
||||
|
||||
static const char *relation_attrs[] = {
|
||||
[GTK_ACCESSIBLE_RELATION_ACTIVE_DESCENDANT] = "activedescendant",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_COUNT] = "colcount",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_INDEX] = "colindex",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_INDEX_TEXT] = "colindextext",
|
||||
[GTK_ACCESSIBLE_RELATION_COL_SPAN] = "colspan",
|
||||
[GTK_ACCESSIBLE_RELATION_CONTROLS] = "controls",
|
||||
[GTK_ACCESSIBLE_RELATION_DESCRIBED_BY] = "describedby",
|
||||
[GTK_ACCESSIBLE_RELATION_DETAILS] = "details",
|
||||
[GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE] = "errormessage",
|
||||
[GTK_ACCESSIBLE_RELATION_FLOW_TO] = "flowto",
|
||||
[GTK_ACCESSIBLE_RELATION_LABELLED_BY] = "labelledby",
|
||||
[GTK_ACCESSIBLE_RELATION_OWNS] = "owns",
|
||||
[GTK_ACCESSIBLE_RELATION_POS_IN_SET] = "posinset",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_COUNT] = "rowcount",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_INDEX] = "rowindex",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_INDEX_TEXT] = "rowindextext",
|
||||
[GTK_ACCESSIBLE_RELATION_ROW_SPAN] = "rowspan",
|
||||
[GTK_ACCESSIBLE_RELATION_SET_SIZE] = "setsize",
|
||||
};
|
||||
|
||||
static const char *state_attrs[] = {
|
||||
[GTK_ACCESSIBLE_STATE_BUSY] = "busy",
|
||||
[GTK_ACCESSIBLE_STATE_CHECKED] = "checked",
|
||||
[GTK_ACCESSIBLE_STATE_DISABLED] = "disabled",
|
||||
[GTK_ACCESSIBLE_STATE_EXPANDED] = "expanded",
|
||||
[GTK_ACCESSIBLE_STATE_HIDDEN] = "hidden",
|
||||
[GTK_ACCESSIBLE_STATE_INVALID] = "invalid",
|
||||
[GTK_ACCESSIBLE_STATE_PRESSED] = "pressed",
|
||||
[GTK_ACCESSIBLE_STATE_SELECTED] = "selected",
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_at_context_init (GtkATContext *self)
|
||||
{
|
||||
self->accessible_role = GTK_ACCESSIBLE_ROLE_WIDGET;
|
||||
|
||||
self->properties = gtk_accessible_property_set_new ();
|
||||
self->relations = gtk_accessible_relation_set_new ();
|
||||
self->states = gtk_accessible_state_set_new ();
|
||||
self->properties =
|
||||
gtk_accessible_attribute_set_new (N_PROPERTIES,
|
||||
property_attrs,
|
||||
(GtkAccessibleAttributeDefaultFunc) gtk_accessible_value_get_default_for_property);
|
||||
self->relations =
|
||||
gtk_accessible_attribute_set_new (N_RELATIONS,
|
||||
relation_attrs,
|
||||
(GtkAccessibleAttributeDefaultFunc) gtk_accessible_value_get_default_for_relation);
|
||||
self->states =
|
||||
gtk_accessible_attribute_set_new (N_STATES,
|
||||
state_attrs,
|
||||
(GtkAccessibleAttributeDefaultFunc) gtk_accessible_value_get_default_for_state);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -271,27 +338,12 @@ gtk_at_context_update (GtkATContext *self)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
|
||||
|
||||
GtkAccessibleStateChange changed_states = 0;
|
||||
GtkAccessiblePropertyChange changed_properties = 0;
|
||||
GtkAccessibleRelationChange changed_relations = 0;
|
||||
|
||||
for (int i = 0; i < GTK_ACCESSIBLE_STATE_SELECTED; i++)
|
||||
{
|
||||
if (gtk_accessible_state_set_contains (self->states, i))
|
||||
changed_states |= (1 << i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT; i++)
|
||||
{
|
||||
if (gtk_accessible_property_set_contains (self->properties, i))
|
||||
changed_properties |= (1 << i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < GTK_ACCESSIBLE_RELATION_SET_SIZE; i++)
|
||||
{
|
||||
if (gtk_accessible_relation_set_contains (self->relations, i))
|
||||
changed_relations |= (1 << i);
|
||||
}
|
||||
GtkAccessibleStateChange changed_states =
|
||||
gtk_accessible_attribute_set_get_changed (self->states);
|
||||
GtkAccessiblePropertyChange changed_properties =
|
||||
gtk_accessible_attribute_set_get_changed (self->properties);
|
||||
GtkAccessibleRelationChange changed_relations =
|
||||
gtk_accessible_attribute_set_get_changed (self->relations);
|
||||
|
||||
GTK_AT_CONTEXT_GET_CLASS (self)->state_change (self,
|
||||
changed_states,
|
||||
@ -323,9 +375,9 @@ gtk_at_context_set_accessible_state (GtkATContext *self,
|
||||
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
|
||||
|
||||
if (value != NULL)
|
||||
gtk_accessible_state_set_add (self->states, state, value);
|
||||
gtk_accessible_attribute_set_add (self->states, state, value);
|
||||
else
|
||||
gtk_accessible_state_set_remove (self->states, state);
|
||||
gtk_accessible_attribute_set_remove (self->states, state);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
@ -349,9 +401,9 @@ gtk_at_context_set_accessible_property (GtkATContext *self,
|
||||
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
|
||||
|
||||
if (value != NULL)
|
||||
gtk_accessible_property_set_add (self->properties, property, value);
|
||||
gtk_accessible_attribute_set_add (self->properties, property, value);
|
||||
else
|
||||
gtk_accessible_property_set_remove (self->properties, property);
|
||||
gtk_accessible_attribute_set_remove (self->properties, property);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
@ -375,7 +427,7 @@ gtk_at_context_set_accessible_relation (GtkATContext *self,
|
||||
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
|
||||
|
||||
if (value != NULL)
|
||||
gtk_accessible_relation_set_add (self->relations, relation, value);
|
||||
gtk_accessible_attribute_set_add (self->relations, relation, value);
|
||||
else
|
||||
gtk_accessible_relation_set_remove (self->relations, relation);
|
||||
gtk_accessible_attribute_set_remove (self->relations, relation);
|
||||
}
|
||||
|
@ -22,9 +22,7 @@
|
||||
|
||||
#include "gtkatcontext.h"
|
||||
|
||||
#include "gtkaccessiblepropertysetprivate.h"
|
||||
#include "gtkaccessiblerelationsetprivate.h"
|
||||
#include "gtkaccessiblestatesetprivate.h"
|
||||
#include "gtkaccessibleattributesetprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -89,9 +87,9 @@ struct _GtkATContext
|
||||
GtkAccessibleRole accessible_role;
|
||||
GtkAccessible *accessible;
|
||||
|
||||
GtkAccessibleStateSet *states;
|
||||
GtkAccessiblePropertySet *properties;
|
||||
GtkAccessibleRelationSet *relations;
|
||||
GtkAccessibleAttributeSet *states;
|
||||
GtkAccessibleAttributeSet *properties;
|
||||
GtkAccessibleAttributeSet *relations;
|
||||
};
|
||||
|
||||
struct _GtkATContextClass
|
||||
@ -102,9 +100,9 @@ struct _GtkATContextClass
|
||||
GtkAccessibleStateChange changed_states,
|
||||
GtkAccessiblePropertyChange changed_properties,
|
||||
GtkAccessibleRelationChange changed_relations,
|
||||
GtkAccessibleStateSet *states,
|
||||
GtkAccessiblePropertySet *properties,
|
||||
GtkAccessibleRelationSet *relations);
|
||||
GtkAccessibleAttributeSet *states,
|
||||
GtkAccessibleAttributeSet *properties,
|
||||
GtkAccessibleAttributeSet *relations);
|
||||
};
|
||||
|
||||
GtkATContext * gtk_at_context_create (GtkAccessibleRole accessible_role,
|
||||
|
@ -37,15 +37,15 @@ gtk_test_at_context_state_change (GtkATContext *self,
|
||||
GtkAccessibleStateChange changed_states,
|
||||
GtkAccessiblePropertyChange changed_properties,
|
||||
GtkAccessibleRelationChange changed_relations,
|
||||
GtkAccessibleStateSet *states,
|
||||
GtkAccessiblePropertySet *properties,
|
||||
GtkAccessibleRelationSet *relations)
|
||||
GtkAccessibleAttributeSet *states,
|
||||
GtkAccessibleAttributeSet *properties,
|
||||
GtkAccessibleAttributeSet *relations)
|
||||
{
|
||||
GtkAccessible *accessible = gtk_at_context_get_accessible (self);
|
||||
GtkAccessibleRole role = gtk_at_context_get_accessible_role (self);
|
||||
char *states_str = gtk_accessible_state_set_to_string (states);
|
||||
char *properties_str = gtk_accessible_property_set_to_string (properties);
|
||||
char *relations_str = gtk_accessible_relation_set_to_string (relations);
|
||||
char *states_str = gtk_accessible_attribute_set_to_string (states);
|
||||
char *properties_str = gtk_accessible_attribute_set_to_string (properties);
|
||||
char *relations_str = gtk_accessible_attribute_set_to_string (relations);
|
||||
|
||||
g_print ("*** Accessible state changed for accessible “%s”, with role %d:\n"
|
||||
"*** states = %s\n"
|
||||
|
@ -16,9 +16,7 @@ gtk_private_sources = files([
|
||||
'fnmatch.c',
|
||||
'tools/gdkpixbufutils.c',
|
||||
'gsettings-mapping.c',
|
||||
'gtkaccessiblepropertyset.c',
|
||||
'gtkaccessiblerelationset.c',
|
||||
'gtkaccessiblestateset.c',
|
||||
'gtkaccessibleattributeset.c',
|
||||
'gtkaccessiblevalue.c',
|
||||
'gtkaccessiblevaluestatic.c',
|
||||
'gtkactionhelper.c',
|
||||
|
Loading…
Reference in New Issue
Block a user