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 000000000..9e3749241 --- /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-toplevel-sidebar-widget.desktop.in b/tests/interactive-panels/applications/gtp-toplevel-sidebar-widget.desktop.in new file mode 100644 index 000000000..a6d4aa8b3 --- /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 index c688d5514..2657f9588 100644 --- a/tests/interactive-panels/applications/meson.build +++ b/tests/interactive-panels/applications/meson.build @@ -5,7 +5,9 @@ desktop_files = [ 'dynamic-panel', 'header-widget', + 'sidebar-widget', 'static-init', + 'toplevel-sidebar-widget', ] foreach desktop_file : desktop_files diff --git a/tests/interactive-panels/gtp-sidebar-widget.c b/tests/interactive-panels/gtp-sidebar-widget.c new file mode 100644 index 000000000..139572424 --- /dev/null +++ b/tests/interactive-panels/gtp-sidebar-widget.c @@ -0,0 +1,56 @@ +/* gtp-sidebar-widget.c + * + * Copyright 2018 Georges Basile Stavracas Neto + * + * 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 . + * + * 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 000000000..3bf8dfee9 --- /dev/null +++ b/tests/interactive-panels/gtp-sidebar-widget.h @@ -0,0 +1,30 @@ +/* gtp-sidebar-widget.h + * + * Copyright 2018 Georges Basile Stavracas Neto + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include + +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 000000000..ad91c725c --- /dev/null +++ b/tests/interactive-panels/gtp-sidebar-widget.ui @@ -0,0 +1,47 @@ + + + + + + + True + I'm a sidebar widget + + + diff --git a/tests/interactive-panels/main.c b/tests/interactive-panels/main.c index 13e43cb3c..0b0faaad2 100644 --- a/tests/interactive-panels/main.c +++ b/tests/interactive-panels/main.c @@ -31,13 +31,16 @@ #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 }, - { "static-init", gtp_static_init_get_type, gtp_static_init_func }, + { "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 diff --git a/tests/interactive-panels/meson.build b/tests/interactive-panels/meson.build index 6c0f15166..04856ee7d 100644 --- a/tests/interactive-panels/meson.build +++ b/tests/interactive-panels/meson.build @@ -7,6 +7,7 @@ subdir('applications') sources = files( 'gtp-dynamic-panel.c', 'gtp-header-widget.c', + 'gtp-sidebar-widget.c', 'gtp-static-init.c', 'main.c', ) @@ -19,6 +20,7 @@ sources = files( resource_data = files( 'gtp-dynamic-panel.ui', 'gtp-header-widget.ui', + 'gtp-sidebar-widget.ui', 'gtp-static-init.ui', ) diff --git a/tests/interactive-panels/panels.gresource.xml b/tests/interactive-panels/panels.gresource.xml index 5a3cfe613..9fc6605c8 100644 --- a/tests/interactive-panels/panels.gresource.xml +++ b/tests/interactive-panels/panels.gresource.xml @@ -3,6 +3,7 @@ gtp-dynamic-panel.ui gtp-header-widget.ui + gtp-sidebar-widget.ui gtp-static-init.ui