Re: Shared scrollbar between 2 Text widgets




Marc Aubry <marc@upr41.univ-rennes1.fr> writes:

> > But here is what might work - let each text widget have
> > its own adjustment, only connect one of them to the scrollbar,
> > then monitor changes on that adjustment, and change the
> > other adjustment yourself.
> > 
> >      vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
> >      gtk_signal_connect (GTK_OBJECT (GTK_TEXT (text)->vadj),
> >                          "changed",
> >                          GTK_SIGNAL_FUNC (changed_cb),
> >                          GTK_TEXT (text2)->vadj);
> > 
> > void
> > my_changed_cb (GtkAdjustment *adj1, GtkAdjustment *adj2)
> > {
> >   adj2->value = CLAMP (adj1->value, 0, adj2->upper - adj2->page_size);
> >   gtk_signal_emit_by_name (GTK_OBJECT (adj2), "changed");
> > }
> > 
> 
> The idea of changed_cb is good...but the problem is still the same: the
> application segfaults when inserting two much text in one of the text
> widgets.
> More, the two text widgets are no longer scrolling together anymore...
> The vscrollbar is only connected to the text widget text (and not with
> text and text2).

Hmm. I misspole when I said "changed" - it should be "value_changed".
"changed" means that the upper/lower/page_size/etc. changed,
while "value_changed" means that adj->value changed. If that
change doesn't help things, could you make up a short test case
that exhibits the problem?

Thanks,
                                        Owen



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