[gnome-builder/wip/gtk4-port: 242/343] plugins/project-tree: port workspace addin to GTK 4




commit 9f9c4667965871526ced360ad147c8386848f9ee
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 31 02:14:21 2022 -0700

    plugins/project-tree: port workspace addin to GTK 4

 .../gbp-project-tree-workspace-addin.c             | 36 +++++++---------------
 1 file changed, 11 insertions(+), 25 deletions(-)
---
diff --git a/src/plugins/project-tree/gbp-project-tree-workspace-addin.c 
b/src/plugins/project-tree/gbp-project-tree-workspace-addin.c
index f7b49c708..374d4d6ef 100644
--- a/src/plugins/project-tree/gbp-project-tree-workspace-addin.c
+++ b/src/plugins/project-tree/gbp-project-tree-workspace-addin.c
@@ -23,7 +23,6 @@
 #include "config.h"
 
 #include <glib/gi18n.h>
-#include <libide-editor.h>
 #include <libide-gui.h>
 
 #include "gbp-project-tree-workspace-addin.h"
@@ -44,29 +43,18 @@ gbp_project_tree_workspace_addin_load (IdeWorkspaceAddin *addin,
   IdeSurface *surface;
 
   g_assert (GBP_IS_PROJECT_TREE_WORKSPACE_ADDIN (self));
-  g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace) ||
-            IDE_IS_EDITOR_WORKSPACE (workspace));
-
-  surface = ide_workspace_get_surface_by_name (workspace, "editor");
-  g_assert (IDE_IS_EDITOR_SURFACE (surface));
-
-  sidebar = ide_editor_surface_get_sidebar (IDE_EDITOR_SURFACE (surface));
-  g_assert (IDE_IS_EDITOR_SIDEBAR (sidebar));
+  g_assert (IDE_IS_WORKSPACE (workspace));
 
   self->pane = g_object_new (GBP_TYPE_PROJECT_TREE_PANE,
-                             "visible", TRUE,
+                             "title", _("Project Tree"),
+                             "icon-name", "view-list-symbolic",
                              NULL);
-  g_signal_connect (self->pane,
-                    "destroy",
-                    G_CALLBACK (gtk_widget_destroyed),
-                    &self->pane);
-  ide_editor_sidebar_add_section (sidebar,
-                                  "project-tree",
-                                  _("Project Tree"),
-                                  "view-list-symbolic",
-                                  NULL, NULL,
-                                  GTK_WIDGET (self->pane),
-                                  0);
+
+  position = ide_panel_position_new ();
+  ide_panel_position_set_edge (position, PANEL_DOCK_POSITION_START);
+  ide_panel_position_set_row (position, 0);
+
+  ide_workspace_add_pane (workspace, IDE_PANE (self->pane), position);
 }
 
 static void
@@ -76,11 +64,9 @@ gbp_project_tree_workspace_addin_unload (IdeWorkspaceAddin *addin,
   GbpProjectTreeWorkspaceAddin *self = (GbpProjectTreeWorkspaceAddin *)addin;
 
   g_assert (GBP_IS_PROJECT_TREE_WORKSPACE_ADDIN (self));
-  g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace) ||
-            IDE_IS_EDITOR_WORKSPACE (workspace));
+  g_assert (IDE_IS_WORKSPACE (workspace));
 
-  if (self->pane != NULL)
-    gtk_widget_destroy (GTK_WIDGET (self->pane));
+  g_clear_pointer ((IdePane **)&self->pane, ide_pane_destroy);
 }
 
 static void


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