anjuta r3488 - in trunk: . plugins/editor



Author: jhs
Date: Thu Jan 17 23:50:28 2008
New Revision: 3488
URL: http://svn.gnome.org/viewvc/anjuta?rev=3488&view=rev

Log:
2008-01-18  Johannes Schmid <jhs gnome org>

  Patch from: kilork yandex ru

	* plugins/editor/text_editor.c: (load_from_file),
	(text_editor_save_file):
	
	Fixed symlinks (#510238) and file permission (#405321)
	handling for scintilla editor.  

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

Modified: trunk/plugins/editor/text_editor.c
==============================================================================
--- trunk/plugins/editor/text_editor.c	(original)
+++ trunk/plugins/editor/text_editor.c	Thu Jan 17 23:50:28 2008
@@ -1325,7 +1325,10 @@
 	scintilla_send_message (SCINTILLA (te->scintilla), SCI_CLEARALL,
 							0, 0);
 	vfs_uri = gnome_vfs_uri_new(uri);
-	result = gnome_vfs_get_file_info_uri(vfs_uri, &info, GNOME_VFS_FILE_INFO_DEFAULT);
+	result = gnome_vfs_get_file_info_uri (vfs_uri,
+										  &info,
+										  GNOME_VFS_FILE_INFO_DEFAULT |
+										  GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
 	if (result != GNOME_VFS_OK)
 	{
 		*err = g_strdup (_("Could not get file info"));
@@ -1639,33 +1642,66 @@
 	{
 		GnomeVFSURI *src_uri;
 		GnomeVFSURI *dest_uri;
+		GnomeVFSFileInfo info;
 		
 		src_uri = gnome_vfs_uri_new (save_uri);
 		dest_uri = gnome_vfs_uri_new (te->uri);
 		
-		/* Move 'file~' to 'file' */
-		result = gnome_vfs_xfer_uri (src_uri, dest_uri,
-									 GNOME_VFS_XFER_DELETE_ITEMS |
-									 GNOME_VFS_XFER_REMOVESOURCE,
-									 GNOME_VFS_XFER_ERROR_MODE_ABORT,
-									 GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
-									 NULL, NULL);
-		/* we need to update UI with the call to scintilla */
-		text_editor_thaw (te);
+		result = gnome_vfs_get_file_info_uri (dest_uri,
+											  &info,
+											  GNOME_VFS_FILE_INFO_DEFAULT |
+											  GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
 		if (result != GNOME_VFS_OK)
 		{
 			anjuta_util_dialog_error (parent,
-						  _("Could not save file %s: %s."),
-						  te->uri,
-						  gnome_vfs_result_to_string (result));
+									  _("Couldn't get file info %s : %s"),
+									  te->uri,
+									  gnome_vfs_result_to_string (result));
 		}
 		else
 		{
-			scintilla_send_message (SCINTILLA (te->scintilla),
-						SCI_SETSAVEPOINT, 0, 0);
-			g_signal_emit_by_name (G_OBJECT (te), "saved", te->uri);
-			anjuta_status (te->status, _("File saved successfully"), 5);
-			ret = TRUE;
+			if (info.flags & GNOME_VFS_FILE_FLAGS_SYMLINK &&
+				info.valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)
+			{
+				gnome_vfs_uri_unref (dest_uri);
+				dest_uri = gnome_vfs_uri_new (info.symlink_name);
+			}
+			/* Move 'file~' to 'file' */
+			result = gnome_vfs_xfer_uri (src_uri, dest_uri,
+										 GNOME_VFS_XFER_DELETE_ITEMS |
+										 GNOME_VFS_XFER_REMOVESOURCE,
+										 GNOME_VFS_XFER_ERROR_MODE_ABORT,
+										 GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+										 NULL, NULL);
+			/* we need to update UI with the call to scintilla */
+			text_editor_thaw (te);
+			if (result != GNOME_VFS_OK)
+			{
+				anjuta_util_dialog_error (parent,
+					_("Could not save file %s: %s."),
+					te->uri,
+					gnome_vfs_result_to_string (result));
+			}
+			else
+			{
+				result = gnome_vfs_set_file_info_uri (dest_uri, &info,
+					GNOME_VFS_SET_FILE_INFO_PERMISSIONS);
+				if (result != GNOME_VFS_OK)
+				{
+					anjuta_util_dialog_error (parent,
+						_("Could not set file permissions %s: %s."),
+						te->uri,
+						gnome_vfs_result_to_string (result));
+				}
+				else
+				{
+					scintilla_send_message (SCINTILLA (te->scintilla),
+											SCI_SETSAVEPOINT, 0, 0);
+					g_signal_emit_by_name (G_OBJECT (te), "saved", te->uri);
+					anjuta_status (te->status, _("File saved successfully"), 5);
+					ret = TRUE;
+				}
+			}
 		}
 		gnome_vfs_uri_unref (src_uri);
 		gnome_vfs_uri_unref (dest_uri);



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