[gnome-builder] project-tree: port to new editor perspective
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] project-tree: port to new editor perspective
- Date: Wed, 19 Jul 2017 11:02:49 +0000 (UTC)
commit db63145fae26953a99338759052ab24155c4a9e5
Author: Christian Hergert <chergert redhat com>
Date: Fri Jun 30 00:13:25 2017 -0700
project-tree: port to new editor perspective
This will probably become a legacy plugin but we should keep it working
for people that would rather have a tree than the stacklist.
plugins/project-tree/gb-project-tree-actions.c | 7 +--
plugins/project-tree/gb-project-tree-addin.c | 62 +++++++-----------------
2 files changed, 20 insertions(+), 49 deletions(-)
---
diff --git a/plugins/project-tree/gb-project-tree-actions.c b/plugins/project-tree/gb-project-tree-actions.c
index ca2b2ed..0dd1f8a 100644
--- a/plugins/project-tree/gb-project-tree-actions.c
+++ b/plugins/project-tree/gb-project-tree-actions.c
@@ -782,11 +782,10 @@ gb_project_tree_actions_move_to_trash (GSimpleAction *action,
*/
for (iter = removal.views; iter; iter = iter->next)
{
- GtkWidget *stack;
+ IdeLayoutView *view = iter->data;
- stack = gtk_widget_get_ancestor (iter->data, IDE_TYPE_LAYOUT_STACK);
- if (stack != NULL)
- ide_layout_stack_remove (IDE_LAYOUT_STACK (stack), iter->data);
+ if (IDE_IS_EDITOR_VIEW (view))
+ gtk_widget_destroy (GTK_WIDGET (view));
}
g_list_free_full (removal.views, g_object_unref);
diff --git a/plugins/project-tree/gb-project-tree-addin.c b/plugins/project-tree/gb-project-tree-addin.c
index 0230019..9fb6031 100644
--- a/plugins/project-tree/gb-project-tree-addin.c
+++ b/plugins/project-tree/gb-project-tree-addin.c
@@ -50,25 +50,13 @@ gb_project_tree_addin_context_set (GtkWidget *widget,
}
static void
-gb_project_tree_addin_grid_empty (GbProjectTreeAddin *self,
- IdeLayoutGrid *grid)
-{
- g_assert (GB_IS_PROJECT_TREE_ADDIN (self));
- g_assert (IDE_IS_LAYOUT_GRID (grid));
-
- gtk_widget_grab_focus (GTK_WIDGET (self->tree));
-}
-
-static void
gb_project_tree_addin_load (IdeWorkbenchAddin *addin,
IdeWorkbench *workbench)
{
GbProjectTreeAddin *self = (GbProjectTreeAddin *)addin;
+ IdeEditorSidebar *sidebar;
IdePerspective *editor;
- GtkWidget *pane;
- GtkWidget *content;
GtkWidget *scroller;
- GtkWidget *grid;
g_assert (IDE_IS_WORKBENCH_ADDIN (self));
g_assert (IDE_IS_WORKBENCH (workbench));
@@ -76,38 +64,29 @@ gb_project_tree_addin_load (IdeWorkbenchAddin *addin,
editor = ide_workbench_get_perspective_by_name (workbench, "editor");
g_assert (editor != NULL);
- pane = ide_editor_perspective_get_left_edge (IDE_EDITOR_PERSPECTIVE (editor));
- g_assert (pane != NULL);
-
- content = ide_editor_perspective_get_center_widget (IDE_EDITOR_PERSPECTIVE (editor));
- g_assert (content != NULL);
-
- grid = dzl_gtk_widget_find_child_typed (content, IDE_TYPE_LAYOUT_GRID);
- g_assert (grid != NULL);
-
- g_signal_connect_object (grid,
- "empty",
- G_CALLBACK (gb_project_tree_addin_grid_empty),
- self,
- G_CONNECT_SWAPPED);
+ sidebar = ide_editor_perspective_get_sidebar (IDE_EDITOR_PERSPECTIVE (editor));
+ g_assert (IDE_IS_EDITOR_SIDEBAR (sidebar));
scroller = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
NULL);
+
self->tree = g_object_new (GB_TYPE_PROJECT_TREE,
"headers-visible", FALSE,
"visible", TRUE,
NULL);
- g_object_add_weak_pointer (G_OBJECT (self->tree), (gpointer *)&self->tree);
+ g_signal_connect (self->tree,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &self->tree);
gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET (self->tree));
- self->panel = g_object_new (DZL_TYPE_DOCK_WIDGET,
- "expand", TRUE,
- "title", _("Project"),
- "visible", TRUE,
- NULL);
- gtk_container_add (GTK_CONTAINER (self->panel), GTK_WIDGET (scroller));
- gtk_container_add (GTK_CONTAINER (pane), GTK_WIDGET (self->panel));
+ ide_editor_sidebar_add_section (sidebar,
+ "project-tree-view",
+ _("Project Tree"),
+ "view-list-symbolic",
+ NULL, NULL,
+ GTK_WIDGET (scroller));
ide_widget_set_context_handler (self->tree, gb_project_tree_addin_context_set);
@@ -124,16 +103,9 @@ gb_project_tree_addin_unload (IdeWorkbenchAddin *addin,
g_assert (IDE_IS_WORKBENCH (workbench));
if (self->tree != NULL)
- {
- g_signal_handlers_disconnect_by_func (self->tree,
- G_CALLBACK (gb_project_tree_addin_grid_empty),
- self);
- g_object_remove_weak_pointer (G_OBJECT (self->tree), (gpointer *)&self->tree);
- self->tree = NULL;
- }
-
- gtk_widget_destroy (self->panel);
- self->panel = NULL;
+ gtk_widget_destroy (GTK_WIDGET (self->tree));
+
+ g_object_set_data (G_OBJECT (workbench), "GB_PROJECT_TREE", NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]