forked from AuroraMiddleware/gtk
Return -1 for AtkText::get_caret_offset on failure
ATK now expects this virtual method to return -1 on failure. This allows ATs to distinguish between a caret at position 0 and a failure.
This commit is contained in:
parent
f454a31caa
commit
c8d250deb1
@ -874,12 +874,18 @@ static gint
|
||||
gtk_entry_accessible_get_caret_offset (AtkText *text)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gboolean result;
|
||||
int cursor_position;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
|
||||
if (widget == NULL)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
return gtk_editable_get_position (GTK_EDITABLE (widget));
|
||||
result = gtk_editable_get_selection_bounds (GTK_EDITABLE (widget), NULL, &cursor_position);
|
||||
if (!result)
|
||||
return -1;
|
||||
|
||||
return cursor_position;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -822,7 +822,11 @@ gtk_label_accessible_get_caret_offset (AtkText *text)
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
|
||||
if (widget == NULL)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
/* Non-selectable labels cannot have a caret. */
|
||||
if (!gtk_label_get_selectable (GTK_LABEL (widget)))
|
||||
return -1;
|
||||
|
||||
return _gtk_label_get_cursor_position (GTK_LABEL (widget));
|
||||
}
|
||||
|
@ -317,12 +317,18 @@ static gint
|
||||
gtk_text_accessible_get_caret_offset (AtkText *text)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gboolean result;
|
||||
int cursor_position;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
|
||||
if (widget == NULL)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
return gtk_editable_get_position (GTK_EDITABLE (widget));
|
||||
result = gtk_editable_get_selection_bounds (GTK_EDITABLE (widget), NULL, &cursor_position);
|
||||
if (!result)
|
||||
return -1;
|
||||
|
||||
return cursor_position;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -198,6 +198,7 @@ static void
|
||||
gtk_text_cell_accessible_init (GtkTextCellAccessible *text_cell)
|
||||
{
|
||||
text_cell->priv = gtk_text_cell_accessible_get_instance_private (text_cell);
|
||||
text_cell->priv->caret_pos = -1;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
@ -412,7 +412,7 @@ gtk_text_view_accessible_get_caret_offset (AtkText *text)
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
|
||||
if (widget == NULL)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
|
||||
return get_insert_offset (buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user