selection = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
}
} else if (GTK_IS_LABEL (focused)) {
- gint start, end;
- if (gtk_label_get_selection_bounds (GTK_LABEL (focused), &start, &end)) {
- const gchar *start_offset;
- const gchar *end_offset;
- start_offset = gtk_label_get_text (GTK_LABEL (focused));
- start_offset = g_utf8_offset_to_pointer (start_offset, start);
- end_offset = gtk_label_get_text (GTK_LABEL (focused));
- end_offset = g_utf8_offset_to_pointer (end_offset, end);
- selection = g_strndup (start_offset, end_offset - start_offset);
- g_message (selection);
- }
+ selection = modest_text_utils_label_get_selection (GTK_LABEL (focused));
} else {
gboolean do_check = TRUE;
GtkClipboard *clipboard;
if (GTK_IS_TEXT_VIEW (focused)) {
GtkTextBuffer *buffer = NULL;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused));
- has_selection = gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buffer));
+ has_selection = modest_text_utils_buffer_selection_is_valid (buffer);
} else if (GTK_IS_EDITABLE (focused)) {
has_selection = gtk_editable_get_selection_bounds (GTK_EDITABLE (focused), NULL, NULL);
}