[gedit/wip/loader-saver: 13/52] Add gedit_document_get_file()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/loader-saver: 13/52] Add gedit_document_get_file()
- Date: Mon, 7 Jul 2014 15:11:28 +0000 (UTC)
commit 3e7b268f37e159fed091fa080b67aef37a05f866
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Jun 11 19:09:43 2014 +0200
Add gedit_document_get_file()
The function returns the associated GtkSourceFile.
docs/reference/gedit-sections.txt | 1 +
gedit/gedit-document.c | 29 +++++++++++++++++++++++++++++
gedit/gedit-document.h | 2 ++
3 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gedit-sections.txt b/docs/reference/gedit-sections.txt
index caa1935..898ded7 100644
--- a/docs/reference/gedit-sections.txt
+++ b/docs/reference/gedit-sections.txt
@@ -50,6 +50,7 @@ GeditDocumentCompressionType
GEDIT_DOCUMENT_ERROR
gedit_document_error_quark
gedit_document_new
+gedit_document_get_file
gedit_document_get_location
gedit_document_set_location
gedit_document_get_uri_for_display
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index ecba9c5..068a4eb 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -62,6 +62,8 @@ static void gedit_document_save_real (GeditDocument *doc,
struct _GeditDocumentPrivate
{
+ GtkSourceFile *file;
+
GSettings *editor_settings;
GFile *location;
@@ -280,6 +282,7 @@ gedit_document_dispose (GObject *object)
g_clear_object (&doc->priv->editor_settings);
g_clear_object (&doc->priv->metadata_info);
g_clear_object (&doc->priv->search_context);
+ g_clear_object (&doc->priv->file);
G_OBJECT_CLASS (gedit_document_parent_class)->dispose (object);
}
@@ -917,6 +920,8 @@ gedit_document_init (GeditDocument *doc)
priv->encoding = gedit_encoding_get_utf8 ();
+ priv->file = gtk_source_file_new (GTK_SOURCE_BUFFER (doc));
+
g_settings_bind (priv->editor_settings,
GEDIT_SETTINGS_MAX_UNDO_ACTIONS,
doc,
@@ -2555,4 +2560,28 @@ _gedit_document_get_empty_search (GeditDocument *doc)
return doc->priv->empty_search;
}
+/**
+ * gedit_document_get_file:
+ * @doc: a #GeditDocument.
+ *
+ * Gets the associated #GtkSourceFile. You should use it only for reading
+ * purposes, not for creating a #GtkSourceFileLoader or #GtkSourceFileSaver,
+ * because gedit does some extra work when loading or saving a file and
+ * maintains an internal state. If you use in a plugin a file loader or saver on
+ * the returned #GtkSourceFile, the internal state of gedit won't be updated.
+ *
+ * If you want to save the #GeditDocument to a secondary file, you can create a
+ * new #GtkSourceFile and use a #GtkSourceFileSaver.
+ *
+ * Returns: (transfer none): the associated #GtkSourceFile.
+ * Since: 3.14
+ */
+GtkSourceFile *
+gedit_document_get_file (GeditDocument *doc)
+{
+ g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL);
+
+ return doc->priv->file;
+}
+
/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h
index 98290f3..63a84af 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -285,6 +285,8 @@ GMountOperation
gboolean _gedit_document_get_empty_search (GeditDocument *doc);
+GtkSourceFile *gedit_document_get_file (GeditDocument *doc);
+
G_END_DECLS
#endif /* __GEDIT_DOCUMENT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]