Re: TextView and ScrolledWindow not behaving properly (repost from gtk-app-devel-list)



Hi,

On Wed, 2002-07-17 at 22:37, Morten Brix Pedersen wrote:
> I have a TextView in a ScrolledWindow, but it's not behaving like it
> should, here's my "requirements":
> 
>  * It should be possible to shrink the window to a size less than the
>    text width (my example can show why this isn't always true)
>  * The TextWidget should not expand the window while you type or insert
>    text into it. E.g. a 50x50 window should stay 50x50 nomatter the text
>    inserted.
>  * The text should wrap.
>  * There should be no horizontal scrollbar.
> 
> The below example illustrates my problem, I have set wrap_mode to
> GTK_WRAP_CHAR, but the text doesn't wrap when the window is shrinked.
> 

[snip]

>     gtk_scrolled_window_add_with_viewport (
>             GTK_SCROLLED_WINDOW (scrolled_window), view);

I think this is your problem.  You should be using gtk_container_add
directly, since GtkTextView supports scrolling natively.  From the
reference documentation:

    Used to add children without native scrolling capabilities. This is
    simply a convenience function; it is equivalent to adding the
    unscrollable child to a viewport, then adding the viewport to the
    scrolled window. If a child has native scrolling, use
    gtk_container_add() instead of this function.
    
    ...
    
    A widget supports scrolling natively if the
    set_scroll_adjustments_signal field in GtkWidgetClass is non-zero,
    i.e. has been filled in with a valid signal identifier.

The gtk_widget_set_size_request is not necessary.

Cheers,
Gustavo





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]