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

Re: Problem with adjustments



Hi,

* Aaron Lehmann <aaronl@vitelus.com> writes:

> I have a noneditable GtkText in my application that the app inserts to. It
> has a vertical scroll bar and I want to scroll it to the bottom when I
> append stuff. I've tried this code:

>       gtk_adjustment_set_value (GTK_TEXT(text)->vadj, GTK_TEXT 
> (text)->vadj->upper);
>       gtk_widget_queue_draw (text);

> The result is a segmentation fault.

The following is a re-post, hope it helps:

------------------------------------------------------------------------
From: Noonian Soong <noonian@dreamhaven.net>
Subject: Re: Scrolling to the last line in a text widget from inside the app
To: gtk-app-devel-list@redhat.com
X-Sent: 10 weeks, 19 hours, 27 minutes, 24 seconds ago
Reply-To: gtk-app-devel-list@redhat.com
X-Mailing-List: <gtk-app-devel-list@redhat.com> archive/latest/2125
Message-ID: <Pine.LNX.4.04.9905262001080.14759-100000@eaganj.student.lawrence.edu>

On 26 May 1999, Colin Marquardt wrote:

> My current solution: freeze the text widget, insert the text, thaw
> it, insert a space character. This single space brings the point to
> the end of the file, but to get there there is this scroll-effect,
> pretty sloooooow. Moving the scrollbar is much faster. As I´m
> currently deleting all the content of the text widget if there is
> something new to show, this is quite annoying.

Here's what I'm currently doing.  It will be slightly different because I
want to keep a fairly large scrollback buffer and only have it scroll if
you're at the end (that way you can scrollback and not have it snap back
to the bottom while you're reading what already scrolled by).  It just
checks if the scrollbar is at the bottom and if so, snaps it down after
the text is added.  There's prolly a better way.  Code example follows (as
usual, use at your own risk, ymmv, pink flamingos are your friends, &c).

  adj = textArea->vadj;
  if (adj->upper - adj->page_size = adj->value)
      snap = TRUE;
  gtk_text_freeze(textArea);

  ...

  gtk_text_thaw(textArea);
  if (snap)
      gtk_adjustment_set_value( adj, adj->upper - adj->lower - adj->page_size );

=======================================|  Dr. Noonian Soong  |==|  Noonian@dal.net  |==|  Noonian on DALnet  |=
-----------------------------------------------------------------------------
=|  Ferengi Rule of Aquisition Number 34:  War is good for business.     |=
=|  Ferengi Rule of Aquisition Number 35:  Peace is good for business.   |=
======================================

-- 
         To unsubscribe: mail gtk-app-devel-list-request@redhat.com with 
                       "unsubscribe" as the Subject.

	Mailing list concerns should be mailed to <listmaster@redhat.com>

-- 
Colin Marquardt <colin.marquardt@gmx.de>



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