[gnome-builder/wip/gtk4-port] plugins/testui: port to GTK 4
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] plugins/testui: port to GTK 4
- Date: Tue, 12 Apr 2022 00:51:24 +0000 (UTC)
commit fcac593647163f21e1c2303a28b4efa9d34ed3d8
Author: Christian Hergert <chergert redhat com>
Date: Mon Apr 11 17:49:07 2022 -0700
plugins/testui: port to GTK 4
src/plugins/meson.build | 2 +-
src/plugins/testui/gbp-test-output-panel.c | 60 ++++++++++++++++++++----------
src/plugins/testui/gbp-test-output-panel.h | 4 +-
src/plugins/testui/gbp-test-tree-addin.c | 30 ++++++++-------
4 files changed, 60 insertions(+), 36 deletions(-)
---
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 1472eb417..9537515c9 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -128,7 +128,7 @@ subdir('stylelint')
#subdir('sysprof')
#subdir('sysroot')
subdir('terminal')
-#subdir('testui')
+subdir('testui')
subdir('todo')
subdir('ts-language-server')
subdir('trim-spaces')
diff --git a/src/plugins/testui/gbp-test-output-panel.c b/src/plugins/testui/gbp-test-output-panel.c
index 537bf989a..74ea38be1 100644
--- a/src/plugins/testui/gbp-test-output-panel.c
+++ b/src/plugins/testui/gbp-test-output-panel.c
@@ -45,28 +45,14 @@ gbp_test_output_panel_class_init (GbpTestOutputPanelClass *klass)
}
static void
-gbp_testui_output_panel_save_in_file (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
+gbp_test_output_panel_save_in_file_cb (GbpTestOutputPanel *self,
+ int res,
+ GtkFileChooserNative *native)
{
- GbpTestOutputPanel *self = user_data;
- g_autoptr(GtkFileChooserNative) native = NULL;
- GtkWidget *window;
- gint res;
-
IDE_ENTRY;
- g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (GBP_IS_TEST_OUTPUT_PANEL (self));
-
- window = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW);
- native = gtk_file_chooser_native_new (_("Save File"),
- GTK_WINDOW (window),
- GTK_FILE_CHOOSER_ACTION_SAVE,
- _("_Save"),
- _("_Cancel"));
-
- res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
+ g_assert (GTK_IS_FILE_CHOOSER_NATIVE (native));
if (res == GTK_RESPONSE_ACCEPT)
{
@@ -101,6 +87,40 @@ gbp_testui_output_panel_save_in_file (GSimpleAction *action,
}
}
+ gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
+
+ IDE_EXIT;
+}
+
+static void
+gbp_testui_output_panel_save_in_file (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpTestOutputPanel *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));
+
+ window = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW);
+ native = gtk_file_chooser_native_new (_("Save File"),
+ GTK_WINDOW (window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ _("_Save"),
+ _("_Cancel"));
+
+ g_signal_connect_object (native,
+ "response",
+ G_CALLBACK (gbp_test_output_panel_save_in_file_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
+ gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
+
IDE_EXIT;
}
@@ -129,8 +149,8 @@ gbp_test_output_panel_init (GbpTestOutputPanel *self)
gtk_widget_init_template (GTK_WIDGET(self));
- dzl_dock_widget_set_title (DZL_DOCK_WIDGET (self), _("Unit Test Output"));
- dzl_dock_widget_set_icon_name (DZL_DOCK_WIDGET (self), "builder-unit-tests-symbolic");
+ panel_widget_set_title (PANEL_WIDGET (self), _("Unit Test Output"));
+ panel_widget_set_icon_name (PANEL_WIDGET (self), "builder-unit-tests-symbolic");
actions = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), self);
diff --git a/src/plugins/testui/gbp-test-output-panel.h b/src/plugins/testui/gbp-test-output-panel.h
index e22147bdb..873238308 100644
--- a/src/plugins/testui/gbp-test-output-panel.h
+++ b/src/plugins/testui/gbp-test-output-panel.h
@@ -20,10 +20,10 @@
#pragma once
-#include <libide-gui.h>
-#include <dazzle.h>
#include <vte/vte.h>
+#include <libide-gui.h>
+
G_BEGIN_DECLS
#define GBP_TYPE_TEST_OUTPUT_PANEL (gbp_test_output_panel_get_type())
diff --git a/src/plugins/testui/gbp-test-tree-addin.c b/src/plugins/testui/gbp-test-tree-addin.c
index 646a9489b..96a76a2d1 100644
--- a/src/plugins/testui/gbp-test-tree-addin.c
+++ b/src/plugins/testui/gbp-test-tree-addin.c
@@ -23,6 +23,7 @@
#include "config.h"
#include <glib/gi18n.h>
+
#include <libide-editor.h>
#include <libide-foundry.h>
#include <libide-gui.h>
@@ -75,22 +76,22 @@ show_test_panel (GbpTestTreeAddin *self)
if (self->panel == NULL)
{
- GtkWidget *surface;
- GtkWidget *utils;
+ g_autoptr(IdePanelPosition) position = NULL;
+ IdeWorkspace *workspace;
VtePty *pty;
pty = ide_test_manager_get_pty (test_manager);
+
self->panel = GBP_TEST_OUTPUT_PANEL (gbp_test_output_panel_new (pty));
- g_signal_connect (self->panel,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &self->panel);
- surface = gtk_widget_get_ancestor (GTK_WIDGET (self->tree), IDE_TYPE_EDITOR_SURFACE);
- utils = ide_editor_surface_get_utilities (IDE_EDITOR_SURFACE (surface));
- gtk_container_add (GTK_CONTAINER (utils), GTK_WIDGET (self->panel));
- gtk_widget_show (GTK_WIDGET (self->panel));
- dzl_dock_item_present (DZL_DOCK_ITEM (self->panel));
+ g_object_ref_sink (self->panel);
+
+ workspace = ide_widget_get_workspace (GTK_WIDGET (self->tree));
+ position = ide_panel_position_new ();
+ ide_panel_position_set_edge (position, PANEL_DOCK_POSITION_BOTTOM);
+ ide_workspace_add_pane (workspace, IDE_PANE (self->panel), position);
}
+
+ panel_widget_raise (PANEL_WIDGET (self->panel));
}
static void
@@ -320,8 +321,11 @@ gbp_test_tree_addin_unload (IdeTreeAddin *addin,
self->tree = NULL;
self->model = NULL;
- if (self->panel != NULL)
- gtk_widget_destroy (GTK_WIDGET (self->panel));
+ if (self->panel)
+ {
+ panel_widget_close (PANEL_WIDGET (self->panel));
+ g_clear_object (&self->panel);
+ }
context = ide_object_get_context (IDE_OBJECT (model));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]