[gnome-builder/wip/gtk4-port: 307/736] libide/gui: setup various run/build menus




commit 8d9d41aea1bc304818e8e89a907bb50996b4d255
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 1 00:14:01 2022 -0700

    libide/gui: setup various run/build menus
    
    These aren't final or anything, but it's what we should try to aspire to
    for GNOME 43 if we can make it. Obviously simulators are unlikely to make
    it on top of all the other work we have to do in porting.

 src/libide/gui/gtk/menus.ui             | 138 ++++++++++++++++++++++++++++++++
 src/libide/gui/ide-application.c        |   7 +-
 src/libide/gui/ide-omni-bar.c           |  41 ++++++++++
 src/libide/gui/ide-primary-workspace.ui |   1 +
 4 files changed, 185 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/gui/gtk/menus.ui b/src/libide/gui/gtk/menus.ui
index 4daba82e9..9acbac1f1 100644
--- a/src/libide/gui/gtk/menus.ui
+++ b/src/libide/gui/gtk/menus.ui
@@ -56,7 +56,107 @@
     <section id="open-document-section">
     </section>
   </menu>
+  <menu id="build-menu">
+    <section id="build-menu-config">
+      <submenu id="build-menu-configs">
+        <attribute name="label" translatable="yes">Active Configuration</attribute>
+      </submenu>
+      <item>
+        <attribute name="label" translatable="yes">Configure Project…</attribute>
+        <attribute name="action">buildui.configure</attribute>
+      </item>
+    </section>
+    <section id="build-menu-target">
+      <submenu id="build-menu-targets">
+        <attribute name="label" translatable="yes">Build Target</attribute>
+      </submenu>
+    </section>
+    <section id="build-commands">
+      <item>
+        <attribute name="label" translatable="yes">_Build</attribute>
+        <attribute name="action">build-manager.build</attribute>
+        <attribute name="accel">&lt;ctrl&gt;&lt;shift&gt;space</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Rebuild</attribute>
+        <attribute name="action">build-manager.rebuild</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Clean</attribute>
+        <attribute name="action">build-manager.clean</attribute>
+      </item>
+    </section>
+    <section id="build-cork">
+      <item>
+        <attribute name="label" translatable="yes">Stop Build</attribute>
+        <attribute name="action">build-manager.cancel</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Pause Builds</attribute>
+        <attribute name="action">build-manager.pause</attribute>
+        <attribute name="role">check</attribute>
+      </item>
+    </section>
+    <section id="build-output">
+      <item>
+        <attribute name="label" translatable="yes">Show Build Log</attribute>
+        <attribute name="action">buildui.show-log</attribute>
+        <attribute name="accel">&lt;ctrl&gt;&lt;shift&gt;l</attribute>
+      </item>
+    </section>
+    <section id="build-deps">
+      <item>
+        <attribute name="label" translatable="yes">Update Dependencies…</attribute>
+        <attribute name="action">buildui.update-deps</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Manage SDKs…</attribute>
+        <attribute name="action">foundryui.manage-sdks</attribute>
+      </item>
+    </section>
+    <section id="build-export"/>
+  </menu>
   <menu id="run-menu">
+    <section id="run-command-section">
+      <submenu id="run-commands">
+        <attribute name="label" translatable="yes">Run Command</attribute>
+      </submenu>
+      <item>
+        <attribute name="label" translatable="yes">Custom Command…</attribute>
+        <attribute name="action">runui.custom</attribute>
+      </item>
+    </section>
+    <section id="run-menu-device-section">
+      <submenu id="run-menu-devices">
+        <attribute name="id">run-device</attribute>
+        <attribute name="label" translatable="yes">Device (My Computer)</attribute>
+        <section id="run-menu-device-localhost">
+          <item>
+            <attribute name="label" translatable="yes">My Computer</attribute>
+            <attribute name="action">deviceui.device</attribute>
+            <attribute name="target" type="s">'host'</attribute>
+            <attribute name="role">check</attribute>
+          </item>
+          <item>
+            <attribute name="label" translatable="yes">My Computer (32-bit)</attribute>
+            <attribute name="action">deviceui.device</attribute>
+            <attribute name="target" type="s">'host-32'</attribute>
+            <attribute name="role">check</attribute>
+          </item>
+        </section>
+        <section id="run-menu-simulators-section">
+          <submenu id="run-menu-simulators">
+            <attribute name="label" translatable="yes">Simulators</attribute>
+          </submenu>
+          <submenu id="run-menu-simulators-aarch64">
+            <attribute name="label" translatable="yes">Simulators (aarch64)</attribute>
+          </submenu>
+        </section>
+        <section id="run-menu-connected-devices">
+          <attribute name="label" translatable="yes">Connected Devices</attribute>
+        </section>
+      </submenu>
+    </section>
     <section id="run-menu-observation-section">
       <attribute name="label" translatable="yes">Observation</attribute>
       <item>
@@ -67,6 +167,44 @@
         <attribute name="verb-icon-name">builder-run-start-symbolic</attribute>
       </item>
     </section>
+    <section id="run-menu-settings-section">
+      <attribute name="label" translatable="yes">Settings</attribute>
+      <submenu id="run-menu-appearance">
+        <attribute name="label" translatable="yes">Appearance</attribute>
+        <item>
+          <attribute name="label">Follow System Style</attribute>
+          <attribute name="role">radio</attribute>
+          <attribute name="action">runui.color-scheme</attribute>
+          <attribute name="target" type="s">'default'</attribute>
+        </item>
+        <item>
+          <attribute name="label">Force Light</attribute>
+          <attribute name="role">radio</attribute>
+          <attribute name="action">runui.color-scheme</attribute>
+          <attribute name="target" type="s">'force-dark'</attribute>
+        </item>
+        <item>
+          <attribute name="label">Force Dark</attribute>
+          <attribute name="role">radio</attribute>
+          <attribute name="action">runui.color-scheme</attribute>
+          <attribute name="target" type="s">'force-dark'</attribute>
+        </item>
+      </submenu>
+      <submenu id="run-menu-a11y">
+        <attribute name="label" translatable="yes">Accessibility</attribute>
+        <item>
+          <attribute name="label" translatable="yes">High Contrast</attribute>
+          <attribute name="role">check</attribute>
+          <attribute name="action">runui.high-contrast</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">Right-to-Left</attribute>
+          <attribute name="role">check</attribute>
+          <attribute name="action">runui.textdir</attribute>
+          <attribute name="target" type="s">'rtl'</attribute>
+        </item>
+      </submenu>
+    </section>
   </menu>
   <menu id="new-document-menu">
     <section id="new-document-section"/>
diff --git a/src/libide/gui/ide-application.c b/src/libide/gui/ide-application.c
index 77631e0d3..a620e343b 100644
--- a/src/libide/gui/ide-application.c
+++ b/src/libide/gui/ide-application.c
@@ -721,11 +721,11 @@ ide_application_find_addin_by_module_name (IdeApplication *self,
 /**
  * ide_application_get_menu_by_id:
  * @self: a #IdeApplication
- * @menu_id: the menu identifier
+ * @menu_id: (nullable): the menu identifier
  *
  * Gets the merged menu by it's identifier.
  *
- * Returns: (transfer none): a #GMenu
+ * Returns: (transfer none) (nullable): a #GMenu or %NULL if @menu_id is %NULL
  */
 GMenu *
 ide_application_get_menu_by_id (IdeApplication *self,
@@ -733,5 +733,8 @@ ide_application_get_menu_by_id (IdeApplication *self,
 {
   g_return_val_if_fail (IDE_IS_APPLICATION (self), NULL);
 
+  if (menu_id == NULL)
+    return NULL;
+
   return ide_menu_manager_get_menu_by_id (self->menu_manager, menu_id);
 }
diff --git a/src/libide/gui/ide-omni-bar.c b/src/libide/gui/ide-omni-bar.c
index 3af22a161..bbc2dd9eb 100644
--- a/src/libide/gui/ide-omni-bar.c
+++ b/src/libide/gui/ide-omni-bar.c
@@ -24,6 +24,7 @@
 
 #include <libpeas/peas.h>
 
+#include "ide-application.h"
 #include "ide-gui-global.h"
 #include "ide-notification-list-box-row-private.h"
 #include "ide-notification-stack-private.h"
@@ -59,7 +60,14 @@ G_DEFINE_FINAL_TYPE_WITH_CODE (IdeOmniBar, ide_omni_bar, PANEL_TYPE_OMNI_BAR,
                                G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, ide_omni_bar_init_action_group)
                                G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, buildable_iface_init))
 
+enum {
+  PROP_0,
+  PROP_MENU_ID,
+  N_PROPS
+};
+
 static GtkBuildableIface *parent_buildable_iface;
+static GParamSpec *properties [N_PROPS];
 
 static void
 ide_omni_bar_notification_stack_changed_cb (IdeOmniBar           *self,
@@ -280,6 +288,29 @@ ide_omni_bar_dispose (GObject *object)
   G_OBJECT_CLASS (ide_omni_bar_parent_class)->dispose (object);
 }
 
+static void
+ide_omni_bar_set_property (GObject      *object,
+                           guint         prop_id,
+                           const GValue *value,
+                           GParamSpec   *pspec)
+{
+  IdeOmniBar *self = IDE_OMNI_BAR (object);
+
+  switch (prop_id)
+    {
+    case PROP_MENU_ID:
+      {
+        const char *menu_id = g_value_get_string (value);
+        GMenu *menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, menu_id);
+        g_object_set (self, "menu-model", menu, NULL);
+        break;
+      }
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
 static void
 ide_omni_bar_class_init (IdeOmniBarClass *klass)
 {
@@ -287,10 +318,20 @@ ide_omni_bar_class_init (IdeOmniBarClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   object_class->dispose = ide_omni_bar_dispose;
+  object_class->set_property = ide_omni_bar_set_property;
 
   widget_class->query_tooltip = ide_omni_bar_query_tooltip;
   widget_class->measure = ide_omni_bar_measure;
 
+  properties [PROP_MENU_ID] =
+    g_param_spec_string ("menu-id",
+                         "Menu ID",
+                         "The identifier for the merged menu",
+                         NULL,
+                         (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/libide-gui/ui/ide-omni-bar.ui");
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, notification_stack);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, notifications_list_box);
diff --git a/src/libide/gui/ide-primary-workspace.ui b/src/libide/gui/ide-primary-workspace.ui
index a4a89832d..bbf7e4a7b 100644
--- a/src/libide/gui/ide-primary-workspace.ui
+++ b/src/libide/gui/ide-primary-workspace.ui
@@ -24,6 +24,7 @@
               <object class="IdeOmniBar" id="omni_bar">
                 <property name="icon-name">builder-build-symbolic</property>
                 <property name="action-name">build-manager.build</property>
+                <property name="menu-id">build-menu</property>
                 <child type="placeholder">
                   <object class="GtkLabel" id="project_title">
                     <property name="ellipsize">end</property>


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