Re: someone please answer, clearing text in a GtkTextView!



* Roger Leigh (roger whinlatter uklinux net) wrote:
> "Carl B. Constantine" <duckwing duckwing ca> writes:
> 
> > I have a GtkTextView in a window used for data entry into a database.
> > The text typed in the view gets put in the database no problem, but once
> > the data entry has occurred, I want to clear the view so that the next
> > screen of data can be input.
> 
> Do you want to clear the *view* (the GtkTextView) or the *model* (the
> GtkTextBuffer)?
> 
> If the former, you want to remove the TextBuffer and replace it with a
> new one.
> 
> If the latter, you just need to clear the buffer.  Try something like:
> 

> GtkTextIter start, end;
> gtk_text_buffer_get_start_iter(textbuffer, &start);
> gtk_text_buffer_get_end_iter(textbuffer, &end);
> gtk_textbuffer_delete(textbuffer, &start, &end);

I did that and it crashed. The answer, thanks to a couple other posters
was to set the text buffer to null:

gtk_text_buffer_set_text(textbuffer, "\0", -1);

-- 
 .''`.      Carl B. Constantine
: :' :     duckwing duckwing ca
`. `'    GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom
  "Claiming that your operating system is the best in the world because more
  people use it is like saying McDonalds makes the best food in the world."



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