[gnome-builder] code: try harder to notify about file-loaded event
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] code: try harder to notify about file-loaded event
- Date: Wed, 10 Apr 2019 07:36:26 +0000 (UTC)
commit ee67c92c6cb9a3f86024ca1fffedc6bb5e4aa12f
Author: Christian Hergert <chergert redhat com>
Date: Wed Apr 10 00:20:10 2019 -0700
code: try harder to notify about file-loaded event
This tries in a few more corner cases to notify the addins that a file
was loaded by the buffer. Doing so can simplify addin code that needs
to create//change resources in response to this.
src/libide/code/ide-buffer-addin.c | 16 +++++++++++++++-
src/libide/code/ide-buffer.c | 9 +++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/code/ide-buffer-addin.c b/src/libide/code/ide-buffer-addin.c
index ce0f168a4..d9b78b887 100644
--- a/src/libide/code/ide-buffer-addin.c
+++ b/src/libide/code/ide-buffer-addin.c
@@ -314,12 +314,26 @@ _ide_buffer_addin_load_cb (IdeExtensionSetAdapter *set,
PeasExtension *exten,
gpointer user_data)
{
+ IdeBuffer *buffer = user_data;
+
g_return_if_fail (IDE_IS_EXTENSION_SET_ADAPTER (set));
g_return_if_fail (plugin_info != NULL);
g_return_if_fail (IDE_IS_BUFFER_ADDIN (exten));
g_return_if_fail (IDE_IS_BUFFER (user_data));
- ide_buffer_addin_load (IDE_BUFFER_ADDIN (exten), IDE_BUFFER (user_data));
+ ide_buffer_addin_load (IDE_BUFFER_ADDIN (exten), buffer);
+
+ if (ide_buffer_get_state (buffer) == IDE_BUFFER_STATE_READY &&
+ !ide_buffer_get_is_temporary (buffer))
+ {
+ IdeBufferFileLoad closure = {
+ .buffer = buffer,
+ .file = ide_buffer_get_file (buffer),
+ };
+
+ _ide_buffer_addin_file_loaded_cb (set, plugin_info, exten, &closure);
+ }
+
}
void
diff --git a/src/libide/code/ide-buffer.c b/src/libide/code/ide-buffer.c
index 5978216c8..3eec82765 100644
--- a/src/libide/code/ide-buffer.c
+++ b/src/libide/code/ide-buffer.c
@@ -302,6 +302,15 @@ _ide_buffer_set_file (IdeBuffer *self,
g_clear_object (&self->readlink_file);
self->readlink_file = _ide_g_file_readlink (file);
ide_buffer_reload_file_settings (self);
+
+ if (self->addins != NULL)
+ {
+ IdeBufferFileLoad closure = { self, file };
+ ide_extension_set_adapter_foreach (self->addins,
+ _ide_buffer_addin_file_loaded_cb,
+ &closure);
+ }
+
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_FILE]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]