diff options
Diffstat (limited to '')
21 files changed, 802 insertions, 0 deletions
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 0000000..8a550ba --- /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 0000000..4ffbf20 --- /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-sidebar-widget.desktop.in b/tests/interactive-panels/applications/gtp-sidebar-widget.desktop.in new file mode 100644 index 0000000..9e37492 --- /dev/null +++ b/tests/interactive-panels/applications/gtp-sidebar-widget.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Another Sidebar Widget +Comment=Panel that embeds a widget at the sidebar +Exec=gnome-control-center sidebar-widget +Icon=go-first-symbolic +Terminal=false +Type=Application +NoDisplay=true +StartupNotify=true +Categories=GNOME;GTK;Settings;X-GNOME-Settings-Panel;X-GNOME-DetailsSettings; +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 0000000..e8ccdf5 --- /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/gtp-toplevel-sidebar-widget.desktop.in b/tests/interactive-panels/applications/gtp-toplevel-sidebar-widget.desktop.in new file mode 100644 index 0000000..a6d4aa8 --- /dev/null +++ b/tests/interactive-panels/applications/gtp-toplevel-sidebar-widget.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Sidebar Widget +Comment=Panel that embeds a widget at the sidebar +Exec=gnome-control-center sidebar-widget +Icon=go-first-symbolic +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 0000000..2657f95 --- /dev/null +++ b/tests/interactive-panels/applications/meson.build @@ -0,0 +1,23 @@ +################# +# Desktop files # +################# + +desktop_files = [ + 'dynamic-panel', + 'header-widget', + 'sidebar-widget', + 'static-init', + 'toplevel-sidebar-widget', +] + +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, + install : false, + ) +endforeach diff --git a/tests/interactive-panels/gtp-dynamic-panel.c b/tests/interactive-panels/gtp-dynamic-panel.c new file mode 100644 index 0000000..31efa30 --- /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 0000000..84ad5cc --- /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 0000000..77516cf --- /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 0000000..44f6d80 --- /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, GTK_POS_LEFT); +} + +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 0000000..99f7ce0 --- /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 0000000..00e3b68 --- /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">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">I'm a header widget</property> + </object> +</interface> + diff --git a/tests/interactive-panels/gtp-sidebar-widget.c b/tests/interactive-panels/gtp-sidebar-widget.c new file mode 100644 index 0000000..1395724 --- /dev/null +++ b/tests/interactive-panels/gtp-sidebar-widget.c @@ -0,0 +1,56 @@ +/* gtp-sidebar-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-sidebar-widget.h" + +struct _GtpSidebarWidget +{ + CcPanel parent; + + GtkWidget *sidebar_widget; +}; + +G_DEFINE_TYPE (GtpSidebarWidget, gtp_sidebar_widget, CC_TYPE_PANEL) + +static GtkWidget* +gtp_sidebar_widget_get_sidebar_widget (CcPanel *panel) +{ + GtpSidebarWidget *self = GTP_SIDEBAR_WIDGET (panel); + return self->sidebar_widget; +} + +static void +gtp_sidebar_widget_class_init (GtpSidebarWidgetClass *klass) +{ + CcPanelClass *panel_class = CC_PANEL_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + panel_class->get_sidebar_widget = gtp_sidebar_widget_get_sidebar_widget; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/tests/panels/gtp-sidebar-widget.ui"); + + gtk_widget_class_bind_template_child (widget_class, GtpSidebarWidget, sidebar_widget); +} + +static void +gtp_sidebar_widget_init (GtpSidebarWidget *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} diff --git a/tests/interactive-panels/gtp-sidebar-widget.h b/tests/interactive-panels/gtp-sidebar-widget.h new file mode 100644 index 0000000..3bf8dfe --- /dev/null +++ b/tests/interactive-panels/gtp-sidebar-widget.h @@ -0,0 +1,30 @@ +/* gtp-sidebar-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_SIDEBAR_WIDGET (gtp_sidebar_widget_get_type()) +G_DECLARE_FINAL_TYPE (GtpSidebarWidget, gtp_sidebar_widget, GTP, SIDEBAR_WIDGET, CcPanel) + +G_END_DECLS diff --git a/tests/interactive-panels/gtp-sidebar-widget.ui b/tests/interactive-panels/gtp-sidebar-widget.ui new file mode 100644 index 0000000..ad91c72 --- /dev/null +++ b/tests/interactive-panels/gtp-sidebar-widget.ui @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="3.22"/> + <template class="GtpSidebarWidget" 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-first-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">Embedding widgets in the sidebar</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> + </object> + </child> + </template> + + <object class="GtkLabel" id="sidebar_widget"> + <property name="visible">True</property> + <property name="label">I'm a sidebar 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 0000000..c6b7a4f --- /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 0000000..1dbbea2 --- /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 0000000..e733888 --- /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">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 0000000..0b0faaa --- /dev/null +++ b/tests/interactive-panels/main.c @@ -0,0 +1,80 @@ +/* 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-sidebar-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 }, + { "sidebar-widget", gtp_sidebar_widget_get_type, NULL }, + { "static-init", gtp_static_init_get_type, gtp_static_init_func }, + { "toplevel-sidebar-widget", gtp_sidebar_widget_get_type, NULL }, +}; + +static void +override_xdg_data_dirs (void) +{ + g_autoptr(GString) extended_xdg_data_dirs = NULL; + const gchar *xdg_data_dirs; + + extended_xdg_data_dirs = g_string_new ("."); + xdg_data_dirs = g_getenv ("XDG_DATA_DIRS"); + + if (xdg_data_dirs) + g_string_append_printf (extended_xdg_data_dirs, ":%s", xdg_data_dirs); + + g_setenv ("XDG_DATA_DIRS", extended_xdg_data_dirs->str, TRUE); +} + +gint +main (gint argc, + gchar *argv[]) +{ + 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 XDG_DATA_DIRS */ + override_xdg_data_dirs (); + + 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 0000000..04856ee --- /dev/null +++ b/tests/interactive-panels/meson.build @@ -0,0 +1,49 @@ +subdir('applications') + +########### +# Sources # +########### + +sources = files( + 'gtp-dynamic-panel.c', + 'gtp-header-widget.c', + 'gtp-sidebar-widget.c', + 'gtp-static-init.c', + 'main.c', +) + + +############## +# GResources # +############## + +resource_data = files( + 'gtp-dynamic-panel.ui', + 'gtp-header-widget.ui', + 'gtp-sidebar-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 0000000..9fc6605 --- /dev/null +++ b/tests/interactive-panels/panels.gresource.xml @@ -0,0 +1,10 @@ +<?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-sidebar-widget.ui</file> + <file preprocess="xml-stripblanks">gtp-static-init.ui</file> + </gresource> +</gresources> + |