diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-11-16 15:16:34 -0200 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-11-16 19:25:13 -0200 |
commit | 896ff73c2b0af6fc82eb5ad4634776874136971c (patch) | |
tree | 0efe9a9f3bc05fad53ccea8d24fcb9a9668ccda7 /tests | |
parent | fdf22ad255767607210465579225d30f3b7ff1ff (diff) | |
download | gnome-control-center-896ff73c2b0af6fc82eb5ad4634776874136971c.tar.gz |
tests: Add test panels for sidebar widget
Two tests for sidebar widget were added: one at the main
sidebar view, the other inside the Details category.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/interactive-panels/applications/gtp-sidebar-widget.desktop.in | 11 | ||||
-rw-r--r-- | tests/interactive-panels/applications/gtp-toplevel-sidebar-widget.desktop.in | 11 | ||||
-rw-r--r-- | tests/interactive-panels/applications/meson.build | 2 | ||||
-rw-r--r-- | tests/interactive-panels/gtp-sidebar-widget.c | 56 | ||||
-rw-r--r-- | tests/interactive-panels/gtp-sidebar-widget.h | 30 | ||||
-rw-r--r-- | tests/interactive-panels/gtp-sidebar-widget.ui | 47 | ||||
-rw-r--r-- | tests/interactive-panels/main.c | 9 | ||||
-rw-r--r-- | tests/interactive-panels/meson.build | 2 | ||||
-rw-r--r-- | tests/interactive-panels/panels.gresource.xml | 1 |
9 files changed, 166 insertions, 3 deletions
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 <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 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 <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 000000000..ad91c725c --- /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/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 @@ <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> |