anjuta r4361 - in trunk: . plugins/symbol-db
- From: mcora svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4361 - in trunk: . plugins/symbol-db
- Date: Sat, 25 Oct 2008 19:01:23 +0000 (UTC)
Author: mcora
Date: Sat Oct 25 19:01:23 2008
New Revision: 4361
URL: http://svn.gnome.org/viewvc/anjuta?rev=4361&view=rev
Log:
* plugins/symbol-db/plugin.c
(on_editor_buffer_symbols_update_timeout),
(on_project_element_added), (on_project_element_removed),
(do_import_system_src_after_abort),
(do_import_project_src_after_abort), (do_import_project_sources),
(on_project_root_added):
* plugins/symbol-db/symbol-db-engine-iterator-node.c:
* plugins/symbol-db/symbol-db-engine.c
(symbol_db_engine_update_project_symbols):
* plugins/symbol-db/symbol-db-engine.h:
ported to GIO. The only file that remains out is symbol-db-system.c: it'll fixed
as soon as my distrib'll give out gnome 2.24 (glib 2.18)
Modified:
trunk/ChangeLog
trunk/plugins/symbol-db/plugin.c
trunk/plugins/symbol-db/symbol-db-engine-iterator-node.c
trunk/plugins/symbol-db/symbol-db-engine-iterator-node.h
trunk/plugins/symbol-db/symbol-db-engine.c
trunk/plugins/symbol-db/symbol-db-engine.h
Modified: trunk/plugins/symbol-db/plugin.c
==============================================================================
--- trunk/plugins/symbol-db/plugin.c (original)
+++ trunk/plugins/symbol-db/plugin.c Sat Oct 25 19:01:23 2008
@@ -24,8 +24,7 @@
#include <config.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <gio/gio.h>
#include <libanjuta/anjuta-shell.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-utils.h>
@@ -98,8 +97,8 @@
IAnjutaEditor *ed;
gchar *current_buffer = NULL;
gint buffer_size = 0;
- gchar *uri = NULL;
gdouble seconds_elapsed;
+ GFile* file;
g_return_val_if_fail (user_data != NULL, FALSE);
@@ -130,28 +129,23 @@
if (sdb_plugin->current_editor)
{
- GFile* file;
ed = IANJUTA_EDITOR (sdb_plugin->current_editor);
buffer_size = ianjuta_editor_get_length (ed, NULL);
current_buffer = ianjuta_editor_get_text_all (ed, NULL);
file = ianjuta_file_get_file (IANJUTA_FILE (ed), NULL);
- uri = g_file_get_uri (file);
- g_object_unref (file);
}
else
return FALSE;
- if (uri)
+ if (file)
{
- DEBUG_PRINT ("uri for buffer updating: %s", uri);
-
GPtrArray *real_files_list;
GPtrArray *text_buffers;
GPtrArray *buffer_sizes;
- gchar * local_path = gnome_vfs_get_local_path_from_uri (uri);
+ gchar * local_path = g_file_get_path (file);
real_files_list = g_ptr_array_new ();
g_ptr_array_add (real_files_list, local_path);
@@ -166,12 +160,11 @@
sdb_plugin->project_opened,
real_files_list,
text_buffers,
- buffer_sizes);
-
- g_free (uri);
+ buffer_sizes);
}
g_free (current_buffer);
+ g_object_unref (file);
sdb_plugin->need_symbols_update = FALSE;
@@ -655,7 +648,8 @@
on_project_element_added (IAnjutaProjectManager *pm, const gchar *uri,
SymbolDBPlugin *sdb_plugin)
{
- gchar *filename;
+ GFile *gfile = NULL;
+ GFileInfo *gfile_info = NULL;
IAnjutaLanguage* lang_manager;
g_return_if_fail (sdb_plugin->project_root_uri != NULL);
@@ -668,15 +662,32 @@
DEBUG_PRINT ("on_project_element_added");
- filename = gnome_vfs_get_local_path_from_uri (uri);
- if (filename)
+ gfile = g_file_new_for_uri (uri);
+
+ if (gfile)
{
+ gchar *filename;
GPtrArray *files_array;
GPtrArray *languages_array;
const gchar* file_mime;
IAnjutaLanguageId lang_id;
const gchar* lang;
- file_mime = gnome_vfs_get_mime_type_for_name (filename);
+
+ gfile_info = g_file_query_info (gfile,
+ "*",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+ if (gfile_info == NULL)
+ {
+ g_object_unref (gfile);
+ return;
+ }
+
+ file_mime = g_file_info_get_attribute_string (gfile_info,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
+
+ DEBUG_PRINT ("got mime %s", file_mime);
lang_id = ianjuta_language_get_from_mime_type (lang_manager, file_mime,
NULL);
@@ -684,7 +695,8 @@
/* No supported language... */
if (!lang_id)
{
- g_free (filename);
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
return;
}
@@ -692,18 +704,25 @@
files_array = g_ptr_array_new();
languages_array = g_ptr_array_new();
+ filename = g_file_get_path (gfile);
+
g_ptr_array_add (files_array, filename);
g_ptr_array_add (languages_array, g_strdup (lang));
symbol_db_engine_add_new_files (sdb_plugin->sdbe_project,
sdb_plugin->project_opened, files_array, languages_array, TRUE);
- g_free (filename);
g_ptr_array_free (files_array, TRUE);
g_ptr_array_foreach (languages_array, (GFunc)g_free, NULL);
g_ptr_array_free (languages_array, TRUE);
}
+
+ if (gfile)
+ g_object_unref (gfile);
+
+ if (gfile_info)
+ g_object_unref (gfile_info);
}
static void
@@ -711,11 +730,14 @@
SymbolDBPlugin *sdb_plugin)
{
gchar *filename;
+ GFile *gfile;
if (!sdb_plugin->project_root_uri)
return;
- filename = gnome_vfs_get_local_path_from_uri (uri);
+ gfile = g_file_new_for_uri (uri);
+ filename = g_file_get_path (gfile);
+
if (filename)
{
DEBUG_PRINT ("on_project_element_removed");
@@ -725,6 +747,8 @@
g_free (filename);
}
+
+ g_object_unref (gfile);
}
static void
@@ -939,28 +963,57 @@
const gchar *file_mime;
const gchar *lang;
const gchar *local_filename;
+ GFile *gfile;
+ GFileInfo *gfile_info;
IAnjutaLanguageId lang_id;
local_filename = g_ptr_array_index (sources_array, i);
if (local_filename == NULL)
continue;
- file_mime = gnome_vfs_get_mime_type_for_name (local_filename);
+
+ gfile = g_file_new_for_path (local_filename);
+ if (gfile == NULL)
+ continue;
+
+ gfile_info = g_file_query_info (gfile,
+ "*",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+ if (gfile_info == NULL)
+ {
+ g_object_unref (gfile);
+ continue;
+ }
+
+ file_mime = g_file_info_get_attribute_string (gfile_info,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
lang_id = ianjuta_language_get_from_mime_type (lang_manager,
file_mime, NULL);
- if (!lang_id)
+ if (!lang_id)
+ {
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
continue;
+ }
lang = ianjuta_language_get_name (lang_manager, lang_id, NULL);
/* test its existence */
- if (g_file_test (local_filename, G_FILE_TEST_EXISTS) == FALSE)
+ if (g_file_test (local_filename, G_FILE_TEST_EXISTS) == FALSE)
+ {
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
continue;
+ }
g_ptr_array_add (languages_array, g_strdup (lang));
g_ptr_array_add (to_scan_array, g_strdup (local_filename));
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
}
symbol_db_system_parse_aborted_package (sdb_plugin->sdbs,
@@ -1004,19 +1057,40 @@
const gchar *file_mime;
const gchar *lang;
const gchar *local_filename;
+ GFile *gfile;
+ GFileInfo *gfile_info;
IAnjutaLanguageId lang_id;
local_filename = g_ptr_array_index (sources_array, i);
if (local_filename == NULL)
continue;
- file_mime = gnome_vfs_get_mime_type_for_name (local_filename);
+
+ gfile = g_file_new_for_path (local_filename);
+ if (gfile == NULL)
+ continue;
+
+ gfile_info = g_file_query_info (gfile,
+ "*",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+ if (gfile_info == NULL)
+ {
+ g_object_unref (gfile);
+ continue;
+ }
+
+ file_mime = g_file_info_get_attribute_string (gfile_info,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
lang_id = ianjuta_language_get_from_mime_type (lang_manager,
file_mime, NULL);
if (!lang_id)
{
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
continue;
}
@@ -1025,12 +1099,16 @@
/* test its existence */
if (g_file_test (local_filename, G_FILE_TEST_EXISTS) == FALSE)
{
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
continue;
}
sdb_plugin->files_count_project++;
g_ptr_array_add (languages_array, g_strdup (lang));
g_ptr_array_add (to_scan_array, g_strdup (local_filename));
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
}
/* connect to receive signals on single file scan complete. We'll
@@ -1113,13 +1191,28 @@
const gchar *file_mime;
const gchar *lang;
IAnjutaLanguageId lang_id;
-
- local_filename =
- gnome_vfs_get_local_path_from_uri (g_list_nth_data (
+ GFile *gfile = NULL;
+ GFileInfo *gfile_info;
+
+ gfile = g_file_new_for_uri (g_list_nth_data (
prj_elements_list, i));
+ if (gfile == NULL)
+ {
+ continue;
+ }
+
+
+ local_filename = g_file_get_path (gfile);
+/* DEBUG_PRINT ("local_filename %s [was %s]", local_filename, g_list_nth_data (
+ prj_elements_list, i));*/
- if (local_filename == NULL)
+ if (local_filename == NULL ||
+ g_file_test (local_filename, G_FILE_TEST_EXISTS) == FALSE)
+ {
+ if (gfile)
+ g_object_unref (gfile);
continue;
+ }
/* check if it's already present in the list. This avoids
* duplicates.
@@ -1136,9 +1229,28 @@
/* you're a dup! we don't want you */
g_free (local_filename);
continue;
+ }
+
+ if (gfile == NULL)
+ {
+ g_free (local_filename);
+ continue;
}
-
- file_mime = gnome_vfs_get_mime_type_for_name (local_filename);
+
+ gfile_info = g_file_query_info (gfile,
+ "*",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+ if (gfile_info == NULL)
+ {
+ g_free (local_filename);
+ g_object_unref (gfile);
+ continue;
+ }
+
+ file_mime = g_file_info_get_attribute_string (gfile_info,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
lang_id = ianjuta_language_get_from_mime_type (lang_manager,
file_mime, NULL);
@@ -1146,18 +1258,13 @@
if (!lang_id)
{
g_free (local_filename);
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
continue;
}
-
+
lang = ianjuta_language_get_name (lang_manager, lang_id, NULL);
- DEBUG_PRINT ("Language of %s is %s", local_filename, file_mime);
- /* test its existence */
- if (g_file_test (local_filename, G_FILE_TEST_EXISTS) == FALSE)
- {
- g_free (local_filename);
- continue;
- }
-
+
if (!sources_array)
sources_array = g_ptr_array_new ();
@@ -1167,6 +1274,8 @@
sdb_plugin->files_count_project++;
g_ptr_array_add (sources_array, local_filename);
g_ptr_array_add (languages_array, g_strdup (lang));
+ g_object_unref (gfile);
+ g_object_unref (gfile_info);
}
DEBUG_PRINT ("calling symbol_db_engine_add_new_files with root_dir %s",
@@ -1178,9 +1287,12 @@
g_signal_connect (G_OBJECT (sdb_plugin->sdbe_project), "single-file-scan-end",
G_CALLBACK (on_project_single_file_scan_end), plugin);
- symbol_db_engine_add_new_files (sdb_plugin->sdbe_project,
- sdb_plugin->project_opened,
- sources_array, languages_array, TRUE);
+ if (sources_array == NULL || languages_array == NULL)
+ g_warning ("source or language arrays are NULL. Could not import project's files.");
+ else
+ symbol_db_engine_add_new_files (sdb_plugin->sdbe_project,
+ sdb_plugin->project_opened,
+ sources_array, languages_array, TRUE);
g_hash_table_unref (check_unique_file);
@@ -1413,10 +1525,16 @@
if (root_uri)
{
- gchar *root_dir = gnome_vfs_get_local_path_from_uri (root_uri);
+ gchar *root_dir;
+ GFile *gfile;
+ gfile = g_file_new_for_uri (root_uri);
+
+ root_dir = g_file_get_path (gfile);
DEBUG_PRINT ("Symbol-DB: added project root_dir %s, name %s", root_dir,
name);
+ g_object_unref (gfile);
+
/* FIXME: where's the project name itself? */
DEBUG_PRINT ("FIXME: where's the project name itself? ");
sdb_plugin->project_opened = g_strdup (root_dir);
@@ -1476,8 +1594,7 @@
{
/*
* no import needed. But we may have aborted the scan of sources ..
- */
-
+ */
GPtrArray *sources_array = NULL;
sources_array =
Modified: trunk/plugins/symbol-db/symbol-db-engine-iterator-node.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-iterator-node.c (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-iterator-node.c Sat Oct 25 19:01:23 2008
@@ -25,7 +25,6 @@
#include <libanjuta/interfaces/ianjuta-symbol.h>
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/anjuta-debug.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "symbol-db-engine-iterator-node.h"
#include "symbol-db-engine.h"
Modified: trunk/plugins/symbol-db/symbol-db-engine-iterator-node.h
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-iterator-node.h (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-iterator-node.h Sat Oct 25 19:01:23 2008
@@ -53,7 +53,7 @@
GObjectClass parent_class;
};
-
+
GType sdb_engine_iterator_node_get_type (void) G_GNUC_CONST;
gint
Modified: trunk/plugins/symbol-db/symbol-db-engine.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine.c (original)
+++ trunk/plugins/symbol-db/symbol-db-engine.c Sat Oct 25 19:01:23 2008
@@ -109,7 +109,7 @@
#include <fcntl.h> /* For O_* constants */
#include <string.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
#include <libanjuta/interfaces/ianjuta-symbol.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-launcher.h>
@@ -5461,8 +5461,12 @@
SymbolDBEnginePriv *priv;
g_return_val_if_fail (dbe != NULL, FALSE);
- g_return_val_if_fail (project != NULL, FALSE);
+
priv = dbe->priv;
+
+ g_return_val_if_fail (project != NULL, FALSE);
+ g_return_val_if_fail (priv->project_directory != NULL, FALSE);
+
value = gda_value_new (G_TYPE_STRING);
g_value_set_static_string (value, project);
@@ -5523,12 +5527,13 @@
{
const GValue *value, *value1;
const gchar *file_name;
- gchar *file_abs_path;
+ gchar *file_abs_path = NULL;
struct tm filetm;
time_t db_file_time;
gchar *date_string;
- gchar *abs_vfs_path;
- GnomeVFSHandle *handle;
+ GFile *gfile;
+ GFileInfo* gfile_info;
+ GFileInputStream* gfile_is;
if ((value =
gda_data_model_get_value_at (data_model,
@@ -5543,44 +5548,33 @@
file_name = g_value_get_string (value);
if (priv->project_directory != NULL)
{
- /* FIXME */
- abs_vfs_path = g_strdup_printf ("file://%s%s", priv->project_directory,
- file_name);
file_abs_path = g_strdup_printf ("%s%s", priv->project_directory,
file_name);
}
- else
- {
- /* FIXME */
- abs_vfs_path = g_strdup_printf ("file://%s", file_name);
- file_abs_path = g_strdup (file_name);
- }
-
- GnomeVFSURI *uri = gnome_vfs_uri_new (abs_vfs_path);
- GnomeVFSFileInfo *file_info = gnome_vfs_file_info_new ();
+ gfile = g_file_new_for_path (file_abs_path);
+ if (gfile == NULL)
+ continue;
+
+ gfile_is = g_file_read (gfile, NULL, NULL);
/* retrieve data/time info */
- if (gnome_vfs_open_uri (&handle, uri,
- GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM) !=
- GNOME_VFS_OK)
- {
- g_message ("could not open URI %s", abs_vfs_path);
- gnome_vfs_uri_unref (uri);
- gnome_vfs_file_info_unref (file_info);
- g_free (abs_vfs_path);
+ if (gfile_is == NULL)
+ {
+ g_message ("could not open path %s", file_abs_path);
g_free (file_abs_path);
+ g_object_unref (gfile);
continue;
}
+ g_object_unref (gfile_is);
+
+ gfile_info = g_file_query_info (gfile, "*", G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
- if (gnome_vfs_get_file_info_from_handle (handle, file_info,
- GNOME_VFS_FILE_INFO_DEFAULT) !=
- GNOME_VFS_OK)
+ if (gfile_info == NULL)
{
g_message ("cannot get file info from handle");
- gnome_vfs_close (handle);
- gnome_vfs_uri_unref (uri);
- gnome_vfs_file_info_unref (file_info);
g_free (file_abs_path);
+ g_object_unref (gfile);
continue;
}
@@ -5616,19 +5610,15 @@
/* subtract one hour to the db_file_time. */
db_file_time = mktime (&filetm) /*- 3600*/;
- if (difftime (db_file_time, file_info->mtime) < 0)
+
+ if (difftime (db_file_time, g_file_info_get_attribute_uint32 (gfile_info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED)) < 0)
{
-/* g_message ("FILES TO BE UPDATED ===> : %s [diff time %f] date string is %s",
- file_name, difftime (db_file_time, file_info->mtime),
- date_string);
-*/
g_ptr_array_add (files_to_scan, file_abs_path);
}
- gnome_vfs_close (handle);
- gnome_vfs_uri_unref (uri);
- gnome_vfs_file_info_unref (file_info);
- g_free (abs_vfs_path);
+ g_object_unref (gfile_info);
+ g_object_unref (gfile);
/* no need to free file_abs_path, it's been added to files_to_scan */
}
@@ -5739,7 +5729,7 @@
/* Update symbols of a file by a memory-buffer to perform a real-time updating
* of symbols.
* real_files_list: full path on disk to 'real file' to update. e.g.
- * /home/foouser/fooproject/src/main.c
+ * /home/foouser/fooproject/src/main.c. They'll be freed inside this function.
*/
gboolean
symbol_db_engine_update_buffer_symbols (SymbolDBEngine * dbe, const gchar *project,
Modified: trunk/plugins/symbol-db/symbol-db-engine.h
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine.h (original)
+++ trunk/plugins/symbol-db/symbol-db-engine.h Sat Oct 25 19:01:23 2008
@@ -221,6 +221,8 @@
/**
* Update symbols of a file by a memory-buffer to perform a real-time updating
* of symbols.
+ * real_files_list: full path on disk to 'real file' to update. e.g.
+ * /home/foouser/fooproject/src/main.c. They'll be freed inside this function.
*/
gboolean
symbol_db_engine_update_buffer_symbols (SymbolDBEngine * dbe, const gchar * project,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]