[gnome-builder] tree: add build items



commit 59d0eca4fa32f18f5d82fce0a6286a890d14c21c
Author: Christian Hergert <christian hergert me>
Date:   Sun Apr 5 22:54:58 2015 -0700

    tree: add build items

 data/gtk/menus.ui                  |   12 ++++++++++++
 src/tree/gb-project-tree-builder.c |   15 ++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index 90567b6..7b9d63b 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -153,4 +153,16 @@
       </item>
     </section>
   </menu>
+  <menu id="project-tree-build">
+    <section id="build-section">
+      <item>
+        <attribute name="label" translatable="yes">_Build</attribute>
+        <attribute name="action">workbench.build</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Rebuild</attribute>
+        <attribute name="action">workbench.rebuild</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>
diff --git a/src/tree/gb-project-tree-builder.c b/src/tree/gb-project-tree-builder.c
index 2f0f8be..a6810fd 100644
--- a/src/tree/gb-project-tree-builder.c
+++ b/src/tree/gb-project-tree-builder.c
@@ -289,27 +289,32 @@ gb_project_tree_builder_node_popup (GbTreeBuilder *builder,
                                     GMenu         *menu)
 {
   GbProjectTreeBuilder *self = (GbProjectTreeBuilder *)builder;
+  GtkApplication *app;
   GObject *item;
+  GMenu *submenu;
 
   g_assert (GB_IS_PROJECT_TREE_BUILDER (self));
   g_assert (GB_IS_TREE_NODE (node));
   g_assert (G_IS_MENU (menu));
 
+  app = GTK_APPLICATION (g_application_get_default ());
   item = gb_tree_node_get_item (node);
 
-  if (IDE_IS_PROJECT_FILE (item))
+  if (IDE_IS_PROJECT_ITEM (item) || IDE_IS_PROJECT (item))
     {
-      GtkApplication *app;
-      GMenu *submenu;
-
-      app = GTK_APPLICATION (g_application_get_default ());
+      submenu = gtk_application_get_menu_by_id (app, "project-tree-build");
+      g_menu_prepend_section (menu, NULL, G_MENU_MODEL (submenu));
+    }
 
+  if (IDE_IS_PROJECT_FILE (item))
+    {
       submenu = gtk_application_get_menu_by_id (app, "project-tree-open-containing");
       g_menu_prepend_section (menu, NULL, G_MENU_MODEL (submenu));
 
       submenu = gtk_application_get_menu_by_id (app, "project-tree-open");
       g_menu_prepend_section (menu, NULL, G_MENU_MODEL (submenu));
     }
+
 }
 
 static gboolean


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