[gnome-builder/wip/gtk4-port] plugins/testui: stub out panel for unit tests



commit d750b88bb0e3f0251e3027b426d7148d62b6932a
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 29 11:05:14 2022 -0700

    plugins/testui: stub out panel for unit tests

 src/plugins/testui/gbp-testui-panel.c           | 75 +++++++++++++++++++
 src/plugins/testui/gbp-testui-panel.h           | 33 +++++++++
 src/plugins/testui/gbp-testui-panel.ui          | 70 ++++++++++++++++++
 src/plugins/testui/gbp-testui-workspace-addin.c | 98 +++++++++++++++++++++++++
 src/plugins/testui/gbp-testui-workspace-addin.h | 31 ++++++++
 src/plugins/testui/meson.build                  |  4 +-
 src/plugins/testui/testui-plugin.c              |  9 ++-
 src/plugins/testui/testui.gresource.xml         |  1 +
 src/plugins/testui/testui.plugin                |  6 +-
 9 files changed, 318 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/testui/gbp-testui-panel.c b/src/plugins/testui/gbp-testui-panel.c
new file mode 100644
index 000000000..7bffb2178
--- /dev/null
+++ b/src/plugins/testui/gbp-testui-panel.c
@@ -0,0 +1,75 @@
+/* gbp-testui-panel.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-testui-panel"
+
+#include "config.h"
+
+#include "gbp-testui-panel.h"
+
+struct _GbpTestuiPanel
+{
+  IdePane parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpTestuiPanel, gbp_testui_panel, IDE_TYPE_PANE)
+
+static void
+gbp_testui_panel_activate_cb (GbpTestuiPanel *self,
+                              guint           position,
+                              GtkListView    *list_view)
+{
+  GtkSelectionModel *model;
+  g_autoptr(IdeTest) test = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_TESTUI_PANEL (self));
+  g_assert (GTK_IS_LIST_VIEW (list_view));
+
+  model = gtk_list_view_get_model (list_view);
+  test = g_list_model_get_item (G_LIST_MODEL (model), position);
+
+  g_debug ("Activating test \"%s\"", ide_test_get_title (test));
+
+  IDE_EXIT;
+}
+
+static void
+gbp_testui_panel_class_init (GbpTestuiPanelClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, "/plugins/testui/gbp-testui-panel.ui");
+  gtk_widget_class_bind_template_callback (widget_class, gbp_testui_panel_activate_cb);
+}
+
+static void
+gbp_testui_panel_init (GbpTestuiPanel *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+GbpTestuiPanel *
+gbp_testui_panel_new (void)
+{
+  return g_object_new (GBP_TYPE_TESTUI_PANEL, NULL);
+}
diff --git a/src/plugins/testui/gbp-testui-panel.h b/src/plugins/testui/gbp-testui-panel.h
new file mode 100644
index 000000000..fe5391060
--- /dev/null
+++ b/src/plugins/testui/gbp-testui-panel.h
@@ -0,0 +1,33 @@
+/* gbp-testui-panel.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-gui.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_TESTUI_PANEL (gbp_testui_panel_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpTestuiPanel, gbp_testui_panel, GBP, TESTUI_PANEL, IdePane)
+
+GbpTestuiPanel *gbp_testui_panel_new (void);
+
+G_END_DECLS
diff --git a/src/plugins/testui/gbp-testui-panel.ui b/src/plugins/testui/gbp-testui-panel.ui
new file mode 100644
index 000000000..996901425
--- /dev/null
+++ b/src/plugins/testui/gbp-testui-panel.ui
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GbpTestuiPanel" parent="IdePane">
+    <property name="title" translatable="yes">Unit Tests</property>
+    <property name="icon-name">builder-unit-tests-symbolic</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="vexpand">true</property>
+        <child>
+          <object class="GtkListView" id="list_view">
+            <signal name="activate" handler="gbp_testui_panel_activate_cb" swapped="true" 
object="GbpTestuiPanel"/>
+            <property name="orientation">vertical</property>
+            <property name="single-click-activate">true</property>
+            <property name="model">
+              <object class="GtkNoSelection" id="selection">
+              </object>
+            </property>
+            <property name="factory">
+              <object class="GtkBuilderListItemFactory">
+                <property name="bytes"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GtkListItem">
+    <property name="child">
+      <object class="GtkTreeExpander" id="expander">
+        <binding name="list-row">
+          <lookup name="item">GtkListItem</lookup>
+        </binding>
+        <property name="child">
+          <object class="GtkBox">
+            <property name="spacing">6</property>
+            <property name="margin-top">3</property>
+            <property name="margin-bottom">3</property>
+            <property name="margin-start">3</property>
+            <property name="margin-end">3</property>
+            <child>
+              <object class="GtkImage">
+                <binding name="icon-name">
+                  <lookup name="icon-name" type="IdeTest">
+                    <lookup name="item">expander</lookup>
+                  </lookup>
+                </binding>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="halign">start</property>
+                <binding name="label">
+                  <lookup name="title" type="IdeTest">
+                    <lookup name="item">expander</lookup>
+                  </lookup>
+                </binding>
+              </object>
+            </child>
+          </object>
+        </property>
+      </object>
+    </property>
+  </template>
+</interface>
+]]>
+                </property>
+              </object>
+            </property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/plugins/testui/gbp-testui-workspace-addin.c b/src/plugins/testui/gbp-testui-workspace-addin.c
new file mode 100644
index 000000000..2741d5ee2
--- /dev/null
+++ b/src/plugins/testui/gbp-testui-workspace-addin.c
@@ -0,0 +1,98 @@
+/* gbp-testui-workspace-addin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-testui-workspace-addin"
+
+#include "config.h"
+
+#include <libide-foundry.h>
+#include <libide-gui.h>
+
+#include "gbp-testui-panel.h"
+#include "gbp-testui-workspace-addin.h"
+
+struct _GbpTestuiWorkspaceAddin
+{
+  GObject         parent_instance;
+  IdeWorkspace   *workspace;
+  GbpTestuiPanel *panel;
+};
+
+static void
+gbp_testui_workspace_addin_load (IdeWorkspaceAddin *addin,
+                                 IdeWorkspace      *workspace)
+{
+  GbpTestuiWorkspaceAddin *self = (GbpTestuiWorkspaceAddin *)addin;
+  g_autoptr(IdePanelPosition) position = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_TESTUI_WORKSPACE_ADDIN (self));
+  g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace));
+
+  self->workspace = workspace;
+
+  self->panel = gbp_testui_panel_new ();
+  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);
+
+  IDE_EXIT;
+}
+
+static void
+gbp_testui_workspace_addin_unload (IdeWorkspaceAddin *addin,
+                                   IdeWorkspace      *workspace)
+{
+  GbpTestuiWorkspaceAddin *self = (GbpTestuiWorkspaceAddin *)addin;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_TESTUI_WORKSPACE_ADDIN (self));
+  g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace));
+
+  g_clear_pointer ((IdePane **)&self->panel, ide_pane_destroy);
+
+  self->workspace = NULL;
+
+  IDE_EXIT;
+}
+
+static void
+workspace_addin_iface_init (IdeWorkspaceAddinInterface *iface)
+{
+  iface->load = gbp_testui_workspace_addin_load;
+  iface->unload = gbp_testui_workspace_addin_unload;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpTestuiWorkspaceAddin, gbp_testui_workspace_addin, G_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKSPACE_ADDIN, workspace_addin_iface_init))
+
+static void
+gbp_testui_workspace_addin_class_init (GbpTestuiWorkspaceAddinClass *klass)
+{
+}
+
+static void
+gbp_testui_workspace_addin_init (GbpTestuiWorkspaceAddin *self)
+{
+}
diff --git a/src/plugins/testui/gbp-testui-workspace-addin.h b/src/plugins/testui/gbp-testui-workspace-addin.h
new file mode 100644
index 000000000..8786331dc
--- /dev/null
+++ b/src/plugins/testui/gbp-testui-workspace-addin.h
@@ -0,0 +1,31 @@
+/* gbp-testui-workspace-addin.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_TESTUI_WORKSPACE_ADDIN (gbp_testui_workspace_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpTestuiWorkspaceAddin, gbp_testui_workspace_addin, GBP, TESTUI_WORKSPACE_ADDIN, 
GObject)
+
+G_END_DECLS
diff --git a/src/plugins/testui/meson.build b/src/plugins/testui/meson.build
index 3778eb403..86df86f39 100644
--- a/src/plugins/testui/meson.build
+++ b/src/plugins/testui/meson.build
@@ -1,8 +1,8 @@
 plugins_sources += files([
   'testui-plugin.c',
-  'gbp-test-path.c',
   'gbp-test-output-panel.c',
-  'gbp-test-tree-addin.c',
+  'gbp-testui-workspace-addin.c',
+  'gbp-testui-panel.c',
 ])
 
 plugin_testui_resources = gnome.compile_resources(
diff --git a/src/plugins/testui/testui-plugin.c b/src/plugins/testui/testui-plugin.c
index 4b8199fab..3271126a5 100644
--- a/src/plugins/testui/testui-plugin.c
+++ b/src/plugins/testui/testui-plugin.c
@@ -22,15 +22,16 @@
 
 #include "config.h"
 
-#include <libide-tree.h>
 #include <libpeas/peas.h>
 
-#include "gbp-test-tree-addin.h"
+#include <libide-gui.h>
+
+#include "gbp-testui-workspace-addin.h"
 
 _IDE_EXTERN void
 _gbp_testui_register_types (PeasObjectModule *module)
 {
   peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_TREE_ADDIN,
-                                              GBP_TYPE_TEST_TREE_ADDIN);
+                                              IDE_TYPE_WORKSPACE_ADDIN,
+                                              GBP_TYPE_TESTUI_WORKSPACE_ADDIN);
 }
diff --git a/src/plugins/testui/testui.gresource.xml b/src/plugins/testui/testui.gresource.xml
index e26f525cc..38f7d500a 100644
--- a/src/plugins/testui/testui.gresource.xml
+++ b/src/plugins/testui/testui.gresource.xml
@@ -3,5 +3,6 @@
   <gresource prefix="/plugins/testui">
     <file>testui.plugin</file>
     <file preprocess="xml-stripblanks">gbp-test-output-panel.ui</file>
+    <file preprocess="xml-stripblanks">gbp-testui-panel.ui</file>
   </gresource>
 </gresources>
diff --git a/src/plugins/testui/testui.plugin b/src/plugins/testui/testui.plugin
index a8060cd3a..a0ae7f392 100644
--- a/src/plugins/testui/testui.plugin
+++ b/src/plugins/testui/testui.plugin
@@ -1,10 +1,10 @@
 [Plugin]
 Authors=Christian Hergert <christian hergert me>
 Builtin=true
-Copyright=Copyright © 2017-2018 Christian Hergert
-Description=Unit testing for Builder
+Copyright=Copyright © 2017-2022 Christian Hergert
+Description=Unit Testing
 Embedded=_gbp_testui_register_types
 Hidden=true
 Module=testui
 Name=Unit Testing
-X-Tree-Kind=project-tree;
+X-Workspace-Kind=primary;


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