[Glade-users] Problem with gtk_text_view and gtk_text_buffer...



On 5/1/05, SBBG <sbbgnew gmail com> wrote:
Hello,
   I got a problem while using Gtk Text View, I 'm trying to set the
text view's content according to a text buffer. And ONLY show the
content of the text buffer, thus I choose the function
"gtk_text_view_set_buffer." But somehow, while executing, the console
keep showing that :
=20
Gtk-CRITICAL **: gtk_text_buffer_set_text: assertion
`GTK_IS_TEXT_BUFFER (buffer)' failed
=20
and set text to text view failed, too. OOPS!!
Following is the code where shxt happened:
=20
void refresh( char *memU, char *regU, GtkTextView *memView,
GtkTextView *regView )
{
  GtkTextBuffer *memBuffer=3DNULL;
  GtkTextBuffer *regBuffer=3DNULL;
  gtk_text_buffer_set_text( memBuffer, memU, -1 );
  gtk_text_buffer_set_text( regBuffer, regU, -1 );
  gtk_text_view_set_buffer( GTK_TEXT_VIEW(memView), memBuffer );
  gtk_text_view_set_buffer( GTK_TEXT_VIEW(regView), regBuffer );
}

The problem is you call gtk_text_buffer_set_text() with a NULL 1st argument=
.
You should instead have something as:

memBuffer =3D gtk_text_view_get_buffer( GTK_TEXT_VIEW(memView));
gtk_text_buffer_set_text( memBuffer, memU, -1 );

and the same for regView.

Vivien




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