cc-panel: Require explicit "subpage" widget child type for subpages
Require the use of <child type="subpage"> for when an AdwNavigationPage is expected to be added to CcPanel.navigation. This way we can avoid programming errors when a child widget is wrongly packed in the navigation view. See also https://gitlab.gnome.org/GNOME/gnome-control-center/-/wikis/shell/CcPanel#child-packing Co-authored-by: Matthijs Velsink <mvelsink@gnome.org>
This commit is contained in:
parent
baf3b3bb2b
commit
ba74864b61
6 changed files with 29 additions and 21 deletions
|
@ -2,7 +2,7 @@
|
|||
<interface>
|
||||
<template class="CcApplicationsPanel" parent="CcPanel">
|
||||
<!-- App Search Page (Main Landing Page) -->
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage">
|
||||
<property name="title" translatable="yes">Apps</property>
|
||||
<property name="child">
|
||||
|
@ -94,7 +94,7 @@
|
|||
</child>
|
||||
|
||||
<!-- Default Apps Page -->
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage">
|
||||
<property name="title" translatable="yes">Default Apps</property>
|
||||
<property name="tag">default-apps</property>
|
||||
|
@ -137,7 +137,7 @@
|
|||
</child>
|
||||
|
||||
<!-- App Settings Page -->
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage" id="app_settings_page">
|
||||
<property name="title" translatable="yes">App Settings</property>
|
||||
<property name="child">
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage">
|
||||
<property name="title" translatable="yes">Displays</property>
|
||||
<property name="child">
|
||||
|
@ -168,7 +168,7 @@
|
|||
</child>
|
||||
|
||||
<!-- Night Light page -->
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage">
|
||||
<property name="tag">night-light</property>
|
||||
<property name="title" translatable="yes">Night Light</property>
|
||||
|
@ -231,7 +231,7 @@
|
|||
</child>
|
||||
|
||||
<!-- Display Settings page -->
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage" id="display_settings_page">
|
||||
<property name="tag">display-settings</property>
|
||||
<property name="child">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="CcPrivacyPanel" parent="CcPanel">
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage">
|
||||
<property name="title" translatable="yes">Privacy & Security</property>
|
||||
<property name="child">
|
||||
|
@ -118,23 +118,23 @@
|
|||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcScreenPage"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcCameraPage"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcUsagePage"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcDiagnosticsPage" id="diagnostics_page"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcFirmwareSecurityPage" id="security_page"/>
|
||||
</child>
|
||||
</template>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="CcSystemPanel" parent="CcPanel">
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage">
|
||||
<property name="title" translatable="yes">System</property>
|
||||
<property name="child">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="CcUaPanel" parent="CcPanel">
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="AdwNavigationPage" id="main_page">
|
||||
<property name="title" translatable="yes">Accessibility</property>
|
||||
<property name="child">
|
||||
|
@ -90,23 +90,23 @@
|
|||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcUaSeeingPage" id="seeing_page"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcUaHearingPage" id="hearing_page"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcUaTypingPage" id="typing_page"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcUaMousePage" id="mouse_page"/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<child type="subpage">
|
||||
<object class="CcUaZoomPage" id="zoom_page"/>
|
||||
</child>
|
||||
</template>
|
||||
|
|
|
@ -96,11 +96,19 @@ cc_panel_buildable_add_child (GtkBuildable *buildable,
|
|||
const gchar *type)
|
||||
{
|
||||
CcPanelPrivate *priv = cc_panel_get_instance_private (CC_PANEL (buildable));
|
||||
gboolean is_subpage_child = g_strcmp0 (type, "subpage") == 0;
|
||||
|
||||
/* This is a hub panel (with subpages) such as System and Privacy. */
|
||||
if (ADW_IS_NAVIGATION_PAGE (child))
|
||||
if (ADW_IS_NAVIGATION_PAGE (child)) {
|
||||
if (!is_subpage_child) {
|
||||
g_warning ("<child type=\"subpage\" is expected for an AdwNavigationPage child widget");
|
||||
return;
|
||||
}
|
||||
adw_navigation_view_add (priv->navigation, ADW_NAVIGATION_PAGE (child));
|
||||
else
|
||||
} else if (is_subpage_child) {
|
||||
g_warning ("<child type=\"subpage\" expects an AdwNavigationPage child widget");
|
||||
return;
|
||||
} else
|
||||
parent_buildable_iface->add_child (buildable, builder, child, type);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue