summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk3/gtkinst.cxx
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-03-09 11:38:36 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2023-03-10 10:48:29 +0000
commitba0e36e607d1c380fd09b6725a4ebcb69ff399de (patch)
tree63ff31b4da11e562d92eef149a9010b5ccf3117c /vcl/unx/gtk3/gtkinst.cxx
parent1fbf95190ea0b3f14060193c51ff31ae178a992a (diff)
tdf#153657 tdf#140659 gtk3 a11y: Use IconView item tooltip as a11y desc
Similar to how the non-gtk SalInstanceIconView does since commit 2a28ebeef5ea3e2b01d836a7233d2316b765bf38 Date: Wed Jun 1 11:18:26 2022 +0300 Accessibility for IconView , use the tooltip as accessible description for the gtk3's IconView implementation as well. (Another alternative might be to always require passing a text/name in weld::IconView::insert, e.g. by turning the `const OUString* pStr` param into a `const OUString&` and adding a bool param to indicate whether the text should be shown on screen or only used for the accessible *name*. Might make sense to reconsider that when looking into the remaining aspects from the IconView a11y discussions in [1] and [2].) Together with Change-Id Ic77cf485ed4b2b413d3d3368c15b788d693111cd "tdf#153657 a11y: Set tooltip/a11y desc for fontwork styles", this makes Orca announce the items in the fontwork gallery by their title when using the gtk3 VCL plugin as well. Setting the accessible description for the items in Math's elements side bar still doesn't work with this change by itself, since the fact that the IconView is frozen (s. the call to `freeze()` in `SmElementsControl::addElements`) apparently prevents the creation of the accessible child objects on insertion (s. upcoming Change-Id Id0c241d68ec4fbf933312008f7d0ee86bd3eab0c, "tdf#140659 gtk a11y: Don't unset model when freezing icon view"). [1] https://gerrit.libreoffice.org/c/core/+/135226 [2] https://gerrit.libreoffice.org/c/core/+/135593 Change-Id: I10249bbd8c684e89174ba91ce4690d37c24b5d5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148534 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/unx/gtk3/gtkinst.cxx')
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 501521e82491..fd1124e6cb00 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -16825,6 +16825,37 @@ private:
return !aTooltip.isEmpty();
}
+ /* Set the item's tooltip text as its accessible description as well. */
+ void set_item_accessible_description_from_tooltip(GtkTreeIter& iter)
+ {
+#if GTK_CHECK_VERSION(4, 0, 0)
+ (void)iter;
+#else
+ AtkObject* pAtkObject = gtk_widget_get_accessible(GTK_WIDGET(m_pIconView));
+ assert(pAtkObject);
+ GtkTreePath* pPath = gtk_tree_model_get_path(GTK_TREE_MODEL(m_pTreeStore), &iter);
+ assert(gtk_tree_path_get_depth(pPath) == 1);
+ int* indices = gtk_tree_path_get_indices(pPath);
+ const int nIndex = indices[0];
+ const int nChildCount = atk_object_get_n_accessible_children(pAtkObject);
+ if (nIndex >= nChildCount)
+ {
+ SAL_WARN("vcl.gtk",
+ "item index "
+ << nIndex << " greater than ItemView's accessible child count "
+ << nChildCount
+ << ". Is the IconView frozen, preventing creation of a11y children?");
+ return;
+ }
+
+ const OUString sTooltipText = signal_query_tooltip(GtkInstanceTreeIter(iter));
+ AtkObject* pChild = atk_object_ref_accessible_child(pAtkObject, nIndex);
+ atk_object_set_description(pChild,
+ OUStringToOString(sTooltipText, RTL_TEXTENCODING_UTF8).getStr());
+ g_object_unref(pChild);
+#endif
+ }
+
void insert_item(GtkTreeIter& iter, int pos, const OUString* pId, const OUString* pText, const OUString* pIconName)
{
// m_nTextCol may be -1, so pass it last, to not terminate the sequence before the Id value
@@ -16839,6 +16870,8 @@ private:
if (pixbuf)
g_object_unref(pixbuf);
}
+
+ set_item_accessible_description_from_tooltip(iter);
}
void insert_item(GtkTreeIter& iter, int pos, const OUString* pId, const OUString* pText, const VirtualDevice* pIcon)
@@ -16855,6 +16888,8 @@ private:
if (pixbuf)
g_object_unref(pixbuf);
}
+
+ set_item_accessible_description_from_tooltip(iter);
}
OUString get(const GtkTreeIter& iter, int col) const