[gnome-builder/wip/chergert/perspective] layout-view: use merged menu from IdeApplication



commit b84c1084356774f6b7d742138e4e205a90a80df1
Author: Christian Hergert <chergert redhat com>
Date:   Fri Dec 4 14:51:53 2015 -0800

    layout-view: use merged menu from IdeApplication

 data/gtk/menus.ui                     |   60 +++++++++++++++++++++++++++++++++
 libide/ide-layout-stack.c             |   15 ++++----
 libide/ide-layout-view.c              |   11 +-----
 libide/resources/libide.gresource.xml |    1 -
 4 files changed, 70 insertions(+), 17 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index 9715052..7a0a84a 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -308,4 +308,64 @@
       </submenu>
     </section>
   </menu>
+  <menu id="ide-layout-stack-menu">
+    <section id="ide-layout-stack-menu-splits-section">
+      <attribute name="display-hint">horizontal-buttons</attribute>
+      <attribute name="label" translatable="yes">Split</attribute>
+      <item>
+        <attribute name="label" translatable="yes">Split Left</attribute>
+        <attribute name="action">view-stack.split-left</attribute>
+        <attribute name="verb-icon">builder-split-tab-left-symbolic</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Split Right</attribute>
+        <attribute name="action">view-stack.split-right</attribute>
+        <attribute name="verb-icon">builder-split-tab-right-symbolic</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Split Down</attribute>
+        <attribute name="action">view-stack.split-down</attribute>
+        <attribute name="verb-icon">builder-split-tab-symbolic</attribute>
+      </item>
+    </section>
+    <section id="ide-layout-stack-menu-move-section">
+      <attribute name="display-hint">horizontal-buttons</attribute>
+      <attribute name="label" translatable="yes">Move</attribute>
+      <item>
+        <attribute name="label" translatable="yes">Move Left</attribute>
+        <attribute name="action">view-stack.move-left</attribute>
+        <attribute name="verb-icon">builder-move-left-symbolic</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Move Right</attribute>
+        <attribute name="action">view-stack.move-right</attribute>
+        <attribute name="verb-icon">builder-move-right-symbolic</attribute>
+      </item>
+    </section>
+    <section id="ide-layout-stack-menu-preview-section">
+      <attribute name="label" translatable="yes">Preview</attribute>
+    </section>
+    <section id="ide-layout-stack-menu-save-section">
+      <item>
+        <attribute name="label" translatable="yes">_Save</attribute>
+        <attribute name="action">view.save</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Save As</attribute>
+        <attribute name="action">view.save-as</attribute>
+      </item>
+    </section>
+    <section id="ide-layout-stack-menu-print-section">
+      <item>
+        <attribute name="label" translatable="yes">_Print</attribute>
+        <attribute name="action">view.print</attribute>
+      </item>
+    </section>
+    <section id="ide-layout-stack-menu-close-section">
+      <item>
+        <attribute name="label" translatable="yes">_Close</attribute>
+        <attribute name="action">view-stack.close</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>
diff --git a/libide/ide-layout-stack.c b/libide/ide-layout-stack.c
index 691ef57..001b9a0 100644
--- a/libide/ide-layout-stack.c
+++ b/libide/ide-layout-stack.c
@@ -18,6 +18,7 @@
 
 #include <glib/gi18n.h>
 
+#include "ide-application.h"
 #include "ide-back-forward-item.h"
 #include "ide-buffer.h"
 #include "ide-buffer-manager.h"
@@ -454,6 +455,8 @@ static void
 ide_layout_stack_constructed (GObject *object)
 {
   IdeLayoutStack *self = (IdeLayoutStack *)object;
+  GtkPopover *popover;
+  GMenu *menu;
 
   G_OBJECT_CLASS (ide_layout_stack_parent_class)->constructed (object);
 
@@ -485,6 +488,11 @@ ide_layout_stack_constructed (GObject *object)
   gtk_widget_set_sensitive (GTK_WIDGET (self->close_button), FALSE);
   gtk_widget_set_sensitive (GTK_WIDGET (self->views_button), FALSE);
   gtk_widget_set_sensitive (GTK_WIDGET (self->document_button), FALSE);
+
+  menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "ide-layout-stack-menu");
+  popover = g_object_new (GTK_TYPE_POPOVER, NULL);
+  gtk_popover_bind_model (popover, G_MENU_MODEL (menu), NULL);
+  gtk_menu_button_set_popover (self->document_button, GTK_WIDGET (popover));
 }
 
 static void
@@ -684,18 +692,11 @@ ide_layout_stack_set_active_view (IdeLayoutStack *self,
           GtkWidget *controls;
           GBinding *binding;
           GActionGroup *group;
-          GMenu *menu;
-          GtkPopover *popover;
 
           ide_set_weak_pointer (&self->active_view, active_view);
           if (active_view != gtk_stack_get_visible_child (self->stack))
             gtk_stack_set_visible_child (self->stack, active_view);
 
-          menu = ide_layout_view_get_menu (IDE_LAYOUT_VIEW (active_view));
-          popover = g_object_new (GTK_TYPE_POPOVER, NULL);
-          gtk_popover_bind_model (popover, G_MENU_MODEL (menu), NULL);
-          gtk_menu_button_set_popover (self->document_button, GTK_WIDGET (popover));
-
           self->focus_history = g_list_remove (self->focus_history, active_view);
           self->focus_history = g_list_prepend (self->focus_history, active_view);
 
diff --git a/libide/ide-layout-view.c b/libide/ide-layout-view.c
index bf3d733..a8b26e8 100644
--- a/libide/ide-layout-view.c
+++ b/libide/ide-layout-view.c
@@ -18,12 +18,12 @@
 
 #include <glib/gi18n.h>
 
+#include "ide-application.h"
 #include "ide-layout-view.h"
 
 typedef struct
 {
   GtkBox *controls;
-  GMenu  *menu;
 } IdeLayoutViewPrivate;
 
 static void buildable_iface_init (GtkBuildableIface *iface);
@@ -249,9 +249,6 @@ ide_layout_view_class_init (IdeLayoutViewClass *klass)
 
   widget_class->destroy = ide_layout_view_destroy;
 
-  gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/ide-layout-view.ui");
-  gtk_widget_class_bind_template_child_private (widget_class, IdeLayoutView, menu);
-
   properties [PROP_CAN_SPLIT] =
     g_param_spec_boolean ("can-split",
                           "Can Split",
@@ -294,8 +291,6 @@ ide_layout_view_init (IdeLayoutView *self)
   IdeLayoutViewPrivate *priv = ide_layout_view_get_instance_private (self);
   GtkBox *controls;
 
-  gtk_widget_init_template (GTK_WIDGET (self));
-
   controls = g_object_new (GTK_TYPE_BOX,
                            "orientation", GTK_ORIENTATION_HORIZONTAL,
                            "visible", TRUE,
@@ -333,11 +328,9 @@ buildable_iface_init (GtkBuildableIface *iface)
 GMenu *
 ide_layout_view_get_menu (IdeLayoutView *self)
 {
-  IdeLayoutViewPrivate *priv = ide_layout_view_get_instance_private (self);
-
   g_return_val_if_fail (IDE_IS_LAYOUT_VIEW (self), NULL);
 
-  return priv->menu;
+  return ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "ide-layout-view-menu");
 }
 
 /*
diff --git a/libide/resources/libide.gresource.xml b/libide/resources/libide.gresource.xml
index afb9ee5..7260e24 100644
--- a/libide/resources/libide.gresource.xml
+++ b/libide/resources/libide.gresource.xml
@@ -50,7 +50,6 @@
     <file alias="ide-layout.ui">../../data/ui/ide-layout.ui</file>
     <file alias="ide-layout-pane.ui">../../data/ui/ide-layout-pane.ui</file>
     <file alias="ide-layout-stack.ui">../../data/ui/ide-layout-stack.ui</file>
-    <file alias="ide-layout-view.ui">../../data/ui/ide-layout-view.ui</file>
     <file alias="ide-omni-search-group.ui">../../data/ui/ide-omni-search-group.ui</file>
     <file alias="ide-omni-search-row.ui">../../data/ui/ide-omni-search-row.ui</file>
     <file alias="ide-preferences-entry.ui">../../data/ui/ide-preferences-entry.ui</file>


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