[gnome-builder: 124/139] symbol-tree: port to libide-editor and libide-gui



commit b8f252a471b1aaead8503a76dafd12736af5949e
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 17:39:01 2019 -0800

    symbol-tree: port to libide-editor and libide-gui
    
    This renames a bunch of objects to match what we have in libide-gui as well
    as how we integrate with libide-editor.

 ...yout-stack-addin.c => gbp-symbol-frame-addin.c} | 291 +++++++++------------
 ...yout-stack-addin.h => gbp-symbol-frame-addin.h} |   8 +-
 .../symbol-tree/gbp-symbol-hover-provider.c        |  63 ++---
 .../symbol-tree/gbp-symbol-hover-provider.h        |   2 +-
 src/plugins/symbol-tree/gbp-symbol-menu-button.c   |   3 +-
 src/plugins/symbol-tree/gbp-symbol-menu-button.h   |   2 +-
 src/plugins/symbol-tree/gbp-symbol-tree-builder.c  |  15 +-
 src/plugins/symbol-tree/gbp-symbol-tree-builder.h  |   2 +-
 src/plugins/symbol-tree/meson.build                |  26 +-
 src/plugins/symbol-tree/symbol-tree-plugin.c       |  15 +-
 src/plugins/symbol-tree/symbol-tree.gresource.xml  |   6 +-
 src/plugins/symbol-tree/symbol-tree.plugin         |  13 +-
 12 files changed, 202 insertions(+), 244 deletions(-)
---
diff --git a/src/plugins/symbol-tree/gbp-symbol-layout-stack-addin.c 
b/src/plugins/symbol-tree/gbp-symbol-frame-addin.c
similarity index 61%
rename from src/plugins/symbol-tree/gbp-symbol-layout-stack-addin.c
rename to src/plugins/symbol-tree/gbp-symbol-frame-addin.c
index ceb19fe09..ce25848ee 100644
--- a/src/plugins/symbol-tree/gbp-symbol-layout-stack-addin.c
+++ b/src/plugins/symbol-tree/gbp-symbol-frame-addin.c
@@ -1,4 +1,4 @@
-/* gbp-symbol-layout-stack-addin.c
+/* gbp-symbol-frame-addin.c
  *
  * Copyright 2017-2019 Christian Hergert <chergert redhat com>
  *
@@ -18,19 +18,20 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#define G_LOG_DOMAIN "gbp-symbol-layout-stack-addin"
+#define G_LOG_DOMAIN "gbp-symbol-frame-addin"
 
 #include "config.h"
 
+#include <libide-editor.h>
 #include <glib/gi18n.h>
 
-#include "gbp-symbol-layout-stack-addin.h"
+#include "gbp-symbol-frame-addin.h"
 #include "gbp-symbol-menu-button.h"
 
 #define CURSOR_MOVED_DELAY_MSEC 500
 #define I_(s) (g_intern_static_string(s))
 
-struct _GbpSymbolLayoutStackAddin {
+struct _GbpSymbolFrameAddin {
   GObject              parent_instance;
 
   GbpSymbolMenuButton *button;
@@ -39,15 +40,13 @@ struct _GbpSymbolLayoutStackAddin {
   DzlSignalGroup      *buffer_signals;
 
   guint                cursor_moved_handler;
-
-  guint                resolvers_loaded : 1;
 };
 
 typedef struct
 {
   GPtrArray         *resolvers;
   IdeBuffer         *buffer;
-  IdeSourceLocation *location;
+  IdeLocation *location;
 } SymbolResolverTaskData;
 
 static DzlShortcutEntry symbol_tree_shortcuts[] = {
@@ -68,33 +67,17 @@ symbol_resolver_task_data_free (SymbolResolverTaskData *data)
 
   g_clear_pointer (&data->resolvers, g_ptr_array_unref);
   g_clear_object (&data->buffer);
-  g_clear_pointer (&data->location, ide_source_location_unref);
+  g_clear_object (&data->location);
   g_slice_free (SymbolResolverTaskData, data);
 }
 
 static void
-get_extension (IdeExtensionSetAdapter *set,
-               PeasPluginInfo         *plugin_info,
-               PeasExtension          *extension,
-               gpointer                user_data)
-{
-  SymbolResolverTaskData *data = user_data;
-  IdeSymbolResolver *resolver = (IdeSymbolResolver *)extension;
-
-  g_assert (data != NULL);
-  g_assert (data->resolvers != NULL);
-  g_assert (IDE_IS_SYMBOL_RESOLVER (resolver));
-
-  g_ptr_array_add (data->resolvers, g_object_ref (resolver));
-}
-
-static void
-gbp_symbol_layout_stack_addin_find_scope_cb (GObject      *object,
-                                             GAsyncResult *result,
-                                             gpointer      user_data)
+gbp_symbol_frame_addin_find_scope_cb (GObject      *object,
+                                      GAsyncResult *result,
+                                      gpointer      user_data)
 {
   IdeSymbolResolver *symbol_resolver = (IdeSymbolResolver *)object;
-  GbpSymbolLayoutStackAddin *self;
+  GbpSymbolFrameAddin *self;
   g_autoptr(IdeSymbol) symbol = NULL;
   g_autoptr(GError) error = NULL;
   g_autoptr(IdeTask) task = user_data;
@@ -108,7 +91,7 @@ gbp_symbol_layout_stack_addin_find_scope_cb (GObject      *object,
   g_assert (symbol != NULL || error != NULL);
 
   self = ide_task_get_source_object (task);
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
 
   data = ide_task_get_task_data (task);
   g_assert (data != NULL);
@@ -127,7 +110,7 @@ gbp_symbol_layout_stack_addin_find_scope_cb (GObject      *object,
       ide_symbol_resolver_find_nearest_scope_async (resolver,
                                                     data->location,
                                                     self->scope_cancellable,
-                                                    gbp_symbol_layout_stack_addin_find_scope_cb,
+                                                    gbp_symbol_frame_addin_find_scope_cb,
                                                     g_steal_pointer (&task));
 
       return;
@@ -144,12 +127,12 @@ gbp_symbol_layout_stack_addin_find_scope_cb (GObject      *object,
 }
 
 static gboolean
-gbp_symbol_layout_stack_addin_cursor_moved_cb (gpointer user_data)
+gbp_symbol_frame_addin_cursor_moved_cb (gpointer user_data)
 {
-  GbpSymbolLayoutStackAddin *self = user_data;
+  GbpSymbolFrameAddin *self = user_data;
   IdeBuffer *buffer;
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
 
   g_cancellable_cancel (self->scope_cancellable);
   g_clear_object (&self->scope_cancellable);
@@ -158,11 +141,12 @@ gbp_symbol_layout_stack_addin_cursor_moved_cb (gpointer user_data)
 
   if (buffer != NULL)
     {
-      IdeExtensionSetAdapter *adapter;
+      g_autoptr(GPtrArray) resolvers = NULL;
 
-      adapter = ide_buffer_get_symbol_resolvers (buffer);
+      resolvers = ide_buffer_get_symbol_resolvers (buffer);
+      IDE_PTR_ARRAY_SET_FREE_FUNC (resolvers, g_object_unref);
 
-      if (ide_extension_set_adapter_get_n_extensions (adapter))
+      if (resolvers->len > 0)
         {
           g_autoptr(IdeTask) task = NULL;
           SymbolResolverTaskData *data;
@@ -171,24 +155,21 @@ gbp_symbol_layout_stack_addin_cursor_moved_cb (gpointer user_data)
           self->scope_cancellable = g_cancellable_new ();
 
           task = ide_task_new (self, self->scope_cancellable, NULL, NULL);
-          ide_task_set_source_tag (task, gbp_symbol_layout_stack_addin_cursor_moved_cb);
+          ide_task_set_source_tag (task, gbp_symbol_frame_addin_cursor_moved_cb);
           ide_task_set_priority (task, G_PRIORITY_LOW);
 
           data = g_slice_new0 (SymbolResolverTaskData);
-          data->resolvers = g_ptr_array_new_with_free_func (g_object_unref);
+          data->resolvers = g_steal_pointer (&resolvers);
           data->location = ide_buffer_get_insert_location (buffer);
           data->buffer = g_object_ref (buffer);
           ide_task_set_task_data (task, data, symbol_resolver_task_data_free);
 
-          ide_extension_set_adapter_foreach_by_priority (adapter, get_extension, data);
-          g_assert (data->resolvers->len > 0);
-
           resolver = g_ptr_array_index (data->resolvers, data->resolvers->len - 1);
           /* Go through symbol resolvers one by one to find nearest scope */
           ide_symbol_resolver_find_nearest_scope_async (resolver,
                                                         data->location,
                                                         self->scope_cancellable,
-                                                        gbp_symbol_layout_stack_addin_find_scope_cb,
+                                                        gbp_symbol_frame_addin_find_scope_cb,
                                                         g_steal_pointer (&task));
         }
     }
@@ -199,14 +180,14 @@ gbp_symbol_layout_stack_addin_cursor_moved_cb (gpointer user_data)
 }
 
 static void
-gbp_symbol_layout_stack_addin_cursor_moved (GbpSymbolLayoutStackAddin *self,
-                                            const GtkTextIter         *location,
-                                            IdeBuffer                 *buffer)
+gbp_symbol_frame_addin_cursor_moved (GbpSymbolFrameAddin *self,
+                                     const GtkTextIter   *location,
+                                     IdeBuffer           *buffer)
 {
   GSource *source;
   gint64 ready_time;
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
   g_assert (location != NULL);
   g_assert (IDE_IS_BUFFER (buffer));
 
@@ -215,7 +196,7 @@ gbp_symbol_layout_stack_addin_cursor_moved (GbpSymbolLayoutStackAddin *self,
       self->cursor_moved_handler =
         gdk_threads_add_timeout_full (G_PRIORITY_LOW,
                                       CURSOR_MOVED_DELAY_MSEC,
-                                      gbp_symbol_layout_stack_addin_cursor_moved_cb,
+                                      gbp_symbol_frame_addin_cursor_moved_cb,
                                       g_object_ref (self),
                                       g_object_unref);
       return;
@@ -228,12 +209,12 @@ gbp_symbol_layout_stack_addin_cursor_moved (GbpSymbolLayoutStackAddin *self,
 }
 
 static void
-gbp_symbol_layout_stack_addin_get_symbol_tree_cb (GObject      *object,
-                                                  GAsyncResult *result,
-                                                  gpointer      user_data)
+gbp_symbol_frame_addin_get_symbol_tree_cb (GObject      *object,
+                                           GAsyncResult *result,
+                                           gpointer      user_data)
 {
   IdeSymbolResolver *symbol_resolver = (IdeSymbolResolver *)object;
-  GbpSymbolLayoutStackAddin *self;
+  GbpSymbolFrameAddin *self;
   g_autoptr(IdeSymbolTree) tree = NULL;
   g_autoptr(GError) error = NULL;
   g_autoptr(IdeTask) task = user_data;
@@ -257,17 +238,19 @@ gbp_symbol_layout_stack_addin_get_symbol_tree_cb (GObject      *object,
   /* If tree is not fetched and symbol resolvers are left then try those */
   if (tree == NULL && data->resolvers->len > 0)
     {
-      GFile *file;
+      g_autoptr(GBytes) content = NULL;
       IdeSymbolResolver *resolver;
+      GFile *file;
 
-      file = ide_file_get_file (ide_buffer_get_file (data->buffer));
+      file = ide_buffer_get_file (data->buffer);
       resolver = g_ptr_array_index (data->resolvers, data->resolvers->len - 1);
+      content = ide_buffer_dup_content (data->buffer);
 
       ide_symbol_resolver_get_symbol_tree_async (resolver,
                                                  file,
-                                                 data->buffer,
+                                                 content,
                                                  self->cancellable,
-                                                 gbp_symbol_layout_stack_addin_get_symbol_tree_cb,
+                                                 gbp_symbol_frame_addin_get_symbol_tree_cb,
                                                  g_steal_pointer (&task));
       return;
     }
@@ -290,120 +273,127 @@ gbp_symbol_layout_stack_addin_get_symbol_tree_cb (GObject      *object,
 }
 
 static void
-gbp_symbol_layout_stack_addin_update_tree (GbpSymbolLayoutStackAddin *self,
-                                           IdeBuffer                 *buffer)
+gbp_symbol_frame_addin_update_tree (GbpSymbolFrameAddin *self,
+                                    IdeBuffer           *buffer)
 {
-  IdeExtensionSetAdapter *adapter;
-  IdeFile *file;
   g_autoptr(IdeTask) task = NULL;
+  g_autoptr(GPtrArray) resolvers = NULL;
+  g_autoptr(GBytes) content = NULL;
   SymbolResolverTaskData *data;
   IdeSymbolResolver *resolver;
+  GFile *file;
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
   g_assert (IDE_IS_BUFFER (buffer));
 
   /* Cancel any in-flight work */
   g_cancellable_cancel (self->cancellable);
   g_clear_object (&self->cancellable);
 
-  adapter = ide_buffer_get_symbol_resolvers (buffer);
+  resolvers = ide_buffer_get_symbol_resolvers (buffer);
+  IDE_PTR_ARRAY_SET_FREE_FUNC (resolvers, g_object_unref);
 
-  gtk_widget_set_visible (GTK_WIDGET (self->button),
-                          ide_extension_set_adapter_get_n_extensions (adapter));
+  if (resolvers->len == 0)
+    {
+      gtk_widget_hide (GTK_WIDGET (self->button));
+      return;
+    }
 
-  if (!ide_extension_set_adapter_get_n_extensions (adapter))
-    return;
+  gtk_widget_show (GTK_WIDGET (self->button));
 
   file = ide_buffer_get_file (buffer);
-  g_assert (IDE_IS_FILE (file));
+  g_assert (G_IS_FILE (file));
+
+  content = ide_buffer_dup_content (buffer);
 
   self->cancellable = g_cancellable_new ();
 
   task = ide_task_new (self, self->cancellable, NULL, NULL);
-  ide_task_set_source_tag (task, gbp_symbol_layout_stack_addin_update_tree);
+  ide_task_set_source_tag (task, gbp_symbol_frame_addin_update_tree);
   ide_task_set_priority (task, G_PRIORITY_LOW);
 
   data = g_slice_new0 (SymbolResolverTaskData);
-  data->resolvers = g_ptr_array_new_with_free_func (g_object_unref);
+  data->resolvers = g_steal_pointer (&resolvers);
   data->buffer = g_object_ref (buffer);
   ide_task_set_task_data (task, data, symbol_resolver_task_data_free);
 
-  ide_extension_set_adapter_foreach_by_priority (adapter, get_extension, data);
   g_assert (data->resolvers->len > 0);
 
   resolver = g_ptr_array_index (data->resolvers, data->resolvers->len - 1);
   ide_symbol_resolver_get_symbol_tree_async (resolver,
-                                             ide_file_get_file (file),
-                                             data->buffer,
+                                             file,
+                                             content,
                                              self->cancellable,
-                                             gbp_symbol_layout_stack_addin_get_symbol_tree_cb,
+                                             gbp_symbol_frame_addin_get_symbol_tree_cb,
                                              g_steal_pointer (&task));
 }
 
 static void
-gbp_symbol_layout_stack_addin_change_settled (GbpSymbolLayoutStackAddin *self,
-                                              IdeBuffer                 *buffer)
+gbp_symbol_frame_addin_change_settled (GbpSymbolFrameAddin *self,
+                                       IdeBuffer           *buffer)
 {
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
   g_assert (IDE_IS_BUFFER (buffer));
 
   /* Ignore this request unless the button is active */
   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->button)))
     return;
 
-  gbp_symbol_layout_stack_addin_update_tree (self, buffer);
+  gbp_symbol_frame_addin_update_tree (self, buffer);
 }
 
 static void
-gbp_symbol_layout_stack_addin_button_toggled (GbpSymbolLayoutStackAddin *self,
-                                              GtkMenuButton             *button)
+gbp_symbol_frame_addin_button_toggled (GbpSymbolFrameAddin *self,
+                                       GtkMenuButton       *button)
 {
   IdeBuffer *buffer;
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
   g_assert (GTK_IS_MENU_BUTTON (button));
 
   buffer = dzl_signal_group_get_target (self->buffer_signals);
   g_assert (!buffer || IDE_IS_BUFFER (buffer));
 
   if (buffer != NULL && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
-    gbp_symbol_layout_stack_addin_update_tree (self, buffer);
+    gbp_symbol_frame_addin_update_tree (self, buffer);
 }
 
 static void
-gbp_symbol_layout_stack_addin_bind (GbpSymbolLayoutStackAddin *self,
-                                    IdeBuffer                 *buffer,
-                                    DzlSignalGroup            *buffer_signals)
+gbp_symbol_frame_addin_notify_has_symbol_resolvers (GbpSymbolFrameAddin *self,
+                                                    GParamSpec          *pspec,
+                                                    IdeBuffer           *buffer)
 {
-  IdeExtensionSetAdapter *adapter;
-  guint n_extensions;
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
+  g_assert (IDE_IS_BUFFER (buffer));
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  gtk_widget_set_visible (GTK_WIDGET (self->button),
+                          ide_buffer_has_symbol_resolvers (buffer));
+  gbp_symbol_frame_addin_update_tree (self, buffer);
+}
+
+static void
+gbp_symbol_frame_addin_bind (GbpSymbolFrameAddin *self,
+                             IdeBuffer           *buffer,
+                             DzlSignalGroup      *buffer_signals)
+{
+  g_autoptr(GPtrArray) resolvers = NULL;
+
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
   g_assert (IDE_IS_BUFFER (buffer));
   g_assert (DZL_IS_SIGNAL_GROUP (buffer_signals));
 
   self->cancellable = g_cancellable_new ();
 
   gbp_symbol_menu_button_set_symbol (self->button, NULL);
-
-  if (self->resolvers_loaded)
-    return;
-
-  adapter = ide_buffer_get_symbol_resolvers (buffer);
-  n_extensions = ide_extension_set_adapter_get_n_extensions (adapter);
-
-  if (n_extensions)
-    self->resolvers_loaded = TRUE;
-
-  gtk_widget_set_visible (GTK_WIDGET (self->button), n_extensions);
-  gbp_symbol_layout_stack_addin_update_tree (self, buffer);
+  gbp_symbol_frame_addin_notify_has_symbol_resolvers (self, NULL, buffer);
 }
 
 static void
-gbp_symbol_layout_stack_addin_unbind (GbpSymbolLayoutStackAddin *self,
-                                      DzlSignalGroup            *buffer_signals)
+gbp_symbol_frame_addin_unbind (GbpSymbolFrameAddin *self,
+                               DzlSignalGroup      *buffer_signals)
 {
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
   g_assert (DZL_IS_SIGNAL_GROUP (buffer_signals));
 
   dzl_clear_source (&self->cursor_moved_handler);
@@ -415,29 +405,6 @@ gbp_symbol_layout_stack_addin_unbind (GbpSymbolLayoutStackAddin *self,
   g_clear_object (&self->scope_cancellable);
 
   gtk_widget_hide (GTK_WIDGET (self->button));
-  self->resolvers_loaded = FALSE;
-}
-
-static void
-gbp_symbol_layout_stack_addin_symbol_resolvers_loaded (GbpSymbolLayoutStackAddin *self,
-                                                       IdeBuffer                 *buffer)
-{
-  IdeExtensionSetAdapter *adapter;
-  guint n_extensions;
-
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
-  g_assert (IDE_IS_BUFFER (buffer));
-
-  if (self->resolvers_loaded)
-    return;
-
-  adapter = ide_buffer_get_symbol_resolvers (buffer);
-  n_extensions = ide_extension_set_adapter_get_n_extensions (adapter);
-
-  gtk_widget_set_visible (GTK_WIDGET (self->button), n_extensions);
-  self->resolvers_loaded = TRUE;
-
-  gbp_symbol_layout_stack_addin_update_tree (self, buffer);
 }
 
 static void
@@ -445,20 +412,20 @@ search_action_cb (GSimpleAction *action,
                   GVariant      *param,
                   gpointer       user_data)
 {
-  GbpSymbolLayoutStackAddin *self = user_data;
+  GbpSymbolFrameAddin *self = user_data;
 
   g_assert (G_IS_SIMPLE_ACTION (action));
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
 
   if (gtk_widget_get_visible (GTK_WIDGET (self->button)))
     gtk_widget_activate (GTK_WIDGET (self->button));
 }
 
 static void
-gbp_symbol_layout_stack_addin_load (IdeLayoutStackAddin *addin,
-                                    IdeLayoutStack      *stack)
+gbp_symbol_frame_addin_load (IdeFrameAddin *addin,
+                             IdeFrame      *stack)
 {
-  GbpSymbolLayoutStackAddin *self = (GbpSymbolLayoutStackAddin *)addin;
+  GbpSymbolFrameAddin *self = (GbpSymbolFrameAddin *)addin;
   g_autoptr(GSimpleActionGroup) actions = NULL;
   DzlShortcutController *controller;
   GtkWidget *header;
@@ -466,8 +433,8 @@ gbp_symbol_layout_stack_addin_load (IdeLayoutStackAddin *addin,
     { "search", search_action_cb },
   };
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
-  g_assert (IDE_IS_LAYOUT_STACK (stack));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
+  g_assert (IDE_IS_FRAME (stack));
 
   controller = dzl_shortcut_controller_find (GTK_WIDGET (stack));
 
@@ -487,7 +454,7 @@ gbp_symbol_layout_stack_addin_load (IdeLayoutStackAddin *addin,
                                   G_ACTION_GROUP (actions));
 
   /* Add our menu button to the header */
-  header = ide_layout_stack_get_titlebar (stack);
+  header = ide_frame_get_titlebar (stack);
   self->button = g_object_new (GBP_TYPE_SYMBOL_MENU_BUTTON, NULL);
   g_signal_connect (self->button,
                     "destroy",
@@ -495,9 +462,9 @@ gbp_symbol_layout_stack_addin_load (IdeLayoutStackAddin *addin,
                     &self->button);
   g_signal_connect_swapped (self->button,
                             "toggled",
-                            G_CALLBACK (gbp_symbol_layout_stack_addin_button_toggled),
+                            G_CALLBACK (gbp_symbol_frame_addin_button_toggled),
                             self);
-  ide_layout_stack_header_add_custom_title (IDE_LAYOUT_STACK_HEADER (header),
+  ide_frame_header_add_custom_title (IDE_FRAME_HEADER (header),
                                             GTK_WIDGET (self->button),
                                             100);
 
@@ -506,37 +473,37 @@ gbp_symbol_layout_stack_addin_load (IdeLayoutStackAddin *addin,
 
   g_signal_connect_swapped (self->buffer_signals,
                             "bind",
-                            G_CALLBACK (gbp_symbol_layout_stack_addin_bind),
+                            G_CALLBACK (gbp_symbol_frame_addin_bind),
                             self);
 
   g_signal_connect_swapped (self->buffer_signals,
                             "unbind",
-                            G_CALLBACK (gbp_symbol_layout_stack_addin_unbind),
+                            G_CALLBACK (gbp_symbol_frame_addin_unbind),
                             self);
 
   dzl_signal_group_connect_swapped (self->buffer_signals,
                                     "cursor-moved",
-                                    G_CALLBACK (gbp_symbol_layout_stack_addin_cursor_moved),
+                                    G_CALLBACK (gbp_symbol_frame_addin_cursor_moved),
                                     self);
 
   dzl_signal_group_connect_swapped (self->buffer_signals,
                                     "change-settled",
-                                    G_CALLBACK (gbp_symbol_layout_stack_addin_change_settled),
+                                    G_CALLBACK (gbp_symbol_frame_addin_change_settled),
                                     self);
   dzl_signal_group_connect_swapped (self->buffer_signals,
-                                    "symbol-resolvers-loaded",
-                                    G_CALLBACK (gbp_symbol_layout_stack_addin_symbol_resolvers_loaded),
+                                    "notify::has-symbol-resolvers",
+                                    G_CALLBACK (gbp_symbol_frame_addin_notify_has_symbol_resolvers),
                                     self);
 }
 
 static void
-gbp_symbol_layout_stack_addin_unload (IdeLayoutStackAddin *addin,
-                                      IdeLayoutStack      *stack)
+gbp_symbol_frame_addin_unload (IdeFrameAddin *addin,
+                               IdeFrame      *stack)
 {
-  GbpSymbolLayoutStackAddin *self = (GbpSymbolLayoutStackAddin *)addin;
+  GbpSymbolFrameAddin *self = (GbpSymbolFrameAddin *)addin;
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
-  g_assert (IDE_IS_LAYOUT_STACK (stack));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
+  g_assert (IDE_IS_FRAME (stack));
 
   gtk_widget_insert_action_group (GTK_WIDGET (stack), "symbol-tree", NULL);
 
@@ -549,45 +516,45 @@ gbp_symbol_layout_stack_addin_unload (IdeLayoutStackAddin *addin,
 }
 
 static void
-gbp_symbol_layout_stack_addin_set_view (IdeLayoutStackAddin *addin,
-                                        IdeLayoutView       *view)
+gbp_symbol_frame_addin_set_page (IdeFrameAddin *addin,
+                                 IdePage       *page)
 {
-  GbpSymbolLayoutStackAddin *self = (GbpSymbolLayoutStackAddin *)addin;
+  GbpSymbolFrameAddin *self = (GbpSymbolFrameAddin *)addin;
   IdeBuffer *buffer = NULL;
 
-  g_assert (GBP_IS_SYMBOL_LAYOUT_STACK_ADDIN (self));
-  g_assert (!view || IDE_IS_LAYOUT_VIEW (view));
+  g_assert (GBP_IS_SYMBOL_FRAME_ADDIN (self));
+  g_assert (!page || IDE_IS_PAGE (page));
 
   /* First clear any old symbol tree */
   gbp_symbol_menu_button_set_symbol_tree (self->button, NULL);
 
-  if (IDE_IS_EDITOR_VIEW (view))
-    buffer = ide_editor_view_get_buffer (IDE_EDITOR_VIEW (view));
+  if (IDE_IS_EDITOR_PAGE (page))
+    buffer = ide_editor_page_get_buffer (IDE_EDITOR_PAGE (page));
 
   dzl_signal_group_set_target (self->buffer_signals, buffer);
 }
 
 static void
-layout_stack_addin_iface_init (IdeLayoutStackAddinInterface *iface)
+frame_addin_iface_init (IdeFrameAddinInterface *iface)
 {
-  iface->load = gbp_symbol_layout_stack_addin_load;
-  iface->unload = gbp_symbol_layout_stack_addin_unload;
-  iface->set_view = gbp_symbol_layout_stack_addin_set_view;
+  iface->load = gbp_symbol_frame_addin_load;
+  iface->unload = gbp_symbol_frame_addin_unload;
+  iface->set_page = gbp_symbol_frame_addin_set_page;
 }
 
-G_DEFINE_TYPE_WITH_CODE (GbpSymbolLayoutStackAddin,
-                         gbp_symbol_layout_stack_addin,
+G_DEFINE_TYPE_WITH_CODE (GbpSymbolFrameAddin,
+                         gbp_symbol_frame_addin,
                          G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (IDE_TYPE_LAYOUT_STACK_ADDIN,
-                                                layout_stack_addin_iface_init))
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_FRAME_ADDIN,
+                                                frame_addin_iface_init))
 
 static void
-gbp_symbol_layout_stack_addin_class_init (GbpSymbolLayoutStackAddinClass *klass)
+gbp_symbol_frame_addin_class_init (GbpSymbolFrameAddinClass *klass)
 {
 }
 
 static void
-gbp_symbol_layout_stack_addin_init (GbpSymbolLayoutStackAddin *self)
+gbp_symbol_frame_addin_init (GbpSymbolFrameAddin *self)
 {
   dzl_shortcut_manager_add_shortcut_entries (NULL,
                                              symbol_tree_shortcuts,
diff --git a/src/plugins/symbol-tree/gbp-symbol-layout-stack-addin.h 
b/src/plugins/symbol-tree/gbp-symbol-frame-addin.h
similarity index 75%
rename from src/plugins/symbol-tree/gbp-symbol-layout-stack-addin.h
rename to src/plugins/symbol-tree/gbp-symbol-frame-addin.h
index d380a7acb..db160ac53 100644
--- a/src/plugins/symbol-tree/gbp-symbol-layout-stack-addin.h
+++ b/src/plugins/symbol-tree/gbp-symbol-frame-addin.h
@@ -1,4 +1,4 @@
-/* gbp-symbol-layout-stack-addin.h
+/* gbp-symbol-frame-addin.h
  *
  * Copyright 2017-2019 Christian Hergert <chergert redhat com>
  *
@@ -20,12 +20,12 @@
 
 #pragma once
 
-#include <ide.h>
+#include <libide-gui.h>
 
 G_BEGIN_DECLS
 
-#define GBP_TYPE_SYMBOL_LAYOUT_STACK_ADDIN (gbp_symbol_layout_stack_addin_get_type())
+#define GBP_TYPE_SYMBOL_FRAME_ADDIN (gbp_symbol_frame_addin_get_type())
 
-G_DECLARE_FINAL_TYPE (GbpSymbolLayoutStackAddin, gbp_symbol_layout_stack_addin, GBP, 
SYMBOL_LAYOUT_STACK_ADDIN, GObject)
+G_DECLARE_FINAL_TYPE (GbpSymbolFrameAddin, gbp_symbol_frame_addin, GBP, SYMBOL_FRAME_ADDIN, GObject)
 
 G_END_DECLS
diff --git a/src/plugins/symbol-tree/gbp-symbol-hover-provider.c 
b/src/plugins/symbol-tree/gbp-symbol-hover-provider.c
index 19073141f..60f1387a1 100644
--- a/src/plugins/symbol-tree/gbp-symbol-hover-provider.c
+++ b/src/plugins/symbol-tree/gbp-symbol-hover-provider.c
@@ -22,6 +22,9 @@
 
 #include "config.h"
 
+#include <libide-code.h>
+#include <libide-gui.h>
+#include <libide-editor.h>
 #include <glib/gi18n.h>
 
 #include "gbp-symbol-hover-provider.h"
@@ -34,28 +37,24 @@ struct _GbpSymbolHoverProvider
 };
 
 static gboolean
-on_activate_link (GbpSymbolHoverProvider *self,
-                  const gchar            *uristr,
-                  GtkLabel               *label)
+on_activate_link (GtkLabel    *label,
+                  const gchar *uristr,
+                  IdeLocation *location)
 {
-  IdeWorkbench *workbench;
-  g_autoptr(IdeUri) uri = NULL;
+  IdeWorkspace *workspace;
+  IdeSurface *surface;
 
-  g_assert (GBP_IS_SYMBOL_HOVER_PROVIDER (self));
   g_assert (uristr != NULL);
   g_assert (GTK_IS_LABEL (label));
+  g_assert (IDE_IS_LOCATION (location));
 
-  workbench = ide_widget_get_workbench (GTK_WIDGET (label));
-  uri = ide_uri_new (uristr, 0, NULL);
+  if (!(workspace = ide_widget_get_workspace (GTK_WIDGET (label))))
+    return FALSE;
 
-  if (!uri || !workbench)
+  if (!(surface = ide_workspace_get_surface_by_name (workspace, "editor")))
     return FALSE;
 
-  ide_workbench_open_uri_async (workbench,
-                                uri,
-                                "editor",
-                                IDE_WORKBENCH_OPEN_FLAGS_NONE,
-                                NULL, NULL, NULL);
+  ide_editor_surface_focus_location (IDE_EDITOR_SURFACE (surface), location);
 
   return TRUE;
 }
@@ -77,12 +76,11 @@ gbp_symbol_hover_provider_get_symbol_cb (GObject      *object,
   const gchar *name;
   GtkWidget *box;
   struct {
-    const gchar       *kind;
-    IdeSourceLocation *loc;
-  } loc[3] = {
+    const gchar *kind;
+    IdeLocation *loc;
+  } loc[] = {
+    { _("Location"), NULL },
     { _("Declaration"), NULL },
-    { _("Definition"), NULL },
-    { _("Canonical"), NULL },
   };
 
   g_assert (IDE_IS_BUFFER (buffer));
@@ -102,11 +100,10 @@ gbp_symbol_hover_provider_get_symbol_cb (GObject      *object,
   g_assert (context != NULL);
   g_assert (IDE_IS_HOVER_CONTEXT (context));
 
-  loc[0].loc = ide_symbol_get_declaration_location (symbol);
-  loc[1].loc = ide_symbol_get_definition_location (symbol);
-  loc[2].loc = ide_symbol_get_canonical_location (symbol);
+  loc[0].loc = ide_symbol_get_location (symbol);
+  loc[1].loc = ide_symbol_get_header_location (symbol);
 
-  if (!loc[0].loc && !loc[1].loc && !loc[2].loc)
+  if (!loc[0].loc && !loc[1].loc)
     {
       ide_task_return_boolean (task, TRUE);
       return;
@@ -138,13 +135,10 @@ gbp_symbol_hover_provider_get_symbol_cb (GObject      *object,
       if (loc[i].loc != NULL)
         {
           GtkWidget *label;
-          g_autoptr(IdeUri) uri = ide_source_location_get_uri (loc[i].loc);
-          g_autoptr(GFile) file = ide_uri_to_file (uri);
-          g_autofree gchar *uristr = ide_uri_to_string (uri, 0);
+          GFile *file = ide_location_get_file (loc[i].loc);
           g_autofree gchar *base = g_file_get_basename (file);
-          g_autofree gchar *escaped = g_markup_escape_text (uristr, -1);
-          g_autofree gchar *markup = g_strdup_printf ("<span size='smaller'>%s: <a href='%s'>%s</a></span>",
-                                                      loc[i].kind, escaped, base);
+          g_autofree gchar *markup = g_strdup_printf ("<span size='smaller'>%s: <a href='#'>%s</a></span>",
+                                                      loc[i].kind, base);
 
           label = g_object_new (GTK_TYPE_LABEL,
                                 "visible", TRUE,
@@ -152,11 +146,12 @@ gbp_symbol_hover_provider_get_symbol_cb (GObject      *object,
                                 "use-markup", TRUE,
                                 "label", markup,
                                 NULL);
-          g_signal_connect_object (label,
-                                   "activate-link",
-                                   G_CALLBACK (on_activate_link),
-                                   self,
-                                   G_CONNECT_SWAPPED);
+          g_signal_connect_data (label,
+                                 "activate-link",
+                                 G_CALLBACK (on_activate_link),
+                                 g_object_ref (loc[i].loc),
+                                 (GClosureNotify)g_object_unref,
+                                 0);
           gtk_container_add (GTK_CONTAINER (box), label);
         }
     }
diff --git a/src/plugins/symbol-tree/gbp-symbol-hover-provider.h 
b/src/plugins/symbol-tree/gbp-symbol-hover-provider.h
index 084483fea..a550e5a04 100644
--- a/src/plugins/symbol-tree/gbp-symbol-hover-provider.h
+++ b/src/plugins/symbol-tree/gbp-symbol-hover-provider.h
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include <ide.h>
+#include <libide-gui.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/plugins/symbol-tree/gbp-symbol-menu-button.c 
b/src/plugins/symbol-tree/gbp-symbol-menu-button.c
index 28d3787a2..1f6a18aaf 100644
--- a/src/plugins/symbol-tree/gbp-symbol-menu-button.c
+++ b/src/plugins/symbol-tree/gbp-symbol-menu-button.c
@@ -20,6 +20,7 @@
 
 #define G_LOG_DOMAIN "gbp-symbol-menu-button"
 
+#include <libide-sourceview.h>
 #include <glib/gi18n.h>
 
 #include "gbp-symbol-menu-button.h"
@@ -207,7 +208,7 @@ gbp_symbol_menu_button_class_init (GbpSymbolMenuButtonClass *klass)
 
   widget_class->destroy = gbp_symbol_menu_button_destroy;
 
-  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/symbol-tree-plugin/gbp-symbol-menu-button.ui");
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/plugins/symbol-tree/gbp-symbol-menu-button.ui");
   gtk_widget_class_bind_template_child (widget_class, GbpSymbolMenuButton, popover);
   gtk_widget_class_bind_template_child (widget_class, GbpSymbolMenuButton, search_entry);
   gtk_widget_class_bind_template_child (widget_class, GbpSymbolMenuButton, symbol_icon);
diff --git a/src/plugins/symbol-tree/gbp-symbol-menu-button.h 
b/src/plugins/symbol-tree/gbp-symbol-menu-button.h
index 7f98546bb..ebc5503f9 100644
--- a/src/plugins/symbol-tree/gbp-symbol-menu-button.h
+++ b/src/plugins/symbol-tree/gbp-symbol-menu-button.h
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include <ide.h>
+#include <libide-gui.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/plugins/symbol-tree/gbp-symbol-tree-builder.c 
b/src/plugins/symbol-tree/gbp-symbol-tree-builder.c
index 6e2051116..5f6c3900e 100644
--- a/src/plugins/symbol-tree/gbp-symbol-tree-builder.c
+++ b/src/plugins/symbol-tree/gbp-symbol-tree-builder.c
@@ -21,7 +21,8 @@
 #define G_LOG_DOMAIN "gbp-symbol-tree-builder"
 
 #include <glib/gi18n.h>
-#include <ide.h>
+#include <libide-editor.h>
+#include <libide-gui.h>
 
 #include "gbp-symbol-tree-builder.h"
 
@@ -95,10 +96,10 @@ gbp_symbol_tree_builder_get_location_cb (GObject      *object,
 {
   IdeSymbolNode *node = (IdeSymbolNode *)object;
   g_autoptr(GbpSymbolTreeBuilder) self = user_data;
-  g_autoptr(IdeSourceLocation) location = NULL;
+  g_autoptr(IdeLocation) location = NULL;
   g_autoptr(GError) error = NULL;
-  IdePerspective *editor;
-  IdeWorkbench *workbench;
+  IdeSurface *editor;
+  IdeWorkspace *workspace;
   DzlTree *tree;
 
   IDE_ENTRY;
@@ -117,10 +118,10 @@ gbp_symbol_tree_builder_get_location_cb (GObject      *object,
     }
 
   tree = dzl_tree_builder_get_tree (DZL_TREE_BUILDER (self));
-  workbench = ide_widget_get_workbench (GTK_WIDGET (tree));
-  editor = ide_workbench_get_perspective_by_name (workbench, "editor");
+  workspace = ide_widget_get_workspace (GTK_WIDGET (tree));
+  editor = ide_workspace_get_surface_by_name (workspace, "editor");
 
-  ide_editor_perspective_focus_location (IDE_EDITOR_PERSPECTIVE (editor), location);
+  ide_editor_surface_focus_location (IDE_EDITOR_SURFACE (editor), location);
 
   IDE_EXIT;
 }
diff --git a/src/plugins/symbol-tree/gbp-symbol-tree-builder.h 
b/src/plugins/symbol-tree/gbp-symbol-tree-builder.h
index 9304d358a..f999f822c 100644
--- a/src/plugins/symbol-tree/gbp-symbol-tree-builder.h
+++ b/src/plugins/symbol-tree/gbp-symbol-tree-builder.h
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include <ide.h>
+#include <libide-gui.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/plugins/symbol-tree/meson.build b/src/plugins/symbol-tree/meson.build
index a085ab773..b40d3d4e6 100644
--- a/src/plugins/symbol-tree/meson.build
+++ b/src/plugins/symbol-tree/meson.build
@@ -1,23 +1,15 @@
-if get_option('with_symbol_tree')
-
-symbol_tree_resources = gnome.compile_resources(
-  'symbol-tree-resources',
-  'symbol-tree.gresource.xml',
-  c_name: 'symbol_tree',
-)
-
-symbol_tree_sources = [
+plugins_sources += files([
   'gbp-symbol-hover-provider.c',
-  'gbp-symbol-layout-stack-addin.c',
-  'gbp-symbol-layout-stack-addin.h',
+  'gbp-symbol-frame-addin.c',
   'gbp-symbol-menu-button.c',
-  'gbp-symbol-menu-button.h',
   'gbp-symbol-tree-builder.c',
-  'gbp-symbol-tree-builder.h',
   'symbol-tree-plugin.c',
-]
+])
 
-gnome_builder_plugins_sources += files(symbol_tree_sources)
-gnome_builder_plugins_sources += symbol_tree_resources[0]
+plugin_symbol_tree_resources = gnome.compile_resources(
+  'gbp-symbol-tree-resources',
+  'symbol-tree.gresource.xml',
+  c_name: 'gbp_symbol_tree',
+)
 
-endif
+plugins_sources += plugin_symbol_tree_resources[0]
diff --git a/src/plugins/symbol-tree/symbol-tree-plugin.c b/src/plugins/symbol-tree/symbol-tree-plugin.c
index df39b32a9..0408a034e 100644
--- a/src/plugins/symbol-tree/symbol-tree-plugin.c
+++ b/src/plugins/symbol-tree/symbol-tree-plugin.c
@@ -18,18 +18,21 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
+#include "config.h"
+
 #include <libpeas/peas.h>
-#include <ide.h>
+#include <libide-sourceview.h>
+#include <libide-gui.h>
 
-#include "gbp-symbol-layout-stack-addin.h"
+#include "gbp-symbol-frame-addin.h"
 #include "gbp-symbol-hover-provider.h"
 
-void
-gbp_symbol_tree_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_gbp_symbol_tree_register_types (PeasObjectModule *module)
 {
   peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_LAYOUT_STACK_ADDIN,
-                                              GBP_TYPE_SYMBOL_LAYOUT_STACK_ADDIN);
+                                              IDE_TYPE_FRAME_ADDIN,
+                                              GBP_TYPE_SYMBOL_FRAME_ADDIN);
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_HOVER_PROVIDER,
                                               GBP_TYPE_SYMBOL_HOVER_PROVIDER);
diff --git a/src/plugins/symbol-tree/symbol-tree.gresource.xml 
b/src/plugins/symbol-tree/symbol-tree.gresource.xml
index 66a593430..44bbb417c 100644
--- a/src/plugins/symbol-tree/symbol-tree.gresource.xml
+++ b/src/plugins/symbol-tree/symbol-tree.gresource.xml
@@ -1,10 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/org/gnome/builder/plugins">
+  <gresource prefix="/plugins/symbol-tree">
     <file>symbol-tree.plugin</file>
-  </gresource>
-  <gresource prefix="/org/gnome/builder/plugins/symbol-tree-plugin">
-    <file>themes/shared.css</file>
     <file>gbp-symbol-menu-button.ui</file>
+    <file>themes/shared.css</file>
   </gresource>
 </gresources>
diff --git a/src/plugins/symbol-tree/symbol-tree.plugin b/src/plugins/symbol-tree/symbol-tree.plugin
index 844edc75e..cc49c678d 100644
--- a/src/plugins/symbol-tree/symbol-tree.plugin
+++ b/src/plugins/symbol-tree/symbol-tree.plugin
@@ -1,9 +1,10 @@
 [Plugin]
-Module=symbol-tree-plugin
-Name=Symbol Tree
-Description=Provides a Symbol Tree for the currently focused document
 Authors=Christian Hergert <christian hergert me>
-Copyright=Copyright © 2015 Christian Hergert
-Depends=editor
 Builtin=true
-Embedded=gbp_symbol_tree_register_types
+Copyright=Copyright © 2015-2018 Christian Hergert
+Depends=editor;
+Description=Provides a Symbol Tree for the currently focused document
+Embedded=_gbp_symbol_tree_register_types
+Hidden=true
+Module=symbol-tree
+Name=Symbol Tree



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