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.
This commit is contained in:
Georges Basile Stavracas Neto 2018-11-16 15:16:34 -02:00
parent fdf22ad255
commit 896ff73c2b
No known key found for this signature in database
GPG key ID: 886C17EE170D1385
9 changed files with 166 additions and 3 deletions

View file

@ -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;

View file

@ -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;

View file

@ -5,7 +5,9 @@
desktop_files = [
'dynamic-panel',
'header-widget',
'sidebar-widget',
'static-init',
'toplevel-sidebar-widget',
]
foreach desktop_file : desktop_files

View file

@ -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));
}

View file

@ -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

View file

@ -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>

View file

@ -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

View file

@ -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',
)

View file

@ -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>