[gnome-builder] file: add helper to peek at settings



commit 37b1685e74c8221176b482f3627ea7b9e0544071
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jan 29 16:24:55 2018 -0800

    file: add helper to peek at settings
    
    If a file is open, we should have the file settings loaded. This allows
    components to access the file settings without having to go through the
    async flow, since it should be unnecessary. That simplifies some of our
    code in completion providers if/when they need to use file settings.

 src/libide/files/ide-file.c | 18 ++++++++++++++++++
 src/libide/files/ide-file.h |  2 ++
 2 files changed, 20 insertions(+)
---
diff --git a/src/libide/files/ide-file.c b/src/libide/files/ide-file.c
index 82a95b753..e8200c8a2 100644
--- a/src/libide/files/ide-file.c
+++ b/src/libide/files/ide-file.c
@@ -352,6 +352,24 @@ ide_file_load_settings_finish (IdeFile              *self,
   IDE_RETURN (ret);
 }
 
+/**
+ * ide_file_peek_settings:
+ * @self: a #IdeFile
+ *
+ * Returns the #IdeFileSettings if they've been loaded.
+ *
+ * Returns: (nullable) (transfer none): an #IdeFileSettings or %NULL
+ *
+ * Since: 3.28
+ */
+IdeFileSettings *
+ide_file_peek_settings (IdeFile *self)
+{
+  g_return_val_if_fail (IDE_IS_FILE (self), NULL);
+
+  return self->file_settings;
+}
+
 /**
  * ide_file_get_temporary_id:
  * @self: (in): an #IdeFile.
diff --git a/src/libide/files/ide-file.h b/src/libide/files/ide-file.h
index 6d940c606..e5135ae10 100644
--- a/src/libide/files/ide-file.h
+++ b/src/libide/files/ide-file.h
@@ -64,6 +64,8 @@ IDE_AVAILABLE_IN_ALL
 IdeFileSettings   *ide_file_load_settings_finish (IdeFile              *self,
                                                   GAsyncResult         *result,
                                                   GError              **error);
+IDE_AVAILABLE_IN_3_28
+IdeFileSettings   *ide_file_peek_settings        (IdeFile              *self);
 IDE_AVAILABLE_IN_ALL
 void               ide_file_find_other_async     (IdeFile              *self,
                                                   GCancellable         *cancellable,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]