[gnome-control-center/gbsneto/interactive-test-panels: 34/34] Introduce interactive test for panels



commit 21da5e1dbb7774f449a2d1ff36900de73c2b0782
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Nov 9 01:09:40 2018 -0200

    Introduce interactive test for panels
    
    The purpose of this interactive test is to be able to
    prototype new features for CcPanel without having to
    adapt existing panels.
    
    Three test panels were added as part of this initial
    patch:
    
     * Dynamic panels: panel exercising the ability to
       show and hide itself at runtime.
     * Header: panel that embeds a header widget.
     * Static Initializer: panel that sets a static init
       function to run at startup.

 .../applications/gtp-dynamic-panel.desktop.in      | 11 +++
 .../applications/gtp-header-widget.desktop.in      | 11 +++
 .../applications/gtp-static-init.desktop.in        | 11 +++
 tests/interactive-panels/applications/meson.build  | 20 +++++
 tests/interactive-panels/gtp-dynamic-panel.c       | 85 ++++++++++++++++++++++
 tests/interactive-panels/gtp-dynamic-panel.h       | 30 ++++++++
 tests/interactive-panels/gtp-dynamic-panel.ui      | 76 +++++++++++++++++++
 tests/interactive-panels/gtp-header-widget.c       | 61 ++++++++++++++++
 tests/interactive-panels/gtp-header-widget.h       | 30 ++++++++
 tests/interactive-panels/gtp-header-widget.ui      | 47 ++++++++++++
 tests/interactive-panels/gtp-static-init.c         | 49 +++++++++++++
 tests/interactive-panels/gtp-static-init.h         | 32 ++++++++
 tests/interactive-panels/gtp-static-init.ui        | 42 +++++++++++
 tests/interactive-panels/main.c                    | 70 ++++++++++++++++++
 tests/interactive-panels/meson.build               | 47 ++++++++++++
 tests/interactive-panels/panels.gresource.xml      |  9 +++
 tests/meson.build                                  |  3 +
 17 files changed, 634 insertions(+)
---
diff --git a/tests/interactive-panels/applications/gtp-dynamic-panel.desktop.in 
b/tests/interactive-panels/applications/gtp-dynamic-panel.desktop.in
new file mode 100644
index 000000000..8a550ba0e
--- /dev/null
+++ b/tests/interactive-panels/applications/gtp-dynamic-panel.desktop.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Dynamic Panel
+Comment=Panel that can be hidden from the sidebar
+Exec=gnome-control-center dynamic-panels
+Icon=weather-clear-night
+Terminal=false
+Type=Application
+NoDisplay=true
+StartupNotify=true
+Categories=GNOME;GTK;Settings;X-GNOME-Settings-Panel;X-GNOME-ConnectivitySettings;
+OnlyShowIn=GNOME;Unity;
\ No newline at end of file
diff --git a/tests/interactive-panels/applications/gtp-header-widget.desktop.in 
b/tests/interactive-panels/applications/gtp-header-widget.desktop.in
new file mode 100644
index 000000000..4ffbf20d6
--- /dev/null
+++ b/tests/interactive-panels/applications/gtp-header-widget.desktop.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Header
+Comment=Panel that embeds a widget at the header bar
+Exec=gnome-control-center thunderbolt
+Icon=view-sort-descending
+Terminal=false
+Type=Application
+NoDisplay=true
+StartupNotify=true
+Categories=GNOME;GTK;Settings;X-GNOME-Settings-Panel;X-GNOME-ConnectivitySettings;
+OnlyShowIn=GNOME;Unity;
\ No newline at end of file
diff --git a/tests/interactive-panels/applications/gtp-static-init.desktop.in 
b/tests/interactive-panels/applications/gtp-static-init.desktop.in
new file mode 100644
index 000000000..e8ccdf5ac
--- /dev/null
+++ b/tests/interactive-panels/applications/gtp-static-init.desktop.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Static Initializer
+Comment=Panel with a static initializer function
+Exec=gnome-control-center static-init
+Icon=view-continuous
+Terminal=false
+Type=Application
+NoDisplay=true
+StartupNotify=true
+Categories=GNOME;GTK;Settings;X-GNOME-Settings-Panel;X-GNOME-ConnectivitySettings;
+OnlyShowIn=GNOME;Unity;
\ No newline at end of file
diff --git a/tests/interactive-panels/applications/meson.build 
b/tests/interactive-panels/applications/meson.build
new file mode 100644
index 000000000..9ef905c35
--- /dev/null
+++ b/tests/interactive-panels/applications/meson.build
@@ -0,0 +1,20 @@
+#################
+# Desktop files #
+#################
+
+desktop_files = [
+  'dynamic-panel',
+  'header-widget',
+  'static-init',
+]
+
+foreach desktop_file : desktop_files
+  i18n.merge_file(
+         desktop,
+                type : 'desktop',
+               input : 'gtp-@0  desktop in'.format(desktop_file),
+              output : 'gnome-@0@-panel.desktop'.format(desktop_file),
+              po_dir : po_dir,
+    build_by_default : true,
+  )
+endforeach
diff --git a/tests/interactive-panels/gtp-dynamic-panel.c b/tests/interactive-panels/gtp-dynamic-panel.c
new file mode 100644
index 000000000..31efa30d8
--- /dev/null
+++ b/tests/interactive-panels/gtp-dynamic-panel.c
@@ -0,0 +1,85 @@
+/* gtp-dynamic-panel.c
+ *
+ * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail 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 "gtp-dynamic-panel"
+
+#include "gtp-dynamic-panel.h"
+
+#include "shell/cc-application.h"
+#include "shell/cc-shell-model.h"
+
+struct _GtpDynamicPanel
+{
+  CcPanel parent;
+};
+
+G_DEFINE_TYPE (GtpDynamicPanel, gtp_dynamic_panel, CC_TYPE_PANEL)
+
+/* Auxiliary methods */
+
+static void
+set_visibility (CcPanelVisibility visibility)
+{
+  GApplication *application;
+  CcShellModel *model;
+
+  application = g_application_get_default ();
+  model = cc_application_get_model (CC_APPLICATION (application));
+
+  cc_shell_model_set_panel_visibility (model, "dynamic-panel", visibility);
+}
+
+/* Callbacks */
+
+static gboolean
+show_panel_cb (gpointer data)
+{
+  g_debug ("Showing panel");
+
+  set_visibility (CC_PANEL_VISIBLE);
+
+  return G_SOURCE_REMOVE;
+}
+
+static void
+on_button_clicked_cb (GtkButton       *button,
+                      GtpDynamicPanel *self)
+{
+  g_debug ("Hiding panel");
+
+  set_visibility (CC_PANEL_HIDDEN);
+  g_timeout_add_seconds (3, show_panel_cb, self);
+}
+
+static void
+gtp_dynamic_panel_class_init (GtpDynamicPanelClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/tests/panels/gtp-dynamic-panel.ui");
+
+  gtk_widget_class_bind_template_callback (widget_class, on_button_clicked_cb);
+}
+
+static void
+gtp_dynamic_panel_init (GtpDynamicPanel *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/tests/interactive-panels/gtp-dynamic-panel.h b/tests/interactive-panels/gtp-dynamic-panel.h
new file mode 100644
index 000000000..84ad5cc6c
--- /dev/null
+++ b/tests/interactive-panels/gtp-dynamic-panel.h
@@ -0,0 +1,30 @@
+/* gtp-dynamic-panel.h
+ *
+ * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail 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 <shell/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define GTP_TYPE_DYNAMIC_PANEL (gtp_dynamic_panel_get_type())
+G_DECLARE_FINAL_TYPE (GtpDynamicPanel, gtp_dynamic_panel, GTP, DYNAMIC_PANEL, CcPanel)
+
+G_END_DECLS
diff --git a/tests/interactive-panels/gtp-dynamic-panel.ui b/tests/interactive-panels/gtp-dynamic-panel.ui
new file mode 100644
index 000000000..77516cfc2
--- /dev/null
+++ b/tests/interactive-panels/gtp-dynamic-panel.ui
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.22"/>
+  <template class="GtpDynamicPanel" parent="CcPanel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="hexpand">True</property>
+            <property name="orientation">vertical</property>
+          </object>
+        </child>
+
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="valign">center</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pixel_size">96</property>
+                <property name="icon_name">weather-clear-night-symbolic</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="max-width-chars">50</property>
+                <property name="wrap">True</property>
+                <property name="label">Dynamic panels may hide if you don't have some hardware. Use the 
switch below to toggle the panel visibility:</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="label">Hide</property>
+                <signal name="clicked" handler="on_button_clicked_cb" object="GtpDynamicPanel" swapped="no" 
/>
+              </object>
+            </child>
+          </object>
+        </child>
+
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="hexpand">True</property>
+            <property name="orientation">vertical</property>
+          </object>
+        </child>
+
+      </object>
+    </child>
+  </template>
+</interface>
+
diff --git a/tests/interactive-panels/gtp-header-widget.c b/tests/interactive-panels/gtp-header-widget.c
new file mode 100644
index 000000000..e56f6478f
--- /dev/null
+++ b/tests/interactive-panels/gtp-header-widget.c
@@ -0,0 +1,61 @@
+/* gtp-header-widget.c
+ *
+ * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail 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
+ */
+
+#include "gtp-header-widget.h"
+
+struct _GtpHeaderWidget
+{
+  CcPanel    parent;
+
+  GtkWidget *header_widget;
+};
+
+G_DEFINE_TYPE (GtpHeaderWidget, gtp_header_widget, CC_TYPE_PANEL)
+
+static void
+gtp_header_widget_constructed (GObject *object)
+{
+  GtpHeaderWidget *self = (GtpHeaderWidget *)object;
+  CcShell *shell;
+
+  G_OBJECT_CLASS (gtp_header_widget_parent_class)->constructed (object);
+
+  shell = cc_panel_get_shell (CC_PANEL (self));
+  cc_shell_embed_widget_in_header (shell, self->header_widget);
+}
+
+static void
+gtp_header_widget_class_init (GtpHeaderWidgetClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->constructed = gtp_header_widget_constructed;
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/tests/panels/gtp-header-widget.ui");
+
+  gtk_widget_class_bind_template_child (widget_class, GtpHeaderWidget, header_widget);
+}
+
+static void
+gtp_header_widget_init (GtpHeaderWidget *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/tests/interactive-panels/gtp-header-widget.h b/tests/interactive-panels/gtp-header-widget.h
new file mode 100644
index 000000000..99f7ce094
--- /dev/null
+++ b/tests/interactive-panels/gtp-header-widget.h
@@ -0,0 +1,30 @@
+/* gtp-header-widget.h
+ *
+ * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail 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 <shell/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define GTP_TYPE_HEADER_WIDGET (gtp_header_widget_get_type())
+G_DECLARE_FINAL_TYPE (GtpHeaderWidget, gtp_header_widget, GTP, HEADER_WIDGET, CcPanel)
+
+G_END_DECLS
diff --git a/tests/interactive-panels/gtp-header-widget.ui b/tests/interactive-panels/gtp-header-widget.ui
new file mode 100644
index 000000000..551803d09
--- /dev/null
+++ b/tests/interactive-panels/gtp-header-widget.ui
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.22"/>
+  <template class="GtpHeaderWidget" parent="CcPanel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="pixel_size">96</property>
+            <property name="icon_name">go-top-symbolic</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Embedding widgets in the header bar</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+
+  <object class="GtkLabel" id="header_widget">
+    <property name="visible">True</property>
+    <property name="label" translatable="yes">I'm a header widget</property>
+  </object>
+</interface>
+
diff --git a/tests/interactive-panels/gtp-static-init.c b/tests/interactive-panels/gtp-static-init.c
new file mode 100644
index 000000000..c6b7a4fec
--- /dev/null
+++ b/tests/interactive-panels/gtp-static-init.c
@@ -0,0 +1,49 @@
+/* gtp-static-init.c
+ *
+ * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail 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
+ */
+
+#include "gtp-static-init.h"
+
+struct _GtpStaticInit
+{
+  CcPanel parent;
+};
+
+G_DEFINE_TYPE (GtpStaticInit, gtp_static_init, CC_TYPE_PANEL)
+
+void
+gtp_static_init_func (void)
+{
+  g_message ("GtpStaticInit: running outside the panel instance");
+}
+
+static void
+gtp_static_init_class_init (GtpStaticInitClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/tests/panels/gtp-static-init.ui");
+
+}
+
+static void
+gtp_static_init_init (GtpStaticInit *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/tests/interactive-panels/gtp-static-init.h b/tests/interactive-panels/gtp-static-init.h
new file mode 100644
index 000000000..1dbbea276
--- /dev/null
+++ b/tests/interactive-panels/gtp-static-init.h
@@ -0,0 +1,32 @@
+/* gtp-static-init.h
+ *
+ * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail 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 <shell/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define GTP_TYPE_STATIC_INIT (gtp_static_init_get_type())
+G_DECLARE_FINAL_TYPE (GtpStaticInit, gtp_static_init, GTP, STATIC_INIT, CcPanel)
+
+void gtp_static_init_func (void);
+
+G_END_DECLS
diff --git a/tests/interactive-panels/gtp-static-init.ui b/tests/interactive-panels/gtp-static-init.ui
new file mode 100644
index 000000000..e578179ee
--- /dev/null
+++ b/tests/interactive-panels/gtp-static-init.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.22"/>
+  <template class="GtpStaticInit" parent="CcPanel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="pixel_size">96</property>
+            <property name="icon_name">view-continuous-symbolic</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Static initializers</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
+
diff --git a/tests/interactive-panels/main.c b/tests/interactive-panels/main.c
new file mode 100644
index 000000000..7b5a5df69
--- /dev/null
+++ b/tests/interactive-panels/main.c
@@ -0,0 +1,70 @@
+/* main.c
+ *
+ * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail 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
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "shell/cc-application.h"
+#include "shell/cc-panel-loader.h"
+#include "shell/resources.h"
+#include "test-panels-resources.h"
+
+#include "gtp-dynamic-panel.h"
+#include "gtp-header-widget.h"
+#include "gtp-static-init.h"
+
+/* Test panels */
+static CcPanelLoaderVtable test_panels[] = {
+  { "dynamic-panel", gtp_dynamic_panel_get_type, NULL                 },
+  { "header-widget", gtp_header_widget_get_type, NULL                 },
+  { "static-init",   gtp_static_init_get_type,   gtp_static_init_func },
+};
+
+gint
+main (gint   argc,
+      gchar *argv[])
+{
+  const gchar *orig_data_dirs;
+  g_autoptr(GtkApplication) application = NULL;
+
+  /* Manually register GResources */
+  g_resources_register (gnome_control_center_get_resource ());
+  g_resources_register (test_panels_get_resource ());
+
+  /* Override the panels vtable with the test panels */
+  cc_panel_loader_override_vtable (test_panels, G_N_ELEMENTS (test_panels));
+
+  /* Override */
+  /*g_desktop_app_info_new_from_filename ("./gnome-dynamic-panel-panel.desktop");
+  g_desktop_app_info_new_from_filename ("./gnome-header-widget-panel.desktop");
+  g_desktop_app_info_new_from_filename ("./gnome-static-init-panel.desktop");*/
+  orig_data_dirs = g_strdup (g_getenv ("XDG_DATA_DIRS"));
+  if (orig_data_dirs)
+    g_setenv ("XDG_DATA_DIRS", g_strconcat (".", ":", orig_data_dirs, NULL), TRUE);
+  else
+    g_setenv ("XDG_DATA_DIRS", ".", TRUE);
+
+  application = cc_application_new ();
+
+  return g_application_run (G_APPLICATION (application), argc, argv);
+}
diff --git a/tests/interactive-panels/meson.build b/tests/interactive-panels/meson.build
new file mode 100644
index 000000000..6c0f15166
--- /dev/null
+++ b/tests/interactive-panels/meson.build
@@ -0,0 +1,47 @@
+subdir('applications')
+
+###########
+# Sources #
+###########
+
+sources = files(
+  'gtp-dynamic-panel.c',
+  'gtp-header-widget.c',
+  'gtp-static-init.c',
+  'main.c',
+)
+
+
+##############
+# GResources #
+##############
+
+resource_data = files(
+  'gtp-dynamic-panel.ui',
+  'gtp-header-widget.ui',
+  'gtp-static-init.ui',
+)
+
+sources += gnome.compile_resources(
+  'test-panels-resources',
+   'panels.gresource.xml',
+              source_dir : '.',
+                  c_name : 'test_panels',
+            dependencies : resource_data,
+                  export : true,
+)
+
+
+######################
+# interactive-panels #
+######################
+
+includes = [top_inc]
+
+exe = executable(
+  'test-interactive-panels',
+               sources,
+  include_directories : includes,
+         dependencies : shell_deps + [libtestshell_dep],
+               c_args : cflags
+)
diff --git a/tests/interactive-panels/panels.gresource.xml b/tests/interactive-panels/panels.gresource.xml
new file mode 100644
index 000000000..5a3cfe613
--- /dev/null
+++ b/tests/interactive-panels/panels.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/tests/panels">
+    <file preprocess="xml-stripblanks">gtp-dynamic-panel.ui</file>
+    <file preprocess="xml-stripblanks">gtp-header-widget.ui</file>
+    <file preprocess="xml-stripblanks">gtp-static-init.ui</file>
+  </gresource>
+</gresources>
+
diff --git a/tests/meson.build b/tests/meson.build
index 7c894e480..7d745d779 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -3,5 +3,8 @@ subdir('common')
 #if host_is_linux
 #  subdir('network')
 #endif
+
+subdir('interactive-panels')
+
 subdir('printers')
 subdir('info')


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