[gnome-builder] buffer-mangaer: allow accessing loading buffers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] buffer-mangaer: allow accessing loading buffers
- Date: Wed, 13 Dec 2017 09:35:25 +0000 (UTC)
commit e852399fc74c5e0c6da6bebb09fd10c8a4484252
Author: Christian Hergert <chergert redhat com>
Date: Wed Dec 13 01:25:51 2017 -0800
buffer-mangaer: allow accessing loading buffers
This allows you to start loading then fetch the buffer. That is
useful if you want to be in control of creating the target
view and place it in a specific location.
src/libide/buffers/ide-buffer-manager.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/buffers/ide-buffer-manager.c b/src/libide/buffers/ide-buffer-manager.c
index 6e67417..b7782d1 100644
--- a/src/libide/buffers/ide-buffer-manager.c
+++ b/src/libide/buffers/ide-buffer-manager.c
@@ -910,7 +910,9 @@ ide_buffer_manager_load_file_async (IdeBufferManager *self,
g_task_set_task_data (task, state, load_state_free);
- g_hash_table_insert (self->loading, g_object_ref (file), NULL);
+ g_hash_table_insert (self->loading,
+ g_object_ref (file),
+ g_object_ref (state->buffer));
g_signal_connect_object (task,
"notify::completed",
@@ -1680,7 +1682,8 @@ ide_buffer_manager_init (IdeBufferManager *self)
self->settings = g_settings_new ("org.gnome.builder.editor");
self->loading = g_hash_table_new_full ((GHashFunc)ide_file_hash,
(GEqualFunc)ide_file_equal,
- g_object_unref, NULL);
+ g_object_unref,
+ g_object_unref);
g_settings_bind (self->settings, "minimum-word-size", self->word_completion, "minimum-word-size",
G_SETTINGS_BIND_GET);
g_settings_bind (self->settings, "auto-save", self, "auto-save", G_SETTINGS_BIND_GET);
@@ -1793,12 +1796,13 @@ IdeBuffer *
ide_buffer_manager_find_buffer (IdeBufferManager *self,
GFile *file)
{
- gsize i;
+ GHashTableIter iter;
+ gpointer key, value;
g_return_val_if_fail (IDE_IS_BUFFER_MANAGER (self), NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
- for (i = 0; i < self->buffers->len; i++)
+ for (guint i = 0; i < self->buffers->len; i++)
{
IdeBuffer *buffer;
IdeFile *buffer_file;
@@ -1810,6 +1814,17 @@ ide_buffer_manager_find_buffer (IdeBufferManager *self,
return buffer;
}
+ g_hash_table_iter_init (&iter, self->loading);
+
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ IdeFile *buffer_file = key;
+ IdeBuffer *buffer = value;
+
+ if (g_file_equal (file, ide_file_get_file (buffer_file)))
+ return buffer;
+ }
+
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]