El Developer
El Developer

Reputation: 3346

GtkTextView can't wrap line

Hello I'm using Gtk on C, I need to have a GtkTextView in the middle of my window with many other widgets, I can't make the widget wrap lines. This is a very annoying behavior, anyone have any idea of what am I missing? This is the code I'm using to set it's properties:

gtk_text_view_set_left_margin(GTK_TEXT_VIEW(commentsTextView),20);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(commentsTextView),290);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(commentsTextView),GTK_WRAP_WORD);
gtk_text_view_set_pixels_inside_wrap(GTK_TEXT_VIEW(commentsTextView),0);
gtk_widget_set_size_request(commentsTextView,300,300);

Edit:

I solved this in a different way, still the problem remains unsolved :S

Upvotes: 2

Views: 1753

Answers (2)

thomas.cloud
thomas.cloud

Reputation: 963

You also need to make sure there are spaces in your text if you want the wrapping to occur on words. If there are no spaces in your string that is inserted into the text view gtk won't know where 1 word ends and the other begins.

If you want the text to wrap on a string without spaces you could use GTK_WRAP_CHAR in place of GTK_WRAP_WORD.

Upvotes: 0

ptomato
ptomato

Reputation: 57910

Did you put your text view into a GtkScrolledWindow?

Upvotes: 1

Related Questions