anjuta r4046 - in trunk: . plugins/document-manager plugins/file-manager plugins/project-manager plugins/sourceview plugins/symbol-browser



Author: jhs
Date: Fri Jul  4 15:54:00 2008
New Revision: 4046
URL: http://svn.gnome.org/viewvc/anjuta?rev=4046&view=rev

Log:
2008-07-04  Johannes Schmid  <jhs gnome org>

	* plugins/document-manager/action-callbacks.c
	(on_close_file_activate):
	* plugins/document-manager/anjuta-docman.c:
	* plugins/project-manager/plugin.c (value_added_current_editor):
	* plugins/symbol-browser/plugin.c (value_added_current_editor):
	Fixed GFile* related stuff
	
	* plugins/file-manager/file-model.c (file_model_update_file):
	Do not unref GIcon* as it is owned by GFileInfo*
	
	* plugins/sourceview/anjuta-document-loader.c:
	* plugins/sourceview/anjuta-document-loader.h:
	* plugins/sourceview/anjuta-document-saver.c:
	* plugins/sourceview/anjuta-document-saver.h:
	* plugins/sourceview/anjuta-document.c:
	* plugins/sourceview/anjuta-document.h:
	* plugins/sourceview/anjuta-utils.c:
	* plugins/sourceview/anjuta-utils.h:
	Deleted old (gedit) gnome-vfs stuff.
	
	* plugins/sourceview/sourceview.io.c
	* plugins/sourceview/sourceview.io.h:
	New helper class that takes care of file saving/loading
	and is much smaller than the gnome-vfs stuff as many things are
	handled by gio now.
	
	* plugins/sourceview/Makefile.am:
	* plugins/sourceview/anjuta-view.c (anjuta_view_new),
	(anjuta_view_cut_clipboard), (anjuta_view_paste_clipboard),
	(anjuta_view_delete_selection), (anjuta_view_expose):
	* plugins/sourceview/anjuta-view.h:
	* plugins/sourceview/sourceview-private.h:
	* plugins/sourceview/sourceview.c (sourceview_create_markers),
	(sourceview_create_highligth_indic), (goto_line),
	(on_document_modified_changed), (on_mark_set),
	(on_reload_dialog_response), (on_file_changed), (on_open_failed),
	(on_open_finish), (on_save_failed), (on_save_finish),
	(sourceview_instance_init), (sourceview_dispose),
	(sourceview_finalize), (sourceview_new), (ifile_open),
	(ifile_get_file), (ifile_savable_save), (ifile_savable_save_as),
	(ieditor_goto_line), (wordcharacters_contains),
	(ieditor_get_current_word), (idocument_get_filename), (mark_real),
	(autodetect_language), (ihover_iface_init):
	Adapted to use the new IO class, clean up a bit

Added:
   trunk/plugins/sourceview/sourceview-io.c
   trunk/plugins/sourceview/sourceview-io.h
Removed:
   trunk/plugins/sourceview/anjuta-document-loader.c
   trunk/plugins/sourceview/anjuta-document-loader.h
   trunk/plugins/sourceview/anjuta-document-saver.c
   trunk/plugins/sourceview/anjuta-document-saver.h
   trunk/plugins/sourceview/anjuta-document.c
   trunk/plugins/sourceview/anjuta-document.h
   trunk/plugins/sourceview/anjuta-utils.c
   trunk/plugins/sourceview/anjuta-utils.h
Modified:
   trunk/ChangeLog
   trunk/plugins/document-manager/action-callbacks.c
   trunk/plugins/document-manager/anjuta-docman.c
   trunk/plugins/file-manager/file-model.c
   trunk/plugins/project-manager/plugin.c
   trunk/plugins/sourceview/Makefile.am
   trunk/plugins/sourceview/anjuta-view.c
   trunk/plugins/sourceview/anjuta-view.h
   trunk/plugins/sourceview/sourceview-private.h
   trunk/plugins/sourceview/sourceview.c
   trunk/plugins/symbol-browser/plugin.c

Modified: trunk/plugins/document-manager/action-callbacks.c
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.c	(original)
+++ trunk/plugins/document-manager/action-callbacks.c	Fri Jul  4 15:54:00 2008
@@ -191,7 +191,13 @@
 		/* Prompt for unsaved data */
 		save_prompt = anjuta_save_prompt_new (GTK_WINDOW (parent));
 		file = ianjuta_file_get_file (IANJUTA_FILE (doc), NULL);
-		uri = g_file_get_uri (file);
+		if (file)
+		{
+			uri = g_file_get_uri (file);
+			g_object_unref (file);
+		}
+		else
+			uri = NULL;
 		/* NULL uri ok */
 		anjuta_save_prompt_add_item (save_prompt,
 									 ianjuta_document_get_filename (doc, NULL),

Modified: trunk/plugins/document-manager/anjuta-docman.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-docman.c	(original)
+++ trunk/plugins/document-manager/anjuta-docman.c	Fri Jul  4 15:54:00 2008
@@ -30,9 +30,6 @@
 #include <libanjuta/interfaces/ianjuta-editor-factory.h>
 
 #include <gtk/gtkfilechooserdialog.h>
-#include <libgnomevfs/gnome-vfs.h>
-
-#include <gdl/gdl-icons.h>
 
 #include "anjuta-docman.h"
 #include "file_history.h"

Modified: trunk/plugins/file-manager/file-model.c
==============================================================================
--- trunk/plugins/file-manager/file-model.c	(original)
+++ trunk/plugins/file-manager/file-model.c	Fri Jul  4 15:54:00 2008
@@ -128,7 +128,6 @@
 											GTK_ICON_LOOKUP_GENERIC_FALLBACK);
 	pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
 	gtk_icon_info_free(icon_info);
-	g_object_unref (icon);
 	
 	if (g_file_info_get_file_type(file_info) == G_FILE_TYPE_DIRECTORY)
 		is_dir = TRUE;

Modified: trunk/plugins/project-manager/plugin.c
==============================================================================
--- trunk/plugins/project-manager/plugin.c	(original)
+++ trunk/plugins/project-manager/plugin.c	Fri Jul  4 15:54:00 2008
@@ -1077,7 +1077,13 @@
 	if (pm_plugin->current_editor_uri)
 		g_free (pm_plugin->current_editor_uri);
 	file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
-	pm_plugin->current_editor_uri = g_file_get_uri (file);
+	if (file)
+	{
+		pm_plugin->current_editor_uri = g_file_get_uri (file);
+		g_object_unref (file);
+	}
+	else
+		pm_plugin->current_editor_uri = NULL;
 
 }
 

Modified: trunk/plugins/sourceview/Makefile.am
==============================================================================
--- trunk/plugins/sourceview/Makefile.am	(original)
+++ trunk/plugins/sourceview/Makefile.am	Fri Jul  4 15:54:00 2008
@@ -59,14 +59,6 @@
 	assist-window.c \
 	anjuta-view.h \
 	anjuta-view.c \
-	anjuta-document-loader.c \
-	anjuta-document-loader.h \
-	anjuta-document-saver.c \
-	anjuta-document-saver.h \
-	anjuta-document.c \
-	anjuta-document.h \
-	anjuta-utils.h \
-	anjuta-utils.c \
 	sourceview-prefs.h \
 	sourceview-prefs.c \
 	sourceview-private.h \
@@ -75,7 +67,9 @@
 	sourceview-print.h \
 	sourceview-print.c \
 	assist-tip.h \
-	assist-tip.c
+	assist-tip.c \
+	sourceview-io.h \
+	sourceview-io.c
 
 libanjuta_sourceview_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 

Modified: trunk/plugins/sourceview/anjuta-view.c
==============================================================================
--- trunk/plugins/sourceview/anjuta-view.c	(original)
+++ trunk/plugins/sourceview/anjuta-view.c	Fri Jul  4 15:54:00 2008
@@ -103,15 +103,6 @@
 }
 
 static void
-document_read_only_notify_handler (AnjutaDocument *document, 
-			           GParamSpec    *pspec,
-				   AnjutaView     *view)
-{
-	gtk_text_view_set_editable (GTK_TEXT_VIEW (view), 
-				    !anjuta_document_get_readonly (document));
-}
-
-static void
 anjuta_view_set_property (GObject * object,
 			   guint property_id,
 			   const GValue * value, GParamSpec * pspec)
@@ -383,20 +374,10 @@
 {
 	GtkWidget *view;
 
-	g_return_val_if_fail (ANJUTA_IS_DOCUMENT (sv->priv->document), NULL);
-
 	view = GTK_WIDGET (g_object_new (ANJUTA_TYPE_VIEW, NULL));
 	
 	gtk_text_view_set_buffer (GTK_TEXT_VIEW (view),
 				  GTK_TEXT_BUFFER (sv->priv->document));
-  		
-	g_signal_connect (sv->priv->document,
-			  "notify::read-only",
-			  G_CALLBACK (document_read_only_notify_handler),
-			  view);
-
-	gtk_text_view_set_editable (GTK_TEXT_VIEW (view), 
-				    !anjuta_document_get_readonly (sv->priv->document));					  
 
 	gtk_widget_show_all (view);
 
@@ -422,8 +403,7 @@
 	/* FIXME: what is default editability of a buffer? */
   	gtk_text_buffer_cut_clipboard (buffer,
   				       clipboard,
-				       !anjuta_document_get_readonly (
-				       		ANJUTA_DOCUMENT (buffer)));
+				       TRUE);
   	
 	gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
 				      gtk_text_buffer_get_insert (buffer),
@@ -470,8 +450,7 @@
   	gtk_text_buffer_paste_clipboard (buffer,
 					 clipboard,
 					 NULL,
-					 !anjuta_document_get_readonly (
-						ANJUTA_DOCUMENT (buffer)));
+					 TRUE);
 
 	gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
 				      gtk_text_buffer_get_insert (buffer),
@@ -494,8 +473,7 @@
 	/* FIXME: what is default editability of a buffer? */
 	gtk_text_buffer_delete_selection (buffer,
 					  TRUE,
-					  !anjuta_document_get_readonly (
-						ANJUTA_DOCUMENT (buffer)));
+					  TRUE);
 						
 	gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
 				      gtk_text_buffer_get_insert (buffer),
@@ -569,11 +547,11 @@
                    GdkEventExpose *event)
 {
 	GtkTextView *text_view;
-	AnjutaDocument *doc;
+	GtkTextBuffer *doc;
 	
 	text_view = GTK_TEXT_VIEW (widget);
 	
-	doc = ANJUTA_DOCUMENT (gtk_text_view_get_buffer (text_view));
+	doc = gtk_text_view_get_buffer (text_view);
 	
 	if ((event->window == gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT)))
 	{

Modified: trunk/plugins/sourceview/anjuta-view.h
==============================================================================
--- trunk/plugins/sourceview/anjuta-view.h	(original)
+++ trunk/plugins/sourceview/anjuta-view.h	Fri Jul  4 15:54:00 2008
@@ -33,7 +33,6 @@
 
 #include <gtk/gtk.h>
 
-#include "anjuta-document.h"
 #include "sourceview.h"
 #include <gtksourceview/gtksourceview.h>
 
@@ -74,7 +73,7 @@
 {
 	GtkSourceViewClass parent_class;
 	
-	void (* char_added)  		(AnjutaDocument    *document,
+	void (* char_added)  		(GtkTextBuffer    *document,
 								 gint position,
 								 gchar character);
 };

Added: trunk/plugins/sourceview/sourceview-io.c
==============================================================================
--- (empty file)
+++ trunk/plugins/sourceview/sourceview-io.c	Fri Jul  4 15:54:00 2008
@@ -0,0 +1,500 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta-trunk
+ * Copyright (C) Johannes Schmid 2008 <jhs gnome org>
+ * 
+ * anjuta-trunk is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta-trunk is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "sourceview-io.h"
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/anjuta-convert.h>
+#include <libanjuta/anjuta-encodings.h>
+#include <sourceview-private.h>
+
+#define READ_SIZE 4096
+#define RATE_LIMIT 5000 /* Use a big rate limit to avoid duplicates */
+#define TIMEOUT 5
+
+enum
+{
+	SAVE_STATUS,
+	SAVE_FINISHED,
+	OPEN_STATUS,
+	OPEN_FINISHED,
+	OPEN_FAILED,
+	SAVE_FAILED,
+
+	LAST_SIGNAL
+};
+
+#define IO_ERROR_QUARK g_quark_from_string ("SourceviewIO-Error")
+
+static guint io_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (SourceviewIO, sourceview_io, G_TYPE_OBJECT);
+
+static void
+sourceview_io_init (SourceviewIO *object)
+{
+	object->file = NULL;
+	object->filename = NULL;
+	object->read_buffer = NULL;
+	object->write_buffer = NULL;
+	object->cancel = g_cancellable_new();
+	object->monitor = NULL;
+}
+
+static void
+sourceview_io_finalize (GObject *object)
+{
+	SourceviewIO* sio = SOURCEVIEW_IO(object);
+	if (sio->file)
+		g_object_unref (sio->file);
+	g_free(sio->filename);
+	g_free(sio->read_buffer);
+	g_free(sio->write_buffer);
+	g_object_unref (sio->cancel);
+	if (sio->monitor_idle > 0)
+		g_source_remove (sio->monitor_idle);
+	if (sio->monitor)
+		g_object_unref (sio->monitor);
+	
+	G_OBJECT_CLASS (sourceview_io_parent_class)->finalize (object);
+}
+
+static void
+sourceview_io_class_init (SourceviewIOClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	GObjectClass* parent_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = sourceview_io_finalize;
+
+	klass->changed = NULL;
+	klass->save_finished = NULL;
+	klass->open_finished = NULL;
+	klass->open_failed = NULL;
+	klass->save_failed = NULL;
+
+	io_signals[SAVE_STATUS] =
+		g_signal_new ("changed",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              0,
+		              G_STRUCT_OFFSET (SourceviewIOClass, changed),
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__VOID,
+		              G_TYPE_NONE, 0,
+		              NULL);
+
+	io_signals[SAVE_FINISHED] =
+		g_signal_new ("save-finished",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              0,
+		              G_STRUCT_OFFSET (SourceviewIOClass, save_finished),
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__VOID,
+		              G_TYPE_NONE, 0,
+		              NULL);
+
+	io_signals[OPEN_FINISHED] =
+		g_signal_new ("open-finished",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              0,
+		              G_STRUCT_OFFSET (SourceviewIOClass, open_finished),
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__VOID,
+		              G_TYPE_NONE, 0,
+		              NULL);
+
+	io_signals[OPEN_FAILED] =
+		g_signal_new ("open-failed",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              0,
+		              G_STRUCT_OFFSET (SourceviewIOClass, open_failed),
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__POINTER,
+		              G_TYPE_NONE, 1,
+		              G_TYPE_POINTER);
+
+	io_signals[SAVE_FAILED] =
+		g_signal_new ("save-failed",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              0,
+		              G_STRUCT_OFFSET (SourceviewIOClass, save_failed),
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__POINTER,
+		              G_TYPE_NONE, 1,
+		              G_TYPE_POINTER);
+}
+
+static void on_file_changed (GFileMonitor* monitor, 
+							 GFile* file,
+							 GFile* other_file,
+							 GFileMonitorEvent event_type,
+							 gpointer data)
+{
+	SourceviewIO* sio = SOURCEVIEW_IO(data);
+	
+	g_signal_emit_by_name (sio, "changed");
+}
+
+static gboolean
+setup_monitor_idle(gpointer data)
+{
+	SourceviewIO* sio = SOURCEVIEW_IO(data);
+	sio->monitor_idle = 0;
+	if (sio->monitor != NULL)
+		g_object_unref (sio->monitor);
+	sio->monitor = g_file_monitor_file (sio->file,
+										G_FILE_MONITOR_NONE,
+										NULL,
+										NULL);
+	if (sio->monitor)
+	{
+		g_signal_connect (sio->monitor, "changed", 
+						  G_CALLBACK(on_file_changed), sio);
+		g_file_monitor_set_rate_limit (sio->monitor, RATE_LIMIT);
+	}
+	return FALSE;
+}
+
+static void
+setup_monitor(SourceviewIO* sio)
+{
+	if (sio->monitor_idle > 0)
+		g_source_remove (sio->monitor_idle);
+	
+	sio->monitor_idle = g_timeout_add_seconds (TIMEOUT,
+											   setup_monitor_idle,
+											   sio);
+}
+
+static void
+cancel_monitor (SourceviewIO* sio)
+{
+	if (sio->monitor != NULL)
+		g_object_unref (sio->monitor);
+	sio->monitor = NULL;
+}
+
+static void
+set_display_name (SourceviewIO* sio)
+{
+	GFileInfo* file_info = g_file_query_info (sio->file,
+											  G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+											  G_FILE_QUERY_INFO_NONE,
+											  NULL,
+											  NULL);
+	if (file_info)
+	{
+		g_free (sio->filename);
+		sio->filename = g_strdup(g_file_info_get_display_name (file_info));
+	}
+	else
+	{
+		g_free (sio->filename);
+		sio->filename = NULL;
+	}
+	
+}
+
+static void
+on_save_finished (GObject* output_stream, GAsyncResult* result, gpointer data)
+{
+	SourceviewIO* sio = SOURCEVIEW_IO(data);
+	GError* err = NULL;
+	g_output_stream_write_finish (G_OUTPUT_STREAM(output_stream),
+								  result,
+								  &err);
+	if (err)
+	{
+		g_signal_emit_by_name (sio, "save-failed", err);
+		g_error_free (err);
+	}
+	else
+	{
+		set_display_name (sio);
+		g_signal_emit_by_name (sio, "save-finished");
+		g_output_stream_close(G_OUTPUT_STREAM (output_stream), NULL, NULL);
+		setup_monitor (sio);
+	}
+	g_free (sio->write_buffer);
+	sio->write_buffer = NULL;
+	g_object_unref (output_stream);
+}
+
+void
+sourceview_io_save (SourceviewIO* sio)
+{
+	if (!sio->file)
+	{
+		GError* error = NULL;
+		g_set_error (&error, IO_ERROR_QUARK, 0, 
+					 _("Could not save file because filename not yet specified"));
+		g_signal_emit_by_name (sio, "save-failed", error);
+		g_error_free(error);
+	}
+	else
+		sourceview_io_save_as (sio, sio->file);
+}
+
+void
+sourceview_io_save_as (SourceviewIO* sio, GFile* file)
+{
+	GFileOutputStream* output_stream;
+	GError* err = NULL;
+	g_return_if_fail (file != NULL);
+	
+	cancel_monitor (sio);
+	
+	output_stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &err);
+	if (!output_stream)
+	{
+		if (err->code != G_IO_ERROR_EXISTS)
+		{
+			g_signal_emit_by_name (sio, "save-failed", err);
+			g_error_free (err);
+			return;
+		}
+		else
+		{
+			output_stream = g_file_replace (file, NULL, TRUE, G_FILE_CREATE_NONE,
+											NULL, NULL);
+			if (!output_stream)
+			{
+				g_signal_emit_by_name (sio, "save-failed", err);
+				g_error_free (err);
+				return;
+			}
+		}
+	}
+	sio->write_buffer = ianjuta_editor_get_text_all (IANJUTA_EDITOR(sio->sv), 
+													 NULL);
+	g_cancellable_reset (sio->cancel);
+	g_output_stream_write_async (G_OUTPUT_STREAM (output_stream),
+								 sio->write_buffer,
+								 strlen (sio->write_buffer),
+								 G_PRIORITY_LOW,
+								 sio->cancel,
+								 on_save_finished,
+								 sio);
+	
+	if (sio->file != file)
+	{
+		if (sio->file)
+			g_object_unref (sio->file);
+		sio->file = file;
+		g_object_ref (file);
+	}
+}
+
+static void insert_text_in_document(SourceviewIO* sio, const gchar* text, gsize len)
+{
+	GtkSourceBuffer* document = GTK_SOURCE_BUFFER (sio->sv->priv->document);
+	gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER (sio->sv->priv->document));
+
+	/* Insert text in the buffer */
+	ianjuta_editor_append (IANJUTA_EDITOR(sio->sv), 
+						   text,
+						   len,
+						   NULL);
+
+	gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (document),
+				      FALSE);
+
+	gtk_source_buffer_end_not_undoable_action (document);
+}
+
+static void
+append_buffer (SourceviewIO* sio, gsize size)
+{
+	/* Text is utf-8 - good */
+	if (g_utf8_validate (sio->read_buffer, size, NULL))
+	{
+		insert_text_in_document (sio, sio->read_buffer, size);
+	}
+	else
+	{
+		/* Text is not utf-8 */
+		GError *conv_error = NULL;
+		gchar *converted_text = NULL;
+		gsize new_len = size;
+		const AnjutaEncoding* enc = NULL;
+			
+		converted_text = anjuta_convert_to_utf8 (sio->read_buffer,
+												 size,
+												 &enc,
+												 &new_len,
+												 &conv_error);
+		if  (converted_text == NULL)	
+		{
+			/* Last change, let's try 8859-15 */
+			enc = anjuta_encoding_get_from_charset( "ISO-8859-15");
+			
+			converted_text = anjuta_convert_to_utf8 (sio->read_buffer,
+													 size,
+													 &enc,
+													 &new_len,
+													 &conv_error);
+		}
+		if (converted_text == NULL)
+		{
+			g_return_if_fail (conv_error != NULL);
+			
+			g_signal_emit_by_name (sio, "open-failed", conv_error);
+			g_error_free (conv_error);
+			g_cancellable_cancel (sio->cancel);
+			return;
+		}
+		insert_text_in_document (sio, converted_text, new_len);
+		g_free (converted_text);
+	}
+}
+
+static void
+on_read_finished (GObject* input, GAsyncResult* result, gpointer data)
+{
+	SourceviewIO* sio = SOURCEVIEW_IO(data);
+	GInputStream* input_stream = G_INPUT_STREAM(input);
+	gsize bytes_read;
+	GError* err = NULL;
+	
+	bytes_read = g_input_stream_read_finish (input_stream, result, &err);
+	if (err)
+	{
+		g_signal_emit_by_name (sio, "open-failed", err);
+		g_error_free (err);
+		g_object_unref (input_stream);
+		return;
+	}
+	append_buffer (sio, bytes_read);
+	if (bytes_read == READ_SIZE)
+	{
+		g_input_stream_read_async (G_INPUT_STREAM (input_stream),
+								   sio->read_buffer,
+								   READ_SIZE,
+								   G_PRIORITY_LOW,
+								   sio->cancel,
+								   on_read_finished,
+								   sio);
+		return;
+	}
+	else
+	{
+		g_signal_emit_by_name (sio, "open-finished");
+		g_object_unref (input_stream);
+		setup_monitor (sio);
+		g_free (sio->read_buffer);
+		sio->read_buffer = NULL;
+	}
+}
+
+void
+sourceview_io_open (SourceviewIO* sio, GFile* file)
+{
+	GFileInputStream* input_stream;
+	GError* err = NULL;
+	
+	g_return_if_fail (file != NULL);
+	
+	if (sio->file)
+		g_object_unref (sio->file);
+	sio->file = file;
+	g_object_ref (sio->file);
+	set_display_name(sio);
+	
+	input_stream = g_file_read (file, NULL, &err);
+	if (!input_stream)
+	{
+		g_signal_emit_by_name (sio, "open-failed", err);
+		g_error_free (err);
+		return;
+	}
+	sio->read_buffer = g_new(gchar, READ_SIZE);
+	g_input_stream_read_async (G_INPUT_STREAM (input_stream),
+							   sio->read_buffer,
+							   READ_SIZE,
+							   G_PRIORITY_LOW,
+							   sio->cancel,
+							   on_read_finished,
+							   sio);
+}
+
+GFile*
+sourceview_io_get_file (SourceviewIO* sio)
+{
+	if (sio->file)
+		g_object_ref (sio->file);
+	return sio->file;
+}
+
+void 
+sourceview_io_cancel (SourceviewIO* sio)
+{
+	g_cancellable_cancel (sio->cancel);
+}
+
+gchar* 
+sourceview_io_get_filename (SourceviewIO* sio)
+{
+	static gint new_file_count = 0;
+	if (sio->filename)
+		return g_strdup(sio->filename);	
+	else /* new file */
+	{
+		sio->filename = g_strdup_printf (_("New file %d"), new_file_count++);
+		return g_strdup (sio->filename);
+	}									 
+}
+
+void 
+sourceview_io_set_filename (SourceviewIO* sio, const gchar* filename)
+{
+	g_free (sio->filename);
+	sio->filename = g_strdup(filename);
+}
+
+gchar* 
+sourceview_io_get_mime_type (SourceviewIO* sio)
+{
+	GFileInfo* file_info;
+	
+	if (!sio->file)
+		return NULL;
+	
+	file_info = g_file_query_info (sio->file,
+								   G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+								   G_FILE_QUERY_INFO_NONE,
+								   NULL,
+								   NULL);
+	if (file_info)
+	{
+		gchar* mime_type = g_strdup (g_file_info_get_content_type (file_info));
+		g_object_unref (file_info);
+		return mime_type;
+	}
+	else
+		return NULL;
+	
+}
+
+
+SourceviewIO*
+sourceview_io_new (Sourceview* sv)
+{
+	SourceviewIO* sio = SOURCEVIEW_IO(g_object_new (SOURCEVIEW_TYPE_IO, NULL));
+	sio->sv = sv;
+	return sio;
+}

Added: trunk/plugins/sourceview/sourceview-io.h
==============================================================================
--- (empty file)
+++ trunk/plugins/sourceview/sourceview-io.h	Fri Jul  4 15:54:00 2008
@@ -0,0 +1,78 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta-trunk
+ * Copyright (C) Johannes Schmid 2008 <jhs gnome org>
+ * 
+ * anjuta-trunk is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta-trunk is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOURCEVIEW_IO_H_
+#define _SOURCEVIEW_IO_H_
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include "sourceview.h"
+
+G_BEGIN_DECLS
+
+#define SOURCEVIEW_TYPE_IO             (sourceview_io_get_type ())
+#define SOURCEVIEW_IO(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOURCEVIEW_TYPE_IO, SourceviewIO))
+#define SOURCEVIEW_IO_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), SOURCEVIEW_TYPE_IO, SourceviewIOClass))
+#define SOURCEVIEW_IS_IO(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOURCEVIEW_TYPE_IO))
+#define SOURCEVIEW_IS_IO_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SOURCEVIEW_TYPE_IO))
+#define SOURCEVIEW_IO_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), SOURCEVIEW_TYPE_IO, SourceviewIOClass))
+
+typedef struct _SourceviewIOClass SourceviewIOClass;
+typedef struct _SourceviewIO SourceviewIO;
+
+struct _SourceviewIOClass
+{
+	GObjectClass parent_class;
+
+	/* Signals */
+	void(* changed) (SourceviewIO *self);
+	void(* save_finished) (SourceviewIO *self);
+	void(* open_finished) (SourceviewIO *self);
+	void(* open_failed) (SourceviewIO *self, GError* error);
+	void(* save_failed) (SourceviewIO *self, GError* error);
+};
+
+struct _SourceviewIO
+{
+	GObject parent_instance;
+	
+	GFile* file;
+	gchar* filename;
+	Sourceview* sv;
+	gchar* write_buffer;
+	gchar* read_buffer;
+	GCancellable* cancel;
+	GFileMonitor* monitor;
+	guint monitor_idle;
+};
+
+GType sourceview_io_get_type (void) G_GNUC_CONST;
+void sourceview_io_save (SourceviewIO* sio);
+void sourceview_io_save_as (SourceviewIO* sio, GFile* file);
+void sourceview_io_open (SourceviewIO* sio, GFile* file);
+void sourceview_io_cancel (SourceviewIO* sio);
+GFile* sourceview_io_get_file (SourceviewIO* sio);
+gchar* sourceview_io_get_filename (SourceviewIO* sio);
+void sourceview_io_set_filename (SourceviewIO* sio, const gchar* filename);
+gchar* sourceview_io_get_mime_type (SourceviewIO* sio);
+SourceviewIO* sourceview_io_new (Sourceview* sv);
+
+G_END_DECLS
+
+#endif /* _SOURCEVIEW_IO_H_ */

Modified: trunk/plugins/sourceview/sourceview-private.h
==============================================================================
--- trunk/plugins/sourceview/sourceview-private.h	(original)
+++ trunk/plugins/sourceview/sourceview-private.h	Fri Jul  4 15:54:00 2008
@@ -18,11 +18,11 @@
 #define SOURCEVIEW_PRIVATE_H
 
 #include "anjuta-view.h"
-#include "anjuta-document.h"
 
 #include "assist-window.h"
 #include "assist-tip.h"
 #include "sourceview-cell.h"
+#include "sourceview-io.h"
 
 #include <libanjuta/anjuta-plugin.h>
 #include <glib.h>
@@ -32,20 +32,15 @@
 	AnjutaView* view;
 	
 	/* GtkSourceBuffer */
-	AnjutaDocument* document;
-	
-	/* Filename */
-	gchar* filename;
+	GtkSourceBuffer* document;
 	
 	/* Highlight Tag */
 	GtkTextTag *important_indic;
 	GtkTextTag *warning_indic;
 	GtkTextTag *critical_indic;
 	
-	/* VFS Monitor */
-	GnomeVFSMonitorHandle* monitor;
-	gchar* last_saved_content;
-	gboolean monitor_delay;
+	/* IO */
+	SourceviewIO* io;
 	
 	/* Preferences */
 	AnjutaPreferences* prefs;
@@ -60,7 +55,6 @@
 	
 	/* Goto line hack */
 	gboolean loading;
-	gboolean saving;
 	gint goto_line;
 	
 	/* Idle marking */

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Fri Jul  4 15:54:00 2008
@@ -45,11 +45,6 @@
 #include <libanjuta/interfaces/ianjuta-editor-search.h>
 #include <libanjuta/interfaces/ianjuta-editor-hover.h>
 
-#include <libgnomevfs/gnome-vfs-init.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs.h>
-
 #include <gtksourceview/gtksourceview.h>
 #include <gtksourceview/gtksourcelanguage.h>
 #include <gtksourceview/gtksourcelanguagemanager.h>
@@ -57,17 +52,15 @@
 #include <gtksourceview/gtksourceiter.h>
 
 #include "config.h"
-#include "anjuta-document.h"
 #include "anjuta-view.h"
 
 #include "sourceview.h"
+#include "sourceview-io.h"
 #include "sourceview-private.h"
 #include "sourceview-prefs.h"
 #include "sourceview-print.h"
 #include "sourceview-cell.h"
 #include "plugin.h"
-
-#define HAVE_TOOLTIP_API (GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 12))
 		 
 #define FORWARD 	0
 #define BACKWARD 	1
@@ -86,12 +79,117 @@
 
 static GObjectClass *parent_class = NULL;
 
-#if HAVE_TOOLTIP_API
 static gboolean on_sourceview_hover_over (GtkWidget *widget, gint x, gint y,
 										  gboolean keyboard_tip, GtkTooltip *tooltip,
 										  gpointer data); 
-#endif
-static gboolean sourceview_add_monitor(Sourceview* sv);
+
+/* Utils */
+/* Sync with IANJUTA_MARKABLE_MARKER  */
+
+#define MARKER_PIXMAP_LINEMARKER "anjuta-linemark-16.png"
+#define MARKER_PIXMAP_PROGRAM_COUNTER "anjuta-pcmark-16.png"
+#define MARKER_PIXMAP_BREAKPOINT_DISABLED "anjuta-breakpoint-disabled-16.png"
+#define MARKER_PIXMAP_BREAKPOINT_ENABLED "anjuta-breakpoint-enabled-16.png"
+#define MARKER_PIXMAP_BOOKMARK "anjuta-bookmark-16.png"
+
+
+/* Keep in sync with IAnjutaMarkableMarker */
+
+static const gchar* marker_types [] =
+{
+	"sv-linemarker",
+	"sv-bookmark",
+	"sv-breakpoint-enabled",
+	"sv-breakpoint-disabled",
+	"sv-program-counter",
+	NULL
+};
+
+/* HIGHLIGHTED TAGS */
+
+#define IMPORTANT_INDIC "important_indic"
+#define WARNING_INDIC "warning_indic"
+#define CRITICAL_INDIC "critical_indic"
+
+/* Create pixmaps for the markers */
+static void sourceview_create_markers(Sourceview* sv)
+{
+	GdkPixbuf * pixbuf;
+	GtkSourceView* view = 	GTK_SOURCE_VIEW(sv->priv->view);
+
+	
+	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_BOOKMARK, NULL)))
+	{
+		gtk_source_view_set_mark_category_pixbuf (view, 
+			marker_types[IANJUTA_MARKABLE_BOOKMARK], pixbuf);
+		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_BOOKMARK],
+											 IANJUTA_MARKABLE_BOOKMARK);
+		g_object_unref (pixbuf);
+	}
+	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_BREAKPOINT_DISABLED, NULL)))
+	{
+		gtk_source_view_set_mark_category_pixbuf (view, 
+			marker_types[IANJUTA_MARKABLE_BREAKPOINT_DISABLED], pixbuf);
+		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_BREAKPOINT_DISABLED],
+											 IANJUTA_MARKABLE_BREAKPOINT_DISABLED);
+
+		g_object_unref (pixbuf);
+	}
+	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_BREAKPOINT_ENABLED, NULL)))
+	{
+		gtk_source_view_set_mark_category_pixbuf (view, 
+			marker_types[IANJUTA_MARKABLE_BREAKPOINT_ENABLED], pixbuf);
+		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_BREAKPOINT_ENABLED],
+											 IANJUTA_MARKABLE_BREAKPOINT_ENABLED);
+		g_object_unref (pixbuf);
+	}
+	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_PROGRAM_COUNTER, NULL)))
+	{
+		gtk_source_view_set_mark_category_pixbuf (view, 
+			marker_types[IANJUTA_MARKABLE_PROGRAM_COUNTER], pixbuf);
+		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_PROGRAM_COUNTER],
+											 IANJUTA_MARKABLE_PROGRAM_COUNTER);
+		g_object_unref (pixbuf);
+	}
+	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_LINEMARKER, NULL)))
+	{
+		gtk_source_view_set_mark_category_pixbuf (view, 
+			marker_types[IANJUTA_MARKABLE_LINEMARKER], pixbuf);
+		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_LINEMARKER],
+											 IANJUTA_MARKABLE_LINEMARKER);
+		g_object_unref (pixbuf);
+	}
+}
+
+/* Create tags for highlighting */
+static void sourceview_create_highligth_indic(Sourceview* sv)
+{	
+	sv->priv->important_indic = 
+		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
+									IMPORTANT_INDIC,
+									"background", "#FFFF00", NULL);  
+	sv->priv->warning_indic = 
+		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
+									WARNING_INDIC,
+									"foreground", "#00FF00", NULL); 
+	sv->priv->critical_indic = 
+		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
+									CRITICAL_INDIC,
+									"foreground", "#FF0000", "underline", 
+									PANGO_UNDERLINE_ERROR, NULL);
+}
+
+static void
+goto_line (Sourceview* sv, gint line)
+{
+	GtkTextIter iter;
+	GtkTextBuffer* buffer = GTK_TEXT_BUFFER (sv->priv->document);
+	
+	gtk_text_buffer_get_iter_at_line (buffer,
+									  &iter,
+									  line);
+	gtk_text_buffer_select_range (buffer, &iter, &iter);
+}
 
 /* Callbacks */
 
@@ -147,33 +245,35 @@
 }
 
 /* Called whenever the document is changed */
-static void on_document_modified_changed(AnjutaDocument* buffer, Sourceview* sv)
+static void on_document_modified_changed(GtkTextBuffer* buffer, Sourceview* sv)
 {
 	/* Emit IAnjutaFileSavable signals */
 	g_signal_emit_by_name(G_OBJECT(sv), "save_point",
-						  !gtk_text_buffer_get_modified(GTK_TEXT_BUFFER(buffer)));
+						  !gtk_text_buffer_get_modified(buffer));
 }
 
-/* Called whenever the curser moves */
-static void on_cursor_moved(AnjutaDocument *widget,
-							 Sourceview* sv)
+static void on_mark_set (GtkTextBuffer *buffer,
+						 GtkTextIter* location,
+						 GtkTextMark* mark,
+						 Sourceview* sv)
 {
-	/* Emit IAnjutaEditor signals */
-	g_signal_emit_by_name(G_OBJECT(sv), "update_ui");
+	/* Emit IAnjutaEditor signal */
+	if (mark == gtk_text_buffer_get_insert (buffer))
+		g_signal_emit_by_name(G_OBJECT(sv), "update_ui");
 }
 
+/* Open / Save stuff */
+
 /* Callback for dialog below */
 static void 
 on_reload_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
 {
 	if (res == GTK_RESPONSE_YES)
 	{
-		gchar* uri = anjuta_document_get_uri(sv->priv->document);
-		GFile* file = g_file_new_for_uri (uri);
+		GFile* file = sourceview_io_get_file (sv->priv->io);
 		ianjuta_file_open(IANJUTA_FILE(sv),
 						  file, NULL);
 		g_object_unref (file);
-		g_free (uri);
 	}
 	else
 	{
@@ -183,22 +283,8 @@
 	gtk_widget_destroy (message_area);
 }
 
-/* Update Monitor on load/save */
-static void
-sourceview_remove_monitor(Sourceview* sv)
-{
-	gboolean monitor_enabled = anjuta_preferences_get_int (sv->priv->prefs, MONITOR_KEY);
-
-	if (monitor_enabled && sv->priv->monitor != NULL)
-	{
-		DEBUG_PRINT ("Monitor removed for %s", anjuta_document_get_uri(sv->priv->document));
-		gnome_vfs_monitor_cancel(sv->priv->monitor);
-		sv->priv->monitor = NULL;
-	}
-}
-
 static gboolean
-on_sourceview_uri_changed_prompt (Sourceview* sv)
+on_file_changed (SourceviewIO* sio, Sourceview* sv)
 {
 	GtkWidget *message_area;
 	IAnjutaDocumentManager *docman;
@@ -206,14 +292,16 @@
 	AnjutaShell *shell;
 	gchar *buff;
 	
-	g_print ("OK\n");
+	gchar* filename = sourceview_io_get_filename (sio);
 	
 	buff =
 		g_strdup_printf (_
 						 ("The file '%s' on the disk is more recent than "
 						  "the current buffer.\nDo you want to reload it?"),
-						 ianjuta_document_get_filename(IANJUTA_DOCUMENT(sv), NULL));
+						 filename);
 
+	g_free (filename);
+	
 	shell = ANJUTA_PLUGIN (sv->priv->plugin)->shell;
 	docman = anjuta_shell_get_interface (shell, IAnjutaDocumentManager, NULL);
 	if (!docman)
@@ -243,193 +331,106 @@
 }
 
 static void
-on_sourceview_uri_changed (GnomeVFSMonitorHandle *handle,
-							const gchar *monitor_uri,
-							const gchar *info_uri,
-							GnomeVFSMonitorEventType event_type,
-							gpointer user_data)
+on_open_failed (SourceviewIO* io, GError* err, Sourceview* sv)
 {
-	Sourceview *sv = ANJUTA_SOURCEVIEW (user_data);
+	AnjutaShell* shell = ANJUTA_PLUGIN (sv->priv->plugin)->shell;
+	IAnjutaDocumentManager *docman = 
+		anjuta_shell_get_interface (shell, IAnjutaDocumentManager, NULL);
+	GtkWidget* message_area;
+	g_return_if_fail (docman != NULL);
+	
+	/* Could not open <filename>: <error message> */
+	gchar* message = g_strdup_printf (_("Could not open %s: %s"),
+									  sourceview_io_get_filename (sv->priv->io), 
+									  err->message);
+	message_area = anjuta_message_area_new (message, GTK_STOCK_DIALOG_WARNING);
+	anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+									GTK_STOCK_OK,
+									GTK_RESPONSE_OK);
+	g_free (message);
 	
-	if (!(event_type == GNOME_VFS_MONITOR_EVENT_CHANGED ||
-		  event_type == GNOME_VFS_MONITOR_EVENT_CREATED))
-		return;
+	g_signal_connect (message_area, "response", G_CALLBACK(gtk_widget_destroy), NULL);
 	
-	if (!anjuta_util_diff (anjuta_document_get_uri(sv->priv->document), sv->priv->last_saved_content))
-	{
-		return;
-	}
+	ianjuta_document_manager_set_message_area (docman, IANJUTA_DOCUMENT(sv), 
+											   message_area, NULL);
 	
+	sv->priv->loading = FALSE;
 	
-	if (strcmp (monitor_uri, info_uri) != 0)
-		return;
+	gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view), TRUE);
 	
-	on_sourceview_uri_changed_prompt(sv);	
-}
-
-static gboolean 
-sourceview_add_monitor(Sourceview* sv)
-{
-	gboolean monitor_enabled = anjuta_preferences_get_int (sv->priv->prefs, MONITOR_KEY);
-
-	if (monitor_enabled)
-	{
-		gchar* uri;
-		g_return_val_if_fail(sv->priv->monitor == NULL, FALSE);
-		DEBUG_PRINT ("Monitor added for %s", anjuta_document_get_uri(sv->priv->document));
-		uri = anjuta_document_get_uri(sv->priv->document);
-		gnome_vfs_monitor_add(&sv->priv->monitor, uri,
-							  GNOME_VFS_MONITOR_FILE,
-							  on_sourceview_uri_changed, sv);
-		g_free (uri);
-	}
-	return FALSE; /* for g_idle_add */
+	/* Get rid of reference from ifile_open */
+	g_object_unref(G_OBJECT(sv));
 }
 
 /* Called when document is loaded completly */
-static void on_document_loaded(AnjutaDocument* doc, GError* err, Sourceview* sv)
+static void 
+on_open_finish(SourceviewIO* io, Sourceview* sv)
 {
 	const gchar *lang;
-	if (err)
-	{
-		anjuta_util_dialog_error(NULL,
-			 "Could not open file: %s", err->message);
-	}
-	gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(doc), FALSE);
+	gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), FALSE);
     g_signal_emit_by_name(G_OBJECT(sv), "save_point",
 						  TRUE);
 	
+	sv->priv->loading = FALSE;
 	if (sv->priv->goto_line > 0)
 	{
-		anjuta_document_goto_line(doc, LOCATION_TO_LINE (sv->priv->goto_line));
+		goto_line (sv, sv->priv->goto_line);
 		sv->priv->goto_line = -1;
 	}
+	else
+		goto_line (sv, 0);
 	anjuta_view_scroll_to_cursor(sv->priv->view);
 	sv->priv->loading = FALSE;
-	
-	sourceview_add_monitor(sv);
 
 	/* Autodetect language */
 	ianjuta_editor_language_set_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL, NULL);
 
 	lang = ianjuta_editor_language_get_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL);
 	g_signal_emit_by_name (sv, "language-changed", lang);
+
+	gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view), TRUE);
 	
 	/* Get rid of reference from ifile_open */
 	g_object_unref(G_OBJECT(sv));
 }
 
-/* Show nice progress bar */
-static void on_document_loading(AnjutaDocument    *document,
-					 GnomeVFSFileSize  size,
-					 GnomeVFSFileSize  total_size,
-					 Sourceview* sv)
+static void on_save_failed (SourceviewIO* sio, GError* err, Sourceview* sv)
 {
-	AnjutaShell* shell;
-	AnjutaStatus* status;
-
-	g_object_get(G_OBJECT(sv->priv->plugin), "shell", &shell, NULL);
-	status = anjuta_shell_get_status(shell, NULL);
+	AnjutaShell* shell = ANJUTA_PLUGIN (sv->priv->plugin)->shell;
+	IAnjutaDocumentManager *docman = 
+		anjuta_shell_get_interface (shell, IAnjutaDocumentManager, NULL);
+	GtkWidget* message_area;
+	g_return_if_fail (docman != NULL);
+	
+	/* Could not save <filename>: <error message> */
+	gchar* message = g_strdup_printf (_("Could not save %s: %s"),
+									  sourceview_io_get_filename (sio), 
+									  err->message);
+	message_area = anjuta_message_area_new (message, GTK_STOCK_DIALOG_WARNING);
+	anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+									GTK_STOCK_OK,
+									GTK_RESPONSE_OK);
+	g_free (message);
 	
-	if (!sv->priv->loading)
-	{
-		gint procentage = 0;
-		if (size)
-			procentage = total_size/size;
-		anjuta_status_progress_add_ticks(status,procentage + 1);
-		sv->priv->loading = TRUE;
-	}
-	anjuta_status_progress_tick(status, NULL,  _("Loading"));
-}
-
-/* Show nice progress bar */
-static void on_document_saving(AnjutaDocument    *document,
-					 GnomeVFSFileSize  size,
-					 GnomeVFSFileSize  total_size,
-					 Sourceview* sv)
-{
-	AnjutaShell* shell;
-	AnjutaStatus* status;
-
-	g_object_get(G_OBJECT(sv->priv->plugin), "shell", &shell, NULL);
-	status = anjuta_shell_get_status(shell, NULL);
+	g_signal_connect (message_area, "response", G_CALLBACK(gtk_widget_destroy), NULL);
 	
-	if (!sv->priv->saving)
-	{
-		gint procentage = 0;
-		if (size)
-			procentage = total_size/size;
-		anjuta_status_progress_add_ticks(status,procentage + 1);
-		sv->priv->saving = TRUE;
-	}
-	anjuta_status_progress_tick(status, NULL, _("Saving..."));
-}
-
-static gboolean save_if_modified(AnjutaDocument* doc, GtkWindow* parent)
-{
-	GtkWidget* dialog = gtk_message_dialog_new(parent,
-    	GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, 
-    	_("The file %s was modified by another application. Save it anyway?"), anjuta_document_get_uri_for_display(doc));
-    int result = gtk_dialog_run(GTK_DIALOG(dialog));
-    gtk_widget_destroy(dialog);
-    switch (result)
-    {
-    	case GTK_RESPONSE_YES:
-    	{
-    		return TRUE;
-   		}
-   		default:
-   			return FALSE;
-   	}
-}
-
-/* Need to avoid crash when unref is done before add_monitor */
-static gboolean timeout_unref(Sourceview* sv)
-{
-	g_object_unref(G_OBJECT(sv));
-	return FALSE;
+	ianjuta_document_manager_set_message_area (docman, IANJUTA_DOCUMENT(sv), 
+											   message_area, NULL);
+	
+	g_object_unref (sv);
 }
 
 /* Called when document is saved completly */
-static void on_document_saved(AnjutaDocument* doc, GError* err, Sourceview* sv)
-{
-	if (err)
-	{
-		switch(err->code)
-		{
-			case ANJUTA_DOCUMENT_ERROR_EXTERNALLY_MODIFIED:
-			{
-    			if (save_if_modified(doc, GTK_WINDOW(sv->priv->plugin->shell)))
-    			{
-    				anjuta_document_save(doc, ANJUTA_DOCUMENT_SAVE_IGNORE_MTIME);
-    			}
-    			break;
-			}
-			default:
-			{
-				anjuta_util_dialog_error(NULL,
-				 		"Could not save file %s: %s",anjuta_document_get_uri_for_display(doc),  err->message);
-				break;
-			}
-		}
-	}
-	else
-	{
-		const gchar* lang;
-		gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(doc), FALSE);
-		g_signal_emit_by_name(G_OBJECT(sv), "save_point", TRUE);
-		/* Set up 2 sec timer */
-		if (sv->priv->monitor_delay > 0)
- 			g_source_remove (sv->priv->monitor_delay);
-		sv->priv->monitor_delay = g_timeout_add (2000,
-							(GSourceFunc)sourceview_add_monitor, sv);
-		sv->priv->saving = FALSE;
-		/* Autodetect language */
-		ianjuta_editor_language_set_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL, NULL);
-		lang = ianjuta_editor_language_get_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL);
-		g_signal_emit_by_name (sv, "language-changed", lang);
-	}
-	g_timeout_add(3000, (GSourceFunc)timeout_unref, sv);
+static void on_save_finish(SourceviewIO* sio, Sourceview* sv)
+{	
+	const gchar* lang;
+	gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), FALSE);
+	g_signal_emit_by_name(G_OBJECT(sv), "save_point", TRUE);
+	/* Autodetect language */
+	ianjuta_editor_language_set_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL, NULL);
+	lang = ianjuta_editor_language_get_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL);
+	g_signal_emit_by_name (sv, "language-changed", lang);
+	g_object_unref (sv);
 }
 
 static void 
@@ -443,10 +444,44 @@
 		gtk_widget_destroy (GTK_WIDGET (sv->priv->assist_tip));
 }
 
+/* Construction/Deconstruction */
+
 static void 
 sourceview_instance_init(Sourceview* sv)
-{
+
+{	
 	sv->priv = g_slice_new0 (SourceviewPrivate);
+	sv->priv->io = sourceview_io_new (sv);
+	g_signal_connect (sv->priv->io, "changed", G_CALLBACK (on_file_changed), sv);
+	g_signal_connect (sv->priv->io, "open-finished", G_CALLBACK (on_open_finish),
+					  sv);
+	g_signal_connect (sv->priv->io, "open-failed", G_CALLBACK (on_open_failed),
+					  sv);
+	g_signal_connect (sv->priv->io, "save-finished", G_CALLBACK (on_save_finish),
+					  sv);
+	g_signal_connect (sv->priv->io, "save-failed", G_CALLBACK (on_save_failed),
+					  sv);
+	
+	/* Create buffer */
+	sv->priv->document = gtk_source_buffer_new(NULL);
+	g_signal_connect_after(G_OBJECT(sv->priv->document), "modified-changed", 
+					 G_CALLBACK(on_document_modified_changed), sv);
+	g_signal_connect_after(G_OBJECT(sv->priv->document), "mark-set", 
+					 G_CALLBACK(on_mark_set),sv);
+	g_signal_connect_after (G_OBJECT(sv->priv->document), "insert-text",
+					  G_CALLBACK(on_insert_text), sv);
+					 
+	/* Create View instance */
+	sv->priv->view = ANJUTA_VIEW(anjuta_view_new(sv));
+	g_signal_connect (G_OBJECT(sv->priv->view), "query-tooltip",
+					  G_CALLBACK (on_sourceview_hover_over), sv);
+	g_object_set (G_OBJECT (sv->priv->view), "has-tooltip", TRUE, NULL);
+	gtk_source_view_set_smart_home_end(GTK_SOURCE_VIEW(sv->priv->view), FALSE);
+	
+	/* Create Markers */
+	sourceview_create_markers(sv);
+	/* Create Higlight Tag */
+	sourceview_create_highligth_indic(sv);
 }
 
 static void
@@ -472,12 +507,15 @@
 		on_assist_cancel(cobj->priv->assist_win, cobj);
 	if (cobj->priv->assist_tip)
 		gtk_widget_destroy(GTK_WIDGET(cobj->priv->assist_tip));
+	g_object_unref (cobj->priv->io);
 	
 	for (node = cobj->priv->idle_sources; node != NULL; node = g_slist_next (node))
 	{
 		g_source_remove (GPOINTER_TO_UINT (node->data));
 	}
 	g_slist_free (cobj->priv->idle_sources);
+
+	sourceview_prefs_destroy(cobj);
 	
 	G_OBJECT_CLASS (parent_class)->dispose (object);
 }
@@ -488,112 +526,11 @@
 	Sourceview *cobj;
 	cobj = ANJUTA_SOURCEVIEW(object);
 	
-	sourceview_remove_monitor(cobj);
-	sourceview_prefs_destroy(cobj);
-	
-	g_object_unref(cobj->priv->view);
-	
 	g_slice_free(SourceviewPrivate, cobj->priv);
 	G_OBJECT_CLASS(parent_class)->finalize(object);
 	DEBUG_PRINT("=========== finalise =============");
 }
 
-/* Sync with IANJUTA_MARKABLE_MARKER  */
-
-#define MARKER_PIXMAP_LINEMARKER "anjuta-linemark-16.png"
-#define MARKER_PIXMAP_PROGRAM_COUNTER "anjuta-pcmark-16.png"
-#define MARKER_PIXMAP_BREAKPOINT_DISABLED "anjuta-breakpoint-disabled-16.png"
-#define MARKER_PIXMAP_BREAKPOINT_ENABLED "anjuta-breakpoint-enabled-16.png"
-#define MARKER_PIXMAP_BOOKMARK "anjuta-bookmark-16.png"
-
-
-/* Keep in sync with IAnjutaMarkableMarker */
-
-static const gchar* marker_types [] =
-{
-	"sv-linemarker",
-	"sv-bookmark",
-	"sv-breakpoint-enabled",
-	"sv-breakpoint-disabled",
-	"sv-program-counter",
-	NULL
-};
-
-/* HIGHLIGHTED TAGS */
-
-#define IMPORTANT_INDIC "important_indic"
-#define WARNING_INDIC "warning_indic"
-#define CRITICAL_INDIC "critical_indic"
-
-/* Create pixmaps for the markers */
-static void sourceview_create_markers(Sourceview* sv)
-{
-	GdkPixbuf * pixbuf;
-	GtkSourceView* view = 	GTK_SOURCE_VIEW(sv->priv->view);
-
-	
-	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_BOOKMARK, NULL)))
-	{
-		gtk_source_view_set_mark_category_pixbuf (view, 
-			marker_types[IANJUTA_MARKABLE_BOOKMARK], pixbuf);
-		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_BOOKMARK],
-											 IANJUTA_MARKABLE_BOOKMARK);
-		g_object_unref (pixbuf);
-	}
-	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_BREAKPOINT_DISABLED, NULL)))
-	{
-		gtk_source_view_set_mark_category_pixbuf (view, 
-			marker_types[IANJUTA_MARKABLE_BREAKPOINT_DISABLED], pixbuf);
-		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_BREAKPOINT_DISABLED],
-											 IANJUTA_MARKABLE_BREAKPOINT_DISABLED);
-
-		g_object_unref (pixbuf);
-	}
-	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_BREAKPOINT_ENABLED, NULL)))
-	{
-		gtk_source_view_set_mark_category_pixbuf (view, 
-			marker_types[IANJUTA_MARKABLE_BREAKPOINT_ENABLED], pixbuf);
-		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_BREAKPOINT_ENABLED],
-											 IANJUTA_MARKABLE_BREAKPOINT_ENABLED);
-		g_object_unref (pixbuf);
-	}
-	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_PROGRAM_COUNTER, NULL)))
-	{
-		gtk_source_view_set_mark_category_pixbuf (view, 
-			marker_types[IANJUTA_MARKABLE_PROGRAM_COUNTER], pixbuf);
-		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_PROGRAM_COUNTER],
-											 IANJUTA_MARKABLE_PROGRAM_COUNTER);
-		g_object_unref (pixbuf);
-	}
-	if ((pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"MARKER_PIXMAP_LINEMARKER, NULL)))
-	{
-		gtk_source_view_set_mark_category_pixbuf (view, 
-			marker_types[IANJUTA_MARKABLE_LINEMARKER], pixbuf);
-		gtk_source_view_set_mark_category_priority (view, marker_types [IANJUTA_MARKABLE_LINEMARKER],
-											 IANJUTA_MARKABLE_LINEMARKER);
-		g_object_unref (pixbuf);
-	}
-}
-
-/* Create tags for highlighting */
-static void sourceview_create_highligth_indic(Sourceview* sv)
-{	
-	sv->priv->important_indic = 
-		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
-									IMPORTANT_INDIC,
-									"background", "#FFFF00", NULL);  
-	sv->priv->warning_indic = 
-		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
-									WARNING_INDIC,
-									"foreground", "#00FF00", NULL); 
-	sv->priv->critical_indic = 
-		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
-									CRITICAL_INDIC,
-									"foreground", "#FF0000", "underline", 
-									PANGO_UNDERLINE_ERROR, NULL);
-}
-
-
 /* Create a new sourceview instance. If uri is valid,
 the file will be loaded in the buffer */
 
@@ -605,45 +542,12 @@
 	
 	Sourceview *sv = ANJUTA_SOURCEVIEW(g_object_new(ANJUTA_TYPE_SOURCEVIEW, NULL));
 	
-	/* Create buffer */
-	sv->priv->document = anjuta_document_new();
-	g_signal_connect_after(G_OBJECT(sv->priv->document), "modified-changed", 
-					 G_CALLBACK(on_document_modified_changed), sv);
-	g_signal_connect_after(G_OBJECT(sv->priv->document), "cursor-moved", 
-					 G_CALLBACK(on_cursor_moved),sv);
-	g_signal_connect_after(G_OBJECT(sv->priv->document), "loaded", 
-					 G_CALLBACK(on_document_loaded), sv);
-	g_signal_connect(G_OBJECT(sv->priv->document), "loading", 
-					 G_CALLBACK(on_document_loading), sv);				 
-	g_signal_connect_after(G_OBJECT(sv->priv->document), "saved", 
-					 G_CALLBACK(on_document_saved), sv);
-	g_signal_connect(G_OBJECT(sv->priv->document), "saving", 
-					 G_CALLBACK(on_document_saving), sv);
-	g_signal_connect_after (G_OBJECT(sv->priv->document), "insert-text",
-					  G_CALLBACK(on_insert_text), sv);
-					 
-	/* Create View instance */
-	sv->priv->view = ANJUTA_VIEW(anjuta_view_new(sv));
-#if HAVE_TOOLTIP_API
-	g_signal_connect (G_OBJECT(sv->priv->view), "query-tooltip",
-					  G_CALLBACK (on_sourceview_hover_over), sv);
-	g_object_set (G_OBJECT (sv->priv->view), "has-tooltip", TRUE, NULL);
-#endif
-	gtk_source_view_set_smart_home_end(GTK_SOURCE_VIEW(sv->priv->view), FALSE);
-	g_object_ref(sv->priv->view);
-	
-	/* VFS monitor */
-	sv->priv->last_saved_content = NULL;
-	
 	/* Apply Preferences */
 	g_object_get(G_OBJECT(plugin), "shell", &shell, NULL);
 	sv->priv->prefs = anjuta_shell_get_preferences(shell, NULL);
 	sourceview_prefs_init(sv);
 	sv->priv->plugin = plugin;
 	
-	/* Create Markers */
-	sourceview_create_markers(sv);
-		
 	/* Add View */
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sv),
 				      GTK_POLICY_AUTOMATIC,
@@ -658,11 +562,8 @@
 		ianjuta_file_open(IANJUTA_FILE(sv), file, NULL);
 	}
 	else if (filename != NULL && strlen(filename) > 0)
-		sv->priv->filename = g_strdup(filename);
-	
-	/* Create Higlight Tag */
-	sourceview_create_highligth_indic(sv);
-	
+		sourceview_io_set_filename (sv->priv->io, filename);
+		
 	DEBUG_PRINT("============ Creating new editor =============");
 	
 	g_signal_emit_by_name (G_OBJECT(sv), "update-ui");
@@ -677,11 +578,15 @@
 ifile_open (IAnjutaFile* ifile, GFile* file, GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(ifile);
-	sourceview_remove_monitor(sv);
 	/* Hold a reference here to avoid a destroyed editor */
 	g_object_ref(G_OBJECT(sv));
-	anjuta_document_load(sv->priv->document, g_file_get_uri (file), NULL,
-						 -1, FALSE);
+	gtk_text_buffer_set_text (GTK_TEXT_BUFFER(sv->priv->document),
+							  "",
+							  0);	
+	gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view),
+								FALSE);
+	sv->priv->loading = TRUE;
+	sourceview_io_open (sv->priv->io, file);
 }
 
 /* Return the currently loaded uri */
@@ -690,10 +595,7 @@
 ifile_get_file (IAnjutaFile* ifile, GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(ifile);
-	gchar* uri = anjuta_document_get_uri(sv->priv->document);
-	GFile* ret_file = g_file_new_for_uri (uri);
-	g_free (uri);
-	return ret_file;
+	return sourceview_io_get_file (sv->priv->io);
 }
 
 /* IAnjutaFileSavable interface */
@@ -703,37 +605,19 @@
 ifile_savable_save (IAnjutaFileSavable* file, GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(file);
-	sourceview_remove_monitor(sv);
 	
 	g_object_ref(G_OBJECT(sv));
-	anjuta_document_save(sv->priv->document, 0);
+	sourceview_io_save (sv->priv->io);
 }
 
 /* Save file as */
 static void 
 ifile_savable_save_as (IAnjutaFileSavable* ifile, GFile* file, GError** e)
 {
-	GtkTextIter start_iter;
-	GtkTextIter end_iter;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(ifile);
-	sourceview_remove_monitor(sv);
-	gchar* uri = g_file_get_uri (file);
-	gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER(sv->priv->document),
-								&start_iter, &end_iter);
-	g_free(sv->priv->last_saved_content);
-	sv->priv->last_saved_content = gtk_text_buffer_get_slice (
-															  GTK_TEXT_BUFFER(sv->priv->document),
-															  &start_iter, &end_iter, TRUE);
+
 	g_object_ref(G_OBJECT(sv));
-	anjuta_document_save_as(sv->priv->document, 
-							uri, anjuta_encoding_get_current(), 0);
-	if (sv->priv->filename)
-	{
-		g_free(sv->priv->filename);
-		sv->priv->filename = NULL;
-	}
-	
-	g_free (uri);
+	sourceview_io_save_as (sv->priv->io, file);
 }
 
 static void 
@@ -815,7 +699,7 @@
 
 	if (!sv->priv->loading)
 	{
-		anjuta_document_goto_line(sv->priv->document, LOCATION_TO_LINE (line));
+		goto_line(sv, LOCATION_TO_LINE (line));
 		anjuta_view_scroll_to_cursor(sv->priv->view);
 		gtk_widget_grab_focus (GTK_WIDGET (sv->priv->view));
 	}
@@ -932,11 +816,63 @@
 	return length;
 }
 
+static gboolean
+wordcharacters_contains (gchar c)
+{
+	const gchar* wordcharacters =
+		"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+	gint pos;
+	
+	for (pos = 0; pos < strlen(wordcharacters); pos++)
+	{
+		if (wordcharacters[pos] == c)
+		{
+			return TRUE;
+		}
+	}
+	return FALSE;
+}
+
 /* Return word on cursor position */
 static gchar* ieditor_get_current_word(IAnjutaEditor *editor, GError **e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	return anjuta_document_get_current_word(sv->priv->document, FALSE);
+	GtkTextIter begin;
+	GtkTextIter end;
+	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
+	gchar* region;
+	gchar* word;
+	gint startword;
+	gint endword;
+	int cplen;
+	const int maxlength = 100;
+	
+	gtk_text_buffer_get_iter_at_mark (buffer, &begin, 
+									  gtk_text_buffer_get_insert(buffer));
+	gtk_text_buffer_get_iter_at_mark (buffer, &end, 
+									  gtk_text_buffer_get_insert(buffer));
+	startword = gtk_text_iter_get_line_offset (&begin);	
+	endword = gtk_text_iter_get_line_offset (&end);
+	
+	gtk_text_iter_set_line_offset (&begin, 0);
+	gtk_text_iter_forward_to_line_end (&end);
+	
+	region = gtk_text_buffer_get_text (buffer, &begin, &end, FALSE);
+	
+	while (startword> 0 && wordcharacters_contains(region[startword - 1]))
+		startword--;
+	while (region[endword] && wordcharacters_contains(region[endword]))
+		endword++;
+	if(startword == endword)
+		return NULL;
+	
+	region[endword] = '\0';
+	cplen = (maxlength < (endword-startword+1))?maxlength:(endword-startword+1);
+	word = g_strndup (region + startword, cplen);
+	
+	g_free(region);
+	
+	return word;
 }
 
 /* Insert text at position */
@@ -1210,9 +1146,7 @@
 static const gchar* idocument_get_filename(IAnjutaDocument *editor, GError **e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	if (sv->priv->filename == NULL)
-		sv->priv->filename = anjuta_document_get_short_name_for_display(sv->priv->document);
-	return sv->priv->filename;
+	return sourceview_io_get_filename (sv->priv->io);
 }
 
 static void 
@@ -1533,9 +1467,9 @@
 	IAnjutaMarkableMarker marker = svmark->marker;
 	gchar* name;
 	
-	if (sv->priv->loading || sv->priv->saving)
+	if (sv->priv->loading)
 	{
-		/* Wait until loading/saving is finished */
+		/* Wait until loading is finished */
 		return TRUE;
 	}
 	
@@ -1906,20 +1840,14 @@
 static const gchar*
 autodetect_language (Sourceview* sv)
 {
-	const gchar* uri = anjuta_document_get_uri (sv->priv->document);
-	const gchar* vfs_mime_type = gnome_vfs_get_slow_mime_type (uri);
 	GStrv languages;
 	GStrv cur_lang;
 	const gchar* detected_language = NULL;
 	g_object_get (G_OBJECT (gtk_source_language_manager_get_default ()), "language-ids",
 							&languages, NULL);
-	if (!vfs_mime_type)
-	{
-		vfs_mime_type = 
-			gnome_vfs_get_mime_type_for_name (ianjuta_document_get_filename (IANJUTA_DOCUMENT (sv),
-																			 NULL));
-	}
-	if (!vfs_mime_type)
+	gchar* io_mime_type = sourceview_io_get_mime_type (sv->priv->io);
+	
+	if (!io_mime_type)
 		return NULL;
 	
 	for (cur_lang = languages; *cur_lang != NULL; cur_lang++)
@@ -1933,7 +1861,7 @@
 		GStrv mime_type;
 		for (mime_type = mime_types; *mime_type != NULL; mime_type++)
 		{
-			if (g_str_equal (*mime_type, vfs_mime_type))
+			if (g_str_equal (*mime_type, io_mime_type))
 			{
 				detected_language = gtk_source_language_get_id (language);				
 				g_signal_emit_by_name (G_OBJECT(sv), "language-changed", 
@@ -1947,6 +1875,7 @@
 	}
 	out:
 		g_strfreev(languages);
+		g_free (io_mime_type);
 	
 	return detected_language;
 }
@@ -2255,7 +2184,6 @@
 }
 
 /* IAnjutaHover */
-#if HAVE_TOOLTIP_API
 static void
 on_sourceview_hover_leave(gpointer data, GObject* where_the_data_was)
 {
@@ -2318,7 +2246,6 @@
 {
 	iface->display = ihover_display;
 }
-#endif
 
 ANJUTA_TYPE_BEGIN(Sourceview, sourceview, GTK_TYPE_SCROLLED_WINDOW);
 ANJUTA_TYPE_ADD_INTERFACE(idocument, IANJUTA_TYPE_DOCUMENT);
@@ -2334,7 +2261,5 @@
 ANJUTA_TYPE_ADD_INTERFACE(iprint, IANJUTA_TYPE_PRINT);
 ANJUTA_TYPE_ADD_INTERFACE(ilanguage, IANJUTA_TYPE_EDITOR_LANGUAGE);
 ANJUTA_TYPE_ADD_INTERFACE(isearch, IANJUTA_TYPE_EDITOR_SEARCH);
-#if HAVE_TOOLTIP_API
 ANJUTA_TYPE_ADD_INTERFACE(ihover, IANJUTA_TYPE_EDITOR_HOVER);
-#endif
 ANJUTA_TYPE_END;

Modified: trunk/plugins/symbol-browser/plugin.c
==============================================================================
--- trunk/plugins/symbol-browser/plugin.c	(original)
+++ trunk/plugins/symbol-browser/plugin.c	Fri Jul  4 15:54:00 2008
@@ -839,8 +839,9 @@
 	update_editor_symbol_model (sv_plugin);
 	
 	file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
-	uri = g_file_get_uri (file);
-	g_object_unref (file);
+	uri = file ? g_file_get_uri (file) : NULL;
+	if (file)
+		g_object_unref (file);
 	if (g_hash_table_lookup (sv_plugin->editor_connected, editor) == NULL)
 	{
 		g_object_weak_ref (G_OBJECT (editor),



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