mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-29 15:01:23 +00:00
Merge branch 'ebassi/accessible-text-util' into 'main'
Rename GtkAccessibleText private header See merge request GNOME/gtk!6982
This commit is contained in:
commit
da2ef6911f
@ -23,7 +23,7 @@
|
||||
#include "gtkatspicontextprivate.h"
|
||||
|
||||
#include "gtkaccessibleprivate.h"
|
||||
#include "gtkaccessibletext-private.h"
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
|
||||
#include "gtkatspiactionprivate.h"
|
||||
#include "gtkatspieditabletextprivate.h"
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "a11y/atspi/atspi-text.h"
|
||||
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
#include "gtkatcontextprivate.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkeditable.h"
|
||||
@ -41,7 +42,6 @@
|
||||
#include "gtkspinbuttonprivate.h"
|
||||
#include "gtktextbufferprivate.h"
|
||||
#include "gtktextviewprivate.h"
|
||||
#include "gtkaccessibletext-private.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
@ -225,56 +225,42 @@ accessible_text_handle_method (GDBusConnection *connection,
|
||||
GVariantBuilder builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("a{ss}"));
|
||||
gboolean include_defaults = FALSE;
|
||||
int offset;
|
||||
gsize n_attrs = 0;
|
||||
gsize n_ranges = 0;
|
||||
GtkAccessibleTextRange *ranges = NULL;
|
||||
int start, end;
|
||||
char **attr_names = NULL;
|
||||
char **attr_values = NULL;
|
||||
GHashTable *attrs;
|
||||
gboolean res;
|
||||
|
||||
g_variant_get (parameters, "(ib)", &offset, &include_defaults);
|
||||
|
||||
attrs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
|
||||
if (include_defaults)
|
||||
res = gtk_accessible_text_get_attributes_run (accessible_text,
|
||||
offset,
|
||||
include_defaults,
|
||||
&n_ranges,
|
||||
&ranges,
|
||||
&attr_names,
|
||||
&attr_values);
|
||||
if (!res)
|
||||
{
|
||||
gtk_accessible_text_get_default_attributes (accessible_text,
|
||||
&attr_names,
|
||||
&attr_values);
|
||||
|
||||
for (int i = 0; attr_names[i] != NULL; i++)
|
||||
g_hash_table_insert (attrs, g_strdup (attr_names[i]), g_strdup (attr_values[i]));
|
||||
|
||||
g_strfreev (attr_names);
|
||||
g_strfreev (attr_values);
|
||||
/* No attributes */
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a{ss}ii)", &builder, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_accessible_text_get_attributes (accessible_text,
|
||||
offset,
|
||||
&n_attrs,
|
||||
&ranges,
|
||||
&attr_names,
|
||||
&attr_values);
|
||||
for (unsigned i = 0; attr_names[i] != NULL; i++)
|
||||
g_variant_builder_add (&builder, "{ss}", attr_names[i], attr_values[i]);
|
||||
|
||||
start = 0;
|
||||
end = G_MAXINT;
|
||||
|
||||
for (int i = 0; i < n_attrs; i++)
|
||||
for (unsigned i = 0; i < n_ranges; i++)
|
||||
{
|
||||
g_hash_table_insert (attrs, g_strdup (attr_names[i]), g_strdup (attr_values[i]));
|
||||
start = MAX (start, ranges[i].start);
|
||||
end = MIN (end, start + ranges[i].length);
|
||||
}
|
||||
|
||||
GHashTableIter attr_iter;
|
||||
gpointer key, value;
|
||||
g_hash_table_iter_init (&attr_iter, attrs);
|
||||
while (g_hash_table_iter_next (&attr_iter, &key, &value))
|
||||
g_variant_builder_add (&builder, "{ss}", key, value);
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a{ss}ii)", &builder, start, end));
|
||||
|
||||
g_clear_pointer (&attrs, g_hash_table_unref);
|
||||
g_clear_pointer (&ranges, g_free);
|
||||
g_strfreev (attr_names);
|
||||
g_strfreev (attr_values);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkaccessibletext-private.h"
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
|
||||
#include "gtkatcontextprivate.h"
|
||||
|
||||
@ -309,6 +309,123 @@ gtk_accessible_text_get_default_attributes (GtkAccessibleText *self,
|
||||
attribute_values);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_text_get_attributes_run:
|
||||
* @self: the accessible object
|
||||
* @offset: the offset, in characters
|
||||
* @include_defaults: whether to include the default attributes in the
|
||||
* returned array
|
||||
* @n_ranges: (out): the number of attributes
|
||||
* @ranges: (out) (array length=n_attributes) (optional): the ranges of the attributes
|
||||
* inside the accessible object
|
||||
* @attribute_names: (out) (array zero-terminated=1) (element-type utf8) (optional) (transfer full):
|
||||
* the names of the attributes inside the accessible object
|
||||
* @attribute_values: (out) (array zero-terminated=1) (element-type utf8) (optional) (transfer full):
|
||||
* the values of the attributes inside the accessible object
|
||||
*
|
||||
* Retrieves the text attributes inside the accessible object.
|
||||
*
|
||||
* Each attribute is composed by:
|
||||
*
|
||||
* - a range
|
||||
* - a name, typically in the form of a reverse DNS identifier
|
||||
* - a value
|
||||
*
|
||||
* If this function returns true, `n_ranges` will be set to a value
|
||||
* greater than or equal to one, @ranges will be set to a newly
|
||||
* allocated array of [struct#Gtk.AccessibleTextRange] which should
|
||||
* be freed with g_free(), @attribute_names and @attribute_values
|
||||
* will be set to string arrays that should be freed with g_strfreev().
|
||||
*
|
||||
* Returns: true if the accessible object has at least an attribute,
|
||||
* and false otherwise
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
gboolean
|
||||
gtk_accessible_text_get_attributes_run (GtkAccessibleText *self,
|
||||
unsigned int offset,
|
||||
gboolean include_defaults,
|
||||
gsize *n_ranges,
|
||||
GtkAccessibleTextRange **ranges,
|
||||
char ***attribute_names,
|
||||
char ***attribute_values)
|
||||
{
|
||||
GHashTable *attrs;
|
||||
GHashTableIter attr_iter;
|
||||
gpointer key, value;
|
||||
char **attr_names, **attr_values;
|
||||
gboolean res;
|
||||
GStrvBuilder *names_builder;
|
||||
GStrvBuilder *values_builder;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCESSIBLE_TEXT (self), FALSE);
|
||||
|
||||
attrs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
|
||||
if (include_defaults)
|
||||
{
|
||||
gtk_accessible_text_get_default_attributes (self,
|
||||
&attr_names,
|
||||
&attr_values);
|
||||
|
||||
for (unsigned i = 0; attr_names[i] != NULL; i++)
|
||||
{
|
||||
g_hash_table_insert (attrs,
|
||||
g_steal_pointer (&attr_names[i]),
|
||||
g_steal_pointer (&attr_values[i]));
|
||||
}
|
||||
|
||||
g_free (attr_names);
|
||||
g_free (attr_values);
|
||||
}
|
||||
|
||||
res = gtk_accessible_text_get_attributes (self,
|
||||
offset,
|
||||
n_ranges,
|
||||
ranges,
|
||||
&attr_names,
|
||||
&attr_values);
|
||||
|
||||
/* If there are no attributes, we can bail out early */
|
||||
if (!res && !include_defaults)
|
||||
{
|
||||
g_hash_table_unref (attrs);
|
||||
*attribute_names = NULL;
|
||||
*attribute_values = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* The text attributes override the default ones */
|
||||
for (unsigned i = 0; i < *n_ranges; i++)
|
||||
{
|
||||
g_hash_table_insert (attrs,
|
||||
g_steal_pointer (&attr_names[i]),
|
||||
g_steal_pointer (&attr_values[i]));
|
||||
}
|
||||
|
||||
g_free (attr_names);
|
||||
g_free (attr_values);
|
||||
|
||||
names_builder = g_strv_builder_new ();
|
||||
values_builder = g_strv_builder_new ();
|
||||
g_hash_table_iter_init (&attr_iter, attrs);
|
||||
while (g_hash_table_iter_next (&attr_iter, &key, &value))
|
||||
{
|
||||
g_strv_builder_add (names_builder, key);
|
||||
g_strv_builder_add (values_builder, value);
|
||||
}
|
||||
|
||||
*attribute_names = g_strv_builder_end (names_builder);
|
||||
*attribute_values = g_strv_builder_end (values_builder);
|
||||
|
||||
g_strv_builder_unref (names_builder);
|
||||
g_strv_builder_unref (values_builder);
|
||||
g_hash_table_unref (attrs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accessible_text_update_caret_position:
|
||||
* @self: the accessible object
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* gtkaccessibletext-private.h: Private definitions for GtkAccessibleText
|
||||
/* gtkaccessibletextprivate.h: Private definitions for GtkAccessibleText
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2023 Emmanuele Bassi
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
@ -43,4 +43,13 @@ gtk_accessible_text_get_default_attributes (GtkAccessibleText *self,
|
||||
char ***attribute_names,
|
||||
char ***attribute_values);
|
||||
|
||||
gboolean
|
||||
gtk_accessible_text_get_attributes_run (GtkAccessibleText *self,
|
||||
unsigned int offset,
|
||||
gboolean include_defaults,
|
||||
gsize *n_ranges,
|
||||
GtkAccessibleTextRange **ranges,
|
||||
char ***attribute_names,
|
||||
char ***attribute_values);
|
||||
|
||||
G_END_DECLS
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "gtkinscriptionprivate.h"
|
||||
|
||||
#include "gtkaccessibletext-private.h"
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkcssstylechangeprivate.h"
|
||||
#include "gtkpangoprivate.h"
|
||||
|
@ -26,37 +26,36 @@
|
||||
|
||||
#include "gtklabelprivate.h"
|
||||
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdragicon.h"
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtkfilelauncher.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkgesturesingle.h"
|
||||
#include "gtkjoinedmenuprivate.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtknotebook.h"
|
||||
#include "gtkpangoprivate.h"
|
||||
#include "gtkpopovermenu.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
#include "gtkrenderlayoutprivate.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
#include "gtkrenderlayoutprivate.h"
|
||||
#include "gtktextutilprivate.h"
|
||||
#include "gtktooltip.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkurilauncher.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkpopovermenu.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdragicon.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkjoinedmenuprivate.h"
|
||||
#include "gtkaccessibletext-private.h"
|
||||
#include "gtkpangoprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -24,11 +24,11 @@
|
||||
|
||||
#include "gtkatcontextprivate.h"
|
||||
#include "gtkaccessibleprivate.h"
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkaccessibletext-private.h"
|
||||
|
||||
struct _GtkTestATContext
|
||||
{
|
||||
|
@ -23,8 +23,9 @@
|
||||
|
||||
#include "gtktextprivate.h"
|
||||
|
||||
#include "gtkaccessibletext-private.h"
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
#include "gtkactionable.h"
|
||||
#include "gtkactionmuxerprivate.h"
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbutton.h"
|
||||
@ -46,19 +47,20 @@
|
||||
#include "gtkimcontextprivate.h"
|
||||
#include "gtkimcontextsimple.h"
|
||||
#include "gtkimmulticontext.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtkjoinedmenuprivate.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmagnifierprivate.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkpangoprivate.h"
|
||||
#include "gtkpopovermenu.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
#include "gtkrenderlayoutprivate.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtktexthandleprivate.h"
|
||||
#include "gtktexthistoryprivate.h"
|
||||
#include "gtktextutilprivate.h"
|
||||
@ -66,15 +68,13 @@
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkwindow.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkactionmuxerprivate.h"
|
||||
#include "gtkjoinedmenuprivate.h"
|
||||
|
||||
#include "deprecated/gtkrender.h"
|
||||
#include "gtkaccessibletext-private.h"
|
||||
#include "a11y/gtkatspipangoprivate.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
#include <string.h>
|
||||
#include <cairo-gobject.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
/**
|
||||
* GtkText:
|
||||
|
@ -29,41 +29,40 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include "gtkaccessibletextprivate.h"
|
||||
#include "gtkadjustmentprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
#include "gtkcsslineheightvalueprivate.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdropcontrollermotion.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtktextiterprivate.h"
|
||||
#include "gtkemojichooser.h"
|
||||
#include "gtkimcontextprivate.h"
|
||||
#include "gtkimmulticontext.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktextutilprivate.h"
|
||||
#include "gtktextbufferprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkwindow.h"
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtktextviewchildprivate.h"
|
||||
#include "gtktexthandleprivate.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkmagnifierprivate.h"
|
||||
#include "gtkemojichooser.h"
|
||||
#include "gtkpangoprivate.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkjoinedmenuprivate.h"
|
||||
#include "gtkcsslineheightvalueprivate.h"
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkmagnifierprivate.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkpangoprivate.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
#include "gtkaccessibletext-private.h"
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtktextiterprivate.h"
|
||||
#include "gtktexthandleprivate.h"
|
||||
#include "gtktextviewchildprivate.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktextbufferprivate.h"
|
||||
#include "gtktextutilprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkwindow.h"
|
||||
|
||||
/**
|
||||
* GtkTextView:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtk/gtkaccessibletext-private.h"
|
||||
#include "gtk/gtkaccessibletextprivate.h"
|
||||
|
||||
static void
|
||||
inscription_text_interface (void)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtk/gtkaccessibletext-private.h"
|
||||
#include "gtk/gtkaccessibletextprivate.h"
|
||||
|
||||
static void
|
||||
label_role (void)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtk/gtkatcontextprivate.h"
|
||||
#include "gtk/gtkaccessibletext-private.h"
|
||||
#include "gtk/gtkaccessibletextprivate.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtk/gtkatcontextprivate.h"
|
||||
#include "gtk/gtkaccessibletext-private.h"
|
||||
#include "gtk/gtkaccessibletextprivate.h"
|
||||
|
||||
static void
|
||||
textview_role (void)
|
||||
|
Loading…
Reference in New Issue
Block a user