forked from AuroraMiddleware/gtk
Merge branch 'get_caret_offset_negative_one' into 'master'
Return -1 for AtkText::get_caret_offset on failure See merge request GNOME/gtk!666
This commit is contained in:
commit
8d4343a550
@ -876,12 +876,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