[gnome-builder] libide: use IdeFileSettings to detect implicit-trailing-newline
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: use IdeFileSettings to detect implicit-trailing-newline
- Date: Mon, 23 Mar 2015 23:41:02 +0000 (UTC)
commit 056ba4843694eb80e1f8fe16e3b84afac971555b
Author: Christian Hergert <christian hergert me>
Date: Tue Feb 24 17:54:17 2015 -0800
libide: use IdeFileSettings to detect implicit-trailing-newline
libide/ide-buffer.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 7f46519..8c44afb 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -23,6 +23,7 @@
#include "ide-buffer.h"
#include "ide-context.h"
#include "ide-file.h"
+#include "ide-file-settings.h"
struct _IdeBufferClass
{
@@ -60,6 +61,30 @@ ide_buffer_set_context (IdeBuffer *self,
}
static void
+ide_buffer__file_load_settings_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ g_autoptr(IdeBuffer) self = user_data;
+ IdeFile *file = (IdeFile *)object;
+ g_autoptr(IdeFileSettings) file_settings = NULL;
+
+ g_assert (IDE_IS_BUFFER (self));
+ g_assert (IDE_IS_FILE (file));
+
+ file_settings = ide_file_load_settings_finish (file, result, NULL);
+
+ if (file_settings)
+ {
+ gboolean insert_trailing_newline;
+
+ insert_trailing_newline = ide_file_settings_get_insert_trailing_newline (file_settings);
+ gtk_source_buffer_set_implicit_trailing_newline (GTK_SOURCE_BUFFER (self),
+ insert_trailing_newline);
+ }
+}
+
+static void
ide_buffer_finalize (GObject *object)
{
IdeBuffer *self = (IdeBuffer *)object;
@@ -202,7 +227,14 @@ ide_buffer_set_file (IdeBuffer *self,
g_return_if_fail (IDE_IS_FILE (file));
if (g_set_object (&self->file, file))
- g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_FILE]);
+ {
+ ide_file_load_settings_async (self->file,
+ NULL,
+ ide_buffer__file_load_settings_cb,
+ g_object_ref (self));
+
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_FILE]);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]