anjuta r4458 - in trunk: . libanjuta plugins/valgrind
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4458 - in trunk: . libanjuta plugins/valgrind
- Date: Fri, 19 Dec 2008 21:33:56 +0000 (UTC)
Author: sgranjoux
Date: Fri Dec 19 21:33:56 2008
New Revision: 4458
URL: http://svn.gnome.org/viewvc/anjuta?rev=4458&view=rev
Log:
* plugins/valgrind/vgdefaultview.c,
plugins/valgrind/plugin.c,
libanjuta/anjuta-utils.c:
#511589 â Anjuta uses GNOME-VFS
Modified:
trunk/ChangeLog
trunk/libanjuta/anjuta-utils.c
trunk/plugins/valgrind/plugin.c
trunk/plugins/valgrind/vgdefaultview.c
Modified: trunk/libanjuta/anjuta-utils.c
==============================================================================
--- trunk/libanjuta/anjuta-utils.c (original)
+++ trunk/libanjuta/anjuta-utils.c Fri Dec 19 21:33:56 2008
@@ -1077,45 +1077,74 @@
return buffer;
}
-/* FIXME: Use gio instead */
/* Diff the text contained in uri with text. Return true if files
-differ, FALSE if they are identical.
-FIXME: Find a better algorithm, this seems ineffective */
+differ, FALSE if they are identical.*/
gboolean anjuta_util_diff(const gchar* uri, const gchar* text)
{
- GnomeVFSFileSize bytes_read;
- gchar* file_text;
- GnomeVFSFileInfo info;
- GnomeVFSHandle* handle = NULL;
-
- gnome_vfs_get_file_info(uri, &info, GNOME_VFS_FILE_INFO_DEFAULT);
-
- if (info.size == 0 && text == NULL)
- return FALSE;
- else if (info.size == 0 || text == NULL)
+ GFile *file;
+ GFileInfo *file_info;
+ guint64 size;
+ gchar* file_text = NULL;
+ gsize bytes_read;
+
+ file = g_file_new_for_uri (uri);
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_SIZE,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+
+ if (file_info == NULL)
+ {
+ g_object_unref (file);
return TRUE;
-
- file_text = g_new0(gchar, info.size + 1);
-
- if (gnome_vfs_open(&handle, uri, GNOME_VFS_OPEN_READ != GNOME_VFS_OK))
+ }
+
+ size = g_file_info_get_attribute_uint64(file_info,
+ G_FILE_ATTRIBUTE_STANDARD_SIZE);
+ g_object_unref (file_info);
+
+ if (size == 0 && text == NULL)
+ {
+ g_object_unref (file);
+ return FALSE;
+ }
+ else if (size == 0 || text == NULL)
+ {
+ g_object_unref (file);
return TRUE;
-
- if ((gnome_vfs_read(handle, file_text, info.size, &bytes_read) == GNOME_VFS_OK)
- && (bytes_read == info.size))
+ }
+
+ if (!g_file_load_contents(file,
+ NULL,
+ &file_text,
+ &bytes_read,
+ NULL,
+ NULL))
{
- gnome_vfs_close(handle);
-
- if ((g_utf8_strlen(file_text, -1) == g_utf8_strlen(text, -1))
- && strcmp(file_text, text) == 0)
- return FALSE;
+ g_object_unref (file);
return TRUE;
}
- else
+ g_object_unref (file);
+
+ if (bytes_read != size)
{
- gnome_vfs_close(handle);
+ g_free (file_text);
return TRUE;
}
+
+ /* according to g_file_load_contents's documentation
+ * file_text is guaranteed to end with \0.
+ */
+ if (strcmp (file_text, text) == 0)
+ {
+ g_free (file_text);
+ return FALSE;
+ }
+
+ g_free (file_text);
+ return TRUE;
}
/**
Modified: trunk/plugins/valgrind/plugin.c
==============================================================================
--- trunk/plugins/valgrind/plugin.c (original)
+++ trunk/plugins/valgrind/plugin.c Fri Dec 19 21:33:56 2008
@@ -22,9 +22,7 @@
*/
#include <config.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-about.h>
#include <libanjuta/anjuta-shell.h>
@@ -79,7 +77,7 @@
if (root_uri)
{
- gchar *root_dir = gnome_vfs_get_local_path_from_uri (root_uri);
+ gchar *root_dir = anjuta_util_get_local_path_from_uri (root_uri);
if (root_dir)
val_plugin->project_root_uri = g_strdup(root_dir);
else
@@ -279,8 +277,11 @@
gchar *program_dir;
SymTab *symtab;
VgToolView *vg_tool_view;
+ GFile *file;
- prgname = gnome_vfs_format_uri_for_display (sel_target);
+ file = g_file_new_for_uri (sel_target);
+ prgname = g_file_get_parse_name (file);
+ g_object_unref (file);
DEBUG_PRINT ("target program selected is %s", prgname);
/* lets set some infos */
@@ -348,7 +349,7 @@
{
GtkWidget *dialog;
gchar* uri = NULL;
- GnomeVFSURI* vfs_uri;
+ GFile* file;
dialog = gtk_file_chooser_dialog_new (_("Choose file where to save Valgrind log"),
NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_SAVE,
@@ -364,8 +365,8 @@
gtk_widget_destroy(dialog);
- vfs_uri = gnome_vfs_uri_new(uri);
- if (gnome_vfs_uri_exists (vfs_uri))
+ file = g_file_new_for_uri (uri);
+ if (g_file_query_exists (file, NULL))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL,
@@ -392,7 +393,7 @@
}
g_free (uri);
- g_free (vfs_uri);
+ g_object_unref (file);
}
static void
Modified: trunk/plugins/valgrind/vgdefaultview.c
==============================================================================
--- trunk/plugins/valgrind/vgdefaultview.c (original)
+++ trunk/plugins/valgrind/vgdefaultview.c Fri Dec 19 21:33:56 2008
@@ -38,7 +38,6 @@
#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/interfaces/ianjuta-document-manager.h>
@@ -621,26 +620,42 @@
VgDefaultView *view = VG_DEFAULT_VIEW (tool);
VgError *err;
GString *str;
+ GFile *file;
+ GFileOutputStream *file_output_stream;
int i;
- GnomeVFSHandle* handle;
if (uri == NULL)
return -1;
+ file = g_file_new_for_uri (uri);
+ file_output_stream = g_file_replace (file,
+ NULL, /* no etag */
+ FALSE, /* no backup */
+ G_FILE_CREATE_NONE,
+ NULL,
+ NULL);
+ g_object_unref (file);
+
/* Create file */
- if (gnome_vfs_create (&handle, uri, GNOME_VFS_OPEN_WRITE, FALSE, 0664) != GNOME_VFS_OK) {
+ if (file_output_stream == NULL) {
return -1;
}
str = g_string_new ("");
for (i = 0; i < view->errors->len; i++) {
- GnomeVFSFileSize written;
+ gsize written;
err = view->errors->pdata[i];
vg_error_to_string (err, str);
- if (gnome_vfs_write (handle, str->str, str->len, &written) != GNOME_VFS_OK) {
+ written = g_output_stream_write (
+ G_OUTPUT_STREAM(file_output_stream),
+ str->str,
+ str->len,
+ NULL,
+ NULL);
+ if (written == -1) {
g_string_free (str, TRUE);
return -1;
}
@@ -648,8 +663,8 @@
}
g_string_free (str, TRUE);
-
- gnome_vfs_close (handle);
+ g_output_stream_close (G_OUTPUT_STREAM(file_output_stream),
+ NULL, NULL);
return 0;
}
@@ -669,7 +684,7 @@
int fd;
gchar *filename;
- filename = gnome_vfs_get_local_path_from_uri (uri);
+ filename = anjuta_util_get_local_path_from_uri (uri);
if ((fd = open (filename, O_RDONLY)) != -1) {
vg_tool_view_connect (tool, fd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]