[anjuta] symbol-db: made anjuta-tags the default scanner



commit 6a5cc47631a458b02b0408bda9ed244446e6445d
Author: Massimo Corà <mcora src gnome org>
Date:   Thu Jun 25 23:41:01 2009 +0200

    symbol-db: made anjuta-tags the default scanner
    
    waiting for ctags-devs to include the patches for our ctags we're defaulting to anjuta-tags.
    Fixed some problems with date in project updating.
    Still missing gui side in sdb preferences.

 plugins/symbol-db/Makefile.am             |    1 +
 plugins/symbol-db/plugin.c                |    5 ++-
 plugins/symbol-db/plugin.h                |    6 ++-
 plugins/symbol-db/symbol-db-engine-core.c |   45 +++++++++++++++-------------
 plugins/symbol-db/symbol-db-prefs.c       |   18 ++++++++----
 plugins/symbol-db/symbol-db-prefs.h       |    2 +
 6 files changed, 47 insertions(+), 30 deletions(-)
---
diff --git a/plugins/symbol-db/Makefile.am b/plugins/symbol-db/Makefile.am
index e7e4404..404080d 100644
--- a/plugins/symbol-db/Makefile.am
+++ b/plugins/symbol-db/Makefile.am
@@ -37,6 +37,7 @@ AM_CPPFLAGS = \
 	$(GDL_CFLAGS) \
 	$(LIBANJUTA_CFLAGS) \
 	$(PLUGIN_SYMBOL_DB_CFLAGS) \
+	-DPACKAGE_BIN_DIR=\"$(bindir)\" \
 	-DG_LOG_DOMAIN=\"libanjuta-symbol-db\"
 
 # Where to install the plugin
diff --git a/plugins/symbol-db/plugin.c b/plugins/symbol-db/plugin.c
index 55d1249..21e8e3b 100644
--- a/plugins/symbol-db/plugin.c
+++ b/plugins/symbol-db/plugin.c
@@ -2151,8 +2151,11 @@ symbol_db_activate (AnjutaPlugin *plugin)
 	sdb_plugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
 	sdb_plugin->project_opened = NULL;
 
-	ctags_path = anjuta_preferences_get (sdb_plugin->prefs, CTAGS_PREFS_KEY); 
+	ctags_path = NULL;
 
+	/* leaving here this code. Maybe in future ctags-devs will include our patches
+	 * upstream and this can be useful again.
+	 */
 	if (ctags_path == NULL) 
 	{
 		DEBUG_PRINT ("ctags is not in preferences. Trying a default one %s", 
diff --git a/plugins/symbol-db/plugin.h b/plugins/symbol-db/plugin.h
index 3784315..c435766 100644
--- a/plugins/symbol-db/plugin.h
+++ b/plugins/symbol-db/plugin.h
@@ -48,8 +48,10 @@ typedef struct _SymbolDBPluginClass SymbolDBPluginClass;
 #include "symbol-db-system.h"
 #include "symbol-db-prefs.h"
 
-/* a sort of 'default' value for ctags executable. User must have it installed */
-#define CTAGS_PATH			"/usr/bin/ctags"
+/* default value for ctags executable. User must have it installed. This is a 
+ * personalized version of ctags for Anjuta.
+ */
+#define CTAGS_PATH	PACKAGE_BIN_DIR"/anjuta-tags"
 
 struct _SymbolDBPlugin {
 	AnjutaPlugin parent;
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index 9479435..02cee54 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -5192,6 +5192,8 @@ sdb_engine_add_new_symbol (SymbolDBEngine * dbe, const tagEntry * tag_entry,
 }
 
 /**
+ * ### Thread note: this function inherits the mutex lock ### 
+ *
  * Select * from __tmp_removed and emits removed signals.
  */
 static void
@@ -5241,9 +5243,8 @@ sdb_engine_detects_removed_ids (SymbolDBEngine *dbe)
 		const GValue *val;
 		gint tmp;
 		val = gda_data_model_get_value_at (data_model, 0, i, NULL);
-		tmp = g_value_get_int (val);
-	
-		/*DEBUG_PRINT ("%s", "EMITTING symbol-removed");*/
+		tmp = g_value_get_int (val);	
+		
 		g_async_queue_push (priv->signals_queue, GINT_TO_POINTER(SYMBOL_REMOVED + 1));
 		g_async_queue_push (priv->signals_queue, GINT_TO_POINTER(tmp));
 	}
@@ -5390,8 +5391,6 @@ on_scan_update_files_symbols_end (SymbolDBEngine * dbe,
 	GValue *ret_value;
 	gboolean ret_bool;
 
-	DEBUG_PRINT ("%s", "");
-
 	g_return_if_fail (dbe != NULL);
 	g_return_if_fail (update_data != NULL);
 	
@@ -5578,7 +5577,7 @@ symbol_db_engine_update_project_symbols (SymbolDBEngine *dbe,
 	
 	SDB_LOCK(priv);
 
-	DEBUG_PRINT ("Updating project symbols...");
+	DEBUG_PRINT ("Updating project symbols (force %d)...", force_all_files);
 	if ((stmt = sdb_engine_get_statement_by_query_id (dbe,
 								 PREP_QUERY_GET_ALL_FROM_FILE_BY_PROJECT_NAME))
 		== NULL)
@@ -5603,12 +5602,12 @@ symbol_db_engine_update_project_symbols (SymbolDBEngine *dbe,
 	
 	/* execute the query with parametes just set */
 	GType gtype_array [6] = {	G_TYPE_INT, 
-							G_TYPE_STRING, 
-							G_TYPE_INT, 
-							G_TYPE_INT, 
-							GDA_TYPE_TIMESTAMP, 
-							G_TYPE_NONE
-						};
+								G_TYPE_STRING, 
+								G_TYPE_INT, 
+								G_TYPE_INT, 
+								GDA_TYPE_TIMESTAMP, 
+								G_TYPE_NONE
+							};
 	data_model = gda_connection_statement_execute_select_full (priv->db_connection, 
 												(GdaStatement*)stmt, 
 	    										(GdaSet*)plist,
@@ -5640,7 +5639,7 @@ symbol_db_engine_update_project_symbols (SymbolDBEngine *dbe,
 		const gchar *file_name;
 		gchar *file_abs_path = NULL;
 		struct tm filetm;
-		time_t db_file_time;
+		time_t db_time;
 		GFile *gfile;
 		GFileInfo* gfile_info;
 		GFileInputStream* gfile_is;
@@ -5701,19 +5700,23 @@ symbol_db_engine_update_project_symbols (SymbolDBEngine *dbe,
 		/* fill a struct tm with the date retrieved by the string. */
 		/* string is something like '2007-04-18 23:51:39' */
 		memset (&filetm, 0, sizeof (struct tm));
-		filetm.tm_year = timestamp->year;		
-		filetm.tm_mon = timestamp->month;
+		filetm.tm_year = timestamp->year - 1900;		
+		filetm.tm_mon = timestamp->month - 1;
 		filetm.tm_mday = timestamp->day;
 		filetm.tm_hour = timestamp->hour;
 		filetm.tm_min = timestamp->minute;
 		filetm.tm_sec = timestamp->second;
 
-		/* subtract one hour to the db_file_time. */
-		db_file_time = mktime (&filetm) /*- 3600*/;
-
-
-		if (difftime (db_file_time, g_file_info_get_attribute_uint64 (gfile_info, 
-										  G_FILE_ATTRIBUTE_TIME_MODIFIED)) < 0 ||
+		/* add one hour to the db_file_time. */
+		db_time = mktime (&filetm) - 3600;
+/*
+		DEBUG_PRINT ("%s %d ## %d", file_abs_path, db_time, 
+		    g_file_info_get_attribute_uint64 (gfile_info, 
+										  G_FILE_ATTRIBUTE_TIME_MODIFIED));
+*/
+		guint64 modified_time = g_file_info_get_attribute_uint64 (gfile_info, 
+										  G_FILE_ATTRIBUTE_TIME_MODIFIED);
+		if (difftime (db_time, modified_time) < 0 ||
 		    force_all_files == TRUE)
 		{
 			g_ptr_array_add (files_to_scan, file_abs_path);
diff --git a/plugins/symbol-db/symbol-db-prefs.c b/plugins/symbol-db/symbol-db-prefs.c
index 55e037b..2a1952c 100644
--- a/plugins/symbol-db/symbol-db-prefs.c
+++ b/plugins/symbol-db/symbol-db-prefs.c
@@ -87,6 +87,7 @@ destroy_parseable_data (ParseableData *pdata)
 
 G_DEFINE_TYPE (SymbolDBPrefs, sdb_prefs, G_TYPE_OBJECT);
 
+#if 0
 static void 
 on_prefs_executable_changed (/*GtkFileChooser *chooser,*/ GtkComboBox *chooser,
                              gpointer user_data)
@@ -118,12 +119,14 @@ on_prefs_executable_changed (/*GtkFileChooser *chooser,*/ GtkComboBox *chooser,
 	}
 }
 
+
 static void
 on_notify_prefs (AnjutaPreferences* prefs, const gchar* key,
                  const gchar* value, gpointer user_data)
 {
 	DEBUG_PRINT ("%s", "on_notify_prefs ()");
 }
+#endif
 
 static void
 on_listall_output (AnjutaLauncher * launcher,
@@ -354,12 +357,14 @@ static void
 sdb_prefs_init1 (SymbolDBPrefs *sdbp)
 {
 	SymbolDBPrefsPriv *priv;
-	GtkWidget *fchooser;
+/*	GtkWidget *fchooser;*/
 	gchar *ctags_value;
 
 	priv = sdbp->priv;
 
+#if 0	
 	fchooser = 	GTK_WIDGET (gtk_builder_get_object (priv->prefs_bxml, CTAGS_PREFS));
+#endif	
 	/* we will reactivate it after the listall has been finished */
 	/*gtk_widget_set_sensitive (fchooser, FALSE);*/
 			
@@ -368,7 +373,7 @@ sdb_prefs_init1 (SymbolDBPrefs *sdbp)
 									 BUILDER_ROOT, 
 									 _("Symbol Database"),  
 									 ICON_FILE);
-	
+#if 0	
 	ctags_value = anjuta_preferences_get (priv->prefs, CTAGS_PREFS_KEY);
 	
 	if (ctags_value == NULL || strlen (ctags_value) <= 0) 
@@ -384,25 +389,26 @@ sdb_prefs_init1 (SymbolDBPrefs *sdbp)
 	 * 
 	 */
 	
-#if 0
+
 	/* FIXME: wtf?! */
 	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fchooser), ctags_value);
 	gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (fchooser), ctags_value);
 	
 	g_signal_connect (G_OBJECT (fchooser), "selection-changed",
 					  G_CALLBACK (on_prefs_executable_changed), sdbp);
-#endif
+
 	
 	g_signal_connect (G_OBJECT (fchooser), "changed",
 					  G_CALLBACK (on_prefs_executable_changed), sdbp);	
-	
+
 
 	priv->prefs_notify_id = anjuta_preferences_notify_add_string (priv->prefs, 
 	                                                              CTAGS_PREFS_KEY, 
 	                                                              on_notify_prefs, 
 	                                                              priv->prefs, NULL);
-	
 	g_free (ctags_value);
+#endif		
+	
 }
 
 static void
diff --git a/plugins/symbol-db/symbol-db-prefs.h b/plugins/symbol-db/symbol-db-prefs.h
index 6c464c3..5188e4f 100644
--- a/plugins/symbol-db/symbol-db-prefs.h
+++ b/plugins/symbol-db/symbol-db-prefs.h
@@ -40,8 +40,10 @@ typedef struct _SymbolDBPrefsPriv SymbolDBPrefsPriv;
 #include "symbol-db-system.h"
 
 
+/*
 #define CTAGS_PREFS			 "preferences_entry:text:/usr/bin/ctags:0:symboldb.ctags"
 #define CTAGS_PREFS_KEY		 "symboldb.ctags"
+ */
 #define PROJECT_AUTOSCAN	 "symboldb.scan_prj_pkgs"
 #define PARALLEL_SCAN		 "symboldb.parallel_scan"
 #define BUFFER_AUTOSCAN		 "symboldb.buffer_update"



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