[gnome-builder] plugins: try harder to set IdeObject:context property



commit 70cf9a93ab9e80187325f609a4914d84838f3b10
Author: Christian Hergert <chergert redhat com>
Date:   Wed Mar 15 00:35:09 2017 -0700

    plugins: try harder to set IdeObject:context property
    
    If we create a plugin whose interface does not require IdeObject but
    plugin inherits from IdeObject, ensure we set the context property.

 libide/plugins/ide-extension-adapter.c     |   17 +++++++++++++----
 libide/plugins/ide-extension-set-adapter.c |   17 +++++++++++++----
 2 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/libide/plugins/ide-extension-adapter.c b/libide/plugins/ide-extension-adapter.c
index c7bfc8e..042a094 100644
--- a/libide/plugins/ide-extension-adapter.c
+++ b/libide/plugins/ide-extension-adapter.c
@@ -168,10 +168,19 @@ ide_extension_adapter_reload (IdeExtensionAdapter *self)
                                        "context", context,
                                        NULL);
       else
-        extension = ide_extension_new (self->engine,
-                                       best_match,
-                                       self->interface_type,
-                                       NULL);
+        {
+          extension = ide_extension_new (self->engine,
+                                         best_match,
+                                         self->interface_type,
+                                         NULL);
+          /*
+           * If the plugin object turned out to have IdeObject
+           * as a base, try to set it now (even though we couldn't
+           * do it at construction time).
+           */
+          if (IDE_IS_OBJECT (extension))
+            ide_object_set_context (IDE_OBJECT (extension), context);
+        }
     }
 
   ide_extension_adapter_set_extension (self, best_match, extension);
diff --git a/libide/plugins/ide-extension-set-adapter.c b/libide/plugins/ide-extension-set-adapter.c
index 143a127..afc3811 100644
--- a/libide/plugins/ide-extension-set-adapter.c
+++ b/libide/plugins/ide-extension-set-adapter.c
@@ -183,10 +183,19 @@ ide_extension_set_adapter_reload (IdeExtensionSetAdapter *self)
                                            "context", context,
                                            NULL);
               else
-                exten = ide_extension_new (self->engine,
-                                           plugin_info,
-                                           self->interface_type,
-                                           NULL);
+                {
+                  exten = ide_extension_new (self->engine,
+                                             plugin_info,
+                                             self->interface_type,
+                                             NULL);
+                  /*
+                   * If the plugin object turned out to have IdeObject
+                   * as a base, try to set it now (even though we couldn't
+                   * do it at construction time).
+                   */
+                  if (IDE_IS_OBJECT (exten))
+                    ide_object_set_context (IDE_OBJECT (exten), context);
+                }
 
               add_extension (self, plugin_info, exten);
             }


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