Setting left-margin or right-margin may make GtkTextView inconsistent
Setting left-margin or right-margin on GtkTextView lets the parent window grow indefinitely. This was tested with the parent container GtkScrolledWindow hscrollpolicy to none, and wrap-mode set to word.
How to reproduce:
- Compile the following file and run.
- Unmaximize and reduce the window width as much as possible.
- Write some text as much so it would exceed the window width.
Result: The window simply grows as more text is fed.
Expected result: The text should be wrapped if the text exceeds the allocated width.
File (modified from sunny.c in gtk3): sunny.c
Diff of relevant code:
diff --git a/examples/sunny.c b/examples/sunny.c index 62f51a9866..e174b2748d 100644 --- a/examples/sunny.c +++ b/examples/sunny.c @@ -24,9 +24,14 @@ new_window (GApplication *app, gtk_container_add (GTK_CONTAINER (window), overlay); scrolled = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_set_hexpand (scrolled, TRUE); gtk_widget_set_vexpand (scrolled, TRUE); view = gtk_text_view_new (); + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); + gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 12); + gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 12); gtk_container_add (GTK_CONTAINER (scrolled), view); gtk_container_add (GTK_CONTAINER (overlay), scrolled);
padding css property works, which is pretty much the same, I believe.