[gtksourceview/wip/metadata] FileLoader: add flag to not load metadata
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/metadata] FileLoader: add flag to not load metadata
- Date: Sat, 30 Apr 2016 15:58:23 +0000 (UTC)
commit 857c5a8c16da574d6b631b515a96f8d2a1093f16
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Apr 30 17:53:02 2016 +0200
FileLoader: add flag to not load metadata
docs/reference/gtksourceview-3.0-sections.txt | 3 +
gtksourceview/gtksourcefileloader.c | 65 ++++++++++++++++++++++++-
gtksourceview/gtksourcefileloader.h | 21 ++++++++
3 files changed, 88 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 6bfacb1..37c1b28 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -281,6 +281,7 @@ gtk_source_file_get_type
GtkSourceFileLoader
GTK_SOURCE_FILE_LOADER_ERROR
GtkSourceFileLoaderError
+GtkSourceFileLoaderFlags
<SUBSECTION>
gtk_source_file_loader_new
gtk_source_file_loader_new_from_stream
@@ -289,6 +290,8 @@ gtk_source_file_loader_get_buffer
gtk_source_file_loader_get_file
gtk_source_file_loader_get_location
gtk_source_file_loader_get_input_stream
+gtk_source_file_loader_set_flags
+gtk_source_file_loader_get_flags
gtk_source_file_loader_load_async
gtk_source_file_loader_load_finish
gtk_source_file_loader_load_metadata
diff --git a/gtksourceview/gtksourcefileloader.c b/gtksourceview/gtksourcefileloader.c
index 32370b6..5a5fdb8 100644
--- a/gtksourceview/gtksourcefileloader.c
+++ b/gtksourceview/gtksourcefileloader.c
@@ -73,7 +73,8 @@ enum
PROP_BUFFER,
PROP_FILE,
PROP_LOCATION,
- PROP_INPUT_STREAM
+ PROP_INPUT_STREAM,
+ PROP_FLAGS
};
#define READ_CHUNK_SIZE 8192
@@ -104,6 +105,7 @@ struct _GtkSourceFileLoaderPrivate
GInputStream *input_stream_property;
GSList *candidate_encodings;
+ GtkSourceFileLoaderFlags flags;
GFileInfo *info;
GFileInfo *metadata;
@@ -192,6 +194,10 @@ gtk_source_file_loader_set_property (GObject *object,
loader->priv->input_stream_property = g_value_dup_object (value);
break;
+ case PROP_FLAGS:
+ gtk_source_file_loader_set_flags (loader, g_value_get_flags (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -224,6 +230,10 @@ gtk_source_file_loader_get_property (GObject *object,
g_value_set_object (value, loader->priv->input_stream_property);
break;
+ case PROP_FLAGS:
+ g_value_set_flags (value, loader->priv->flags);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -436,6 +446,23 @@ gtk_source_file_loader_class_init (GtkSourceFileLoaderClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GtkSourceFileLoader:flags:
+ *
+ * File loading flags.
+ *
+ * Since: 3.22
+ */
+ g_object_class_install_property (object_class, PROP_FLAGS,
+ g_param_spec_flags ("flags",
+ "Flags",
+ "",
+ GTK_SOURCE_TYPE_FILE_LOADER_FLAGS,
+ GTK_SOURCE_FILE_LOADER_FLAGS_NONE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -1021,6 +1048,42 @@ gtk_source_file_loader_get_input_stream (GtkSourceFileLoader *loader)
}
/**
+ * gtk_source_file_loader_set_flags:
+ * @loader: a #GtkSourceFileLoader.
+ * @flags: the new flags.
+ *
+ * Since: 3.22
+ */
+void
+gtk_source_file_loader_set_flags (GtkSourceFileLoader *loader,
+ GtkSourceFileLoaderFlags flags)
+{
+ g_return_if_fail (GTK_SOURCE_IS_FILE_LOADER (loader));
+ g_return_if_fail (loader->priv->task == NULL);
+
+ if (loader->priv->flags != flags)
+ {
+ loader->priv->flags = flags;
+ g_object_notify (G_OBJECT (loader), "flags");
+ }
+}
+
+/**
+ * gtk_source_file_loader_get_flags:
+ * @loader: a #GtkSourceFileLoader.
+ *
+ * Returns: the flags.
+ * Since: 3.22
+ */
+GtkSourceFileLoaderFlags
+gtk_source_file_loader_get_flags (GtkSourceFileLoader *loader)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_FILE_LOADER (loader), GTK_SOURCE_FILE_LOADER_FLAGS_NONE);
+
+ return loader->priv->flags;
+}
+
+/**
* gtk_source_file_loader_load_async:
* @loader: a #GtkSourceFileLoader.
* @io_priority: the I/O priority of the request. E.g. %G_PRIORITY_LOW,
diff --git a/gtksourceview/gtksourcefileloader.h b/gtksourceview/gtksourcefileloader.h
index fc139b6..fc4d9b6 100644
--- a/gtksourceview/gtksourcefileloader.h
+++ b/gtksourceview/gtksourcefileloader.h
@@ -59,6 +59,20 @@ typedef enum
GTK_SOURCE_FILE_LOADER_ERROR_CONVERSION_FALLBACK
} GtkSourceFileLoaderError;
+/**
+ * GtkSourceFileLoaderFlags:
+ * @GTK_SOURCE_FILE_LOADER_FLAGS_NONE: No flags.
+ * @GTK_SOURCE_FILE_LOADER_FLAGS_DO_NOT_LOAD_METADATA: Do not load metadata.
+ *
+ * Flags to define the behavior of a #GtkSourceFileLoader.
+ * Since: 3.22
+ */
+typedef enum
+{
+ GTK_SOURCE_FILE_LOADER_FLAGS_NONE = 0,
+ GTK_SOURCE_FILE_LOADER_FLAGS_DO_NOT_LOAD_METADATA = 1 << 0
+} GtkSourceFileLoaderFlags;
+
struct _GtkSourceFileLoader
{
GObject parent;
@@ -106,6 +120,13 @@ GTK_SOURCE_AVAILABLE_IN_3_14
GInputStream *gtk_source_file_loader_get_input_stream
(GtkSourceFileLoader *loader);
+GTK_SOURCE_AVAILABLE_IN_3_22
+void gtk_source_file_loader_set_flags (GtkSourceFileLoader *loader,
+ GtkSourceFileLoaderFlags flags);
+
+GTK_SOURCE_AVAILABLE_IN_3_22
+GtkSourceFileLoaderFlags gtk_source_file_loader_get_flags (GtkSourceFileLoader *loader);
+
GTK_SOURCE_AVAILABLE_IN_3_14
void gtk_source_file_loader_load_async (GtkSourceFileLoader *loader,
gint io_priority,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]