[gtksourceview] FileSaver: don't check for externally modified for a "save as"
- From: SĂŠbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] FileSaver: don't check for externally modified for a "save as"
- Date: Mon, 28 Jul 2014 19:12:59 +0000 (UTC)
commit 325fc24504126bf69b5bc808c22c8f51ae831287
Author: SĂŠbastien Wilmet <swilmet gnome org>
Date: Mon Jul 28 17:25:03 2014 +0200
FileSaver: don't check for externally modified for a "save as"
gtksourceview/gtksourcefilesaver.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/gtksourcefilesaver.c b/gtksourceview/gtksourcefilesaver.c
index 80262e1..c36933d 100644
--- a/gtksourceview/gtksourcefilesaver.c
+++ b/gtksourceview/gtksourcefilesaver.c
@@ -884,9 +884,6 @@ check_externally_modified_cb (GFile *location,
}
}
- /* FIXME for a "save as" it doesn't work, the mtime stored in
- * GtkSourceFile is not for the good file.
- */
if (_gtk_source_file_get_modification_time (saver->priv->file, &old_mtime) &&
info != NULL &&
g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
@@ -920,7 +917,24 @@ check_externally_modified_cb (GFile *location,
static void
check_externally_modified (GtkSourceFileSaver *saver)
{
- if (saver->priv->flags & GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_MODIFICATION_TIME)
+ gboolean save_as = FALSE;
+
+ if (saver->priv->file != NULL)
+ {
+ GFile *prev_location;
+
+ prev_location = gtk_source_file_get_location (saver->priv->file);
+
+ /* Don't check for externally modified for a "save as" operation,
+ * because the user has normally accepted to overwrite the file if it
+ * already exists.
+ */
+ save_as = !g_file_equal (prev_location, saver->priv->location);
+ }
+
+
+ if (saver->priv->flags & GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_MODIFICATION_TIME ||
+ save_as)
{
begin_write (saver);
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]