+ if (GTK_IS_TEXT_VIEW (focused)) {
+ GtkTextIter start, end;
+ GtkTextBuffer *buffer = NULL;
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused));
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end)) {
+ selection = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+ }
+ } else if (GTK_IS_LABEL (focused)) {
+ selection = modest_text_utils_label_get_selection (GTK_LABEL (focused));
+ } else {
+ gboolean do_check = TRUE;
+ GtkClipboard *clipboard;
+ if (GTK_IS_HTML (focused)) {
+ const gchar *sel;
+ int len = -1;
+ sel = gtk_html_get_selection_html (GTK_HTML (focused), &len);
+ do_check = !((sel == NULL) || (sel[0] == '\0'));
+ }
+ if (do_check) {
+ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ selection = gtk_clipboard_wait_for_text (clipboard);
+ } else {
+ selection = NULL;
+ }
+ }