[anjuta/newproject] Add a new signal in project manager interface to make it works with symbol-db plugin



commit 1493a5a530facb70b74ffbb1d07ff0c36ee927a8
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Thu Apr 29 21:01:30 2010 +0200

    Add a new signal in project manager interface to make it works with symbol-db plugin

 libanjuta/anjuta-project.h                |    3 +-
 libanjuta/interfaces/libanjuta.idl        |   15 +++-
 plugins/am-project/am-project.c           |    9 +-
 plugins/project-manager/plugin.c          |  102 +++++++++++++++------
 plugins/project-manager/project-util.c    |   22 ++++-
 plugins/project-manager/project.c         |   38 +++++++--
 plugins/project-manager/project.h         |    3 +
 plugins/symbol-db/plugin.c                |  138 ++++++++++++++++-------------
 plugins/symbol-db/plugin.h                |    1 +
 plugins/symbol-db/symbol-db-engine-core.c |    2 +-
 10 files changed, 224 insertions(+), 109 deletions(-)
---
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index d4f5006..1fcca83 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -51,7 +51,8 @@ typedef enum
 	ANJUTA_PROJECT_MKENUMS,
 	ANJUTA_PROJECT_GENMARSHAL,
 	ANJUTA_PROJECT_SCRIPT,
-	ANJUTA_PROJECT_PROXY = 1 << 13,
+	ANJUTA_PROJECT_PROXY = 1 << 12,
+	ANJUTA_PROJECT_PROJECT = 1 << 13,
 	ANJUTA_PROJECT_PRIMARY = 1 << 14,
 	ANJUTA_PROJECT_EXECUTABLE = 1 << 15,
 	ANJUTA_PROJECT_ID_MASK = 0xFFF,
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index f731dc0..e54e750 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -3421,6 +3421,7 @@ interface IAnjutaProjectManager
 
 	#include <libanjuta/anjuta-project.h>
 	#include <libanjuta/interfaces/ianjuta-project.h>
+	#include <libanjuta/anjuta-error.h>
 	
 	/**
 	* IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI
@@ -3437,7 +3438,19 @@ interface IAnjutaProjectManager
 	#define CURRENT_URI		"project_manager_current_uri"
 
 	// Signals
-	
+
+	/**
+	* IAnjutaProjectManager::project_loaded:
+	* @obj: Self
+	* @err: Error propagation and reporting.
+	* 
+	* Emitted when the project is fully loaded. It can takes a quite long
+	* time if the project is big. The project is loaded in several parts
+	* in a thread. All functions are available before having the project
+	* fully loaded.
+	*/
+	void ::project_loaded (GError *error);
+
 	/**
 	* IAnjutaProjectManager::element_added:
 	* @obj: Self
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index bc043b2..3ad80eb 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -1497,7 +1497,7 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 
 			/* Create source */
 			src_file = g_file_get_child (parent_file, value);
-			source = amp_source_new (src_file);
+			source = project_node_new (project, ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT, src_file, NULL);
 			g_object_unref (src_file);
 			AMP_SOURCE_DATA(source)->token = arg;
 
@@ -1594,7 +1594,7 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaToken *list, An
 
 			/* Create source */
 			src_file = g_file_get_child (parent_file, value);
-			source = amp_source_new (src_file);
+			source = project_node_new (project, ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT, src_file, NULL);
 			g_object_unref (src_file);
 			AMP_SOURCE_DATA(source)->token = arg;
 
@@ -2063,7 +2063,7 @@ amp_project_load_package (AmpProject *project, AnjutaProjectNode *node, GError *
 						/* Create a source for files */
 						AmpSource *source;
 
-						source = amp_source_new ((GFile *)file->data);
+						source = project_node_new (project, ANJUTA_PROJECT_SOURCE, (GFile *)file->data, NULL);
 						anjuta_project_node_append (node, source);
 						g_object_unref ((GObject *)file->data);
 					}
@@ -2738,7 +2738,8 @@ amp_project_add_sibling_source (AmpProject  *project, AmpTarget *target, GFile *
 	}
 
 	/* Add source node in project tree */
-	source = amp_source_new (file);
+	source = project_node_new (project, ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT, file, NULL);
+;
 	AMP_SOURCE_DATA(source)->token = token;
 	if (after)
 	{
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index b246d9e..5237bf9 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -1287,6 +1287,77 @@ on_project_updated (AnjutaPmProject *project, GError *error, ProjectManagerPlugi
 }
 
 static void
+on_project_loaded (AnjutaPmProject *project, GError *error, ProjectManagerPlugin *plugin)
+{
+	AnjutaStatus *status;
+	gchar *dirname;
+
+	dirname = anjuta_util_get_local_path_from_uri (plugin->project_root_uri);
+	status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell, NULL);
+	if (error)
+	{
+		GtkWidget *toplevel;
+		GtkWindow *win;
+		
+		toplevel = gtk_widget_get_toplevel (plugin->scrolledwindow);
+		if (toplevel && GTK_IS_WINDOW (toplevel))
+			win = GTK_WINDOW (toplevel);
+		else
+			win = GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell);
+
+		anjuta_util_dialog_error (win, _("Failed to parse project (the project is opened, but there will be no project view) %s: %s\n"
+										 ""),
+								  dirname, error->message);
+	}
+	else
+	{
+		/* Restore existing shortcut */
+		if (plugin->shortcuts != NULL)
+		{
+			GList *item;
+			
+			gbf_project_view_set_shortcut_list (GBF_PROJECT_VIEW (plugin->view), plugin->shortcuts);
+			/* Remove used shortcuts */
+			for (item = g_list_first (plugin->shortcuts); item != NULL;)
+			{
+				if (*((char *)item->data) == 'U')
+				{
+					GList *next = g_list_next (item);
+					
+					g_free (item->data);
+					plugin->shortcuts = g_list_remove_link (plugin->shortcuts, item);
+					item = next;
+				}
+				else
+				{
+					item = g_list_next (item);
+				}
+			}
+		}
+		gchar *basename = g_path_get_basename (dirname);
+		
+		anjuta_status_progress_tick (status, NULL, _("Update project viewâ?¦"));
+		update_ui (plugin);
+		anjuta_shell_present_widget (ANJUTA_PLUGIN (plugin)->shell,
+									plugin->scrolledwindow,
+									NULL);
+		anjuta_status_set_default (status, _("Project"), basename);
+		g_free (basename);
+	}
+	g_free (dirname);
+
+	if (plugin->busy)
+	{
+		anjuta_status_pop (status);
+		anjuta_status_busy_pop (status);
+		plugin->busy = FALSE;
+	}
+
+	/* Emit loaded signal for other plugins */
+	g_signal_emit_by_name (G_OBJECT (plugin), "project_loaded", error);
+}
+
+static void
 project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
 {
 	AnjutaStatus *status;
@@ -1504,6 +1575,7 @@ project_manager_plugin_activate_plugin (AnjutaPlugin *plugin)
 	/* Create project */
 	pm_plugin->project = anjuta_pm_project_new (plugin);
 	g_signal_connect (pm_plugin->project, "updated", G_CALLBACK (on_project_updated), plugin);
+	g_signal_connect (pm_plugin->project, "loaded", G_CALLBACK (on_project_loaded), plugin);
 	
 	/* create model & view and bind them */
 	view = gbf_project_view_new ();
@@ -1878,41 +1950,13 @@ iproject_manager_get_targets (IAnjutaProjectManager *project_manager,
 {
 	GList *targets, *node;
 	ProjectManagerPlugin *plugin;
-	gint type_id;
-	gint type_flag;
 	
 	g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
 	
 	plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
 
 	/* Get all targets */
-	targets = gbf_project_util_node_all (anjuta_pm_project_get_root (plugin->project), ANJUTA_PROJECT_TARGET);
-
-	/* Remove all targets not in specified class */
-	type_id = target_type & ANJUTA_PROJECT_ID_MASK;
-	type_flag = target_type & ANJUTA_PROJECT_FLAG_MASK;
-	g_message ("get targets %p", targets);
-	for (node = g_list_first (targets); node != NULL;)
-	{
-		AnjutaProjectNodeType type;
-
-		type = anjuta_project_node_get_full_type (node->data);
-		if ((type_id != 0) && (type_id != (type & ANJUTA_PROJECT_ID_MASK)))
-		{
-			GList *next = g_list_next (node);
-			targets = g_list_delete_link (targets, node);
-			node = next;
-			continue;
-		}
-		if ((type_flag != 0) && ((type & type_flag) == 0))
-		{
-			GList *next = g_list_next (node);
-			targets = g_list_delete_link (targets, node);
-			node = next;
-			continue;
-		}
-		node = g_list_next (node);
-	}
+	targets = gbf_project_util_node_all (anjuta_pm_project_get_root (plugin->project), target_type);
 
 	/* Replace all targets by their corresponding URI */
 	for (node = g_list_first (targets); node != NULL; node = g_list_next (node))
diff --git a/plugins/project-manager/project-util.c b/plugins/project-manager/project-util.c
index 4b0b239..e825732 100644
--- a/plugins/project-manager/project-util.c
+++ b/plugins/project-manager/project-util.c
@@ -843,16 +843,30 @@ gbf_project_util_node_all (AnjutaProjectNode *parent, AnjutaProjectNodeType type
 {
     AnjutaProjectNode *node;
     GList *list = NULL;
- 
+    gint type_id;
+    gint type_flag;
+    gint type_type;
+
+    type_type = type & ANJUTA_PROJECT_TYPE_MASK;
+    type_flag = type & ANJUTA_PROJECT_FLAG_MASK;
+    type_id = type & ANJUTA_PROJECT_ID_MASK;
+    
     for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
     {
         GList *child_list;
         
-        if (anjuta_project_node_get_type (node) == type)
+        if (anjuta_project_node_get_type (node) == type_type)
         {
-            list = g_list_prepend (list, node);
+            gint type;
+        
+            type = anjuta_project_node_get_full_type (node);
+            if (((type_id == 0) || (type_id == (type & ANJUTA_PROJECT_ID_MASK))) && 
+                ((type_flag == 0) || ((type & type_flag) != 0)))
+            {
+                list = g_list_prepend (list, node);
+            }
         }
- 
+
         child_list = gbf_project_util_node_all (node, type);
         child_list = g_list_reverse (child_list);
         list = g_list_concat (child_list, list);
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index a876c5a..4d0402f 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -127,6 +127,7 @@ struct _PmJob
 enum
 {
 	UPDATED,
+	LOADED,
 	LAST_SIGNAL
 };
 
@@ -333,16 +334,26 @@ on_pm_project_reloaded (AnjutaPmProject *project, PmJob *job)
 	if (job->error != NULL)
 	{
 		g_warning ("unable to load node");
+		pm_project_stop_thread (project);
+		g_object_unref (project->project);
+		project->project = NULL;
+		g_signal_emit (G_OBJECT (project), signals[LOADED], 0, job->error);
 	}
 	else
 	{
 		//g_object_set (G_OBJECT (project->model), "project", project, NULL);
 		// Check for incompletely loaded object and load them
 		anjuta_project_node_clear_state (job->node, ANJUTA_PROJECT_LOADING | ANJUTA_PROJECT_INCOMPLETE);
+		g_message ("remaining node %d", project->incomplete_node);
+		project->incomplete_node--;
 		anjuta_project_node_all_foreach (job->node, (AnjutaProjectNodeFunc)on_pm_project_load_incomplete, project);
-		g_message ("Emit project updated on %p", project);
 		//g_signal_emit (G_OBJECT (project), signals[UPDATED], 0, job->error);
 		gbf_project_model_update_tree (project->model, NULL, NULL);
+		
+		if (project->incomplete_node == 0)
+		{
+			g_signal_emit (G_OBJECT (project), signals[LOADED], 0, NULL);
+		}
 	}
 }
 
@@ -353,6 +364,7 @@ on_pm_project_load_incomplete (AnjutaProjectNode *node, AnjutaPmProject *project
 	
 	if ((state & ANJUTA_PROJECT_INCOMPLETE) && !(state & ANJUTA_PROJECT_LOADING))
 	{
+		project->incomplete_node++;
 		anjuta_project_node_set_state (node, ANJUTA_PROJECT_LOADING);
 		pm_project_push_command (project, RELOAD, NULL, NULL, node, on_pm_project_reloaded);
 	}
@@ -368,6 +380,7 @@ on_pm_project_loaded (AnjutaPmProject *project, PmJob *job)
 		pm_project_stop_thread (project);
 		g_object_unref (project->project);
 		project->project = NULL;
+		g_signal_emit (G_OBJECT (project), signals[LOADED], 0, job->error);
 	}
 	else
 	{
@@ -376,12 +389,16 @@ on_pm_project_loaded (AnjutaPmProject *project, PmJob *job)
 		g_message ("root all nodes %d", g_node_n_nodes (job->node, G_TRAVERSE_ALL));
 		project->root = job->node;
 		g_object_set (G_OBJECT (project->model), "project", project, NULL);
-		gbf_project_model_update_tree (project->model, NULL, NULL);		
+		gbf_project_model_update_tree (project->model, NULL, NULL);
+		
+		// Check for incompletely loaded object and load them
+		project->incomplete_node = 0;
+		anjuta_project_node_all_foreach (job->node, (AnjutaProjectNodeFunc)on_pm_project_load_incomplete, project);
+		if (project->incomplete_node == 0)
+		{
+			g_signal_emit (G_OBJECT (project), signals[LOADED], 0, NULL);
+		}
 	}
-	g_signal_emit (G_OBJECT (project), signals[UPDATED], 0, job->error);
-
-	// Check for incompletely loaded object and load them
-	anjuta_project_node_all_foreach (job->node, (AnjutaProjectNodeFunc)on_pm_project_load_incomplete, project);
 }
 
 gboolean 
@@ -750,6 +767,15 @@ anjuta_pm_project_class_init (AnjutaPmProjectClass *klass)
 	    1,
 	    G_TYPE_ERROR);
 	
+	signals[LOADED] = g_signal_new ("loaded",
+		G_OBJECT_CLASS_TYPE (object_class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (AnjutaPmProjectClass, loaded),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__BOXED,
+		G_TYPE_NONE,
+		1,
+		G_TYPE_ERROR);
 }
 
 /* Constructor & Destructor
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index 6d05aab..8434892 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -48,6 +48,7 @@ struct _AnjutaPmProjectClass
 	GObjectClass parent_class;
 
 	void (*updated) (GError *error);
+	void (*loaded) (GError *error);
 };
 
 struct _AnjutaPmProject
@@ -61,6 +62,8 @@ struct _AnjutaPmProject
 
 	AnjutaProjectNode *root;
 	
+	guint incomplete_node;
+	
 	/* project properties dialog */
 	GtkWidget *properties_dialog;
 	
diff --git a/plugins/symbol-db/plugin.c b/plugins/symbol-db/plugin.c
index b60866c..9bf8e1a 100644
--- a/plugins/symbol-db/plugin.c
+++ b/plugins/symbol-db/plugin.c
@@ -1190,13 +1190,10 @@ do_import_system_sources_after_abort (SymbolDBPlugin *sdb_plugin,
 /* we assume that sources_array has already unique elements */
 /* note the *project* word in the function */
 static void
-do_import_project_sources_after_abort (AnjutaPlugin *plugin, 
+do_import_project_sources_after_abort (SymbolDBPlugin *sdb_plugin, 
 							   const GPtrArray *sources_array)
 {
-	SymbolDBPlugin *sdb_plugin;
 	gint real_added;
-	
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (plugin);	
 
 	sdb_plugin->is_project_importing = TRUE;
 	
@@ -1204,7 +1201,7 @@ do_import_project_sources_after_abort (AnjutaPlugin *plugin,
 	 * update a status bar notifying the user about the status
 	 */
 	g_signal_connect (G_OBJECT (sdb_plugin->sdbe_project), "single-file-scan-end",
-		  G_CALLBACK (on_project_single_file_scan_end), plugin);
+		  G_CALLBACK (on_project_single_file_scan_end), sdb_plugin);
 
 	real_added = do_add_new_files (sdb_plugin, sources_array, 
 								   TASK_IMPORT_PROJECT_AFTER_ABORT);
@@ -1219,24 +1216,21 @@ do_import_project_sources_after_abort (AnjutaPlugin *plugin,
 }
 
 static void
-do_import_project_sources (AnjutaPlugin *plugin, IAnjutaProjectManager *pm, 
+do_import_project_sources (SymbolDBPlugin *sdb_plugin, IAnjutaProjectManager *pm, 
 				   const gchar *root_dir)
 {
-	SymbolDBPlugin *sdb_plugin;
 	GList* prj_elements_list;
 	GPtrArray* sources_array;
 	gint i;
 	gint real_added;
-	
-	sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (plugin);	
 
 	prj_elements_list = ianjuta_project_manager_get_elements (pm,
-					   ANJUTA_PROJECT_SOURCE,
+					   ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT,
 					   NULL);
 	
 	if (prj_elements_list == NULL)
 	{
-		g_critical ("No sources found within this project");
+		g_warning ("No sources found within this project");
 		return;
 	}
 	
@@ -1270,7 +1264,7 @@ do_import_project_sources (AnjutaPlugin *plugin, IAnjutaProjectManager *pm,
 	 * update a status bar notifying the user about the status
 	 */
 	g_signal_connect (G_OBJECT (sdb_plugin->sdbe_project), "single-file-scan-end",
-		  G_CALLBACK (on_project_single_file_scan_end), plugin);
+		  G_CALLBACK (on_project_single_file_scan_end), sdb_plugin);
 	
 	real_added = do_add_new_files (sdb_plugin, sources_array, TASK_IMPORT_PROJECT);
 	if (real_added <= 0)
@@ -1399,7 +1393,7 @@ do_check_offline_files_changed (SymbolDBPlugin *sdb_plugin)
 									 IAnjutaProjectManager, NULL);	
 
 	prj_elements_list = ianjuta_project_manager_get_elements (pm,
-		   ANJUTA_PROJECT_SOURCE,
+		   ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT,
 		   NULL);
 	
 	/* fill an hash table with all the items of the list just taken. 
@@ -1522,7 +1516,7 @@ do_check_offline_files_changed (SymbolDBPlugin *sdb_plugin)
 		}
 	}
 	
-	g_object_unref (it);
+	if (it != NULL) g_object_unref (it);
 	g_ptr_array_free (to_add_files, TRUE);
 	g_hash_table_destroy (prj_elements_hash);
 	
@@ -1619,6 +1613,68 @@ on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase,
 	}	
 }
 
+static void
+on_project_loaded (IAnjutaProjectManager *pm, GError *error,
+						  SymbolDBPlugin *sdb_plugin)
+{
+	gchar *filename;
+	gint real_added;
+	GPtrArray *files_array;			
+		
+	g_return_if_fail (sdb_plugin->project_root_uri != NULL);
+	g_return_if_fail (sdb_plugin->project_root_dir != NULL);
+
+	/* Malformed project abort */
+	if (error != NULL) return;
+
+	/*
+	 * we need an initial import 
+	 */
+	if (sdb_plugin->needs_sources_scan == TRUE)
+	{
+		DEBUG_PRINT ("Importing sources.");
+		do_import_project_sources (sdb_plugin, pm, sdb_plugin->project_root_dir);
+	}
+	else	
+	{
+		/*
+		 * no import needed. But we may have aborted the scan of sources in 
+		 * a previous session..
+		 */				
+		GPtrArray *sources_array = NULL;				
+		gboolean flag_offline;
+		gboolean flag_update;
+		
+		
+		sources_array = 
+			symbol_db_util_get_files_with_zero_symbols (sdb_plugin->sdbe_project);
+
+		if (sources_array != NULL && sources_array->len > 0) 
+		{				
+			do_import_project_sources_after_abort (sdb_plugin, sources_array);
+			
+			g_ptr_array_foreach (sources_array, (GFunc)g_free, NULL);
+			g_ptr_array_free (sources_array, TRUE);
+		}
+			
+		/* check for offline changes */				
+		flag_offline = do_check_offline_files_changed (sdb_plugin);
+			
+		/* update any files of the project which isn't up-to-date */
+		flag_update = do_update_project_symbols (sdb_plugin, sdb_plugin->project_root_dir);
+		
+		/* if they're both false then there won't be a place where
+		 * the do_check_languages_count () is called. Check the returns
+		 * and to it here
+		 */
+		if (flag_offline == FALSE && flag_update == FALSE)
+		{
+			/* check for the number of languages used in the opened project. */
+			//do_check_languages_count (sdb_plugin);				
+		}				
+	}
+}
+
 /* add a new project */
 static void
 on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
@@ -1693,7 +1749,6 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 	
 	if (root_dir)
 	{
-		gboolean needs_sources_scan = FALSE;
 		gboolean project_exist = FALSE;
 		GHashTable* lang_hash;
 		guint id;
@@ -1708,7 +1763,8 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 
 		/* is it a fresh-new project? is it an imported project with 
 		 * no 'new' symbol-db database but the 'old' one symbol-browser? 
-		 */		
+		 */
+		sdb_plugin->needs_sources_scan = FALSE;
 		switch (open_status)
 		{
 			case DB_OPEN_STATUS_FATAL:
@@ -1721,7 +1777,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 
 			case DB_OPEN_STATUS_CREATE:
 			case DB_OPEN_STATUS_UPGRADE:
-				needs_sources_scan = TRUE;
+				sdb_plugin->needs_sources_scan = TRUE;
 				project_exist = FALSE;
 				break;
 				
@@ -1738,52 +1794,6 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 											  sdb_plugin->project_opened);
 		}
 
-		/*
-		 * we need an initial import 
-		 */
-		if (needs_sources_scan == TRUE)
-		{
-			DEBUG_PRINT ("Importing sources.");
-			do_import_project_sources (plugin, pm, root_dir);
-		}
-		else	
-		{
-			/*
-			 * no import needed. But we may have aborted the scan of sources in 
-			 * a previous session..
-			 */				
-			GPtrArray *sources_array = NULL;				
-			gboolean flag_offline;
-			gboolean flag_update;
-			
-			
-			sources_array = 
-				symbol_db_util_get_files_with_zero_symbols (sdb_plugin->sdbe_project);
-
-			if (sources_array != NULL && sources_array->len > 0) 
-			{				
-				do_import_project_sources_after_abort (plugin, sources_array);
-				
-				g_ptr_array_foreach (sources_array, (GFunc)g_free, NULL);
-				g_ptr_array_free (sources_array, TRUE);
-			}
-				
-			/* check for offline changes */				
-			flag_offline = do_check_offline_files_changed (sdb_plugin);
-				
-			/* update any files of the project which isn't up-to-date */
-			flag_update = do_update_project_symbols (sdb_plugin, root_dir);
-			
-			/* if they're both false then there won't be a place where
-			 * the do_check_languages_count () is called. Check the returns
-			 * and to it here
-			 */
-			if (flag_offline == FALSE && flag_update == FALSE)
-			{
-				/* check for the number of languages used in the opened project. */
-				//do_check_languages_count (sdb_plugin);				
-			}				
-		}
 		gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sdb_plugin->progress_bar_project),
 								   _("Populating symbol databaseâ?¦"));
 		id = g_idle_add ((GSourceFunc) gtk_progress_bar_pulse, 
@@ -1804,6 +1814,8 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 					  G_CALLBACK (on_project_element_added), sdb_plugin);
 	g_signal_connect (G_OBJECT (pm), "element_removed",
 					  G_CALLBACK (on_project_element_removed), sdb_plugin);
+	g_signal_connect (G_OBJECT (pm), "project_loaded",
+					  G_CALLBACK (on_project_loaded), sdb_plugin);
 }
 
 static void
diff --git a/plugins/symbol-db/plugin.h b/plugins/symbol-db/plugin.h
index 3247ea8..8eaa4f7 100644
--- a/plugins/symbol-db/plugin.h
+++ b/plugins/symbol-db/plugin.h
@@ -82,6 +82,7 @@ struct _SymbolDBPlugin {
 	gchar *project_root_uri;
 	gchar *project_root_dir;
 	gchar *project_opened;
+	gboolean needs_sources_scan;
 	
 	/* Symbol's engine connection to database. Instance for local project */
 	SymbolDBEngine *sdbe_project;
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index 99f5d24..94dac96 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -1758,7 +1758,7 @@ sdb_engine_ctags_output_callback_1 (AnjutaLauncher * launcher,
 	if (priv->timeout_trigger_handler <= 0)
 	{
 		priv->timeout_trigger_handler = 
-			g_timeout_add_full (G_PRIORITY_LOW, TRIGGER_SIGNALS_DELAY, 
+			g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, TRIGGER_SIGNALS_DELAY, 
 						   sdb_engine_timeout_trigger_signals, user_data, NULL);
 		priv->trigger_closure_retries = 0;
 	}



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