[anjuta] sourceview, language-support-cpp-java: Ported everything to the new AnjutaProvider interface



commit fcb0c712e1cf926e6f1d07a98a8b96863df15265
Author: Johannes Schmid <jhs gnome org>
Date:   Sat Nov 21 18:09:25 2009 +0100

    sourceview, language-support-cpp-java: Ported everything to the new AnjutaProvider interface
    symbol-db: Added missing cancel() methods to avoid a crash, needs fixing.

 libanjuta/anjuta-async-notify.h                    |    1 -
 libanjuta/interfaces/libanjuta.idl                 |   18 +-
 .../language-support-cpp-java/cpp-java-assist.c    |  393 ++++++++++----------
 plugins/language-support-cpp-java/plugin.c         |    3 +-
 plugins/sourceview/sourceview-cell.c               |  209 +++++------
 plugins/sourceview/sourceview-cell.h               |    2 +-
 plugins/sourceview/sourceview-provider.c           |   28 +-
 plugins/sourceview/sourceview-provider.h           |    1 +
 plugins/sourceview/sourceview.c                    |  188 ++++++----
 plugins/symbol-db/symbol-db-engine-queries.c       |   10 +-
 plugins/symbol-db/symbol-db-search-command.c       |   13 +-
 11 files changed, 464 insertions(+), 402 deletions(-)
---
diff --git a/libanjuta/anjuta-async-notify.h b/libanjuta/anjuta-async-notify.h
index 0fdbefe..6c0f160 100644
--- a/libanjuta/anjuta-async-notify.h
+++ b/libanjuta/anjuta-async-notify.h
@@ -35,7 +35,6 @@ typedef struct _AnjutaAsyncNotifyClass AnjutaAsyncNotifyClass;
 typedef struct _AnjutaAsyncNotify AnjutaAsyncNotify;
 typedef struct _AnjutaAsyncNotifyPriv AnjutaAsyncNotifyPriv;
 
-
 struct _AnjutaAsyncNotifyClass
 {
 	GObjectClass parent_class;
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index c223766..f0c92eb 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -2034,7 +2034,7 @@ interface IAnjutaEditor
       * proposals async as long as the last call sets finished to TRUE.
       *
       */
-      void proposals(IAnjutaProvider* provider, GList* proposals. gboolean finished);
+      void proposals(IAnjutaProvider* provider, GList* proposals, gboolean finished);
 	}
 	
 	/**
@@ -2500,14 +2500,14 @@ interface IAnjutaProvider
 	*/
   void activate(IAnjutaIterable* iter, gpointer data);
 
- /**
-	* ianjuta_provider_cancelled
-	* @obj: Self
-	* @err: Error propagation and reporting.
-	* 
- 	* Called when the current completion was cancelled
-	*/
-  void cancelled();
+	/**
+	 * ianjuta_provider_get_name
+	 * @obj: Self
+	 *
+	 * Return a (translatable) name for the provider
+	 */
+	const gchar* get_name();
+ 
 
 }
 
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/language-support-cpp-java/cpp-java-assist.c
index c8ff939..f763909 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/language-support-cpp-java/cpp-java-assist.c
@@ -29,6 +29,9 @@
 #include <libanjuta/interfaces/ianjuta-file.h>
 #include <libanjuta/interfaces/ianjuta-editor-cell.h>
 #include <libanjuta/interfaces/ianjuta-editor-selection.h>
+#include <libanjuta/interfaces/ianjuta-editor-assist.h>
+#include <libanjuta/interfaces/ianjuta-editor-tip.h>
+#include <libanjuta/interfaces/ianjuta-provider.h>
 #include <libanjuta/interfaces/ianjuta-document.h>
 #include <libanjuta/interfaces/ianjuta-symbol-manager.h>
 #include "cpp-java-assist.h"
@@ -70,8 +73,14 @@ struct _CppJavaAssistPriv {
 	
 	GCompletion *completion_cache;
 	gboolean editor_only;
-	guint word_idle;
 	IAnjutaIterable* start_iter;
+	
+	GCancellable* cancel_system;
+	GCancellable* cancel_file;
+	GCancellable* cancel_project;
+	gboolean async_file : 1;
+	gboolean async_system : 1;
+	gboolean async_project : 1;
 };
 
 static gchar*
@@ -127,18 +136,12 @@ is_word_character (gchar ch)
 	return FALSE;
 }	
 
-static void
-on_search_complete (gint search_id, IAnjutaIterable* iter, CppJavaAssist* assist)
-{
-
-}
-
 /**
  * If mergeable is NULL than no merge will be made with iter elements, elsewhere
  * mergeable will be returned with iter elements.
  */
 static GCompletion*
-create_completion (IAnjutaEditorAssist* iassist, IAnjutaIterable* iter,
+create_completion (CppJavaAssist* assist, IAnjutaIterable* iter,
 				   GCompletion* mergeable)
 {	
 	GCompletion *completion;	
@@ -178,6 +181,35 @@ create_completion (IAnjutaEditorAssist* iassist, IAnjutaIterable* iter,
 	return completion;
 }
 
+static void cpp_java_assist_update_autocomplete(CppJavaAssist* assist);
+
+static void
+on_query_data (gint search_id, IAnjutaIterable* iter, CppJavaAssist* assist)
+{
+	assist->priv->completion_cache = create_completion (assist,
+	                                                    iter,
+	                                                    assist->priv->completion_cache);
+	cpp_java_assist_update_autocomplete(assist);
+}
+
+static void
+system_finished (AnjutaAsyncNotify* notify, CppJavaAssist* assist)
+{
+	assist->priv->async_system = FALSE;
+}
+
+static void
+file_finished (AnjutaAsyncNotify* notify, CppJavaAssist* assist)
+{
+	assist->priv->async_file = FALSE;
+}
+
+static void
+project_finished (AnjutaAsyncNotify* notify, CppJavaAssist* assist)
+{
+	assist->priv->async_project = FALSE;
+}
+
 #define SCOPE_BRACE_JUMP_LIMIT 50
 
 static gchar*
@@ -268,8 +300,7 @@ cpp_java_assist_get_pre_word (IAnjutaEditor* editor, IAnjutaIterable *iter)
 }
 
 static void
-cpp_java_assist_destroy_completion_cache (CppJavaAssist *assist,
-										  gboolean cancel_idle)
+cpp_java_assist_destroy_completion_cache (CppJavaAssist *assist)
 {
 	if (assist->priv->search_cache)
 	{
@@ -292,203 +323,150 @@ cpp_java_assist_destroy_completion_cache (CppJavaAssist *assist,
 		g_completion_free (assist->priv->completion_cache);
 		assist->priv->completion_cache = NULL;
 	}
-	if (assist->priv->word_idle > 0 && cancel_idle)
-	{
-		g_source_remove (assist->priv->word_idle);
-		assist->priv->word_idle = 0;
-	}
 }
 
-static gboolean
-cpp_java_assist_show_autocomplete (CppJavaAssist *assist)
+static void
+cpp_java_assist_update_autocomplete (CppJavaAssist *assist)
 {
-	IAnjutaIterable *position;
 	gint max_completions, length;
 	GList *completion_list;
 
-	if (assist->priv->completion_cache == NULL) return FALSE;	
+	gboolean queries_active = (assist->priv->async_file || assist->priv->async_project || assist->priv->async_system);
+
+	DEBUG_PRINT ("Queries active: %d", queries_active);
 	
-	if (assist->priv->pre_word)
-		g_completion_complete (assist->priv->completion_cache, assist->priv->pre_word, NULL);
-	else
-		return FALSE;
+	if (assist->priv->completion_cache == NULL || !assist->priv->pre_word)
+	{
+		ianjuta_editor_assist_proposals (assist->priv->iassist, IANJUTA_PROVIDER(assist),
+		                                 NULL, !queries_active, NULL);
+		return;
+	}
+	
+	g_completion_complete (assist->priv->completion_cache, assist->priv->pre_word, NULL);
 
-	position =
-		ianjuta_editor_get_position (IANJUTA_EDITOR (assist->priv->iassist),
-									 NULL);
 	max_completions =
 		anjuta_preferences_get_int_with_default (assist->priv->preferences,
 												 PREF_AUTOCOMPLETE_CHOICES,
 												 MAX_COMPLETIONS);
-	/* If there is cache use that */
-	if (assist->priv->completion_cache->cache)
-		completion_list = assist->priv->completion_cache->cache;
-	
-	/* If there is no cache, it means that no string completion happened
-	 * because the list is being shown for member completion just after
-	 * scope operator where there is no preword yet entered. So use the
-	 * full list because that's the full list of members of that scope.
-	 */
-	else if (!assist->priv->pre_word)
-		completion_list = assist->priv->completion_cache->items;
+	completion_list = assist->priv->completion_cache->cache;
 		
-	else
-		return FALSE;
-	
 	length = g_list_length (completion_list);
+
+	DEBUG_PRINT ("Populating %d proposals", length);
+	
 	if (length <= max_completions)
 	{
-		if (length > 1 || !assist->priv->pre_word ||
-			!g_str_equal (assist->priv->pre_word,
-						  ((CppJavaAssistTag*)completion_list->data)->name))
-		{
-			GList *node, *suggestions = NULL;
-			gint alignment;
+		GList *node, *suggestions = NULL;
 			
-			node = completion_list;
-			while (node)
-			{
-				CppJavaAssistTag *tag = node->data;
+		for (node = completion_list; node != NULL; node = g_list_next (node))
+		{
+			CppJavaAssistTag *tag = node->data;
+			IAnjutaEditorAssistProposal* proposal = g_new0(IAnjutaEditorAssistProposal, 1);
 				
-				gchar *entry;
+			if (tag->is_func)
+				proposal->label = g_strdup_printf ("%s()", tag->name);
+			else
+				proposal->label = g_strdup(tag->name);
 				
-				if (tag->is_func)
-					entry = g_strdup_printf ("%s()", tag->name);
-				else
-					entry = g_strdup_printf ("%s", tag->name);
-				suggestions = g_list_prepend (suggestions, entry);
-				node = g_list_next (node);
-			}
-			suggestions = g_list_reverse (suggestions);
-			alignment = assist->priv->pre_word? strlen (assist->priv->pre_word) : 0;
-			
-			ianjuta_editor_assist_suggest (assist->priv->iassist,
-										   suggestions,
-										   position,
-										   alignment,
-										   NULL);
-			g_list_foreach (suggestions, (GFunc) g_free, NULL);
-			g_list_free (suggestions);
-			g_object_unref (position);
-			return TRUE;
+			proposal->data = tag;
+			suggestions = g_list_prepend (suggestions, proposal);
 		}
+		suggestions = g_list_reverse (suggestions);
+		ianjuta_editor_assist_proposals (assist->priv->iassist, IANJUTA_PROVIDER(assist),
+		                                 suggestions, !queries_active, NULL);
+		g_list_foreach (suggestions, (GFunc) g_free, NULL);
+		g_list_free (suggestions);
+	}
+	else
+	{
+		ianjuta_editor_assist_proposals (assist->priv->iassist, IANJUTA_PROVIDER(assist),
+		                                 NULL, !queries_active, NULL);
+		return;
 	}
-	g_object_unref (position);
-	return FALSE;
 }
 
 static void
 cpp_java_assist_create_word_completion_cache (CppJavaAssist *assist)
 {
 	gint max_completions;
-	GCompletion *completion = NULL;
-	GList* editor_completions = NULL;
-	gboolean shown = FALSE;
 
 	max_completions =
 		anjuta_preferences_get_int_with_default (assist->priv->preferences,
 												 PREF_AUTOCOMPLETE_CHOICES,
 												 MAX_COMPLETIONS);
 	
-	cpp_java_assist_destroy_completion_cache (assist, FALSE);
+	cpp_java_assist_destroy_completion_cache (assist);
+	if (assist->priv->async_file)
+	{
+		g_cancellable_cancel (assist->priv->cancel_file);
+		assist->priv->async_file = FALSE;
+	}
+	g_cancellable_reset (assist->priv->cancel_file);
+	if (assist->priv->async_system)
+	{
+		g_cancellable_cancel (assist->priv->cancel_system);
+		assist->priv->async_system = FALSE;
+	}
+	g_cancellable_reset (assist->priv->cancel_system);
+	if (assist->priv->async_project)
+	{
+		g_cancellable_cancel (assist->priv->cancel_project);
+		assist->priv->async_project = FALSE;
+	}
+	g_cancellable_reset (assist->priv->cancel_project);
 
 	if (!assist->priv->pre_word || strlen(assist->priv->pre_word) < 3)
-		return FALSE;
-	
-	if (!assist->priv->editor_only)
-	{
-		gchar *pattern = g_strconcat (assist->priv->pre_word, "%", NULL);
+		return;
+
+	gchar *pattern = g_strconcat (assist->priv->pre_word, "%", NULL);
 		
-		if (IANJUTA_IS_FILE (assist->priv->iassist))
+	if (IANJUTA_IS_FILE (assist->priv->iassist))
+	{
+		GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
+		if (file != NULL)
 		{
-			GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
-			if (file != NULL)
-			{				
-				IAnjutaIterable* iter_file = ianjuta_symbol_manager_search_file (assist->priv->isymbol_manager,
+			AnjutaAsyncNotify* notify = anjuta_async_notify_new();
+			g_signal_connect (notify, "finished", G_CALLBACK(file_finished), assist);
+			assist->priv->async_file = TRUE;
+			ianjuta_symbol_manager_search_file_async (assist->priv->isymbol_manager,
 																				 IANJUTA_SYMBOL_TYPE_UNDEF,
 																				 TRUE,
 																				 IANJUTA_SYMBOL_FIELD_SIMPLE|IANJUTA_SYMBOL_FIELD_TYPE,
-																				 pattern, file, -1, -1, NULL);
-												 
-				if (iter_file) 
-				{
-					completion = create_completion (assist->priv->iassist, iter_file, NULL);
-					g_object_unref (iter_file);
-				}
-				g_object_unref (file);
-			}
-		}
-		
-		IAnjutaIterable* iter_project = 
-			ianjuta_symbol_manager_search_project (assist->priv->isymbol_manager,
-										   IANJUTA_SYMBOL_TYPE_UNDEF,
-										   TRUE,
-										   IANJUTA_SYMBOL_FIELD_SIMPLE|IANJUTA_SYMBOL_FIELD_TYPE,
-										   pattern, IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1, NULL);
-		
-		IAnjutaIterable* iter_globals = 
-			ianjuta_symbol_manager_search_system (assist->priv->isymbol_manager,
-										   IANJUTA_SYMBOL_TYPE_UNDEF,
-										   TRUE,
-										   IANJUTA_SYMBOL_FIELD_SIMPLE|IANJUTA_SYMBOL_FIELD_TYPE,
-										   pattern, IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1, NULL);
-		g_free (pattern);
-
-		if (iter_project) 
-		{
-			completion = create_completion (assist->priv->iassist, iter_project, completion);
-			g_object_unref (iter_project);
-		}
-		
-		if (iter_globals)
-		{
-			
-			completion = create_completion (assist->priv->iassist, iter_globals, completion);
-			g_object_unref (iter_globals);
+																				 pattern, file, -1, -1, assist->priv->cancel_file,
+																				 notify, (IAnjutaSymbolManagerSearchCallback) on_query_data, assist,
+																				 NULL);
+			g_object_unref (file);
 		}
 	}
-	editor_completions = ianjuta_editor_assist_get_suggestions (assist->priv->iassist,
-																assist->priv->pre_word,
-																NULL);
-	if (editor_completions)
 	{
-		GList* tag_list = NULL;
-		GList* node;
-		for (node = editor_completions; node != NULL; node = g_list_next (node))
-		{
-			CppJavaAssistTag *tag = g_new0 (CppJavaAssistTag, 1);
-			tag->name = node->data;
-			tag->type = 0;
-			tag->is_func = FALSE;
-			if (completion && !g_list_find_custom (completion->items, tag, 
-												   completion_compare))
-				tag_list = g_list_append (tag_list, tag);
-			else
-				cpp_java_assist_tag_destroy (tag);
-		}
-		if (!completion)
-		{
-			completion = g_completion_new(completion_function);
-			assist->priv->editor_only = TRUE;
-		}
-		else
-			assist->priv->editor_only = FALSE;
-
-		tag_list = g_list_sort (tag_list, completion_compare);
-		g_completion_add_items (completion, tag_list);		
-		g_list_free (editor_completions);
+		AnjutaAsyncNotify* notify = anjuta_async_notify_new();
+		g_signal_connect (notify, "finished", G_CALLBACK(project_finished), assist);
+		assist->priv->async_project = TRUE;
+		ianjuta_symbol_manager_search_project_async (assist->priv->isymbol_manager,
+											 IANJUTA_SYMBOL_TYPE_UNDEF,
+											 TRUE,
+											 IANJUTA_SYMBOL_FIELD_SIMPLE|IANJUTA_SYMBOL_FIELD_TYPE,
+											 pattern, IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1, 
+											 assist->priv->cancel_project,
+											 notify, (IAnjutaSymbolManagerSearchCallback) on_query_data, assist,
+											 NULL);
 	}
-
-	assist->priv->completion_cache = completion;
+	{
+		AnjutaAsyncNotify* notify = anjuta_async_notify_new();
+		g_signal_connect (notify, "finished", G_CALLBACK(system_finished), assist);
+		assist->priv->async_system = TRUE;
+		ianjuta_symbol_manager_search_system_async (assist->priv->isymbol_manager,
+											 IANJUTA_SYMBOL_TYPE_UNDEF,
+											 TRUE,
+											 IANJUTA_SYMBOL_FIELD_SIMPLE|IANJUTA_SYMBOL_FIELD_TYPE,
+											 pattern, IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1,
+											 assist->priv->cancel_system,
+											 notify, (IAnjutaSymbolManagerSearchCallback) on_query_data, assist,
+											 NULL);
+	}
+	g_free (pattern);
 	assist->priv->search_cache = g_strdup (assist->priv->pre_word);
-	
-	shown = cpp_java_assist_show_autocomplete (assist);
-	if (!shown)
-		ianjuta_editor_assist_hide_suggestions (assist->priv->iassist,
-												NULL);
-	DEBUG_PRINT ("Show autocomplete: %d", shown);
-	
-	return FALSE;
+	DEBUG_PRINT ("Started async search for: %s", assist->priv->pre_word);
 }
 
 static gchar*
@@ -594,7 +572,7 @@ cpp_java_assist_show_calltip (CppJavaAssist *assist, gchar *call_context,
 		GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
 
 		if (file != NULL)
-		{		
+		{
 			IAnjutaIterable* iter_file = ianjuta_symbol_manager_search_file (assist->priv->isymbol_manager,
 																			 IANJUTA_SYMBOL_TYPE_PROTOTYPE|
 																			 IANJUTA_SYMBOL_TYPE_FUNCTION|
@@ -646,7 +624,7 @@ cpp_java_assist_show_calltip (CppJavaAssist *assist, gchar *call_context,
 	
 	if (tips)
 	{	
-		ianjuta_editor_assist_show_tips (assist->priv->iassist, tips,
+		ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(assist->priv->iassist), tips,
 										 position_iter, 0,
 										 NULL);
 		g_list_foreach (tips, (GFunc) g_free, NULL);
@@ -656,9 +634,9 @@ cpp_java_assist_show_calltip (CppJavaAssist *assist, gchar *call_context,
 	return FALSE;
 }
 
-void
-cpp_java_assist_check (CppJavaAssist *assist
-					             gboolean calltips, gboolean backspace)
+static void
+cpp_java_assist_calltip (CppJavaAssist *assist,
+					      			   gboolean calltips, gboolean backspace)
 {
 	IAnjutaEditor *editor;
 	IAnjutaIterable *iter;
@@ -676,7 +654,7 @@ cpp_java_assist_check (CppJavaAssist *assist
 			cpp_java_assist_get_calltip_context (assist, iter);
 		if (call_context)
 		{
-			if (ianjuta_editor_assist_tip_shown (IANJUTA_EDITOR_ASSIST (editor), NULL))
+			if (ianjuta_editor_tip_visible (IANJUTA_EDITOR_TIP (editor), NULL))
 			{
 				if (assist->priv->calltip_context &&
 				    !g_str_equal (call_context, assist->priv->calltip_context))
@@ -697,7 +675,7 @@ cpp_java_assist_check (CppJavaAssist *assist
 		}
 		else
 		{
-			ianjuta_editor_assist_cancel_tips (assist->priv->iassist, NULL);
+			ianjuta_editor_tip_cancel (IANJUTA_EDITOR_TIP(assist->priv->iassist), NULL);
 			g_free (assist->priv->calltip_context);
 			assist->priv->calltip_context = NULL;
 		}
@@ -714,7 +692,7 @@ on_editor_char_added (IAnjutaEditor *editor, IAnjutaIterable *insert_pos,
 		anjuta_preferences_get_bool_with_default (assist->priv->preferences,
 												 PREF_CALLTIP_ENABLE,
 												 TRUE);
-	cpp_java_assist_check (assist, enable_calltips, (ch == '\b'));
+	cpp_java_assist_calltip(assist, enable_calltips, (ch == '\b'));
 }
 
 static void
@@ -722,41 +700,52 @@ cpp_java_assist_populate (IAnjutaProvider* self, IAnjutaIterable* iter, GError**
 {
 	CppJavaAssist* assist = CPP_JAVA_ASSIST (self);
 	IAnjutaEditor *editor;
-	gboolean autocomplete = anjuta_preferences_get_bool_with_default (assist->priv->prefs,
-	                                                                  AUTOCOMPLETE_ENABLE,
+	gboolean autocomplete = anjuta_preferences_get_bool_with_default (assist->priv->preferences,
+	                                                                  PREF_AUTOCOMPLETE_ENABLE,
 	                                                                  TRUE);	
 	editor = IANJUTA_EDITOR (assist->priv->iassist);
 	
 	if (autocomplete)
 	{
-		gboolean shown = FALSE;
+		ianjuta_iterable_previous (iter, NULL);
 		g_free (assist->priv->pre_word);
+		/* Moved iter to begin of word */
 		assist->priv->pre_word = cpp_java_assist_get_pre_word (editor, iter);
 		DEBUG_PRINT ("Pre word: %s", assist->priv->pre_word);
-
+		
 		if (assist->priv->pre_word && strlen (assist->priv->pre_word) > 3)
 		{
+			if (assist->priv->start_iter)
+				g_object_unref (assist->priv->start_iter);
+			assist->priv->start_iter = ianjuta_iterable_clone(iter, NULL);
+			ianjuta_iterable_next (IANJUTA_ITERABLE (assist->priv->start_iter), NULL);
 			if (!assist->priv->search_cache ||
 			    !g_str_has_prefix (assist->priv->pre_word, assist->priv->search_cache))
 			{
-					cpp_java_assist_create_word_completion_cache(assist);
+				cpp_java_assist_create_word_completion_cache(assist);
+				DEBUG_PRINT ("start iter: %d", ianjuta_iterable_get_position (assist->priv->start_iter, NULL));
+				return;
 			}
 			else
-				shown = cpp_java_assist_update_autocomplete (assist);
+			{
+				cpp_java_assist_update_autocomplete (assist);
+				return;
+			}
 		}
 	}
+	/* Keep completion system happy */
+	ianjuta_editor_assist_proposals (assist->priv->iassist,
+	                                 IANJUTA_PROVIDER(self),
+	                                 NULL, TRUE, NULL);
 } 
 
 static void
-cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* cursor, gpointer data);
+cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* iter, gpointer data, GError** e)
 {
-	CppJavaAssist assist = CPP_JAVA_ASSIST(self);
+	CppJavaAssist* assist = CPP_JAVA_ASSIST(self);
 	CppJavaAssistTag *tag;
-	IAnjutaIterable *cur_pos;
 	GString *assistance;
 	IAnjutaEditor *te;
-	IAnjutaIterable *iter;
-	gchar *pre_word = NULL;
 	gboolean add_space_after_func = FALSE;
 	gboolean add_brace_after_func = FALSE;
 	
@@ -786,7 +775,7 @@ cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* cursor, gpoint
 		
 	ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT (te), NULL);
 	
-	if (ianjuta_iterable_compare(iter, assist->priv->start_iter) != 0)
+	if (ianjuta_iterable_compare(iter, assist->priv->start_iter, NULL) != 0)
 	{
 		ianjuta_editor_selection_set (IANJUTA_EDITOR_SELECTION (te),
 									  assist->priv->start_iter, iter, FALSE, NULL);
@@ -795,33 +784,51 @@ cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* cursor, gpoint
 	}
 	else
 	{
-		ianjuta_editor_insert (te, iter, assistance->str, NULL);
+		ianjuta_editor_insert (te, iter, assistance->str, -1, NULL);
 	}
-	g_object_unref (assist->priv->start_iter);
-	assist->priv->start_iter = NULL;
 	ianjuta_document_end_undo_action (IANJUTA_DOCUMENT (te), NULL);
 	
 	/* Show calltip if we completed function */
 	if (add_brace_after_func)
-		cpp_java_assist_check (assist, TRUE, FALSE);
+		cpp_java_assist_calltip (assist, TRUE, FALSE);
 	
 	g_string_free (assistance, TRUE);
 }
 
+static IAnjutaIterable*
+cpp_java_assist_get_start_iter (IAnjutaProvider* provider, GError** e)
+{
+	CppJavaAssist* assist = CPP_JAVA_ASSIST (provider);
+	return assist->priv->start_iter;
+}
+
+static const gchar*
+cpp_java_assist_get_name (IAnjutaProvider* provider, GError** e)
+{
+	return _("C/C++");
+}
+
 static void
 cpp_java_assist_install (CppJavaAssist *assist, IAnjutaEditorAssist *iassist)
 {
 	g_return_if_fail (assist->priv->iassist == NULL);
 	
-	ianjuta_editor_assist_add (iassist, IANJUTA_PROVIDER(assist));
+	assist->priv->iassist = iassist;
+	
+	g_signal_connect (iassist, "char-added",
+					  G_CALLBACK (on_editor_char_added), assist);
+	
+	ianjuta_editor_assist_add (iassist, IANJUTA_PROVIDER(assist), NULL);
 }
 
 static void
 cpp_java_assist_uninstall (CppJavaAssist *assist)
 {
 	g_return_if_fail (assist->priv->iassist != NULL);
+	
+	g_signal_handlers_disconnect_by_func (assist->priv->iassist, G_CALLBACK (on_editor_char_added), assist);
 
-	ianjuta_editor_assist_remove (assist->priv->iassist, IANJUTA_PROVIDER(assist));
+	ianjuta_editor_assist_remove (assist->priv->iassist, IANJUTA_PROVIDER(assist), NULL);
 
 	assist->priv->iassist = NULL;
 }
@@ -830,6 +837,9 @@ static void
 cpp_java_assist_init (CppJavaAssist *assist)
 {
 	assist->priv = g_new0 (CppJavaAssistPriv, 1);
+	assist->priv->cancel_file = g_cancellable_new();
+	assist->priv->cancel_project = g_cancellable_new();
+	assist->priv->cancel_system = g_cancellable_new();
 }
 
 static void
@@ -837,11 +847,14 @@ cpp_java_assist_finalize (GObject *object)
 {
 	CppJavaAssist *assist = CPP_JAVA_ASSIST (object);
 	cpp_java_assist_uninstall (assist);
-	cpp_java_assist_destroy_completion_cache (assist, TRUE);
+	cpp_java_assist_destroy_completion_cache (assist);
 	if (assist->priv->calltip_context)
 	{
 		g_free (assist->priv->calltip_context);
 		assist->priv->calltip_context = NULL;
+		g_object_unref (assist->priv->cancel_file);
+		g_object_unref (assist->priv->cancel_project);
+		g_object_unref (assist->priv->cancel_system);
 	}
 	g_free (assist->priv);
 	G_OBJECT_CLASS (cpp_java_assist_parent_class)->finalize (object);
@@ -872,5 +885,5 @@ static void cpp_java_assist_iface_init(IAnjutaProviderIface* iface)
 	iface->populate = cpp_java_assist_populate;
 	iface->get_start_iter = cpp_java_assist_get_start_iter;
 	iface->activate = cpp_java_assist_activate;
-	iface->cancelled = cpp_java_assist_cancelled;
+	iface->get_name = cpp_java_assist_get_name;
 }
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index 51bf87f..70d57e5 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -1906,8 +1906,7 @@ on_auto_complete (GtkAction *action, gpointer data)
 {
 	CppJavaPlugin *lang_plugin;
 	lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
-	if (lang_plugin->assist)
-		cpp_java_assist_check (lang_plugin->assist, TRUE, TRUE, FALSE);
+	/* FIXME */
 }
 
 static GtkActionEntry actions[] = {
diff --git a/plugins/sourceview/sourceview-cell.c b/plugins/sourceview/sourceview-cell.c
index 3fda48a..1bd8b08 100644
--- a/plugins/sourceview/sourceview-cell.c
+++ b/plugins/sourceview/sourceview-cell.c
@@ -38,7 +38,7 @@ static void sourceview_cell_instance_init(SourceviewCell *sp);
 static void sourceview_cell_finalize(GObject *object);
 
 struct _SourceviewCellPrivate {
-	GtkTextIter iter;
+	GtkTextMark* mark;
 	GtkTextView* view;
 	GtkTextBuffer* buffer;
 };
@@ -81,23 +81,25 @@ sourceview_cell_new(GtkTextIter* iter, GtkTextView* view)
 	obj = SOURCEVIEW_CELL(g_object_new(SOURCEVIEW_TYPE_CELL, NULL));
 	
 	obj->priv->buffer = gtk_text_view_get_buffer(view);
-	obj->priv->iter = *iter;
+	obj->priv->mark = gtk_text_buffer_create_mark (obj->priv->buffer, NULL, iter, FALSE);
 	obj->priv->view = view;
 	
 	return obj;
 }
 
-GtkTextIter*
-sourceview_cell_get_iter (SourceviewCell* cell)
+void
+sourceview_cell_get_iter (SourceviewCell* cell, GtkTextIter* iter)
 {
-	return &cell->priv->iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, iter, cell->priv->mark);
 }
 
 static gchar*
 icell_get_character(IAnjutaEditorCell* icell, GError** e)
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL(icell);
-	gunichar c = gtk_text_iter_get_char (&cell->priv->iter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);	
+	gunichar c = gtk_text_iter_get_char (&iter);
 	gchar* outbuf = g_new0(gchar, 6);
 	g_unichar_to_utf8 (c, outbuf);
 	return outbuf;
@@ -118,7 +120,9 @@ static gchar
 icell_get_char(IAnjutaEditorCell* icell, gint index, GError** e)
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL(icell);
-	gunichar c = gtk_text_iter_get_char (&cell->priv->iter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gunichar c = gtk_text_iter_get_char (&iter);
 	gchar* outbuf = g_new0(gchar, 6);
 	gint len = g_unichar_to_utf8 (c, outbuf);
 	gchar retval;
@@ -146,168 +150,150 @@ icell_iface_init(IAnjutaEditorCellIface* iface)
 	iface->get_attribute = icell_get_attribute;
 }
 
-static
-GtkTextAttributes* get_attributes(GtkTextIter* iter, GtkTextView* view)
-{
-	GtkTextAttributes* atts = gtk_text_view_get_default_attributes(view);
-	gtk_text_iter_get_attributes(iter, atts);
-	return atts;
-}
-
-static gchar*
-icell_style_get_font_description(IAnjutaEditorCellStyle* icell_style, GError ** e)
-{
-	const gchar* font;
-	SourceviewCell* cell = SOURCEVIEW_CELL(icell_style);
-	GtkTextAttributes* atts = get_attributes(&cell->priv->iter, 
-																					 cell->priv->view);
-	font = pango_font_description_to_string(atts->font);
-	g_free(atts);
-	return g_strdup(font);
-}
-
-static gchar*
-icell_style_get_color(IAnjutaEditorCellStyle* icell_style, GError ** e)
-{
-	gchar* color;
-	SourceviewCell* cell = SOURCEVIEW_CELL(icell_style);
-	GtkTextAttributes* atts = get_attributes(&cell->priv->iter, cell->priv->view);
-	color = anjuta_util_string_from_color(atts->appearance.fg_color.red,
-																				atts->appearance.fg_color.green, atts->appearance.fg_color.blue);
-	g_free(atts);
-	return color;
-}
-
-static gchar*
-icell_style_get_background_color(IAnjutaEditorCellStyle* icell_style, GError ** e)
-{
-	gchar* color;
-	SourceviewCell* cell = SOURCEVIEW_CELL(icell_style);
-	GtkTextAttributes* atts = get_attributes(&cell->priv->iter, cell->priv->view);
-	color = anjuta_util_string_from_color(atts->appearance.bg_color.red,
-																				atts->appearance.bg_color.green, atts->appearance.bg_color.blue);
-	g_free(atts);
-	return color;
-}
-
-static void
-icell_style_iface_init(IAnjutaEditorCellStyleIface* iface)
-{
-	iface->get_font_description = icell_style_get_font_description;
-	iface->get_color = icell_style_get_color;
-	iface->get_background_color = icell_style_get_background_color;
-}
-
 static gboolean
-iiter_first(IAnjutaIterable* iter, GError** e)
+iiter_first(IAnjutaIterable* iiter, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	gboolean retval = gtk_text_iter_is_start (&cell->priv->iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gboolean retval = gtk_text_iter_is_start (&iter);
 	if (!retval)
-		gtk_text_iter_set_offset (&cell->priv->iter, 0);
+	{
+		gtk_text_iter_set_offset (&iter, 0);
+		gtk_text_buffer_move_mark (cell->priv->buffer, cell->priv->mark, &iter);
+	}
 	return retval;
 }
 
 static gboolean
-iiter_next(IAnjutaIterable* iter, GError** e)
+iiter_next(IAnjutaIterable* iiter, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	
-	return gtk_text_iter_forward_char(&cell->priv->iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gboolean retval = gtk_text_iter_forward_char(&iter);
+	if (retval)
+			gtk_text_buffer_move_mark (cell->priv->buffer, cell->priv->mark, &iter);
+	return retval;
 }
 
 static gboolean
-iiter_previous(IAnjutaIterable* iter, GError** e)
+iiter_previous(IAnjutaIterable* iiter, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	
-	return gtk_text_iter_backward_char(&cell->priv->iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gboolean retval = gtk_text_iter_backward_char(&iter);
+	if (retval)
+			gtk_text_buffer_move_mark (cell->priv->buffer, cell->priv->mark, &iter);
+	return retval;
 }
 
 static gboolean
-iiter_last(IAnjutaIterable* iter, GError** e)
+iiter_last(IAnjutaIterable* iiter, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	gboolean retval = gtk_text_iter_is_end (&cell->priv->iter);
-	if (retval)
-		gtk_text_iter_forward_to_end(&cell->priv->iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gboolean retval = gtk_text_iter_is_end (&iter);
+	if (!retval)
+	{
+		gtk_text_iter_forward_to_end(&iter);
+		gtk_text_buffer_move_mark (cell->priv->buffer, cell->priv->mark, &iter);
+	}
 	return retval;
 }
 
 static void
-iiter_foreach(IAnjutaIterable* iter, GFunc callback, gpointer data, GError** e)
+iiter_foreach(IAnjutaIterable* iiter, GFunc callback, gpointer data, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	GtkTextMark* cached = gtk_text_buffer_create_mark (cell->priv->buffer, NULL, &iter, FALSE);
 	
-	gint saved_offset;
+	iiter_first (IANJUTA_ITERABLE(cell), NULL);
 	
-	saved_offset = gtk_text_iter_get_offset (&cell->priv->iter);
-	gtk_text_iter_set_offset(&cell->priv->iter, 0);
-	while (gtk_text_iter_forward_char(&cell->priv->iter))
+	while (iiter_next(IANJUTA_ITERABLE(cell), NULL))
 	{
 		(*callback)(cell, data);
 	}
-	gtk_text_iter_set_offset(&cell->priv->iter, saved_offset);
+	gtk_text_buffer_delete_mark (cell->priv->buffer, cell->priv->mark);
+	cell->priv->mark = cached;
 }
 
 static gboolean
-iiter_set_position (IAnjutaIterable* iter, gint position, GError** e)
+iiter_set_position (IAnjutaIterable* iiter, gint position, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	
-	gtk_text_iter_set_offset (&cell->priv->iter, position);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gtk_text_buffer_move_mark (cell->priv->buffer, cell->priv->mark, &iter);
 	return TRUE;
 }
 
 static gint
-iiter_get_position(IAnjutaIterable* iter, GError** e)
+iiter_get_position(IAnjutaIterable* iiter, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	return gtk_text_iter_get_offset(&cell->priv->iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	return gtk_text_iter_get_offset(&iter);
 }
 
 static gint
-iiter_get_length(IAnjutaIterable* iter, GError** e)
+iiter_get_length(IAnjutaIterable* iiter, GError** e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
 	
-	return gtk_text_buffer_get_char_count (gtk_text_iter_get_buffer(&cell->priv->iter));
+	return gtk_text_buffer_get_char_count (cell->priv->buffer);
 }
 
 static IAnjutaIterable *
-iiter_clone (IAnjutaIterable *iter, GError **e)
+iiter_clone (IAnjutaIterable *iiter, GError **e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	
-	return IANJUTA_ITERABLE (sourceview_cell_new (&cell->priv->iter, cell->priv->view));
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	return IANJUTA_ITERABLE (sourceview_cell_new (&iter, cell->priv->view));
 }
 
 static void
-iiter_assign (IAnjutaIterable *iter, IAnjutaIterable *src_iter, GError **e)
+iiter_assign (IAnjutaIterable *iiter, IAnjutaIterable *src_iter, GError **e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
 	SourceviewCell* src_cell = SOURCEVIEW_CELL(src_iter);
-	
-	cell->priv->iter = src_cell->priv->iter;
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark (src_cell->priv->buffer, &iter, src_cell->priv->mark);
+	gtk_text_buffer_move_mark (cell->priv->buffer, cell->priv->mark, &iter);
 }
 
 static gint
-iiter_compare (IAnjutaIterable *iter, IAnjutaIterable *other_iter, GError **e)
+iiter_compare (IAnjutaIterable *iiter, IAnjutaIterable *iother_iter, GError **e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	SourceviewCell* other_cell = SOURCEVIEW_CELL(other_iter);
-	
-	return gtk_text_iter_compare (&cell->priv->iter, &other_cell->priv->iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	SourceviewCell* other_cell = SOURCEVIEW_CELL(iother_iter);
+	GtkTextIter iter;
+	GtkTextIter other_iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gtk_text_buffer_get_iter_at_mark (other_cell->priv->buffer, &other_iter, other_cell->priv->mark);
+
+	return gtk_text_iter_compare (&iter, &other_iter);
 }
 
 static gint
-iiter_diff (IAnjutaIterable *iter, IAnjutaIterable *other_iter, GError **e)
+iiter_diff (IAnjutaIterable *iiter, IAnjutaIterable *iother_iter, GError **e)
 {
-	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
-	SourceviewCell* other_cell = SOURCEVIEW_CELL(other_iter);
+	SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
+	SourceviewCell* other_cell = SOURCEVIEW_CELL(iother_iter);
+
+	GtkTextIter iter;
+	GtkTextIter other_iter;
+	gtk_text_buffer_get_iter_at_mark (cell->priv->buffer, &iter, cell->priv->mark);
+	gtk_text_buffer_get_iter_at_mark (other_cell->priv->buffer, &other_iter, other_cell->priv->mark);
 	
-	return (gtk_text_iter_get_offset (&other_cell->priv->iter) 
-					- gtk_text_iter_get_offset (&cell->priv->iter));
+	return (gtk_text_iter_get_offset (&other_iter) 
+					- gtk_text_iter_get_offset (&iter));
 }
 
 static void
@@ -330,6 +316,5 @@ iiter_iface_init(IAnjutaIterableIface* iface)
 
 ANJUTA_TYPE_BEGIN(SourceviewCell, sourceview_cell, G_TYPE_OBJECT);
 ANJUTA_TYPE_ADD_INTERFACE(icell, IANJUTA_TYPE_EDITOR_CELL);
-ANJUTA_TYPE_ADD_INTERFACE(icell_style, IANJUTA_TYPE_EDITOR_CELL_STYLE);
 ANJUTA_TYPE_ADD_INTERFACE(iiter, IANJUTA_TYPE_ITERABLE);
 ANJUTA_TYPE_END;
diff --git a/plugins/sourceview/sourceview-cell.h b/plugins/sourceview/sourceview-cell.h
index e49cd35..084f65b 100644
--- a/plugins/sourceview/sourceview-cell.h
+++ b/plugins/sourceview/sourceview-cell.h
@@ -56,7 +56,7 @@ struct _SourceviewCellClass {
 GType sourceview_cell_get_type(void);
 SourceviewCell *sourceview_cell_new(GtkTextIter* iter, GtkTextView* view);
 
-GtkTextIter* sourceview_cell_get_iter (SourceviewCell* cell);
+void sourceview_cell_get_iter (SourceviewCell* cell, GtkTextIter* iter);
 
 G_END_DECLS
 
diff --git a/plugins/sourceview/sourceview-provider.c b/plugins/sourceview/sourceview-provider.c
index 7bf14db..e9fad9e 100644
--- a/plugins/sourceview/sourceview-provider.c
+++ b/plugins/sourceview/sourceview-provider.c
@@ -20,6 +20,7 @@
 #include "sourceview-provider.h"
 #include "sourceview-cell.h"
 #include "sourceview-private.h"
+#include <libanjuta/anjuta-debug.h>
 
 
 static void
@@ -31,10 +32,12 @@ G_DEFINE_TYPE_WITH_CODE (SourceviewProvider,
 			 G_IMPLEMENT_INTERFACE (GTK_TYPE_SOURCE_COMPLETION_PROVIDER,
 			                        sourceview_provider_iface_init))
 
-static void on_context_cancelled (GtkSourceCompletionContext* context,
-                                  SourceviewProvider* prov)
+static void
+on_context_cancelled (GtkSourceCompletionContext* context, SourceviewProvider* provider)
 {
-	ianjuta_provider_cancelled(prov->iprov, NULL);
+	g_signal_handlers_disconnect_by_func (context, on_context_cancelled, provider);
+	provider->cancelled = TRUE;
+	provider->context = NULL;
 }
 
 static void
@@ -46,16 +49,18 @@ sourceview_provider_populate (GtkSourceCompletionProvider* provider, GtkSourceCo
 	gtk_source_completion_context_get_iter(context, &iter);
 	cell = sourceview_cell_new (&iter, GTK_TEXT_VIEW(prov->sv->priv->view));
 	prov->context = context;
+	prov->cancelled = FALSE;
 	g_signal_connect (context, "cancelled", G_CALLBACK(on_context_cancelled), prov);
+	g_message ("populating provider");
 	ianjuta_provider_populate(prov->iprov, IANJUTA_ITERABLE(cell), NULL);
-	prov->context = NULL;
 	g_object_unref (cell);
 }
 
 static const gchar*
 sourceview_provider_get_name (GtkSourceCompletionProvider* provider)
 {
-	return "Internal Sourceview editor provider";
+	SourceviewProvider* prov = SOURCEVIEW_PROVIDER(provider);
+	return ianjuta_provider_get_name (prov->iprov, NULL);
 }
 
 
@@ -68,27 +73,30 @@ sourceview_provider_get_start_iter (GtkSourceCompletionProvider* provider,
 	IAnjutaIterable* iiter = ianjuta_provider_get_start_iter (prov->iprov, NULL);
 	if (iiter)
 	{
+		DEBUG_PRINT ("Setting start iter");
 		SourceviewCell* cell = SOURCEVIEW_CELL(iiter);
-		GtkTextIter* source_iter = sourceview_cell_get_iter(cell);
-		*iter = *source_iter;
+		GtkTextIter source_iter;
+		sourceview_cell_get_iter(cell, &source_iter);
+		*iter = source_iter;
 		return TRUE;
 	}
 	else
 		return FALSE;
 }
 
-static void
+static gboolean
 sourceview_provider_activate_proposal (GtkSourceCompletionProvider* provider,
                                        GtkSourceCompletionProposal* proposal,
                                        GtkTextIter* iter)
 {
 	SourceviewProvider* prov = SOURCEVIEW_PROVIDER (provider);
 	SourceviewCell* cell = sourceview_cell_new (iter, GTK_TEXT_VIEW(prov->sv->priv->view));
-	gpointer data = g_object_get_data (proposal, "__data");
+	gpointer data = g_object_get_data (G_OBJECT(proposal), "__data");
 
-	ianjuta_provider_activate(prov->iprov, IANJUTA_ITERABLE(cell), data);
+	ianjuta_provider_activate(prov->iprov, IANJUTA_ITERABLE(cell), data, NULL);
 	
 	g_object_unref (cell);
+	return TRUE;
 }
 
 static void
diff --git a/plugins/sourceview/sourceview-provider.h b/plugins/sourceview/sourceview-provider.h
index 360e6d6..a56b06e 100644
--- a/plugins/sourceview/sourceview-provider.h
+++ b/plugins/sourceview/sourceview-provider.h
@@ -48,6 +48,7 @@ struct _SourceviewProvider
 	Sourceview* sv;
 	IAnjutaProvider* iprov;
 	GtkSourceCompletionContext* context;
+	gboolean cancelled;
 };
 
 GType sourceview_provider_get_type (void) G_GNUC_CONST;
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index 279f30a..cc7c644 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -874,11 +874,12 @@ static void ieditor_goto_position(IAnjutaEditor *editor, IAnjutaIterable* icell,
 								  GError **e)
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL (icell);
-	GtkTextIter* iter = sourceview_cell_get_iter (cell);
+	GtkTextIter iter;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (sv->priv->document), iter);
+	sourceview_cell_get_iter (cell, &iter);
+	gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (sv->priv->document), &iter);
 	gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (sv->priv->view),
-								  iter, 0, FALSE, 0, 0);
+								  &iter, 0, FALSE, 0, 0);
 }
 
 /* Return a newly allocated pointer containing the whole text */
@@ -886,15 +887,15 @@ static gchar* ieditor_get_text (IAnjutaEditor* editor,
 								IAnjutaIterable* start,
 								IAnjutaIterable* end, GError **e)
 {
-	GtkTextIter* start_iter;
-	GtkTextIter* end_iter;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	
-	start_iter = sourceview_cell_get_iter (SOURCEVIEW_CELL (start));
-	end_iter = sourceview_cell_get_iter (SOURCEVIEW_CELL (end));
+	GtkTextIter start_iter;
+	GtkTextIter end_iter;
+	sourceview_cell_get_iter (SOURCEVIEW_CELL(start), &start_iter);
+	sourceview_cell_get_iter (SOURCEVIEW_CELL(end), &end_iter);
 	
 	return gtk_text_buffer_get_slice(GTK_TEXT_BUFFER(sv->priv->document),
-									start_iter, end_iter, TRUE);
+									&start_iter, &end_iter, TRUE);
 }
 
 static gchar*
@@ -1042,14 +1043,15 @@ static void ieditor_insert(IAnjutaEditor *editor, IAnjutaIterable* icell,
 							   const gchar* text, gint length, GError **e)
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL (icell);
-	GtkTextIter* iter = sourceview_cell_get_iter (cell);
+	GtkTextIter iter;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
+	sourceview_cell_get_iter (cell, &iter);
 	
 	g_signal_handlers_block_by_func (sv->priv->document,
 										  on_insert_text,
 										  sv);
 	gtk_text_buffer_insert(GTK_TEXT_BUFFER(sv->priv->document),
-						   iter, text, length);
+						   &iter, text, length);
 	g_signal_handlers_unblock_by_func (sv->priv->document,
 									 on_insert_text,
 									 sv);
@@ -1072,13 +1074,16 @@ static void ieditor_erase(IAnjutaEditor* editor, IAnjutaIterable* istart_cell,
 						  IAnjutaIterable* iend_cell, GError **e)
 {
 	SourceviewCell* start_cell = SOURCEVIEW_CELL (istart_cell);
-	GtkTextIter* start = sourceview_cell_get_iter (start_cell);
+	GtkTextIter start;
+	GtkTextIter end;
 	SourceviewCell* end_cell = SOURCEVIEW_CELL (iend_cell);
-	GtkTextIter* end = sourceview_cell_get_iter (end_cell);
+	sourceview_cell_get_iter (end_cell, &end);
+	sourceview_cell_get_iter (start_cell, &start);
+	
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
 	
-	gtk_text_buffer_delete (buffer, start, end);
+	gtk_text_buffer_delete (buffer, &start, &end);
 }
 
 static void ieditor_erase_all(IAnjutaEditor *editor, GError **e)
@@ -1120,8 +1125,9 @@ static gint ieditor_get_line_from_position(IAnjutaEditor *editor,
 										   IAnjutaIterable* icell, GError **e)
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL (icell);
-	GtkTextIter* iter = sourceview_cell_get_iter (cell);
-	return LINE_TO_LOCATION (gtk_text_iter_get_line(iter));
+	GtkTextIter iter;
+	sourceview_cell_get_iter (cell, &iter);
+	return LINE_TO_LOCATION (gtk_text_iter_get_line(&iter));
 }
 
 static IAnjutaIterable* ieditor_get_line_begin_position(IAnjutaEditor *editor,
@@ -1466,9 +1472,12 @@ iselect_set (IAnjutaEditorSelection* edit,
 			 GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+	GtkTextIter start, end;
+	sourceview_cell_get_iter (SOURCEVIEW_CELL (istart), &start);
+	sourceview_cell_get_iter (SOURCEVIEW_CELL (iend), &end);
 	set_select(sv,
-			   sourceview_cell_get_iter (SOURCEVIEW_CELL (istart)),
-			   sourceview_cell_get_iter (SOURCEVIEW_CELL (iend)),
+			   &start,
+			   &end,
 			   scroll);
 }
 															
@@ -1585,14 +1594,15 @@ iconvert_to_upper(IAnjutaEditorConvert* edit, IAnjutaIterable *start_position,
 {
   Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
   GtkTextBuffer* buffer = GTK_TEXT_BUFFER (sv->priv->document);
-  GtkTextIter* start = sourceview_cell_get_iter (SOURCEVIEW_CELL (start_position));
-  GtkTextIter* end = sourceview_cell_get_iter (SOURCEVIEW_CELL (end_position));
-	
+  GtkTextIter start, end;
+  sourceview_cell_get_iter (SOURCEVIEW_CELL (end_position), &end);
+  sourceview_cell_get_iter (SOURCEVIEW_CELL (start_position), &start);
+
   gchar* text_buffer = gtk_text_buffer_get_text (buffer,
-											start, end, TRUE);
+											&start, &end, TRUE);
   gtk_text_buffer_begin_user_action (buffer);
-  gtk_text_buffer_delete (buffer, start, end);
-  gtk_text_buffer_insert (buffer, start, g_utf8_strup (text_buffer, -1), -1);
+  gtk_text_buffer_delete (buffer, &start, &end);
+  gtk_text_buffer_insert (buffer, &start, g_utf8_strup (text_buffer, -1), -1);
   gtk_text_buffer_end_user_action (buffer);
   g_free (text_buffer);
 }
@@ -1603,14 +1613,15 @@ iconvert_to_lower(IAnjutaEditorConvert* edit, IAnjutaIterable *start_position,
 {
   Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
   GtkTextBuffer* buffer = GTK_TEXT_BUFFER (sv->priv->document);
-  GtkTextIter* start = sourceview_cell_get_iter (SOURCEVIEW_CELL (start_position));
-  GtkTextIter* end = sourceview_cell_get_iter (SOURCEVIEW_CELL (end_position));
+  GtkTextIter start, end;
+  sourceview_cell_get_iter (SOURCEVIEW_CELL (end_position), &end);
+  sourceview_cell_get_iter (SOURCEVIEW_CELL (start_position), &start);
 	
   gchar* text_buffer = gtk_text_buffer_get_text (buffer,
-											start, end, TRUE);
+											&start, &end, TRUE);
   gtk_text_buffer_begin_user_action (buffer);
-  gtk_text_buffer_delete (buffer, start, end);
-  gtk_text_buffer_insert (buffer, start, g_utf8_strdown (text_buffer, -1), -1);
+  gtk_text_buffer_delete (buffer, &start, &end);
+  gtk_text_buffer_insert (buffer, &start, g_utf8_strdown (text_buffer, -1), -1);
   gtk_text_buffer_end_user_action (buffer);
   g_free (text_buffer);
 
@@ -1811,6 +1822,7 @@ iindic_set (IAnjutaIndicable *indic, IAnjutaIterable* ibegin, IAnjutaIterable *i
 {
 	GtkTextTag *tag = NULL;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(indic);
+	GtkTextIter start, end;
 	
 	switch (indicator)
 	{
@@ -1826,10 +1838,11 @@ iindic_set (IAnjutaIndicable *indic, IAnjutaIterable* ibegin, IAnjutaIterable *i
 		default:
 			return;
 	}
-
+	sourceview_cell_get_iter (SOURCEVIEW_CELL (ibegin), &start);
+	sourceview_cell_get_iter (SOURCEVIEW_CELL (iend), &end);
 	gtk_text_buffer_apply_tag (GTK_TEXT_BUFFER(sv->priv->document), tag, 
-	                           sourceview_cell_get_iter (SOURCEVIEW_CELL (ibegin)),
-							   sourceview_cell_get_iter (SOURCEVIEW_CELL (iend)));
+	                           &start,
+							   &end);
 }
 
 static void
@@ -1978,7 +1991,8 @@ itips_show (IAnjutaEditorTip *iassist, GList* tips, IAnjutaIterable* ipos,
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(iassist);
 	SourceviewCell* cell = SOURCEVIEW_CELL (ipos);
-	GtkTextIter* iter = sourceview_cell_get_iter(cell);
+	GtkTextIter iter;
+	sourceview_cell_get_iter(cell, &iter);
 	
 	g_return_if_fail (tips != NULL);
 	
@@ -1990,13 +2004,13 @@ itips_show (IAnjutaEditorTip *iassist, GList* tips, IAnjutaIterable* ipos,
 		g_object_weak_ref (G_OBJECT(sv->priv->assist_tip),
 		                   (GWeakNotify) on_assist_tip_destroyed,
 		                   sv);
-		assist_tip_move (sv->priv->assist_tip, GTK_TEXT_VIEW (sv->priv->view), iter);
+		assist_tip_move (sv->priv->assist_tip, GTK_TEXT_VIEW (sv->priv->view), &iter);
 		gtk_widget_show (GTK_WIDGET (sv->priv->assist_tip));
 	}
 	else
 	{
 		assist_tip_set_tips (sv->priv->assist_tip, tips);
-		assist_tip_move (sv->priv->assist_tip, GTK_TEXT_VIEW (sv->priv->view), iter);
+		assist_tip_move (sv->priv->assist_tip, GTK_TEXT_VIEW (sv->priv->view), &iter);
 	}
 }
 
@@ -2042,9 +2056,20 @@ iassist_remove(IAnjutaEditorAssist* iassist,
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(iassist);
 	GtkSourceCompletion* completion = gtk_source_view_get_completion(GTK_SOURCE_VIEW(sv->priv->view));
-	gtk_source_completion_remove_provider(completion, 
-	                                      GTK_SOURCE_COMPLETION_PROVIDER(sourceview_provider_new(sv, provider)),
-	                                      NULL);
+	GList* node;
+	for (node = gtk_source_completion_get_providers(completion); node != NULL; node = g_list_next(node))
+	{
+		SourceviewProvider* prov; 
+		if (!SOURCEVIEW_IS_PROVIDER(node->data))
+		    continue;
+		prov = SOURCEVIEW_PROVIDER(node->data);
+		if (prov->iprov == provider)
+		{
+			gtk_source_completion_remove_provider(completion, 
+	        		                              GTK_SOURCE_COMPLETION_PROVIDER(prov),
+	        		                              NULL);
+	    }
+	}
 }
 
 static void
@@ -2057,7 +2082,10 @@ iassist_invoke(IAnjutaEditorAssist* iassist,
 	GList* node;
 	for (node = gtk_source_completion_get_providers(completion); node != NULL; node = g_list_next(node))
 	{
-		SourceviewProvider* prov = SOURCEVIEW_PROVIDER(node->data);
+		SourceviewProvider* prov;
+		if (!SOURCEVIEW_IS_PROVIDER (node->data))
+			continue;
+		prov = SOURCEVIEW_PROVIDER(node->data);
 		if (prov->iprov == provider)
 		{
 			GList* list = g_list_append(NULL, prov);
@@ -2078,7 +2106,7 @@ static void
 iassist_proposals(IAnjutaEditorAssist* iassist, 
                   IAnjutaProvider* provider,
                   GList* proposals,
-                  gboolean finished
+                  gboolean finished,
                   GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(iassist);
@@ -2086,34 +2114,39 @@ iassist_proposals(IAnjutaEditorAssist* iassist,
 	GList* node;
 	for (node = gtk_source_completion_get_providers(completion); node != NULL; node = g_list_next(node))
 	{
-		SourceviewProvider* prov = SOURCEVIEW_PROVIDER(node->data);
+		SourceviewProvider* prov;
+		if (!SOURCEVIEW_IS_PROVIDER (node->data))
+			continue;
+		prov = SOURCEVIEW_PROVIDER(node->data);
+		if (prov->cancelled)
+			continue;
 		if (prov->iprov == provider)
 		{
-    	GList* prop;
-   	  GList* items = NULL;
-    	for (prop = proposals; prop != NULL; prop = g_list_next(node))
-    	{
-    	  IAnjutaEditorAssistProposal* proposal = node->data;
-    	  GtkSourceCompletionItem* item;
-    	  if (proposal->markup)
-    	  {    	    
-    	     item = gtk_source_completion_item_new_with_markup(proposal->markup,
-									 		  	                                   proposal->text,
-    	             										                       proposal->icon,
-    	             										                       proposal->info);
-    	  }
-    	  else
-    	  {
-    	     item = gtk_source_completion_item_new_with_markup(proposal->markup,
-    	                                                       proposal->text,
-    	                                                       proposal->icon,
-    	                                    									 proposal->info);
-    	  }    	                                    
-    	  items = g_list_append (items, item);
-    	  g_object_set_data (G_OBJECT(item), "__data", proposal->data);
-    	}
-    	gtk_source_completion_context_add_proposals (prov->context, GTK_SOURCE_COMPLETION_PROVIDER(prov),
-    																							 items, finished);
+			GList* prop;
+			GList* items = NULL;
+			for (prop = proposals; prop != NULL; prop = g_list_next(prop))
+			{
+				IAnjutaEditorAssistProposal* proposal = prop->data;
+				GtkSourceCompletionItem* item;
+				if (proposal->markup)
+				{    	    
+					item = gtk_source_completion_item_new_with_markup(proposal->markup,
+					                                                  proposal->text,
+					                                                  proposal->icon,
+					                                                  proposal->info);
+				}
+				else
+				{
+					item = gtk_source_completion_item_new(proposal->label,
+					                                      proposal->text,
+					                                      proposal->icon,
+					                                      proposal->info);
+				}    	                                    
+				items = g_list_append (items, item);
+				g_object_set_data (G_OBJECT(item), "__data", proposal->data);
+			}
+			gtk_source_completion_context_add_proposals (prov->context, GTK_SOURCE_COMPLETION_PROVIDER(prov),
+			                                             items, finished);
 		}
 	}
 }
@@ -2142,12 +2175,16 @@ isearch_forward (IAnjutaEditorSearch* isearch,
 	SourceviewCell* start = SOURCEVIEW_CELL (istart);
 	SourceviewCell* end = SOURCEVIEW_CELL (iend);
 	
-	GtkTextIter* start_iter = sourceview_cell_get_iter (start);
-	GtkTextIter* end_iter = sourceview_cell_get_iter (end);
+	GtkTextIter start_iter;
+	GtkTextIter end_iter;
 	
 	GtkTextIter result_start, result_end;
 	
 	GtkSourceSearchFlags flags = 0;
+
+	sourceview_cell_get_iter (start, &start_iter);
+	sourceview_cell_get_iter (end, &end_iter);
+
 	
 	if (!case_sensitive)
 	{
@@ -2155,8 +2192,8 @@ isearch_forward (IAnjutaEditorSearch* isearch,
 	}
 	
 	gboolean result = 
-		gtk_source_iter_forward_search (start_iter, search, flags, &result_start, &result_end,
-									end_iter);
+		gtk_source_iter_forward_search (&start_iter, search, flags, &result_start, &result_end,
+									&end_iter);
 
 	if (result)
 	{
@@ -2190,21 +2227,24 @@ isearch_backward (IAnjutaEditorSearch* isearch,
 	SourceviewCell* start = SOURCEVIEW_CELL (istart);
 	SourceviewCell* end = SOURCEVIEW_CELL (iend);
 	
-	GtkTextIter* start_iter = sourceview_cell_get_iter (start);
-	GtkTextIter* end_iter = sourceview_cell_get_iter (end);
-	
+	GtkTextIter start_iter;
+	GtkTextIter end_iter;	
 	GtkTextIter result_start, result_end;
 	
 	GtkSourceSearchFlags flags = 0;
 	
+	sourceview_cell_get_iter (start, &start_iter);
+	sourceview_cell_get_iter (end, &end_iter);
+
+	
 	if (!case_sensitive)
 	{
 		flags = GTK_SOURCE_SEARCH_CASE_INSENSITIVE;
 	}
 	
 	gboolean result = 
-		gtk_source_iter_backward_search (start_iter, search, flags, &result_start, &result_end,
-									end_iter);
+		gtk_source_iter_backward_search (&start_iter, search, flags, &result_start, &result_end,
+									&end_iter);
 
 	if (result)
 	{
diff --git a/plugins/symbol-db/symbol-db-engine-queries.c b/plugins/symbol-db/symbol-db-engine-queries.c
index 9b4f535..a175453 100644
--- a/plugins/symbol-db/symbol-db-engine-queries.c
+++ b/plugins/symbol-db/symbol-db-engine-queries.c
@@ -2831,7 +2831,7 @@ symbol_db_engine_find_symbol_by_name_pattern_filtered (SymbolDBEngine *dbe,
 	GValue *ret_value;
 	gboolean ret_bool;
 	GPtrArray *filter_kinds_array;
-	
+	GError* error = NULL;
 
 	g_return_val_if_fail (dbe != NULL, NULL);
 	g_return_val_if_fail (pattern != NULL, NULL);
@@ -3155,7 +3155,13 @@ symbol_db_engine_find_symbol_by_name_pattern_filtered (SymbolDBEngine *dbe,
 	/* execute the query with parametes just set */
 	data = gda_connection_statement_execute_select (priv->db_connection, 
 												  (GdaStatement*)dyn_node->stmt, 
-												  (GdaSet*)dyn_node->plist, NULL);
+												  (GdaSet*)dyn_node->plist, &error);
+
+	if (error)
+	{
+		DEBUG_PRINT ("Error while executing statement %s", error->message);
+		g_error_free(error);
+	}
 
 	/* free the filter kinds, if it's not null */
 	if (filter_kinds_array)
diff --git a/plugins/symbol-db/symbol-db-search-command.c b/plugins/symbol-db/symbol-db-search-command.c
index 0f4f472..c3f3398 100644
--- a/plugins/symbol-db/symbol-db-search-command.c
+++ b/plugins/symbol-db/symbol-db-search-command.c
@@ -124,7 +124,7 @@ do_search_prj_glb (SymbolDBSearchCommand *sdbsc)
 					priv->session_packages,
 					priv->results_limit,
 					priv->results_offset,
-					priv->info_fields);	
+					priv->info_fields);
 	
 	return iterator;
 }
@@ -142,6 +142,8 @@ sdb_search_command_run (AnjutaCommand *command)
 
 	priv = sdbsc->priv;
 
+	DEBUG_PRINT ("Searching async");
+	
 	switch (priv->cmd_search_type)
 	{
 		case CMD_SEARCH_FILE:
@@ -156,10 +158,12 @@ sdb_search_command_run (AnjutaCommand *command)
 
 	if (priv->iterator_result == NULL)
 	{
+		DEBUG_PRINT("Async search returned no results");
 		/* 1 is for error occurred */
 		return 1;
 	}
 
+	DEBUG_PRINT ("Notify!");
 	anjuta_command_notify_data_arrived (command);
 	
 	/* 0 should be for no error */
@@ -167,6 +171,12 @@ sdb_search_command_run (AnjutaCommand *command)
 }
 
 static void
+sdb_search_command_cancel(AnjutaCommand* command)
+{
+	/* FIXME: Cancel the query if possible */
+}
+
+static void
 sdb_search_command_class_init (SymbolDBSearchCommandClass *klass)
 {
 	GObjectClass* object_class = G_OBJECT_CLASS (klass);
@@ -174,6 +184,7 @@ sdb_search_command_class_init (SymbolDBSearchCommandClass *klass)
 	
 	object_class->finalize = sdb_search_command_finalize;
 	command_class->run = sdb_search_command_run;
+	command_class->cancel = sdb_search_command_cancel;
 }
 
 /**



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