mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
atspi: Be more careful about indexes
Don't return a number for IndexInParent when we don't have one.
This commit is contained in:
parent
f9ee23825e
commit
578c8b5068
@ -290,12 +290,12 @@ get_index_in_parent (GtkWidget *widget)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (child == widget)
|
if (child == widget)
|
||||||
break;
|
return idx;
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return idx;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -317,12 +317,12 @@ get_index_in_toplevels (GtkWidget *widget)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (window == widget)
|
if (window == widget)
|
||||||
break;
|
return idx;
|
||||||
|
|
||||||
idx += 1;
|
idx += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return idx;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -455,7 +455,10 @@ handle_accessible_method (GDBusConnection *connection,
|
|||||||
else
|
else
|
||||||
idx = get_index_in_parent (GTK_WIDGET (accessible));
|
idx = get_index_in_parent (GTK_WIDGET (accessible));
|
||||||
|
|
||||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", idx));
|
if (idx == -1)
|
||||||
|
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Not found");
|
||||||
|
else
|
||||||
|
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", idx));
|
||||||
}
|
}
|
||||||
else if (g_strcmp0 (method_name, "GetRelationSet") == 0)
|
else if (g_strcmp0 (method_name, "GetRelationSet") == 0)
|
||||||
{
|
{
|
||||||
@ -621,6 +624,21 @@ emit_state_changed (GtkAtSpiContext *self,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
emit_property_changed (GtkAtSpiContext *self,
|
||||||
|
const char *name,
|
||||||
|
GVariant *value)
|
||||||
|
{
|
||||||
|
g_dbus_connection_emit_signal (self->connection,
|
||||||
|
NULL,
|
||||||
|
self->context_path,
|
||||||
|
"org.a11y.atspi.Event.Object",
|
||||||
|
"PropertyChange",
|
||||||
|
g_variant_new ("(siiva{sv})",
|
||||||
|
name, 0, 0, value, NULL),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_at_spi_context_state_change (GtkATContext *ctx,
|
gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||||
GtkAccessibleStateChange changed_states,
|
GtkAccessibleStateChange changed_states,
|
||||||
@ -770,6 +788,15 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
|||||||
value = gtk_accessible_attribute_set_get_value (properties, GTK_ACCESSIBLE_PROPERTY_MULTI_LINE);
|
value = gtk_accessible_attribute_set_get_value (properties, GTK_ACCESSIBLE_PROPERTY_MULTI_LINE);
|
||||||
emit_state_changed (self, "multi-line", gtk_boolean_accessible_value_get (value));
|
emit_state_changed (self, "multi-line", gtk_boolean_accessible_value_get (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_LABEL)
|
||||||
|
{
|
||||||
|
char *label = gtk_at_context_get_label (GTK_AT_CONTEXT (self));
|
||||||
|
GVariant *v = g_variant_new_string (label);
|
||||||
|
emit_property_changed (self, "accessible-description", v);
|
||||||
|
g_variant_unref (v);
|
||||||
|
g_free (label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user