HELP for TextView functions



Hello All

   I am a newbie to the GTK programming. I have an immediate assignment to do. I was trying to make one 
TextView in which I have to update with 
some text asynchronosly. The functionality is basic like I have to update the text view by giving different 
attributes to piece of texts (
 like bold, highlighted etc ). I tried to do some thing by refering the API reference document. I will put a 
piece of code I have written for 
appending some text. 

{

GtkTextBuffer *buffer;
 GtkTextIter iter;
 char fle_buf[10];

  memset(fle_buf, 65, 10);
  fle_buf[5] = '\0';



 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (textview1));
 gtk_text_buffer_get_start_iter(buffer, &st_iter);
 gtk_text_buffer_get_end_iter(buffer, &end_iter);
 txtbuf = gtk_text_buffer_get_text(buffer, &st_iter, &end_iter, 0);
 linecount = gtk_text_buffer_get_line_count(buffer);
 charcount = gtk_text_buffer_get_char_count(buffer);
 printf ("%d, %d \n%s\n",linecount, charcount,txtbuf);

 gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
 gtk_text_buffer_insert(buffer, &iter, fle_buf,10);

}

This is the kind of code i have done in my test application. when I execute this the following message came 

Xlib:  extension "RENDER" missing on display ":0.0".


(testtextwidget:15175): Gtk-CRITICAL **: file gtktextbuffer.c: line 476 (gtk_text_buffer_emit_insert): 
assertion `g_utf8_validate (text, len,
 NULL)' failed


  lol :-) this is my first experience with gtk programming .. :-) .. 

  Can any one give me some sample code which does the following thing on TextView.

  Append the existing text with new string.
  Change the attribute of the new textstring  ( bold, itatlic, highlight )
  append some small icon kind of pictures toi the string.
  mechanism for saving the whole string ( including the tags )
  retrieve the whole string from the file and load it in the text view.

   I hope I will get a help asap. 

Thanks in advance

  Lin



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