Commit 0d9efde3 authored by Matthias Clasen's avatar Matthias Clasen

GtkLabel: Add private api for links

This exposes enough information to implement the AtkHyperText
interface.

More private link api
parent c6d9f829
......@@ -6581,3 +6581,156 @@ gtk_label_get_lines (GtkLabel *label)
return label->priv->lines;
}
gint
_gtk_label_get_n_links (GtkLabel *label)
{
GtkLabelPrivate *priv = label->priv;
if (priv->select_info)
return g_list_length (priv->select_info->links);
return 0;
}
const gchar *
_gtk_label_get_link_uri (GtkLabel *label,
gint idx)
{
GtkLabelPrivate *priv = label->priv;
gint i;
GList *l;
GtkLabelLink *link;
if (priv->select_info)
for (l = priv->select_info->links, i = 0; l; l = l->next, i++)
{
if (i == idx)
{
link = l->data;
return link->uri;
}
}
return NULL;
}
void
_gtk_label_get_link_extent (GtkLabel *label,
gint idx,
gint *start,
gint *end)
{
GtkLabelPrivate *priv = label->priv;
gint i;
GList *l;
GtkLabelLink *link;
if (priv->select_info)
for (l = priv->select_info->links, i = 0; l; l = l->next, i++)
{
if (i == idx)
{
link = l->data;
*start = link->start;
*end = link->end;
return;
}
}
*start = -1;
*end = -1;
}
gint
_gtk_label_get_link_at (GtkLabel *label,
gint pos)
{
GtkLabelPrivate *priv = label->priv;
gint i;
GList *l;
GtkLabelLink *link;
if (priv->select_info)
for (l = priv->select_info->links, i = 0; l; l = l->next, i++)
{
link = l->data;
if (link->start <= pos && pos < link->end)
return i;
}
return -1;
}
void
_gtk_label_activate_link (GtkLabel *label,
gint idx)
{
GtkLabelPrivate *priv = label->priv;
gint i;
GList *l;
GtkLabelLink *link;
if (priv->select_info)
for (l = priv->select_info->links, i = 0; l; l = l->next, i++)
{
if (i == idx)
{
link = l->data;
emit_activate_link (label, link);
return;
}
}
}
gboolean
_gtk_label_get_link_visited (GtkLabel *label,
gint idx)
{
GtkLabelPrivate *priv = label->priv;
gint i;
GList *l;
GtkLabelLink *link;
if (priv->select_info)
for (l = priv->select_info->links, i = 0; l; l = l->next, i++)
{
if (i == idx)
{
link = l->data;
return link->visited;
}
}
return FALSE;
}
gboolean
_gtk_label_get_link_focused (GtkLabel *label,
gint idx)
{
GtkLabelPrivate *priv = label->priv;
gint i;
GList *l;
GtkLabelLink *link;
GtkLabelSelectionInfo *info = priv->select_info;
if (!info)
return FALSE;
if (info->selection_anchor != info->selection_end)
return FALSE;
for (l = info->links, i = 0; l; l = l->next, i++)
{
if (i == idx)
{
link = l->data;
if (link->start <= info->selection_anchor &&
info->selection_anchor <= link->end)
return TRUE;
}
}
return FALSE;
}
......@@ -29,6 +29,22 @@ void _gtk_label_mnemonics_visible_apply_recursively (GtkWidget *widget,
gint _gtk_label_get_cursor_position (GtkLabel *label);
gint _gtk_label_get_selection_bound (GtkLabel *label);
gint _gtk_label_get_n_links (GtkLabel *label);
gint _gtk_label_get_link_at (GtkLabel *label,
gint pos);
void _gtk_label_activate_link (GtkLabel *label,
gint idx);
const gchar *_gtk_label_get_link_uri (GtkLabel *label,
gint idx);
void _gtk_label_get_link_extent (GtkLabel *label,
gint idx,
gint *start,
gint *end);
gboolean _gtk_label_get_link_visited (GtkLabel *label,
gint idx);
gboolean _gtk_label_get_link_focused (GtkLabel *label,
gint idx);
G_END_DECLS
#endif /* __GTK_LABEL_PRIVATE_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment