2

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

El Developer
  • 3,345
  • 1
  • 21
  • 40

2 Answers2

1

Did you put your text view into a GtkScrolledWindow?

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • No, I didn't. That wasn't the behavior I was looking for. Anyway thanks for the answer, I ended up solving it in another way. Sorry I never replied :S – El Developer Feb 03 '12 at 17:48
  • This is probably not what solves the problem but it indeed helps to attack it in another way. – El Developer Feb 18 '12 at 23:10
0

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.

thomas.cloud
  • 881
  • 13
  • 30
  • You can also use `GTK_WRAP_WORD_CHAR` (in Vala, `Gtk.WrapMode.WORD_CHAR`) which might be closer to the behaviour you’d normally want (break at word boundaries if possible and, only if not, break between grapheme clusters). – Aral Balkan Nov 11 '21 at 17:06