[anjuta] symbol-db: added db-ready signal to interface.



commit b82f63b286f47a7e6717e95ec51c82e57955dbc0
Author: Massimo Corà <mcora src gnome org>
Date:   Thu Jun 24 00:32:16 2010 +0200

    symbol-db: added db-ready signal to interface.

 libanjuta/interfaces/libanjuta.idl  |   14 ++++++++++++++
 plugins/symbol-db/plugin.c          |   23 ++++++++++++++++++-----
 plugins/symbol-db/symbol-db-query.c |    3 ++-
 3 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 8054d45..edcc4ae 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -5767,6 +5767,20 @@ interface IAnjutaSymbolManager
 	void ::sys_scan_end (gint process_id);
 
 	/**
+	 * IAnjutaSymbolManager::db_ready:
+	 * @obj: Self
+	 * 
+	 * This signal is emitted when databases are ready for queries. 
+	 * A new database is created with tables, then it becomes ready.
+	 * A connection is made to an existing database, then it becomes ready.
+	 * Note that the signal may be emitted when no symbols are yet present on it:
+	 * you should rely on #IAnjutaSymbolManager::prj_scan_end and 
+	 * #IAnjutaSymbolManager::sys_scan_end to be sure that something has actually
+	 * been inserted into the dbs.
+	 */
+	void ::db_ready ();
+		
+	/**
 	 * ianjuta_symbol_manager_create_query:
 	 * @obj: Self
 	 * @name: Name of the query. It decides what query type it is.
diff --git a/plugins/symbol-db/plugin.c b/plugins/symbol-db/plugin.c
index 1a4e661..06054a8 100644
--- a/plugins/symbol-db/plugin.c
+++ b/plugins/symbol-db/plugin.c
@@ -1572,6 +1572,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 					const GValue *value, gpointer user_data)
 {
 	IAnjutaProjectManager *pm;
+	IAnjutaSymbolManager *sm;
 	SymbolDBPlugin *sdb_plugin;
 	const gchar *root_uri;
 	gchar *root_dir;
@@ -1594,7 +1595,9 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 							  PROJECT_GLOBALS,
 		    				  FALSE) == DB_OPEN_STATUS_FATAL)
 		{
-			g_error ("Opening global project under %s", anjuta_cache_path);
+			g_critical ("Opening global project under %s", anjuta_cache_path);
+			g_free (anjuta_cache_path);
+			return;
 		}
 		g_free (anjuta_cache_path);
 	
@@ -1613,6 +1616,9 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 	
 	pm = anjuta_shell_get_interface (ANJUTA_PLUGIN (sdb_plugin)->shell,
 									 IAnjutaProjectManager, NULL);
+
+	sm = anjuta_shell_get_interface (ANJUTA_PLUGIN (sdb_plugin)->shell,
+									 IAnjutaSymbolManager, NULL);
 	
 	/*
 	 *   The Project thing
@@ -1676,7 +1682,15 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 			default:
 				break;
 		}
-			
+
+
+		/* if we reach this point we have both databases connected. 
+		 * we can then emit the signal for db ready. 
+		 */
+		DEBUG_PRINT ("DBs are ready");
+		g_signal_emit_by_name (sm, "db-ready", NULL);
+
+		
 		/* if project did not exist add a new project */
 		if (project_exist == FALSE)
 		{
@@ -1942,8 +1956,6 @@ symbol_db_activate (AnjutaPlugin *plugin)
 	 */
 	if (ctags_path == NULL) 
 	{
-		DEBUG_PRINT ("ctags is not in preferences. Trying a default one %s", 
-				   CTAGS_PATH);
 		ctags_path = g_strdup (CTAGS_PATH);
 	}
 	
@@ -1997,7 +2009,8 @@ symbol_db_activate (AnjutaPlugin *plugin)
 							  PROJECT_GLOBALS,
 	    					  TRUE) == DB_OPEN_STATUS_FATAL)
 	{
-		g_error ("Opening global project under %s", anjuta_cache_path);
+		g_critical ("Opening global project under %s", anjuta_cache_path);
+		return FALSE;
 	}
 	
 	g_free (anjuta_cache_path);
diff --git a/plugins/symbol-db/symbol-db-query.c b/plugins/symbol-db/symbol-db-query.c
index a00ae0f..ab2109c 100644
--- a/plugins/symbol-db/symbol-db-query.c
+++ b/plugins/symbol-db/symbol-db-query.c
@@ -496,7 +496,8 @@ sdb_query_execute_real (SymbolDBQuery *query)
 
 	if (!symbol_db_engine_is_connected (priv->dbe_selected))
 	{
-		g_warning ("Attempt to make a query when database is not connected");
+		g_warning ("Attempt to make a query when database (%s) is not connected",
+		    symbol_db_engine_get_project_directory (priv->dbe_selected));
 		return GINT_TO_POINTER (-1);
 	}
 	if (symbol_db_engine_is_scanning (priv->dbe_selected))



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