X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atspi%2Fatspi-matchrule.c;h=e9954594741a5e5e3ec711f1bff6d44b61fae945;hb=57ae8d6e0e518151e5e4b87cc8703ce60f46f1e5;hp=76415c28c52a3c1dc34eb2709c9994496868cc45;hpb=05237f4e33de73b6826807aef1bdfa7a0261821b;p=platform%2Fupstream%2Fat-spi2-core.git diff --git a/atspi/atspi-matchrule.c b/atspi/atspi-matchrule.c index 76415c2..e995459 100644 --- a/atspi/atspi-matchrule.c +++ b/atspi/atspi-matchrule.c @@ -55,10 +55,14 @@ static void atspi_match_rule_finalize (GObject *object) { AtspiMatchRule *rule = ATSPI_MATCH_RULE (object); + gint i; - /* TODO: Check that interfaces don't leak */ if (rule->interfaces) + { + for (i = 0; i < rule->interfaces->len; i++) + g_free (g_array_index (rule->interfaces, gchar *, i)); g_array_free (rule->interfaces, TRUE); + } if (rule->attributes) g_hash_table_unref (rule->attributes); @@ -77,29 +81,37 @@ atspi_match_rule_class_init (AtspiMatchRuleClass *klass) /** * atspi_match_rule_new: - * * @states: An #AtspiStateSet specifying the states to match or NULL if none. * @statematchtype: An #AtspiCollectionMatchType specifying how to interpret - * @states. + * @states. * @attributes: (element-type gchar* gchar*): A #GHashTable specifying - * attributes to match. + * attributes to match. To specify multiple attribute values, + * separate each value with a :: If an attribute value contains a :, + * then it can be escaped by preceding it with a \. A backslash can + * likewise be escaped by inserting a double backslash. * @attributematchtype: An #AtspiCollectionMatchType specifying how to - * interpret @attributes. + * interpret @attributes. * @interfaces: (element-type gchar*): An array of interfaces to match, or - * NUL if not applicable. Interface names should be specified - * by their DBus names (org.a11y.Atspi.Accessible, - * org.a11y.Atspi.Component, etc). + * NULL if not applicable. Interface names should be specified + * by their DBus names (org.a11y.Atspi.Accessible, + * org.a11y.Atspi.Component, etc). * @interfacematchtype: An #AtspiCollectionMatchType specifying how to - * interpret @interfaces. + * interpret @interfaces. * @roles: (element-type AtspiRole): A #GArray of roles to match, or NULL if - * not applicable. + * not applicable. * @rolematchtype: An #AtspiCollectionMatchType specifying how to - * interpret @roles. - * @invert: Specifies whether results should be inverted. - * TODO: Document this parameter better. + * interpret @roles. + * @invert: if #TRUE, the match rule should be denied (inverted); if #FALSE, + * it should not. For example, if the match rule defines that a match is + * an object of ROLE_HEADING which has STATE_FOCUSABLE and a click action, + * inverting it would match all objects that are not of ROLE_HEADING, + * focusable and clickable at the same time. + * + * Creates a new #AtspiMatchRule with specified @states, @attributes, + * @interfaces, and @roles. * * Returns: (transfer full): A new #AtspiMatchRule. - */ + **/ AtspiMatchRule * atspi_match_rule_new (AtspiStateSet *states, AtspiCollectionMatchType statematchtype, @@ -114,9 +126,6 @@ atspi_match_rule_new (AtspiStateSet *states, AtspiMatchRule *rule = g_object_new (ATSPI_TYPE_MATCH_RULE, NULL); int i; - if (!rule) - return NULL; - if (states) rule->states = g_object_ref (states); rule->statematchtype = statematchtype; @@ -137,7 +146,14 @@ atspi_match_rule_new (AtspiStateSet *states, rule->attributematchtype = attributematchtype; if (interfaces) - rule->interfaces = g_array_ref (interfaces); + { + rule->interfaces = g_array_new (TRUE, TRUE, sizeof (gchar *)); + for (i = 0; i < interfaces->len; i++) + { + gchar *val = g_strdup (g_array_index (interfaces, gchar *, i)); + rule->interfaces = g_array_append_val (rule->interfaces, val); + } + } rule->interfacematchtype = interfacematchtype; if (roles) @@ -211,7 +227,8 @@ _atspi_match_rule_marshal (AtspiMatchRule *rule, DBusMessageIter *iter) if (!dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "{ss}", &iter_dict)) return FALSE; - g_hash_table_foreach (rule->attributes, append_entry, &iter_dict); + if (rule->attributes) + g_hash_table_foreach (rule->attributes, append_entry, &iter_dict); dbus_message_iter_close_container (&iter_struct, &iter_dict); dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_attributematchtype);