[gtksourceview/wip/metadata: 5/6] FileSaver: add flag to not save metadata
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/metadata: 5/6] FileSaver: add flag to not save metadata
- Date: Fri, 29 Apr 2016 15:13:18 +0000 (UTC)
commit 2545c34bf89dac3b1e90824a13f476239070b15c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Apr 29 15:05:43 2016 +0200
FileSaver: add flag to not save metadata
gtksourceview/gtksourcefilesaver.c | 24 +++++++++++++++++-------
gtksourceview/gtksourcefilesaver.h | 6 ++++--
2 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourcefilesaver.c b/gtksourceview/gtksourcefilesaver.c
index 52a02dd..cfeff1d 100644
--- a/gtksourceview/gtksourcefilesaver.c
+++ b/gtksourceview/gtksourcefilesaver.c
@@ -608,6 +608,7 @@ close_output_stream_cb (GOutputStream *output_stream,
GtkSourceFileSaver *saver)
{
GError *error = NULL;
+ gboolean save_metadata;
DEBUG ({
g_print ("%s\n", G_STRFUNC);
@@ -625,13 +626,22 @@ close_output_stream_cb (GOutputStream *output_stream,
return;
}
- g_file_set_attributes_async (saver->priv->location,
- saver->priv->metadata,
- G_FILE_QUERY_INFO_NONE,
- g_task_get_priority (saver->priv->task),
- g_task_get_cancellable (saver->priv->task),
- (GAsyncReadyCallback) set_metadata_cb,
- saver);
+ save_metadata = (saver->priv->flags & GTK_SOURCE_FILE_SAVER_FLAGS_DO_NOT_SAVE_METADATA) == 0;
+
+ if (save_metadata)
+ {
+ g_file_set_attributes_async (saver->priv->location,
+ saver->priv->metadata,
+ G_FILE_QUERY_INFO_NONE,
+ g_task_get_priority (saver->priv->task),
+ g_task_get_cancellable (saver->priv->task),
+ (GAsyncReadyCallback) set_metadata_cb,
+ saver);
+ }
+ else
+ {
+ query_info (saver);
+ }
}
static void
diff --git a/gtksourceview/gtksourcefilesaver.h b/gtksourceview/gtksourcefilesaver.h
index c376c03..3a42453 100644
--- a/gtksourceview/gtksourcefilesaver.h
+++ b/gtksourceview/gtksourcefilesaver.h
@@ -5,7 +5,7 @@
* Copyright (C) 2005, 2007 - Paolo Maggi
* Copyrhing (C) 2007 - Steve Frécinaux
* Copyright (C) 2008 - Jesse van den Kieboom
- * Copyright (C) 2014 - Sébastien Wilmet
+ * Copyright (C) 2014, 2016 - Sébastien Wilmet
*
* GtkSourceView is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -64,6 +64,7 @@ typedef enum
* @GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_INVALID_CHARS: Ignore invalid characters.
* @GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_MODIFICATION_TIME: Save file despite external modifications.
* @GTK_SOURCE_FILE_SAVER_FLAGS_CREATE_BACKUP: Create a backup before saving the file.
+ * @GTK_SOURCE_FILE_SAVER_FLAGS_DO_NOT_SAVE_METADATA: Do not save metadata. Since 3.22.
*
* Flags to define the behavior of a #GtkSourceFileSaver.
* Since: 3.14
@@ -73,7 +74,8 @@ typedef enum
GTK_SOURCE_FILE_SAVER_FLAGS_NONE = 0,
GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_INVALID_CHARS = 1 << 0,
GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_MODIFICATION_TIME = 1 << 1,
- GTK_SOURCE_FILE_SAVER_FLAGS_CREATE_BACKUP = 1 << 2
+ GTK_SOURCE_FILE_SAVER_FLAGS_CREATE_BACKUP = 1 << 2,
+ GTK_SOURCE_FILE_SAVER_FLAGS_DO_NOT_SAVE_METADATA = 1 << 3
} GtkSourceFileSaverFlags;
struct _GtkSourceFileSaver
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]