[gedit/wip/loader-saver: 2/2] gedit_document_get_file(): returns a GtkSourceFile



commit c785d2117e5455cf52adc075ffc04cb1fa3ee841
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Jun 11 19:09:43 2014 +0200

    gedit_document_get_file(): returns a GtkSourceFile

 docs/reference/gedit-sections.txt |    1 +
 gedit/gedit-document.c            |   19 +++++++++++++++++++
 gedit/gedit-document.h            |    2 ++
 3 files changed, 22 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..41303c6 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,18 @@ _gedit_document_get_empty_search (GeditDocument *doc)
        return doc->priv->empty_search;
 }
 
+/**
+ * gedit_document_get_file:
+ * @doc: a #GeditDocument.
+ *
+ * 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]