Re: linked scrolled text inaccuraccies




On Jan 22, 2006, at 5:37 PM, zentara wrote:

I will mention that if I use set_default_size instead of set_size_request the window expands with the widget's size. I guess I have to think about it more.

You're telling the left textview's scrolled window not to scroll vertically. If you set_size_request on the toplevel, that is honored (and the user cannot shrink below that). If you set_default_size on the toplevel window, the toplevel asks the children how big they want to be. The scroller is told not to scroll its child, so it will respond that it wants all the space the child wants. The child wants enough space to display 500 rows...

You have to tell either the scrolled window or the textview to request *no* vertical space. Then it will work as you want.


when I link the $vadj scroll, the scrolled window WILL NOT
goto the end mark at line 500, it ends up at around line 482.

I don't see this. From your description i suspected it to be something to do with the fact that the two views have different vertical sizes, but can't prove that, as it behaves correctly for me.

P.S. I modified your example to insert 500 lines, and it does not scroll to the end mark either. Does it work for you? Is this a window manager problem?

Worked for me, as you might expect. I wouldn't have posted it, otherwise. ;-)


Now, thinking about it some more and poking through other code, using linked textviews just for line numbers is a bit silly. The second textview + buffer takes up an awful lot of memory just to display line numbers. GtkTextView actually provides border windows for you to draw your own things on, such as line numbers and other annotations, and this is, in fact, what GtkSourceView does.

To that end, attached is a quick, still-somewhat-c-ish port of the line number drawing from gtksourceview.c. It's two almost two hundred lines, but requires no extra memory for a nearly useless text buffer, requires no synchronization of scrollbars, and does not require anything external to Gtk2.

Attachment: line-numbers.pl
Description: Text Data



--
elysse (pregnant): are your hands cold?
me: uh, i suppose so.
elysse: will you put them on me?



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