[gnome-builder/wip/libide-merge] add treebuilder to sidepane



commit 81d0c8588933e3fb21df399b174f56dc30ffd5b5
Author: Christian Hergert <christian hergert me>
Date:   Sun Mar 22 00:12:00 2015 -0700

    add treebuilder to sidepane

 data/ui/gb-editor-workspace.ui           |   22 ++++++++++++++++++++--
 src/editor/gb-editor-workspace-private.h |    7 +++++--
 src/editor/gb-editor-workspace.c         |   16 ++++++++++++++++
 src/gnome-builder.mk                     |    4 ++--
 src/tree/gb-project-tree-builder.c       |    7 ++-----
 src/tree/gb-project-tree-builder.h       |    8 ++++----
 6 files changed, 49 insertions(+), 15 deletions(-)
---
diff --git a/data/ui/gb-editor-workspace.ui b/data/ui/gb-editor-workspace.ui
index 2fa83b4..f4fc293 100644
--- a/data/ui/gb-editor-workspace.ui
+++ b/data/ui/gb-editor-workspace.ui
@@ -3,9 +3,27 @@
   <!-- interface-requires gtk+ 3.15 -->
   <template class="GbEditorWorkspace" parent="GbWorkspace">
     <child>
-      <object class="GbViewGrid" id="view_grid">
-        <property name="expand">true</property>
+      <object class="GtkPaned">
+        <property name="orientation">horizontal</property>
+        <property name="position">250</property>
         <property name="visible">true</property>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="visible">true</property>
+            <child>
+              <object class="GbTree" id="project_tree">
+                <property name="headers-visible">false</property>
+                <property name="visible">true</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GbViewGrid" id="view_grid">
+            <property name="expand">true</property>
+            <property name="visible">true</property>
+          </object>
+        </child>
       </object>
     </child>
   </template>
diff --git a/src/editor/gb-editor-workspace-private.h b/src/editor/gb-editor-workspace-private.h
index 093c5ff..82d2e84 100644
--- a/src/editor/gb-editor-workspace-private.h
+++ b/src/editor/gb-editor-workspace-private.h
@@ -19,8 +19,9 @@
 #ifndef GB_EDITOR_WORKSPACE_PRIVATE_H
 #define GB_EDITOR_WORKSPACE_PRIVATE_H
 
-#include "gb-workspace.h"
+#include "gb-tree.h"
 #include "gb-view-grid.h"
+#include "gb-workspace.h"
 
 G_BEGIN_DECLS
 
@@ -28,7 +29,9 @@ struct _GbEditorWorkspace
 {
   GbWorkspace  parent_instance;
 
-  GbViewGrid  *view_grid;
+  GbTree        *project_tree;
+  GbTreeBuilder *project_tree_builder;
+  GbViewGrid    *view_grid;
 };
 
 G_END_DECLS
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 1222a01..b6c80e9 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -26,7 +26,9 @@
 #include "gb-editor-workspace.h"
 #include "gb-editor-workspace-actions.h"
 #include "gb-editor-workspace-private.h"
+#include "gb-project-tree-builder.h"
 #include "gb-string.h"
+#include "gb-tree.h"
 #include "gb-view-grid.h"
 #include "gb-widget.h"
 
@@ -79,6 +81,7 @@ gb_editor_workspace_context_changed (GtkWidget  *workspace,
                                      IdeContext *context)
 {
   GbEditorWorkspace *self = (GbEditorWorkspace *)workspace;
+  GbTreeNode *root;
 
   g_assert (GB_IS_EDITOR_WORKSPACE (self));
   g_assert (!context || IDE_IS_CONTEXT (context));
@@ -108,6 +111,12 @@ gb_editor_workspace_context_changed (GtkWidget  *workspace,
           IdeBuffer *buffer = g_ptr_array_index (buffers, i);
           gb_editor_workspace__load_buffer_cb (self, buffer, bufmgr);
         }
+
+      root = gb_tree_get_root (self->project_tree);
+      gb_tree_node_set_item (root, G_OBJECT (context));
+
+      gb_project_tree_builder_set_context (GB_PROJECT_TREE_BUILDER (self->project_tree_builder),
+                                           context);
     }
 }
 
@@ -155,8 +164,11 @@ gb_editor_workspace_class_init (GbEditorWorkspaceClass *klass)
   widget_class->grab_focus = gb_editor_workspace_grab_focus;
 
   GB_WIDGET_CLASS_TEMPLATE (klass, "gb-editor-workspace.ui");
+
+  GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_tree);
   GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, view_grid);
 
+  g_type_ensure (GB_TYPE_TREE);
   g_type_ensure (GB_TYPE_VIEW_GRID);
 }
 
@@ -165,6 +177,10 @@ gb_editor_workspace_init (GbEditorWorkspace *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  self->project_tree_builder = gb_project_tree_builder_new (NULL);
+  gb_tree_add_builder (self->project_tree, GB_TREE_BUILDER (self->project_tree_builder));
+  gb_tree_set_root (self->project_tree, gb_tree_node_new ());
+
   gb_widget_set_context_handler (self, gb_editor_workspace_context_changed);
 }
 
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 72836a6..a4eef43 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -98,6 +98,8 @@ libgnome_builder_la_SOURCES = \
        src/search/gb-search-types.h \
        src/support/gb-support.c \
        src/support/gb-support.h \
+       src/tree/gb-project-tree-builder.c \
+       src/tree/gb-project-tree-builder.h \
        src/tree/gb-tree-builder.c \
        src/tree/gb-tree-builder.h \
        src/tree/gb-tree-node.c \
@@ -147,8 +149,6 @@ disabled_files = \
        src/editor/gb-source-formatter.h \
        src/editor/gb-source-highlight-menu.c \
        src/editor/gb-source-highlight-menu.h \
-       src/tree/gb-project-tree-builder.c \
-       src/tree/gb-project-tree-builder.h \
        $(NULL)
 
 libgnome_builder_la_LIBADD = \
diff --git a/src/tree/gb-project-tree-builder.c b/src/tree/gb-project-tree-builder.c
index e132144..1f7c551 100644
--- a/src/tree/gb-project-tree-builder.c
+++ b/src/tree/gb-project-tree-builder.c
@@ -45,7 +45,7 @@ enum {
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 
-GbProjectTreeBuilder *
+GbTreeBuilder *
 gb_project_tree_builder_new (IdeContext *context)
 {
   g_return_val_if_fail (!context || IDE_IS_CONTEXT (context), NULL);
@@ -254,7 +254,6 @@ gb_project_tree_builder_node_activated (GbTreeBuilder *builder,
   if (IDE_IS_PROJECT_FILE (item))
     {
       GbWorkbench *workbench;
-      GbWorkspace *workspace;
       GFileInfo *file_info;
       GbTree *tree;
       GFile *file;
@@ -275,9 +274,7 @@ gb_project_tree_builder_node_activated (GbTreeBuilder *builder,
         goto failure;
 
       workbench = gb_widget_get_workbench (GTK_WIDGET (tree));
-      workspace = gb_workbench_get_workspace (workbench,
-                                              GB_TYPE_EDITOR_WORKSPACE);
-      gb_editor_workspace_open (GB_EDITOR_WORKSPACE (workspace), file);
+      gb_workbench_open (workbench, file);
 
       return TRUE;
     }
diff --git a/src/tree/gb-project-tree-builder.h b/src/tree/gb-project-tree-builder.h
index dc3e357..bfb7a80 100644
--- a/src/tree/gb-project-tree-builder.h
+++ b/src/tree/gb-project-tree-builder.h
@@ -34,10 +34,10 @@ struct _GbProjectTreeBuilderClass
   GbTreeBuilderClass parent;
 };
 
-GbProjectTreeBuilder *gb_project_tree_builder_new         (IdeContext           *context);
-IdeContext           *gb_project_tree_builder_get_context (GbProjectTreeBuilder *self);
-void                  gb_project_tree_builder_set_context (GbProjectTreeBuilder *self,
-                                                           IdeContext           *context);
+GbTreeBuilder  *gb_project_tree_builder_new         (IdeContext           *context);
+IdeContext     *gb_project_tree_builder_get_context (GbProjectTreeBuilder *self);
+void            gb_project_tree_builder_set_context (GbProjectTreeBuilder *self,
+                                                     IdeContext           *context);
 
 G_END_DECLS
 


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