[gnome-builder: 6/7] GbEditorDocument: add gb_editor_document_reload() helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 6/7] GbEditorDocument: add gb_editor_document_reload() helper
- Date: Fri, 12 Dec 2014 07:58:31 +0000 (UTC)
commit 150ebfb38d7a00d1e4f83d2911f14f7f438b2dd0
Author: Christian Hergert <christian hergert me>
Date: Thu Dec 11 23:57:09 2014 -0800
GbEditorDocument: add gb_editor_document_reload() helper
src/editor/gb-editor-document.c | 18 ++++++++++++++++++
src/editor/gb-editor-document.h | 1 +
2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-document.c b/src/editor/gb-editor-document.c
index 9f1f88c..dd41b96 100644
--- a/src/editor/gb-editor-document.c
+++ b/src/editor/gb-editor-document.c
@@ -1060,6 +1060,24 @@ gb_editor_document_load_finish (GbEditorDocument *document,
return g_task_propagate_boolean (task, error);
}
+void
+gb_editor_document_reload (GbEditorDocument *document)
+{
+ GFile *location;
+
+ g_return_if_fail (GB_IS_EDITOR_DOCUMENT (document));
+
+ location = gtk_source_file_get_location (document->priv->file);
+
+ if (!location)
+ {
+ g_warning ("Cannot reload document as it has not been saved to disk.");
+ return;
+ }
+
+ gb_editor_document_load_async (document, location, NULL, NULL, NULL);
+}
+
static void
gb_editor_document_modified_changed (GtkTextBuffer *buffer)
{
diff --git a/src/editor/gb-editor-document.h b/src/editor/gb-editor-document.h
index af3d7d8..6f30c70 100644
--- a/src/editor/gb-editor-document.h
+++ b/src/editor/gb-editor-document.h
@@ -85,6 +85,7 @@ gboolean gb_editor_document_save_finish (GbEditor
GError **error);
void gb_editor_document_reformat (GbEditorDocument *document);
void gb_editor_document_check_externally_modified (GbEditorDocument *document);
+void gb_editor_document_reload (GbEditorDocument *document);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]