[gnome-builder] libide: add basic IdeFileSettings abstraction
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add basic IdeFileSettings abstraction
- Date: Mon, 23 Mar 2015 23:31:20 +0000 (UTC)
commit ba9fc9d0d7127e71934c1e907bbe355fa3cf9df8
Author: Christian Hergert <christian hergert me>
Date: Sat Feb 14 17:22:39 2015 -0800
libide: add basic IdeFileSettings abstraction
This will allow us to have various file settings backends, such as
editorconfig, modelines, or gsettings.
libide/ide-file.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
libide/ide-file.h | 23 ++++++++++++------
libide/ide-types.h | 2 +
libide/ide.c | 2 +
4 files changed, 84 insertions(+), 8 deletions(-)
---
diff --git a/libide/ide-file.c b/libide/ide-file.c
index 0e10441..e4ea535 100644
--- a/libide/ide-file.c
+++ b/libide/ide-file.c
@@ -20,6 +20,7 @@
#include <gtksourceview/gtksource.h>
#include "ide-file.h"
+#include "ide-file-settings.h"
#include "ide-language.h"
typedef struct
@@ -228,6 +229,70 @@ ide_file_set_path (IdeFile *self,
}
static void
+ide_file_load_settings_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeObject) ret = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (G_IS_TASK (task));
+
+ ret = ide_object_new_finish (result, &error);
+
+ if (!ret)
+ {
+ g_task_return_error (task, error);
+ return;
+ }
+
+ g_task_return_pointer (task, g_object_ref (ret), g_object_unref);
+}
+
+void
+ide_file_load_settings_async (IdeFile *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = NULL;
+
+ g_return_if_fail (IDE_IS_FILE (self));
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ task = g_task_new (self, cancellable, callback, user_data);
+
+ ide_object_new_async (IDE_FILE_SETTINGS_EXTENSION_POINT,
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ ide_file_load_settings_cb,
+ g_object_ref (task),
+ "file", self,
+ NULL);
+}
+
+/**
+ * ide_file_load_settings_finish:
+ *
+ *
+ *
+ * Returns: (transfer full): An #IdeFileSettings or %NULL upon failure and
+ * @error is set.
+ */
+IdeFileSettings *
+ide_file_load_settings_finish (IdeFile *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ GTask *task = (GTask *)result;
+
+ g_return_val_if_fail (G_IS_TASK (task), NULL);
+
+ return g_task_propagate_pointer (task, error);
+}
+
+static void
ide_file_finalize (GObject *object)
{
IdeFile *self = (IdeFile *)object;
diff --git a/libide/ide-file.h b/libide/ide-file.h
index 77606a0..da32de0 100644
--- a/libide/ide-file.h
+++ b/libide/ide-file.h
@@ -32,14 +32,21 @@ struct _IdeFile
IdeObject parent_instance;
};
-IdeLanguage *ide_file_get_language (IdeFile *self);
-GFile *ide_file_get_file (IdeFile *self);
-const gchar *ide_file_get_project_path (IdeFile *self);
-guint ide_file_hash (IdeFile *self);
-gboolean ide_file_equal (IdeFile *self,
- IdeFile *other);
-const gchar *ide_file_get_path (IdeFile *self);
-//IdeFileSettings *ide_file_get_file_settings (IdeFile *self);
+IdeLanguage *ide_file_get_language (IdeFile *self);
+GFile *ide_file_get_file (IdeFile *self);
+const gchar *ide_file_get_project_path (IdeFile *self);
+guint ide_file_hash (IdeFile *self);
+gboolean ide_file_equal (IdeFile *self,
+ IdeFile *other);
+const gchar *ide_file_get_path (IdeFile *self);
+void ide_file_load_settings_async (IdeFile *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+IdeFileSettings *ide_file_load_settings_finish (IdeFile *self,
+ GAsyncResult *result,
+ GError **error);
+
G_END_DECLS
diff --git a/libide/ide-types.h b/libide/ide-types.h
index cf16c93..036b35b 100644
--- a/libide/ide-types.h
+++ b/libide/ide-types.h
@@ -68,6 +68,8 @@ typedef struct _IdeExecutableInterface IdeExecutableInterface;
typedef struct _IdeFile IdeFile;
+typedef struct _IdeFileSettings IdeFileSettings;
+
typedef struct _IdeHighlighter IdeHighlighter;
typedef struct _IdeIndenter IdeIndenter;
diff --git a/libide/ide.c b/libide/ide.c
index 62f58ed..adb898b 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -27,6 +27,7 @@
#include "ide-clang-service.h"
#include "ide-directory-build-system.h"
#include "ide-directory-vcs.h"
+#include "ide-file-settings.h"
#include "ide-git-vcs.h"
static gboolean gProgramNameRead;
@@ -60,6 +61,7 @@ ide_init_ctor (void)
g_type_ensure (IDE_TYPE_VCS);
g_io_extension_point_register (IDE_BUILD_SYSTEM_EXTENSION_POINT);
+ g_io_extension_point_register (IDE_FILE_SETTINGS_EXTENSION_POINT);
g_io_extension_point_register (IDE_LANGUAGE_EXTENSION_POINT);
g_io_extension_point_register (IDE_SERVICE_EXTENSION_POINT);
g_io_extension_point_register (IDE_VCS_EXTENSION_POINT);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]