[gedit] Document: metadata: create an internal TeplFile



commit c2904aa80a37021d9fba35ee06d12f29a95b5756
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Nov 14 11:32:21 2019 +0100

    Document: metadata: create an internal TeplFile
    
    First step to re-implement metadata in GeditDocument.

 gedit/gedit-document.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index d776c5151..028a9ce5f 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -28,6 +28,7 @@
 
 #include <string.h>
 #include <glib/gi18n.h>
+#include <tepl/tepl.h>
 
 #include "gedit-settings.h"
 #include "gedit-debug.h"
@@ -46,6 +47,9 @@ typedef struct
 {
        GtkSourceFile *file;
 
+       /* Used only internally for the TeplFileMetadata. */
+       TeplFile *tepl_file;
+
        GSettings   *editor_settings;
 
        gint         untitled_number;
@@ -192,14 +196,15 @@ gedit_document_dispose (GObject *object)
        /* Metadata must be saved here and not in finalize because the language
         * is gone by the time finalize runs.
         */
-       if (priv->file != NULL)
+       if (priv->tepl_file != NULL)
        {
                save_metadata (doc);
 
-               g_object_unref (priv->file);
-               priv->file = NULL;
+               g_object_unref (priv->tepl_file);
+               priv->tepl_file = NULL;
        }
 
+       g_clear_object (&priv->file);
        g_clear_object (&priv->editor_settings);
        g_clear_object (&priv->search_context);
 
@@ -740,6 +745,13 @@ gedit_document_init (GeditDocument *doc)
                                 doc,
                                 0);
 
+       priv->tepl_file = tepl_file_new ();
+
+       /* For using TeplFileMetadata we only need the TeplFile:location. */
+       g_object_bind_property (priv->file, "location",
+                               priv->tepl_file, "location",
+                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+
        g_settings_bind (priv->editor_settings,
                         GEDIT_SETTINGS_MAX_UNDO_ACTIONS,
                         doc,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]