[gnome-builder/wip/gtk4-port] libide/gui: wire up devices into Run menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/gui: wire up devices into Run menu
- Date: Tue, 19 Apr 2022 21:12:29 +0000 (UTC)
commit 94e14baf543d260ea875047be7ef867b77ffb72f
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 19 14:11:50 2022 -0700
libide/gui: wire up devices into Run menu
Long term, I'd like to see the device manager organize these devices into
submenus and handle simulators/etc. However, until we get APIs for that,
it doesn't make sense to have the menuing in place other than to serve
and a way to terrify my ADHD into implementing it.
src/libide/gui/gtk/menus.ui | 35 ++---------------------------------
src/libide/gui/ide-run-button.c | 26 +++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 34 deletions(-)
---
diff --git a/src/libide/gui/gtk/menus.ui b/src/libide/gui/gtk/menus.ui
index 998c8f399..4a579fd25 100644
--- a/src/libide/gui/gtk/menus.ui
+++ b/src/libide/gui/gtk/menus.ui
@@ -120,42 +120,11 @@
<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">
<item>
<attribute name="id">default-run-handler</attribute>
- <attribute name="action">run-manager.handler</attribute>
- <attribute name="target" type='s'>'run'</attribute>
+ <attribute name="action">run-manager.run-with-handler</attribute>
+ <attribute name="target" type="s">'run'</attribute>
<attribute name="label" translatable="yes">Run</attribute>
<attribute name="verb-icon-name">builder-run-start-symbolic</attribute>
</item>
diff --git a/src/libide/gui/ide-run-button.c b/src/libide/gui/ide-run-button.c
index 799bd28bf..be466a1c9 100644
--- a/src/libide/gui/ide-run-button.c
+++ b/src/libide/gui/ide-run-button.c
@@ -25,6 +25,9 @@
#include <glib/gi18n.h>
#include <libide-foundry.h>
+#include <libide-gtk.h>
+
+#include "ide-device-private.h"
#include "ide-application.h"
#include "ide-gui-global.h"
@@ -36,6 +39,7 @@ struct _IdeRunButton
GtkWidget parent_instance;
AdwSplitButton *split_button;
char *run_handler_icon_name;
+ IdeJoinedMenu *joined_menu;
};
G_DEFINE_FINAL_TYPE (IdeRunButton, ide_run_button, GTK_TYPE_WIDGET)
@@ -98,11 +102,19 @@ static void
ide_run_button_load (IdeRunButton *self,
IdeContext *context)
{
+ IdeDeviceManager *device_manager;
IdeRunManager *run_manager;
+ GMenu *menu;
+
+ IDE_ENTRY;
g_assert (IDE_IS_RUN_BUTTON (self));
g_assert (IDE_IS_CONTEXT (context));
+ if (!ide_context_has_project (context))
+ IDE_EXIT;
+
+ device_manager = ide_device_manager_from_context (context);
run_manager = ide_run_manager_from_context (context);
g_signal_connect_object (run_manager,
@@ -117,7 +129,13 @@ ide_run_button_load (IdeRunButton *self,
self,
G_CONNECT_SWAPPED);
+ /* Add devices section */
+ menu = _ide_device_manager_get_menu (device_manager);
+ ide_joined_menu_prepend_menu (self->joined_menu, G_MENU_MODEL (menu));
+
ide_run_button_handler_set (self, NULL, run_manager);
+
+ IDE_EXIT;
}
static void
@@ -208,6 +226,7 @@ ide_run_button_dispose (GObject *object)
IdeRunButton *self = (IdeRunButton *)object;
g_clear_pointer ((GtkWidget **)&self->split_button, gtk_widget_unparent);
+ g_clear_object (&self->joined_menu);
G_OBJECT_CLASS (ide_run_button_parent_class)->dispose (object);
}
@@ -232,8 +251,13 @@ ide_run_button_init (IdeRunButton *self)
gtk_widget_init_template (GTK_WIDGET (self));
+ self->joined_menu = ide_joined_menu_new ();
+
menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "run-menu");
- adw_split_button_set_menu_model (self->split_button, G_MENU_MODEL (menu));
+ ide_joined_menu_append_menu (self->joined_menu, G_MENU_MODEL (menu));
+
+ adw_split_button_set_menu_model (self->split_button,
+ G_MENU_MODEL (self->joined_menu));
g_signal_connect_object (self->split_button,
"query-tooltip",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]