[gnome-builder/wip/file-marks] file-marks: add synchronous variant of saving marks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/file-marks] file-marks: add synchronous variant of saving marks
- Date: Wed, 8 Oct 2014 21:42:46 +0000 (UTC)
commit a36f7016d74720857fed609e8c67f43240f58114
Author: Christian Hergert <christian hergert me>
Date: Wed Oct 8 14:42:13 2014 -0700
file-marks: add synchronous variant of saving marks
This is useful for the shutdown case where we need to persist file-marks
back to the state file.
src/editor/gb-editor-file-marks.c | 30 ++++++++++++++++++++++++++++++
src/editor/gb-editor-file-marks.h | 3 +++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-file-marks.c b/src/editor/gb-editor-file-marks.c
index 17231a6..d3313e9 100644
--- a/src/editor/gb-editor-file-marks.c
+++ b/src/editor/gb-editor-file-marks.c
@@ -211,6 +211,36 @@ gb_editor_file_marks_save_finish (GbEditorFileMarks *marks,
}
gboolean
+gb_editor_file_marks_save (GbEditorFileMarks *marks,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GBytes *bytes;
+ GFile *file;
+ gboolean ret;
+
+ g_return_val_if_fail (GB_IS_EDITOR_FILE_MARKS (marks), FALSE);
+
+ bytes = gb_editor_file_marks_serialize (marks);
+ file = gb_editor_file_marks_get_file (marks);
+
+ ret = g_file_replace_contents (file,
+ g_bytes_get_data (bytes, NULL),
+ g_bytes_get_size (bytes),
+ NULL,
+ FALSE,
+ G_FILE_CREATE_REPLACE_DESTINATION,
+ NULL,
+ cancellable,
+ error);
+
+ g_bytes_unref (bytes);
+ g_clear_object (&file);
+
+ return ret;
+}
+
+gboolean
gb_editor_file_marks_load (GbEditorFileMarks *marks,
GError **error)
{
diff --git a/src/editor/gb-editor-file-marks.h b/src/editor/gb-editor-file-marks.h
index c2a3ddc..e035e25 100644
--- a/src/editor/gb-editor-file-marks.h
+++ b/src/editor/gb-editor-file-marks.h
@@ -55,6 +55,9 @@ GbEditorFileMark *gb_editor_file_marks_get_for_file (GbEditorFileMarks *mark
GFile *file);
gboolean gb_editor_file_marks_load (GbEditorFileMarks *marks,
GError **error);
+gboolean gb_editor_file_marks_save (GbEditorFileMarks *marks,
+ GCancellable *cancellable,
+ GError **error);
void gb_editor_file_marks_save_async (GbEditorFileMarks *marks,
GCancellable *cancellable,
GAsyncReadyCallback callback,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]