[gnome-builder/wip/libide] libide: add ide_buffer_manager_get_buffers()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: add ide_buffer_manager_get_buffers()
- Date: Tue, 3 Mar 2015 22:54:35 +0000 (UTC)
commit 1271f551eb9782e26ad668928f73012e231218b0
Author: Christian Hergert <christian hergert me>
Date: Tue Mar 3 14:52:40 2015 -0800
libide: add ide_buffer_manager_get_buffers()
This method will return a newly allocated GPtrArray with all of the
loaded buffers as elements.
Only a reference to the GPtrArray is returned (transfer container), but
the container has a reference to the buffers.
Simply release with g_ptr_array_unref().
libide/ide-buffer-manager.c | 31 +++++++++++++++++++++++++++++++
libide/ide-buffer-manager.h | 1 +
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-buffer-manager.c b/libide/ide-buffer-manager.c
index f6a0d06..8e8ac61 100644
--- a/libide/ide-buffer-manager.c
+++ b/libide/ide-buffer-manager.c
@@ -1006,3 +1006,34 @@ unregister_auto_save (IdeBufferManager *self,
g_slice_free (AutoSave, state);
}
}
+
+/**
+ * ide_buffer_manager_get_buffers:
+ *
+ * Returns a newly allocated #GPtrArray of all the buffers managed by the #IdeBufferManager
+ * instance.
+ *
+ * Buffers are generally not added to the buffer list until they have been loaded.
+ *
+ * Returns: (transfer container) (element-type IdeBuffer*): A #GPtrArray of buffers.
+ */
+GPtrArray *
+ide_buffer_manager_get_buffers (IdeBufferManager *self)
+{
+ GPtrArray *ret;
+ gsize i;
+
+ g_return_val_if_fail (IDE_IS_BUFFER_MANAGER (self), NULL);
+
+ ret = g_ptr_array_new_with_free_func (g_object_unref);
+
+ for (i = 0; i < self->buffers->len; i++)
+ {
+ IdeBuffer *buffer;
+
+ buffer = g_ptr_array_index (self->buffers, i);
+ g_ptr_array_add (ret, g_object_ref (buffer));
+ }
+
+ return ret;
+}
diff --git a/libide/ide-buffer-manager.h b/libide/ide-buffer-manager.h
index bdf0655..b371aa2 100644
--- a/libide/ide-buffer-manager.h
+++ b/libide/ide-buffer-manager.h
@@ -52,6 +52,7 @@ gboolean ide_buffer_manager_save_file_finish (IdeBufferManager *self,
IdeBuffer *ide_buffer_manager_get_focus_buffer (IdeBufferManager *self);
void ide_buffer_manager_set_focus_buffer (IdeBufferManager *self,
IdeBuffer *buffer);
+GPtrArray *ide_buffer_manager_get_buffers (IdeBufferManager *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]