[Gtk-sharp-list] refreshing Gtk.TextView and EntryCompletion

Javier Díaz javierdiazm@yahoo.com.mx
Thu, 23 Dec 2004 07:27:55 -0600

Hey guys

I'm writing an example of how to use Google Suggest technology in
gtk-sharp applications

here is part of the code:
public class GoogleCompletionGladeApp
	[Widget] Gtk.Entry query_entry;
	[Widget] Gtk.TextView res_textview;
	[Widget] Gtk.Combo combo_res;
	static Gtk.TextBuffer buffer;
	static ACRequestHandler request_handler;
	private static Thread search_thread;
	private static string search_query;
	private static string[] Args;
	public GoogleCompletionGladeApp (string[] args) 
		Args = args;
		request_handler = new ACRequestHandler(); 

		Glade.XML gxml = new Glade.XML (null, "gui.glade", "window1", null);
		gxml.Autoconnect (this);
		buffer = res_textview.Buffer;

	public void OnWindowDeleteEvent (object o, DeleteEventArgs args) 
		Application.Quit ();
		args.RetVal = true;
	public void on_exec_button_clicked (object o, EventArgs args)
		// Not using threads Here.....
		foreach (string s in request_handler.Require(query_entry.Text)){
			buffer.Text += s + '\n';
	public void on_query_entry_changed (object o, EventArgs args)
		// Using threads....
		// "search_query" is a static member
		// it is going to be used by SearchThread()
		// I don't want SearchThread() to access "query_entry"  
		search_query = query_entry.Text;
		if (search_thread != null){

		search_thread = new Thread (new ThreadStart (SearchThread));
	private static void SearchThread()
		try {
			lock (buffer){	

				foreach (string s in request_handler.Require(search_query)){
					buffer.Text += s + '\n';
		} catch (ThreadAbortException) {
You can download the full source code from:

I have the following problem:

The (Gtk.TextBuffer) buffer used to modify the (Gtk.TextView)
res_textview, it is locked and modified by the thread that searches
suggestions,... but the res_textview does not reloads the data from the
buffer, I don't know how to explicitly refresh res_textview.

I can see that res_textview redraws itself very well on Expose event.

Is there any way SearchThread() can redraw res_textview safely ??.

I wish I had some sort of Completion widget like Monodevelo's

is there something like a Gtk.EntryCompletion on Gtk# 1.0.4 ?

Javier Díaz <javierdiazm@yahoo.com.mx>