[gedit/wip/loader-saver: 1/2] Add gedit_document_get_file()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/loader-saver: 1/2] Add gedit_document_get_file()
- Date: Fri, 13 Jun 2014 21:31:00 +0000 (UTC)
commit 90ccfe47e7a54a1d9de39641e8dab678dc22d4f7
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 | 27 +++++++++++++++++++++++++++
gedit/gedit-document.h | 2 ++
3 files changed, 30 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 8d230c2..1630871 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -78,6 +78,8 @@ static void gedit_document_save_real (GeditDocument *doc,
struct _GeditDocumentPrivate
{
+ GtkSourceFile *file;
+
GSettings *editor_settings;
GFile *location;
@@ -288,6 +290,7 @@ gedit_document_dispose (GObject *object)
g_clear_object (&doc->priv->metadata_info);
g_clear_object (&doc->priv->location);
g_clear_object (&doc->priv->search_context);
+ g_clear_object (&doc->priv->file);
doc->priv->dispose_has_run = TRUE;
@@ -919,6 +922,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,
@@ -2594,4 +2599,26 @@ _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. Use
+ * the higher-lever gedit API instead, since those functions do some extra work,
+ * like displaying progress and error information in an info bar.
+ *
+ * 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.
+ */
+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 1a0bef6..be122c4 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -302,6 +302,8 @@ GtkSourceSearchContext *gedit_document_get_search_context (GeditDocument
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]