[gtksourceview/wip/loader-saver] GtkSourceBuffer properties



commit 6dd3a28c0151dc9823908038fea53cf73044384b
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Mar 31 19:39:55 2014 +0200

    GtkSourceBuffer properties

 gtksourceview/gtksourcebuffer.c |  117 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 116 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index b6adde5..1a669bd 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -42,6 +42,7 @@
 #include "gtksourcemark.h"
 #include "gtksourcemarkssequence.h"
 #include "gtksourcesearchcontext.h"
+#include "gtksourceencoding.h"
 #include "gtksourceview-i18n.h"
 #include "gtksourceview-marshal.h"
 #include "gtksourceview-typebuiltins.h"
@@ -140,7 +141,12 @@ enum {
        PROP_MAX_UNDO_LEVELS,
        PROP_LANGUAGE,
        PROP_STYLE_SCHEME,
-       PROP_UNDO_MANAGER
+       PROP_UNDO_MANAGER,
+       PROP_FILE,
+       PROP_ENCODING,
+       PROP_NEWLINE_TYPE,
+       PROP_COMPRESSION_TYPE,
+       PROP_IMPLICIT_TRAILING_NEWLINE
 };
 
 struct _GtkSourceBufferPrivate
@@ -166,10 +172,16 @@ struct _GtkSourceBufferPrivate
 
        GtkTextTag            *invalid_char_tag;
 
+       GFile                    *file;
+       const GtkSourceEncoding  *encoding;
+       GtkSourceNewlineType      newline_type;
+       GtkSourceCompressionType  compression_type;
+
        guint                  highlight_syntax : 1;
        guint                  highlight_brackets : 1;
        guint                  constructed : 1;
        guint                  allow_bracket_match : 1;
+       guint                  implicit_trailing_newline : 1;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceBuffer, gtk_source_buffer, GTK_TYPE_TEXT_BUFFER)
@@ -359,6 +371,85 @@ gtk_source_buffer_class_init (GtkSourceBufferClass *klass)
                                                              GTK_SOURCE_TYPE_UNDO_MANAGER,
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
+       /**
+        * GtkSourceBuffer:file:
+        *
+        * The associated #GFile.
+        *
+        * Since: 3.14
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_FILE,
+                                        g_param_spec_object ("file",
+                                                             _("File"),
+                                                             _("The associated file"),
+                                                             G_TYPE_FILE,
+                                                             G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+       /**
+        * GtkSourceBuffer:encoding:
+        *
+        * The #GtkSourceBuffer:file's encoding. Note that the #GtkSourceBuffer
+        * always has a UTF-8 encoding.
+        *
+        * Since: 3.14
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_ENCODING,
+                                        g_param_spec_boxed ("encoding",
+                                                            _("Encoding"),
+                                                            _("The file's encoding"),
+                                                            GTK_SOURCE_TYPE_ENCODING,
+                                                            G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+       /**
+        * GtkSourceBuffer:newline-type:
+        *
+        * The type of line ending.
+        *
+        * Since: 3.14
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_NEWLINE_TYPE,
+                                        g_param_spec_enum ("newline-type",
+                                                           _("Newline type"),
+                                                           _("The type of line ending"),
+                                                           GTK_SOURCE_TYPE_NEWLINE_TYPE,
+                                                           GTK_SOURCE_NEWLINE_TYPE_LF,
+                                                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+       /**
+        * GtkSourceBuffer:compression-type:
+        *
+        * The #GtkSourceBuffer:file's compression type.
+        *
+        * Since: 3.14
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_COMPRESSION_TYPE,
+                                        g_param_spec_enum ("compression-type",
+                                                           _("Compression type"),
+                                                           _("The file's compression type"),
+                                                           GTK_SOURCE_TYPE_COMPRESSION_TYPE,
+                                                           GTK_SOURCE_COMPRESSION_TYPE_NONE,
+                                                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+       /**
+        * GtkSourceBuffer:implicit-trailing-newline:
+        *
+        * Whether the buffer has an implicit trailing newline.
+        *
+        * Since: 3.14
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_IMPLICIT_TRAILING_NEWLINE,
+                                        g_param_spec_boolean ("implicit-trailing-newline",
+                                                              _("Implicit trailing newline"),
+                                                              _("Whether the buffer has an implicit trailing 
newline"),
+                                                              TRUE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
+                                                              G_PARAM_STATIC_STRINGS));
+
        param_types[0] = GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE;
        param_types[1] = GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE;
 
@@ -629,6 +720,10 @@ gtk_source_buffer_set_property (GObject      *object,
                                                            g_value_get_object (value));
                        break;
 
+               case PROP_IMPLICIT_TRAILING_NEWLINE:
+                       source_buffer->priv->implicit_trailing_newline = g_value_get_boolean (value);
+                       break;
+
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                        break;
@@ -684,6 +779,26 @@ gtk_source_buffer_get_property (GObject    *object,
                        g_value_set_object (value, source_buffer->priv->undo_manager);
                        break;
 
+               case PROP_FILE:
+                       g_value_set_object (value, source_buffer->priv->file);
+                       break;
+
+               case PROP_ENCODING:
+                       g_value_set_boxed (value, source_buffer->priv->encoding);
+                       break;
+
+               case PROP_NEWLINE_TYPE:
+                       g_value_set_enum (value, source_buffer->priv->newline_type);
+                       break;
+
+               case PROP_COMPRESSION_TYPE:
+                       g_value_set_enum (value, source_buffer->priv->compression_type);
+                       break;
+
+               case PROP_IMPLICIT_TRAILING_NEWLINE:
+                       g_value_set_boolean (value, source_buffer->priv->implicit_trailing_newline);
+                       break;
+
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                        break;


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