[gnome-builder] workbench: use DzlMenuButton for perpsective switcher



commit b669d3f84e076a7f87e8424d1d920739cf606916
Author: Christian Hergert <chergert redhat com>
Date:   Sun Jul 9 18:54:21 2017 -0700

    workbench: use DzlMenuButton for perpsective switcher
    
    We no longer need the perspective switcher as we can use the
    menu button from libdazzle. Furthermore, this allows us to
    set the actions/targets using menus.ui rather than additional
    code in perspectives for priority/etc.

 data/gtk/menus.ui                               |   30 ++
 libide/libide.gresource.xml                     |    1 -
 libide/meson.build                              |    2 -
 libide/workbench/ide-perspective-menu-button.c  |  430 -----------------------
 libide/workbench/ide-perspective-menu-button.h  |   34 --
 libide/workbench/ide-perspective-menu-button.ui |   43 ---
 libide/workbench/ide-workbench-private.h        |    3 +-
 libide/workbench/ide-workbench.c                |   20 +-
 libide/workbench/ide-workbench.ui               |   10 +-
 plugins/sysprof/gtk/menus.ui                    |   13 +
 10 files changed, 66 insertions(+), 520 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index e39bb2c..2c4dff2 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -40,6 +40,36 @@
       </item>
     </section>
   </menu>
+  <menu id="perspectives-menu">
+    <section id="perspectives-menu-section">
+      <item>
+        <attribute name="id">perspective-menu-editor</attribute>
+        <attribute name="label" translatable="yes">Editor</attribute>
+        <attribute name="verb-icon-name">builder-editor-symbolic</attribute>
+        <attribute name="accel">&lt;alt&gt;1</attribute>
+        <attribute name="action">win.perspective</attribute>
+        <attribute name="target">editor</attribute>
+      </item>
+    </section>
+    <section id="perspectives-menu-prefs-section">
+      <item>
+        <attribute name="id">perspective-menu-build-prefs</attribute>
+        <attribute name="label" translatable="yes">Build Preferences</attribute>
+        <attribute name="verb-icon-name">builder-build-configure-symbolic</attribute>
+        <attribute name="action">win.perspective</attribute>
+        <attribute name="target">buildperspective</attribute>
+        <attribute name="accel">&lt;alt&gt;comma</attribute>
+      </item>
+      <item>
+        <attribute name="id">perspective-menu-prefs</attribute>
+        <attribute name="label" translatable="yes">Preferences</attribute>
+        <attribute name="verb-icon-name">preferences-system-symbolic</attribute>
+        <attribute name="action">win.perspective</attribute>
+        <attribute name="target">preferences</attribute>
+        <attribute name="accel">&lt;primary&gt;comma</attribute>
+      </item>
+    </section>
+  </menu>
   <menu id="gear-menu">
     <section id="gear-menu-new-section">
       <item>
diff --git a/libide/libide.gresource.xml b/libide/libide.gresource.xml
index f8c256a..c89659b 100644
--- a/libide/libide.gresource.xml
+++ b/libide/libide.gresource.xml
@@ -67,7 +67,6 @@
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-greeter-project-row.ui">greeter/ide-greeter-project-row.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-omni-bar.ui">workbench/ide-omni-bar.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-omni-bar-row.ui">workbench/ide-omni-bar-row.ui</file>
-    <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-perspective-menu-button.ui">workbench/ide-perspective-menu-button.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-preferences-language-row.ui">preferences/ide-preferences-language-row.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-run-button.ui">runner/ide-run-button.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-transfer-row.ui">transfers/ide-transfer-row.ui</file>
diff --git a/libide/meson.build b/libide/meson.build
index 918b17b..775a583 100644
--- a/libide/meson.build
+++ b/libide/meson.build
@@ -568,8 +568,6 @@ libide_sources = libide_generated_headers + libide_public_sources + [
   'util/ide-window-settings.h',
   'workbench/ide-omni-bar-row.c',
   'workbench/ide-omni-bar-row.h',
-  'workbench/ide-perspective-menu-button.c',
-  'workbench/ide-perspective-menu-button.h',
   'workbench/ide-workbench-actions.c',
   'workbench/ide-workbench-private.h',
   'workers/ide-worker-manager.c',
diff --git a/libide/workbench/ide-workbench-private.h b/libide/workbench/ide-workbench-private.h
index c9557c8..d62e554 100644
--- a/libide/workbench/ide-workbench-private.h
+++ b/libide/workbench/ide-workbench-private.h
@@ -22,7 +22,6 @@
 #include <libpeas/peas.h>
 
 #include "workbench/ide-perspective.h"
-#include "workbench/ide-perspective-menu-button.h"
 #include "workbench/ide-workbench.h"
 #include "workbench/ide-workbench-header-bar.h"
 
@@ -49,7 +48,7 @@ struct _IdeWorkbench
 
   GtkStack                  *header_stack;
   IdeWorkbenchHeaderBar     *header_bar;
-  IdePerspectiveMenuButton  *perspective_menu_button;
+  DzlMenuButton             *perspective_menu_button;
   GtkStack                  *perspectives_stack;
   GtkSizeGroup              *header_size_group;
   GtkBox                    *message_box;
diff --git a/libide/workbench/ide-workbench.c b/libide/workbench/ide-workbench.c
index d586818..2fb0b5c 100644
--- a/libide/workbench/ide-workbench.c
+++ b/libide/workbench/ide-workbench.c
@@ -68,17 +68,27 @@ ide_workbench_notify_visible_child (IdeWorkbench *self,
                                     GParamSpec   *pspec,
                                     GtkStack     *stack)
 {
-  IdePerspective *perspective;
+  GtkWidget *perspective;
 
   g_assert (IDE_IS_WORKBENCH (self));
   g_assert (GTK_IS_STACK (stack));
 
-  perspective = IDE_PERSPECTIVE (gtk_stack_get_visible_child (stack));
+  perspective = gtk_stack_get_visible_child (stack);
+
+  if (perspective != NULL)
+    {
+      g_autofree gchar *icon_name = NULL;
+
+      gtk_container_child_get (GTK_CONTAINER (stack), perspective,
+                               "icon-name", &icon_name,
+                               NULL);
+      g_object_set (self->perspective_menu_button,
+                    "icon-name", icon_name,
+                    NULL);
+    }
 
   /* Mux the actions from the perspective for the header bar */
-  dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self),
-                                    perspective ? GTK_WIDGET (perspective) : NULL,
-                                    "IDE_PERSPECTIVE_ACTIONS");
+  dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self), perspective, "IDE_PERSPECTIVE_ACTIONS");
 }
 
 static gint
diff --git a/libide/workbench/ide-workbench.ui b/libide/workbench/ide-workbench.ui
index e8c9e69..c231441 100644
--- a/libide/workbench/ide-workbench.ui
+++ b/libide/workbench/ide-workbench.ui
@@ -14,9 +14,13 @@
             <child internal-child="left">
               <object class="DzlPriorityBox">
                 <child>
-                  <object class="IdePerspectiveMenuButton" id="perspective_menu_button">
-                    <property name="focus-on-click">false</property>
-                    <property name="stack">perspectives_stack</property>
+                  <object class="DzlMenuButton" id="perspective_menu_button">
+                    <property name="icon-name"></property>
+                    <property name="menu-id">perspectives-menu</property>
+                    <property name="show-accels">true</property>
+                    <property name="show-arrow">true</property>
+                    <property name="show-icons">true</property>
+                    <property name="transitions-enabled">false</property>
                     <property name="visible">false</property>
                   </object>
                   <packing>
diff --git a/plugins/sysprof/gtk/menus.ui b/plugins/sysprof/gtk/menus.ui
index 6004cef..2e1c0f4 100644
--- a/plugins/sysprof/gtk/menus.ui
+++ b/plugins/sysprof/gtk/menus.ui
@@ -8,4 +8,17 @@
       </item>
     </section>
   </menu>
+  <menu id="perspectives-menu">
+    <section id="perspectives-menu-section">
+      <item>
+        <attribute name="id">perspective-menu-profiler</attribute>
+        <attribute name="after">perspective-menu-editor</attribute>
+        <attribute name="label" translatable="yes">Profiler</attribute>
+        <attribute name="verb-icon-name">utilities-system-monitor-symbolic</attribute>
+        <attribute name="accel">&lt;alt&gt;3</attribute>
+        <attribute name="action">win.perspective</attribute>
+        <attribute name="target">profiler</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>


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