Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print the text of GtkTextView

How can I print (for example in a label) the text into a GtkTextView? For GtkLabel and GtkEntry there are gtk_label_get_text() and gtk_entry_get_text(), but for GtkTextView?

like image 371
stdio Avatar asked Feb 28 '23 00:02

stdio


1 Answers

Based on doublep's answer, for quick copy/paste:

char *get_text_of_textview(GtkWidget *text_view) {
    GtkTextIter start, end;
    GtkTextBuffer *buffer = gtk_text_view_get_buffer((GtkTextView *)text_view);
    gchar *text;
    gtk_text_buffer_get_bounds(buffer, &start, &end);
    text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
    return text;
}
like image 123
kungfooman Avatar answered Apr 05 '23 23:04

kungfooman