[gtksourceview/wip/loader-saver] FileLoader: update the Buffer properties on successful load
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/loader-saver] FileLoader: update the Buffer properties on successful load
- Date: Wed, 2 Apr 2014 18:00:02 +0000 (UTC)
commit b942dfb6a3e85cd765869ffe28f5e866a157be90
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Apr 2 19:58:28 2014 +0200
FileLoader: update the Buffer properties on successful load
gtksourceview/gtksourcefileloader.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/gtksourceview/gtksourcefileloader.c b/gtksourceview/gtksourcefileloader.c
index 0fcc28b..b68511a 100644
--- a/gtksourceview/gtksourcefileloader.c
+++ b/gtksourceview/gtksourcefileloader.c
@@ -26,6 +26,7 @@
#include "gtksourcefileloader.h"
#include "gtksourcebufferoutputstream.h"
#include "gtksourceencoding.h"
+#include "gtksourcebuffer-private.h"
#include "gtksourceview-typebuiltins.h"
#include "gtksourceview-i18n.h"
@@ -886,6 +887,10 @@ gtk_source_file_loader_load_async (GtkSourceFileLoader *loader,
*
* Finishes a file loading started with gtk_source_file_loader_load_async().
*
+ * If the file has been loaded successfully, the following #GtkSourceBuffer
+ * properties will be updated: the file, the encoding, the newline type and the
+ * compression type.
+ *
* Returns: whether the file was loaded successfully.
* Since: 3.14
*/
@@ -902,6 +907,21 @@ gtk_source_file_loader_load_finish (GtkSourceFileLoader *loader,
ok = g_task_propagate_boolean (G_TASK (result), error);
+ if (ok && loader->priv->source_buffer != NULL)
+ {
+ _gtk_source_buffer_set_file (loader->priv->source_buffer,
+ loader->priv->file);
+
+ _gtk_source_buffer_set_encoding (loader->priv->source_buffer,
+ loader->priv->auto_detected_encoding);
+
+ _gtk_source_buffer_set_newline_type (loader->priv->source_buffer,
+ loader->priv->auto_detected_newline_type);
+
+ _gtk_source_buffer_set_compression_type (loader->priv->source_buffer,
+ loader->priv->auto_detected_compression_type);
+ }
+
reset (loader);
return ok;
@@ -919,9 +939,6 @@ gtk_source_file_loader_get_encoding (GtkSourceFileLoader *loader)
{
g_return_val_if_fail (GTK_SOURCE_IS_FILE_LOADER (loader), NULL);
- g_return_val_if_fail (loader->priv->auto_detected_encoding != NULL,
- gtk_source_encoding_get_current ());
-
return loader->priv->auto_detected_encoding;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]