From: Hosang Kim Date: Tue, 21 May 2024 10:22:14 +0000 (+0900) Subject: libaurum: add role option for getMatches and getMatchesInMatches. X-Git-Tag: accepted/tizen/unified/20240703.100051~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F55%2F311455%2F5;p=platform%2Fcore%2Fuifw%2Faurum.git libaurum: add role option for getMatches and getMatchesInMatches. Change-Id: I4dc0f1239e1df67c60d0a606a799cf78b4b380bc --- diff --git a/libaurum/src/Impl/Accessibility/AtspiMatchRuleConvertor.cc b/libaurum/src/Impl/Accessibility/AtspiMatchRuleConvertor.cc index d5c9294..fed9739 100644 --- a/libaurum/src/Impl/Accessibility/AtspiMatchRuleConvertor.cc +++ b/libaurum/src/Impl/Accessibility/AtspiMatchRuleConvertor.cc @@ -39,6 +39,7 @@ AtspiMatchRuleConvertor::operator AtspiMatchRule *() AtspiCollectionMatchType stateMatchType = ATSPI_Collection_MATCH_INVALID; AtspiCollectionMatchType attributeMatchType = ATSPI_Collection_MATCH_INVALID; + AtspiCollectionMatchType roleMatchType = ATSPI_Collection_MATCH_INVALID; // Add rule of states AtspiStateSet *ss = atspi_state_set_new(nullptr); @@ -87,14 +88,45 @@ AtspiMatchRuleConvertor::operator AtspiMatchRule *() attributeMatchType = ATSPI_Collection_MATCH_ALL; } + GArray *roles = g_array_new(true, true, sizeof(AtspiRole)); + if (mSelector->mMatchRole) + { + if (!strncmp(mSelector->mRole.c_str(), "label", 5)) + { + gint role = ATSPI_ROLE_LABEL; + roles = g_array_append_val(roles, role); + } + else if (!strncmp(mSelector->mRole.c_str(), "image", 5)) + { + gint role = ATSPI_ROLE_IMAGE; + roles = g_array_append_val(roles, role); + } + else if (!strncmp(mSelector->mRole.c_str(), "window", 6)) + { + gint role = ATSPI_ROLE_WINDOW; + roles = g_array_append_val(roles, role); + } + } + + if (roles->len == 0) + { + g_array_free(roles, true); + roles = nullptr; + } + else + { + roleMatchType = ATSPI_Collection_MATCH_ALL; + } + AtspiMatchRule* rule = atspi_match_rule_new(ss, stateMatchType, attributes, attributeMatchType, - nullptr, ATSPI_Collection_MATCH_INVALID, + roles, roleMatchType, nullptr, ATSPI_Collection_MATCH_INVALID, false); if (ss) g_object_unref(ss); if (attributes) g_hash_table_unref (attributes); + if (roles) g_array_free(roles, true); return rule; }