[gtksourceview/wip/loader-saver] GtkSourceFile API with stubs
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/loader-saver] GtkSourceFile API with stubs
- Date: Wed, 11 Dec 2013 14:05:22 +0000 (UTC)
commit de753518647f8d674117324c5783b4577eada686
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Dec 11 14:30:49 2013 +0100
GtkSourceFile API with stubs
gtksourceview/gtksourcefile.c | 172 ++++++++++++++++++++++++++++++++++++++++-
gtksourceview/gtksourcefile.h | 16 ++++-
2 files changed, 185 insertions(+), 3 deletions(-)
---
diff --git a/gtksourceview/gtksourcefile.c b/gtksourceview/gtksourcefile.c
index 33624e2..a3e98e1 100644
--- a/gtksourceview/gtksourcefile.c
+++ b/gtksourceview/gtksourcefile.c
@@ -20,15 +20,106 @@
*/
#include "gtksourcefile.h"
+#include "gtksourcebuffer.h"
+#include "gtksourceencoding.h"
+
+enum
+{
+ PROP_0,
+ PROP_LOCATION,
+ PROP_BUFFER,
+ PROP_ENCODING
+};
struct _GtkSourceFilePrivate
{
- gint something;
+ GFile *location;
+ GtkSourceBuffer *buffer;
+ const GtkSourceEncoding *encoding;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceFile, gtk_source_file, G_TYPE_OBJECT)
static void
+gtk_source_file_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkSourceFile *file;
+
+ g_return_if_fail (GTK_SOURCE_IS_FILE (object));
+
+ file = GTK_SOURCE_FILE (object);
+
+ switch (prop_id)
+ {
+ case PROP_LOCATION:
+ g_value_set_object (value, file->priv->location);
+ break;
+
+ case PROP_BUFFER:
+ g_value_set_object (value, file->priv->buffer);
+ break;
+
+ case PROP_ENCODING:
+ g_value_set_boxed (value, file->priv->encoding);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_source_file_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkSourceFile *file;
+
+ g_return_if_fail (GTK_SOURCE_IS_FILE (object));
+
+ file = GTK_SOURCE_FILE (object);
+
+ switch (prop_id)
+ {
+ case PROP_LOCATION:
+ g_assert (file->priv->location == NULL);
+ file->priv->location = g_value_get_object (value);
+ g_object_ref (file->priv->location);
+ break;
+
+ case PROP_BUFFER:
+ g_assert (file->priv->buffer == NULL);
+ file->priv->buffer = g_value_get_object (value);
+ g_object_ref (file->priv->buffer);
+ break;
+
+ case PROP_ENCODING:
+ gtk_source_file_set_encoding (file, g_value_get_boxed (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_source_file_dispose (GObject *object)
+{
+ GtkSourceFile *file = GTK_SOURCE_FILE (object);
+
+ g_clear_object (&file->priv->location);
+ g_clear_object (&file->priv->buffer);
+
+ G_OBJECT_CLASS (gtk_source_file_parent_class)->dispose (object);
+}
+
+static void
gtk_source_file_finalize (GObject *object)
{
@@ -40,7 +131,36 @@ gtk_source_file_class_init (GtkSourceFileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = gtk_source_file_get_property;
+ object_class->set_property = gtk_source_file_set_property;
+ object_class->dispose = gtk_source_file_dispose;
object_class->finalize = gtk_source_file_finalize;
+
+ g_object_class_install_property (object_class, PROP_LOCATION,
+ g_param_spec_object ("location",
+ "Location",
+ "The file's location",
+ G_TYPE_FILE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class, PROP_BUFFER,
+ g_param_spec_object ("buffer",
+ "Buffer",
+ "The associated GtkSourceBuffer",
+ GTK_SOURCE_TYPE_BUFFER,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class, PROP_ENCODING,
+ g_param_spec_boxed ("encoding",
+ "Encoding",
+ "The GtkSourceEncoding used",
+ GTK_SOURCE_TYPE_ENCODING,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -48,3 +168,53 @@ gtk_source_file_init (GtkSourceFile *self)
{
self->priv = gtk_source_file_get_instance_private (self);
}
+
+GtkSourceFile *
+gtk_source_file_new (GFile *location,
+ GtkSourceBuffer *buffer)
+{
+ g_return_val_if_fail (G_IS_FILE (location), NULL);
+ g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), NULL);
+
+ return g_object_new (GTK_SOURCE_TYPE_FILE,
+ "location", location,
+ "buffer", buffer,
+ NULL);
+}
+
+GFile *
+gtk_source_file_get_location (GtkSourceFile *file)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_FILE (file), NULL);
+
+ return file->priv->location;
+}
+
+GtkSourceBuffer *
+gtk_source_file_get_buffer (GtkSourceFile *file)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_FILE (file), NULL);
+
+ return file->priv->buffer;
+}
+
+const GtkSourceEncoding *
+gtk_source_file_get_encoding (GtkSourceFile *file)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_FILE (file), NULL);
+
+ return file->priv->encoding;
+}
+
+void
+gtk_source_file_set_encoding (GtkSourceFile *file,
+ const GtkSourceEncoding *encoding)
+{
+ g_return_if_fail (GTK_SOURCE_IS_FILE (file));
+
+ if (file->priv->encoding != encoding)
+ {
+ file->priv->encoding = encoding;
+ g_object_notify (G_OBJECT (file), "encoding");
+ }
+}
diff --git a/gtksourceview/gtksourcefile.h b/gtksourceview/gtksourcefile.h
index c1f0b39..650fb5d 100644
--- a/gtksourceview/gtksourcefile.h
+++ b/gtksourceview/gtksourcefile.h
@@ -22,7 +22,7 @@
#ifndef __GTK_SOURCE_FILE_H__
#define __GTK_SOURCE_FILE_H__
-#include <glib-object.h>
+#include <gio/gio.h>
#include <gtksourceview/gtksourcetypes.h>
G_BEGIN_DECLS
@@ -49,7 +49,19 @@ struct _GtkSourceFileClass
GObjectClass parent_class;
};
-GType gtk_source_file_get_type (void) G_GNUC_CONST;
+GType gtk_source_file_get_type (void) G_GNUC_CONST;
+
+GtkSourceFile *gtk_source_file_new (GFile *location,
+ GtkSourceBuffer *buffer);
+
+GFile *gtk_source_file_get_location (GtkSourceFile *file);
+
+GtkSourceBuffer *gtk_source_file_get_buffer (GtkSourceFile *file);
+
+const GtkSourceEncoding *gtk_source_file_get_encoding (GtkSourceFile *file);
+
+void gtk_source_file_set_encoding (GtkSourceFile *file,
+ const GtkSourceEncoding *encoding);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]