[gnome-builder/wip/gtk4-port] plugins/testui: show output panel and connect to PTY
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] plugins/testui: show output panel and connect to PTY
- Date: Fri, 1 Jul 2022 01:14:34 +0000 (UTC)
commit be32ae8440ef185d572720f72c9c64b870baf401
Author: Christian Hergert <chergert redhat com>
Date: Thu Jun 30 18:14:13 2022 -0700
plugins/testui: show output panel and connect to PTY
src/plugins/testui/gbp-test-path.c | 181 ---------
src/plugins/testui/gbp-test-path.h | 37 --
src/plugins/testui/gbp-test-tree-addin.c | 449 ---------------------
src/plugins/testui/gbp-test-tree-addin.h | 31 --
...st-output-panel.c => gbp-testui-output-panel.c} | 44 +-
...st-output-panel.h => gbp-testui-output-panel.h} | 8 +-
...-output-panel.ui => gbp-testui-output-panel.ui} | 2 +-
src/plugins/testui/gbp-testui-panel.c | 25 +-
src/plugins/testui/gbp-testui-workspace-addin.c | 48 ++-
src/plugins/testui/meson.build | 2 +-
src/plugins/testui/testui.gresource.xml | 2 +-
11 files changed, 89 insertions(+), 740 deletions(-)
---
diff --git a/src/plugins/testui/gbp-test-output-panel.c b/src/plugins/testui/gbp-testui-output-panel.c
similarity index 79%
rename from src/plugins/testui/gbp-test-output-panel.c
rename to src/plugins/testui/gbp-testui-output-panel.c
index 74ea38be1..d3df50538 100644
--- a/src/plugins/testui/gbp-test-output-panel.c
+++ b/src/plugins/testui/gbp-testui-output-panel.c
@@ -1,4 +1,4 @@
-/* gbp-test-output-panel.c
+/* gbp-testui-output-panel.c
*
* Copyright 2019 Christian Hergert <chergert redhat com>
*
@@ -18,40 +18,40 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#define G_LOG_DOMAIN "gbp-test-output-panel"
+#define G_LOG_DOMAIN "gbp-testui-output-panel"
#include "config.h"
#include <glib/gi18n.h>
#include <libide-terminal.h>
-#include "gbp-test-output-panel.h"
+#include "gbp-testui-output-panel.h"
-struct _GbpTestOutputPanel
+struct _GbpTestuiOutputPanel
{
IdePane parent_instance;
IdeTerminal *terminal;
};
-G_DEFINE_FINAL_TYPE (GbpTestOutputPanel, gbp_test_output_panel, IDE_TYPE_PANE)
+G_DEFINE_FINAL_TYPE (GbpTestuiOutputPanel, gbp_testui_output_panel, IDE_TYPE_PANE)
static void
-gbp_test_output_panel_class_init (GbpTestOutputPanelClass *klass)
+gbp_testui_output_panel_class_init (GbpTestuiOutputPanelClass *klass)
{
GtkWidgetClass *widget_class = (GtkWidgetClass*)klass;
- gtk_widget_class_set_template_from_resource (widget_class, "/plugins/testui/gbp-test-output-panel.ui");
- gtk_widget_class_bind_template_child (widget_class, GbpTestOutputPanel, terminal);
+ gtk_widget_class_set_template_from_resource (widget_class, "/plugins/testui/gbp-testui-output-panel.ui");
+ gtk_widget_class_bind_template_child (widget_class, GbpTestuiOutputPanel, terminal);
}
static void
-gbp_test_output_panel_save_in_file_cb (GbpTestOutputPanel *self,
+gbp_testui_output_panel_save_in_file_cb (GbpTestuiOutputPanel *self,
int res,
GtkFileChooserNative *native)
{
IDE_ENTRY;
- g_assert (GBP_IS_TEST_OUTPUT_PANEL (self));
+ g_assert (GBP_IS_TESTUI_OUTPUT_PANEL (self));
g_assert (GTK_IS_FILE_CHOOSER_NATIVE (native));
if (res == GTK_RESPONSE_ACCEPT)
@@ -97,14 +97,14 @@ gbp_testui_output_panel_save_in_file (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
- GbpTestOutputPanel *self = user_data;
+ GbpTestuiOutputPanel *self = user_data;
g_autoptr(GtkFileChooserNative) native = NULL;
GtkWidget *window;
IDE_ENTRY;
g_assert (G_IS_SIMPLE_ACTION (action));
- g_assert (GBP_IS_TEST_OUTPUT_PANEL (self));
+ g_assert (GBP_IS_TESTUI_OUTPUT_PANEL (self));
window = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW);
native = gtk_file_chooser_native_new (_("Save File"),
@@ -115,7 +115,7 @@ gbp_testui_output_panel_save_in_file (GSimpleAction *action,
g_signal_connect_object (native,
"response",
- G_CALLBACK (gbp_test_output_panel_save_in_file_cb),
+ G_CALLBACK (gbp_testui_output_panel_save_in_file_cb),
self,
G_CONNECT_SWAPPED);
@@ -130,16 +130,16 @@ gbp_testui_output_panel_clear_activate (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
- GbpTestOutputPanel *self = user_data;
+ GbpTestuiOutputPanel *self = user_data;
- g_assert (GBP_IS_TEST_OUTPUT_PANEL (self));
+ g_assert (GBP_IS_TESTUI_OUTPUT_PANEL (self));
g_assert (G_IS_SIMPLE_ACTION (action));
vte_terminal_reset (VTE_TERMINAL (self->terminal), TRUE, TRUE);
}
static void
-gbp_test_output_panel_init (GbpTestOutputPanel *self)
+gbp_testui_output_panel_init (GbpTestuiOutputPanel *self)
{
static const GActionEntry entries[] = {
{ "clear", gbp_testui_output_panel_clear_activate },
@@ -154,18 +154,18 @@ gbp_test_output_panel_init (GbpTestOutputPanel *self)
actions = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), self);
- gtk_widget_insert_action_group (GTK_WIDGET (self), "test-output", G_ACTION_GROUP (actions));
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "testui-output", G_ACTION_GROUP (actions));
}
-GtkWidget *
-gbp_test_output_panel_new (VtePty *pty)
+GbpTestuiOutputPanel *
+gbp_testui_output_panel_new (VtePty *pty)
{
- GbpTestOutputPanel *self;
+ GbpTestuiOutputPanel *self;
g_return_val_if_fail (VTE_IS_PTY (pty), NULL);
- self = g_object_new (GBP_TYPE_TEST_OUTPUT_PANEL, NULL);
+ self = g_object_new (GBP_TYPE_TESTUI_OUTPUT_PANEL, NULL);
vte_terminal_set_pty (VTE_TERMINAL (self->terminal), pty);
- return GTK_WIDGET (self);
+ return self;
}
diff --git a/src/plugins/testui/gbp-test-output-panel.h b/src/plugins/testui/gbp-testui-output-panel.h
similarity index 75%
rename from src/plugins/testui/gbp-test-output-panel.h
rename to src/plugins/testui/gbp-testui-output-panel.h
index 873238308..aaa9d719e 100644
--- a/src/plugins/testui/gbp-test-output-panel.h
+++ b/src/plugins/testui/gbp-testui-output-panel.h
@@ -1,4 +1,4 @@
-/* gbp-test-output-panel.h
+/* gbp-testui-output-panel.h
*
* Copyright 2019 Christian Hergert <chergert redhat com>
*
@@ -26,10 +26,10 @@
G_BEGIN_DECLS
-#define GBP_TYPE_TEST_OUTPUT_PANEL (gbp_test_output_panel_get_type())
+#define GBP_TYPE_TESTUI_OUTPUT_PANEL (gbp_testui_output_panel_get_type())
-G_DECLARE_FINAL_TYPE (GbpTestOutputPanel, gbp_test_output_panel, GBP, TEST_OUTPUT_PANEL, IdePane)
+G_DECLARE_FINAL_TYPE (GbpTestuiOutputPanel, gbp_testui_output_panel, GBP, TESTUI_OUTPUT_PANEL, IdePane)
-GtkWidget *gbp_test_output_panel_new (VtePty *pty);
+GbpTestuiOutputPanel *gbp_testui_output_panel_new (VtePty *pty);
G_END_DECLS
diff --git a/src/plugins/testui/gbp-test-output-panel.ui b/src/plugins/testui/gbp-testui-output-panel.ui
similarity index 97%
rename from src/plugins/testui/gbp-test-output-panel.ui
rename to src/plugins/testui/gbp-testui-output-panel.ui
index d489c1f15..026a674ce 100644
--- a/src/plugins/testui/gbp-test-output-panel.ui
+++ b/src/plugins/testui/gbp-testui-output-panel.ui
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="GbpTestOutputPanel" parent="IdePane">
+ <template class="GbpTestuiOutputPanel" parent="IdePane">
<property name="hexpand">true</property>
<property name="vexpand">true</property>
<child>
diff --git a/src/plugins/testui/gbp-testui-panel.c b/src/plugins/testui/gbp-testui-panel.c
index ef6c3a819..12387be78 100644
--- a/src/plugins/testui/gbp-testui-panel.c
+++ b/src/plugins/testui/gbp-testui-panel.c
@@ -44,7 +44,13 @@ enum {
N_PROPS
};
+enum {
+ TEST_ACTIVATED,
+ N_SIGNALS
+};
+
static GParamSpec *properties[N_PROPS];
+static guint signals[N_SIGNALS];
static void
gbp_testui_panel_activate_cb (GbpTestuiPanel *self,
@@ -53,8 +59,6 @@ gbp_testui_panel_activate_cb (GbpTestuiPanel *self,
{
GtkSelectionModel *model;
g_autoptr(IdeTest) test = NULL;
- IdeTestManager *test_manager;
- IdeContext *context;
IDE_ENTRY;
@@ -65,13 +69,7 @@ gbp_testui_panel_activate_cb (GbpTestuiPanel *self,
model = gtk_list_view_get_model (list_view);
test = g_list_model_get_item (G_LIST_MODEL (model), position);
- g_assert (IDE_IS_TEST (test));
-
- g_debug ("Activating test \"%s\"", ide_test_get_id (test));
-
- context = ide_widget_get_context (GTK_WIDGET (self));
- test_manager = ide_test_manager_from_context (context);
- ide_test_manager_run_async (test_manager, test, NULL, NULL, NULL);
+ g_signal_emit (self, signals[TEST_ACTIVATED], 0, test);
IDE_EXIT;
}
@@ -156,6 +154,15 @@ gbp_testui_panel_class_init (GbpTestuiPanelClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
+ signals[TEST_ACTIVATED] =
+ g_signal_new ("test-activated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 1, IDE_TYPE_TEST);
+
gtk_widget_class_set_template_from_resource (widget_class, "/plugins/testui/gbp-testui-panel.ui");
gtk_widget_class_bind_template_child (widget_class, GbpTestuiPanel, list_view);
gtk_widget_class_bind_template_child (widget_class, GbpTestuiPanel, selection);
diff --git a/src/plugins/testui/gbp-testui-workspace-addin.c b/src/plugins/testui/gbp-testui-workspace-addin.c
index d2308b553..f87e82766 100644
--- a/src/plugins/testui/gbp-testui-workspace-addin.c
+++ b/src/plugins/testui/gbp-testui-workspace-addin.c
@@ -25,24 +25,52 @@
#include <libide-foundry.h>
#include <libide-gui.h>
+#include "gbp-testui-output-panel.h"
#include "gbp-testui-panel.h"
#include "gbp-testui-workspace-addin.h"
struct _GbpTestuiWorkspaceAddin
{
- GObject parent_instance;
- IdeWorkspace *workspace;
- GbpTestuiPanel *panel;
+ GObject parent_instance;
+ IdeWorkspace *workspace;
+ GbpTestuiPanel *panel;
+ GbpTestuiOutputPanel *output_panel;
};
+static void
+on_test_activated_cb (GbpTestuiWorkspaceAddin *self,
+ IdeTest *test,
+ GbpTestuiPanel *panel)
+{
+ IdeTestManager *test_manager;
+ IdeContext *context;
+
+ IDE_ENTRY;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_TESTUI_WORKSPACE_ADDIN (self));
+ g_assert (IDE_IS_TEST (test));
+ g_assert (GBP_IS_TESTUI_PANEL (panel));
+
+ context = ide_workspace_get_context (self->workspace);
+ test_manager = ide_test_manager_from_context (context);
+ ide_test_manager_run_async (test_manager, test, NULL, NULL, NULL);
+
+ panel_widget_raise (PANEL_WIDGET (self->output_panel));
+
+ IDE_EXIT;
+}
+
static void
gbp_testui_workspace_addin_load (IdeWorkspaceAddin *addin,
IdeWorkspace *workspace)
{
GbpTestuiWorkspaceAddin *self = (GbpTestuiWorkspaceAddin *)addin;
g_autoptr(IdePanelPosition) position = NULL;
+ g_autoptr(IdePanelPosition) output_position = NULL;
IdeTestManager *test_manager;
IdeContext *context;
+ VtePty *pty;
IDE_ENTRY;
@@ -54,15 +82,26 @@ gbp_testui_workspace_addin_load (IdeWorkspaceAddin *addin,
context = ide_workspace_get_context (workspace);
test_manager = ide_test_manager_from_context (context);
+ pty = ide_test_manager_get_pty (test_manager);
+
self->panel = gbp_testui_panel_new ();
g_object_bind_property (test_manager, "model",
self->panel, "model",
G_BINDING_SYNC_CREATE);
-
+ g_signal_connect_object (self->panel,
+ "test-activated",
+ G_CALLBACK (on_test_activated_cb),
+ self,
+ G_CONNECT_SWAPPED);
position = ide_panel_position_new ();
ide_panel_position_set_edge (position, PANEL_DOCK_POSITION_END);
ide_workspace_add_pane (workspace, IDE_PANE (self->panel), position);
+ self->output_panel = gbp_testui_output_panel_new (pty);
+ output_position = ide_panel_position_new ();
+ ide_panel_position_set_edge (output_position, PANEL_DOCK_POSITION_BOTTOM);
+ ide_workspace_add_pane (workspace, IDE_PANE (self->output_panel), output_position);
+
IDE_EXIT;
}
@@ -79,6 +118,7 @@ gbp_testui_workspace_addin_unload (IdeWorkspaceAddin *addin,
g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace));
g_clear_pointer ((IdePane **)&self->panel, ide_pane_destroy);
+ g_clear_pointer ((IdePane **)&self->output_panel, ide_pane_destroy);
self->workspace = NULL;
diff --git a/src/plugins/testui/meson.build b/src/plugins/testui/meson.build
index 86df86f39..ee9e95f6a 100644
--- a/src/plugins/testui/meson.build
+++ b/src/plugins/testui/meson.build
@@ -1,6 +1,6 @@
plugins_sources += files([
'testui-plugin.c',
- 'gbp-test-output-panel.c',
+ 'gbp-testui-output-panel.c',
'gbp-testui-workspace-addin.c',
'gbp-testui-panel.c',
])
diff --git a/src/plugins/testui/testui.gresource.xml b/src/plugins/testui/testui.gresource.xml
index 38f7d500a..7b793ce55 100644
--- a/src/plugins/testui/testui.gresource.xml
+++ b/src/plugins/testui/testui.gresource.xml
@@ -2,7 +2,7 @@
<gresources>
<gresource prefix="/plugins/testui">
<file>testui.plugin</file>
- <file preprocess="xml-stripblanks">gbp-test-output-panel.ui</file>
+ <file preprocess="xml-stripblanks">gbp-testui-output-panel.ui</file>
<file preprocess="xml-stripblanks">gbp-testui-panel.ui</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]