Re: Shared scrollbar between 2 Text widgets




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

> I'm writing an application in which I have:
> 	two Text Widgets (text and text2)
>    and  one vertical scrollbar (vscrollbar).
> ( the 3 widgets are packed horizontally in an hbox )
> 
> The scrollbar is shared between the two text widgets like that:
>     vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
>     gtk_text_set_adjustments (GTK_TEXT (text2), NULL, GTK_TEXT
> (text)->vadj);
> 
> The problem is that when I'm inserting two much text (with
> gtk_text_insert or manually) in one of the two text widget (with respect
> with the other text widget) the program stops with this error signal:
> 	** ERROR **: sigsegv caught

I don't think it will work to share an adjustment between two
text widgets. The problem is that each text widget will want
to change the scrollbar to reflect its own contents. 

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");
}

Regards,
                                        Owen



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