anjuta r4514 - in trunk: . plugins/editor



Author: sgranjoux
Date: Wed Dec 31 15:07:18 2008
New Revision: 4514
URL: http://svn.gnome.org/viewvc/anjuta?rev=4514&view=rev

Log:
	* plugins/editor/text_editor.h,
	plugins/editor/text_editor.c:
	Restore file comparison removed in a previous patch


Modified:
   trunk/ChangeLog
   trunk/plugins/editor/text_editor.c
   trunk/plugins/editor/text_editor.h

Modified: trunk/plugins/editor/text_editor.c
==============================================================================
--- trunk/plugins/editor/text_editor.c	(original)
+++ trunk/plugins/editor/text_editor.c	Wed Dec 31 15:07:18 2008
@@ -313,6 +313,7 @@
 		text_editor_load_file (te);
 	}
 	gtk_widget_destroy (message_area);
+	te->file_modified_widget = NULL;
 	/* DEBUG_PRINT ("%s", "File modified dialog responded"); */
 }
 
@@ -335,6 +336,15 @@
 		  event_type == G_FILE_MONITOR_EVENT_CREATED))
 		return;
 
+	if (!anjuta_util_diff (te->uri, te->last_saved_content))
+	{
+		/* The file content is same. Remove any previous prompt for reload */
+		if (te->file_modified_widget)
+			gtk_widget_destroy (te->file_modified_widget);
+		te->file_modified_widget = NULL;
+		return;
+	}
+
 	buff =
 		g_strdup_printf (_
 						 ("The file '%s' on the disk is more recent than\n"
@@ -354,6 +364,7 @@
 								    GTK_STOCK_CANCEL,
 									GTK_RESPONSE_NO);
 	g_free (buff);	
+	te->file_modified_widget = message_area;
 	
 	g_signal_connect (G_OBJECT(message_area), "response",
 					  G_CALLBACK (on_reload_dialog_response),
@@ -514,6 +525,7 @@
 	g_free (te->filename);
 	g_free (te->uri);
 	g_free (te->force_hilite);
+	g_free (te->last_saved_content);
 	
 	G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
@@ -1228,6 +1240,7 @@
 	GFileInfo *info;
 	gsize nchars;
 	gint dos_filter, editor_mode;
+	gchar *file_content = NULL;
 	gchar *buffer = NULL;
 	guint64 size; 
 
@@ -1283,6 +1296,7 @@
 	if (buffer)
 	{
 		buffer[size] = '\0';
+		file_content = g_strdup (buffer);
 	}
 	
 	if (size != nchars)
@@ -1318,6 +1332,7 @@
 			{
 				/* bail out */
 				g_free (buffer);
+				g_free (file_content);
 				*err = g_strdup (_("The file does not look like a text file or the file encoding is not supported."
 								   " Please check if the encoding of file is in the supported encodings list."
 								   " If not, add it from the preferences."));
@@ -1338,6 +1353,10 @@
 							nchars, (long) buffer);
 	
 	g_free (buffer);
+
+	/* Save the buffer as last saved content */
+	g_free (te->last_saved_content);
+	te->last_saved_content = file_content;
 	
 	g_object_unref (gio_uri);
 
@@ -1438,7 +1457,9 @@
 		}
 	}
 	
-	g_free (data);
+	/* Set last content saved to data */
+	g_free (te->last_saved_content);
+	te->last_saved_content = data;
 	
 	if (result)
 		result = g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, error);

Modified: trunk/plugins/editor/text_editor.h
==============================================================================
--- trunk/plugins/editor/text_editor.h	(original)
+++ trunk/plugins/editor/text_editor.h	Wed Dec 31 15:07:18 2008
@@ -100,6 +100,12 @@
 	/* Current zoom factor */
 	gint zoom_factor;
 	
+	/* Last saved content for comparision on external modifications on
+	 * the file. The content is copied here during file saves.
+	 */
+	gchar *last_saved_content;
+	GtkWidget *file_modified_widget;
+	
 	gboolean hover_tip_on;
 };
 



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