diff options
-rw-r--r-- | gtk/gtklabel.c | 153 | ||||
-rw-r--r-- | gtk/gtklabelprivate.h | 16 |
2 files changed, 169 insertions, 0 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 8d06be7bc2..8f1ef1fe47 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -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; +} diff --git a/gtk/gtklabelprivate.h b/gtk/gtklabelprivate.h index e8fe1b29a2..f99c50fca5 100644 --- a/gtk/gtklabelprivate.h +++ b/gtk/gtklabelprivate.h @@ -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__ */ |