[gnome-control-center/gbsneto/panel-headerbar-cleanup: 10/19] panels: Use new CcPanel helpers for title widgets




commit 4300a4a2908d0c81f427745e55b570dbdd6726ba
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jan 19 18:38:32 2022 -0300

    panels: Use new CcPanel helpers for title widgets
    
    This should significantly simplify these panels, by not forcing
    them to override GObject.constructed all the time. Most panels
    were quite straightfoward.

 panels/applications/cc-applications-panel.c  | 12 ------
 panels/applications/cc-applications-panel.ui | 38 +++++++++++++-----
 panels/bluetooth/cc-bluetooth-panel.c        | 13 ------
 panels/bluetooth/cc-bluetooth-panel.ui       | 20 ++++++----
 panels/camera/cc-camera-panel.c              | 44 ++++++--------------
 panels/camera/cc-camera-panel.ui             |  7 ++++
 panels/datetime/cc-datetime-panel.c          | 13 ------
 panels/datetime/cc-datetime-panel.ui         |  9 ++++-
 panels/display/cc-display-panel.c            |  3 --
 panels/display/cc-display-panel.ui           | 17 ++++----
 panels/location/cc-location-panel.c          | 51 ++++++++---------------
 panels/location/cc-location-panel.ui         |  7 ++++
 panels/microphone/cc-microphone-panel.c      | 45 ++++++++-------------
 panels/microphone/cc-microphone-panel.ui     |  7 ++++
 panels/mouse/cc-mouse-panel.c                | 14 -------
 panels/mouse/cc-mouse-panel.ui               | 22 +++++-----
 panels/network/cc-wifi-panel.c               | 24 -----------
 panels/network/cc-wifi-panel.ui              | 60 ++++++++++++++++++----------
 panels/printers/cc-printers-panel.c          |  9 +++--
 panels/search/cc-search-panel.c              | 60 +++++++++++-----------------
 panels/search/cc-search-panel.ui             | 21 +++++++---
 panels/sharing/cc-sharing-panel.c            | 27 +------------
 panels/sharing/cc-sharing-panel.ui           | 10 +++++
 panels/thunderbolt/cc-bolt-panel.c           |  6 +--
 panels/thunderbolt/cc-bolt-panel.ui          | 24 ++++++-----
 panels/wacom/cc-wacom-panel.c                | 52 +++++++++++-------------
 panels/wwan/cc-wwan-panel.c                  | 26 ++++--------
 panels/wwan/cc-wwan-panel.ui                 | 16 ++++----
 28 files changed, 281 insertions(+), 376 deletions(-)
---
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index 74ffd834d..163d55910 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -1936,13 +1936,9 @@ cc_applications_panel_constructed (GObject *object)
 {
   CcApplicationsPanel *self = CC_APPLICATIONS_PANEL (object);
   GtkListBoxRow *row;
-  CcShell *shell;
 
   G_OBJECT_CLASS (cc_applications_panel_parent_class)->constructed (object);
 
-  shell = cc_panel_get_shell (CC_PANEL (self));
-  cc_shell_embed_widget_in_header (shell, GTK_WIDGET (self->header_button), GTK_POS_RIGHT);
-
   /* Select the first row */
   row = gtk_list_box_get_row_at_index (self->sidebar_listbox, 0);
   gtk_list_box_select_row (self->sidebar_listbox, row);
@@ -1955,13 +1951,6 @@ cc_applications_panel_get_sidebar_widget (CcPanel *panel)
   return GTK_WIDGET (self->sidebar_box);
 }
 
-static GtkWidget *
-cc_applications_panel_get_title_widget (CcPanel *panel)
-{
-  CcApplicationsPanel *self = CC_APPLICATIONS_PANEL (panel);
-  return GTK_WIDGET (self->title_label);
-}
-
 static void
 cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
 {
@@ -1975,7 +1964,6 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
   object_class->set_property = cc_applications_panel_set_property;
 
   panel_class->get_sidebar_widget = cc_applications_panel_get_sidebar_widget;
-  panel_class->get_title_widget = cc_applications_panel_get_title_widget;
 
   g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
 
diff --git a/panels/applications/cc-applications-panel.ui b/panels/applications/cc-applications-panel.ui
index 7316de7fc..98ea10fdd 100644
--- a/panels/applications/cc-applications-panel.ui
+++ b/panels/applications/cc-applications-panel.ui
@@ -1,6 +1,34 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcApplicationsPanel" parent="CcPanel">
+
+    <child type="titlebar">
+      <object class="AdwHeaderBar">
+        <property name="show-end-title-buttons">True</property>
+        <property name="show-start-title-buttons">False</property>
+        <child type="start">
+          <object class="GtkButton">
+            <property name="visible" bind-source="CcApplicationsPanel" bind-property="folded" 
bind-flags="default|sync-create" />
+            <property name="icon-name">go-previous-symbolic</property>
+          </object>
+        </child>
+        <property name="title-widget">
+          <object class="GtkLabel" id="title_label">
+            <property name="label" translatable="yes">Applications</property>
+            <property name="ellipsize">end</property>
+            <style>
+              <class name="title"/>
+            </style>
+          </object>
+        </property>
+        <child type="end">
+          <object class="GtkButton" id="header_button">
+            <property name="label" translatable="yes">Open in Software</property>
+          </object>
+        </child>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkScrolledWindow" id="main_scroll">
         <property name="hscrollbar-policy">never</property>
@@ -371,16 +399,6 @@
       </object>
     </child>
   </template>
-  <object class="GtkLabel" id="title_label">
-    <property name="label" translatable="yes">Applications</property>
-    <property name="ellipsize">end</property>
-    <style>
-      <class name="title"/>
-    </style>
-  </object>
-  <object class="GtkButton" id="header_button">
-    <property name="label" translatable="yes">Open in Software</property>
-  </object>
 
   <!-- Sidebar -->
   <object class="GtkBox" id="sidebar_box">
diff --git a/panels/bluetooth/cc-bluetooth-panel.c b/panels/bluetooth/cc-bluetooth-panel.c
index 5c04ef0b2..175e36550 100644
--- a/panels/bluetooth/cc-bluetooth-panel.c
+++ b/panels/bluetooth/cc-bluetooth-panel.c
@@ -73,18 +73,6 @@ cc_bluetooth_panel_finalize (GObject *object)
        G_OBJECT_CLASS (cc_bluetooth_panel_parent_class)->finalize (object);
 }
 
-static void
-cc_bluetooth_panel_constructed (GObject *object)
-{
-       CcBluetoothPanel *self = CC_BLUETOOTH_PANEL (object);
-
-       G_OBJECT_CLASS (cc_bluetooth_panel_parent_class)->constructed (object);
-
-       /* add kill switch widgets  */
-       cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)),
-                                        GTK_WIDGET (self->header_box), GTK_POS_RIGHT);
-}
-
 static void
 airplane_mode_changed_cb (GObject *source_object,
                          GAsyncResult *res,
@@ -232,7 +220,6 @@ cc_bluetooth_panel_class_init (CcBluetoothPanelClass *klass)
        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
        CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
 
-       object_class->constructed = cc_bluetooth_panel_constructed;
        object_class->finalize = cc_bluetooth_panel_finalize;
 
        panel_class->get_help_uri = cc_bluetooth_panel_get_help_uri;
diff --git a/panels/bluetooth/cc-bluetooth-panel.ui b/panels/bluetooth/cc-bluetooth-panel.ui
index 0b98de458..294ead36a 100644
--- a/panels/bluetooth/cc-bluetooth-panel.ui
+++ b/panels/bluetooth/cc-bluetooth-panel.ui
@@ -1,6 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcBluetoothPanel" parent="CcPanel">
+
+    <child type="titlebar-end">
+      <object class="GtkBox" id="header_box">
+        <child>
+          <object class="GtkSwitch" id="enable_switch">
+            <property name="valign">center</property>
+            <signal name="state-set" handler="enable_switch_state_set_cb" object="CcBluetoothPanel" 
swapped="yes"/>
+          </object>
+        </child>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkStack" id="stack">
         <child>
@@ -51,12 +63,4 @@
       </object>
     </child>
   </template>
-  <object class="GtkBox" id="header_box">
-    <child>
-      <object class="GtkSwitch" id="enable_switch">
-        <property name="valign">center</property>
-        <signal name="state-set" handler="enable_switch_state_set_cb" object="CcBluetoothPanel" 
swapped="yes"/>
-      </object>
-    </child>
-  </object>
 </interface>
diff --git a/panels/camera/cc-camera-panel.c b/panels/camera/cc-camera-panel.c
index c78a245de..3965b67c4 100644
--- a/panels/camera/cc-camera-panel.c
+++ b/panels/camera/cc-camera-panel.c
@@ -35,6 +35,7 @@ struct _CcCameraPanel
 
   GtkStack     *stack;
   GtkListBox   *camera_apps_list_box;
+  GtkSwitch    *main_switch;
 
   GSettings    *privacy_settings;
 
@@ -358,37 +359,6 @@ cc_camera_panel_get_help_uri (CcPanel *panel)
   return "help:gnome-help/camera";
 }
 
-static void
-cc_camera_panel_constructed (GObject *object)
-{
-  CcCameraPanel *self = CC_CAMERA_PANEL (object);
-  GtkWidget *box, *widget;
-
-  G_OBJECT_CLASS (cc_camera_panel_parent_class)->constructed (object);
-
-  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-  gtk_widget_show (box);
-
-  widget = gtk_switch_new ();
-  gtk_widget_show (widget);
-  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
-  gtk_box_append (GTK_BOX (box), widget);
-
-  g_settings_bind (self->privacy_settings, "disable-camera",
-                   widget, "active",
-                   G_SETTINGS_BIND_INVERT_BOOLEAN);
-  g_object_bind_property_full  (widget, "active",
-                                self->stack, "visible-child-name",
-                                G_BINDING_SYNC_CREATE,
-                                to_child_name,
-                                NULL,
-                                NULL, NULL);
-
-  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)),
-                                   box,
-                                   GTK_POS_RIGHT);
-}
-
 static void
 cc_camera_panel_class_init (CcCameraPanelClass *klass)
 {
@@ -399,12 +369,12 @@ cc_camera_panel_class_init (CcCameraPanelClass *klass)
   panel_class->get_help_uri = cc_camera_panel_get_help_uri;
 
   object_class->finalize = cc_camera_panel_finalize;
-  object_class->constructed = cc_camera_panel_constructed;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/camera/cc-camera-panel.ui");
 
   gtk_widget_class_bind_template_child (widget_class, CcCameraPanel, stack);
   gtk_widget_class_bind_template_child (widget_class, CcCameraPanel, camera_apps_list_box);
+  gtk_widget_class_bind_template_child (widget_class, CcCameraPanel, main_switch);
 }
 
 static void
@@ -418,6 +388,16 @@ cc_camera_panel_init (CcCameraPanel *self)
 
   self->privacy_settings = g_settings_new ("org.gnome.desktop.privacy");
 
+  g_settings_bind (self->privacy_settings, "disable-camera",
+                   self->main_switch, "active",
+                   G_SETTINGS_BIND_INVERT_BOOLEAN);
+
+  g_object_bind_property_full  (self->main_switch, "active",
+                                self->stack, "visible-child-name",
+                                G_BINDING_SYNC_CREATE,
+                                to_child_name,
+                                NULL,
+                                NULL, NULL);
 
   self->camera_app_switches = g_hash_table_new_full (g_str_hash,
                                                      g_str_equal,
diff --git a/panels/camera/cc-camera-panel.ui b/panels/camera/cc-camera-panel.ui
index e4c6d897d..256b1f9f5 100644
--- a/panels/camera/cc-camera-panel.ui
+++ b/panels/camera/cc-camera-panel.ui
@@ -1,6 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcCameraPanel" parent="CcPanel">
+
+    <child type="titlebar-end">
+      <object class="GtkSwitch" id="main_switch">
+        <property name="valign">center</property>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkStack" id="stack">
 
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 2d3414ecb..68617d934 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -157,18 +157,6 @@ cc_date_time_panel_dispose (GObject *object)
   G_OBJECT_CLASS (cc_date_time_panel_parent_class)->dispose (object);
 }
 
-static void
-cc_date_time_panel_constructed (GObject *object)
-{
-  CcDateTimePanel *self = CC_DATE_TIME_PANEL (object);
-
-  G_OBJECT_CLASS (cc_date_time_panel_parent_class)->constructed (object);
-
-  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)),
-                                   GTK_WIDGET (self->lock_button),
-                                   GTK_POS_RIGHT);
-}
-
 static const char *
 cc_date_time_panel_get_help_uri (CcPanel *panel)
 {
@@ -963,7 +951,6 @@ cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
 
-  object_class->constructed = cc_date_time_panel_constructed;
   object_class->dispose = cc_date_time_panel_dispose;
 
   panel_class->get_help_uri = cc_date_time_panel_get_help_uri;
diff --git a/panels/datetime/cc-datetime-panel.ui b/panels/datetime/cc-datetime-panel.ui
index 44e4e2203..ec671e247 100644
--- a/panels/datetime/cc-datetime-panel.ui
+++ b/panels/datetime/cc-datetime-panel.ui
@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <object class="GtkLockButton" id="lock_button">
-  </object>
   <object class="GtkListStore" id="city_liststore">
     <columns>
       <!-- column-name city-human-readable -->
@@ -297,6 +295,13 @@
     </child>
   </object>
   <template class="CcDateTimePanel" parent="CcPanel">
+
+    <child type="titlebar-end">
+      <object class="GtkLockButton" id="lock_button">
+        <property name="valign">center</property>
+      </object>
+    </child>
+
     <child type="content">
       <object class="AdwPreferencesPage">
         <child>
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 8b5fb2998..c9015d16f 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -580,7 +580,6 @@ on_toplevel_escape_pressed_cb (GtkWidget      *widget,
 static void
 cc_display_panel_constructed (GObject *object)
 {
-  CcDisplayPanel *self = CC_DISPLAY_PANEL (object);
   CcShell *shell = cc_panel_get_shell (CC_PANEL (object));
   GtkWidget *toplevel = cc_shell_get_toplevel (shell);
 
@@ -591,8 +590,6 @@ cc_display_panel_constructed (GObject *object)
   on_toplevel_folded (CC_DISPLAY_PANEL (object), NULL, toplevel);
 
   G_OBJECT_CLASS (cc_display_panel_parent_class)->constructed (object);
-
-  cc_shell_embed_widget_in_header (shell, self->back_button, GTK_POS_LEFT);
 }
 
 static const char *
diff --git a/panels/display/cc-display-panel.ui b/panels/display/cc-display-panel.ui
index ac733f724..22350b271 100644
--- a/panels/display/cc-display-panel.ui
+++ b/panels/display/cc-display-panel.ui
@@ -15,6 +15,14 @@
       </object>
     </child>
 
+    <child type="titlebar-start">
+      <object class="GtkButton" id="back_button">
+        <property name="visible">False</property>
+        <property name="icon-name">go-previous-symbolic</property>
+        <signal name="clicked" handler="on_back_button_clicked_cb" object="CcDisplayPanel" swapped="no" />
+      </object>
+    </child>
+
     <child type="content">
       <object class="AdwLeaflet" id="leaflet">
         <property name="can-unfold">False</property>
@@ -176,13 +184,4 @@
       </object>
     </child>
   </template>
-
-  <object class="GtkButton" id="back_button">
-    <property name="visible">False</property>
-    <property name="icon-name">go-previous-symbolic</property>
-    <signal name="clicked" handler="on_back_button_clicked_cb" object="CcDisplayPanel" swapped="no" />
-    <style>
-      <class name="flat" />
-    </style>
-  </object>
 </interface>
diff --git a/panels/location/cc-location-panel.c b/panels/location/cc-location-panel.c
index ef8cf4589..4e1077ee3 100644
--- a/panels/location/cc-location-panel.c
+++ b/panels/location/cc-location-panel.c
@@ -36,6 +36,7 @@ struct _CcLocationPanel
 
   GtkStack     *stack;
   GtkListBox   *location_apps_list_box;
+  GtkSwitch    *main_switch;
 
   GSettings    *location_settings;
 
@@ -366,39 +367,6 @@ cc_location_panel_get_help_uri (CcPanel *panel)
   return "help:gnome-help/location";
 }
 
-static void
-cc_location_panel_constructed (GObject *object)
-{
-  CcLocationPanel *self = CC_LOCATION_PANEL (object);
-  GtkWidget *box, *widget;
-
-  G_OBJECT_CLASS (cc_location_panel_parent_class)->constructed (object);
-
-  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-  widget = gtk_switch_new ();
-  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
-  gtk_box_append (GTK_BOX (box), widget);
-
-  g_settings_bind (self->location_settings,
-                   LOCATION_ENABLED,
-                   widget,
-                   "active",
-                   G_SETTINGS_BIND_DEFAULT);
-
-  g_object_bind_property_full  (widget,
-                                "active",
-                                self->stack,
-                                "visible-child-name",
-                                G_BINDING_SYNC_CREATE,
-                                to_child_name,
-                                NULL,
-                                NULL, NULL);
-
-  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)),
-                                   box,
-                                   GTK_POS_RIGHT);
-}
-
 static void
 cc_location_panel_class_init (CcLocationPanelClass *klass)
 {
@@ -409,12 +377,12 @@ cc_location_panel_class_init (CcLocationPanelClass *klass)
   panel_class->get_help_uri = cc_location_panel_get_help_uri;
 
   object_class->finalize = cc_location_panel_finalize;
-  object_class->constructed = cc_location_panel_constructed;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/location/cc-location-panel.ui");
 
   gtk_widget_class_bind_template_child (widget_class, CcLocationPanel, stack);
   gtk_widget_class_bind_template_child (widget_class, CcLocationPanel, location_apps_list_box);
+  gtk_widget_class_bind_template_child (widget_class, CcLocationPanel, main_switch);
 }
 
 static void
@@ -427,6 +395,21 @@ cc_location_panel_init (CcLocationPanel *self)
   self->location_icon_size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
   self->location_settings = g_settings_new ("org.gnome.system.location");
 
+  g_settings_bind (self->location_settings,
+                   LOCATION_ENABLED,
+                   self->main_switch,
+                   "active",
+                   G_SETTINGS_BIND_DEFAULT);
+
+  g_object_bind_property_full  (self->main_switch,
+                                "active",
+                                self->stack,
+                                "visible-child-name",
+                                G_BINDING_SYNC_CREATE,
+                                to_child_name,
+                                NULL,
+                                NULL, NULL);
+
   self->location_app_switches = g_hash_table_new_full (g_str_hash,
                                                        g_str_equal,
                                                        g_free,
diff --git a/panels/location/cc-location-panel.ui b/panels/location/cc-location-panel.ui
index fdcd6101d..d2c48d494 100644
--- a/panels/location/cc-location-panel.ui
+++ b/panels/location/cc-location-panel.ui
@@ -1,6 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcLocationPanel" parent="CcPanel">
+
+    <child type="titlebar-end">
+      <object class="GtkSwitch" id="main_switch">
+        <property name="valign">center</property>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkStack" id="stack">
 
diff --git a/panels/microphone/cc-microphone-panel.c b/panels/microphone/cc-microphone-panel.c
index 3bf0e8be7..7583f993b 100644
--- a/panels/microphone/cc-microphone-panel.c
+++ b/panels/microphone/cc-microphone-panel.c
@@ -32,6 +32,7 @@ struct _CcMicrophonePanel
 {
   CcPanel       parent_instance;
 
+  GtkSwitch    *main_switch;
   GtkListBox   *microphone_apps_list_box;
   GtkStack     *stack;
 
@@ -365,34 +366,6 @@ cc_microphone_panel_get_help_uri (CcPanel *panel)
   return "help:gnome-help/microphone";
 }
 
-static void
-cc_microphone_panel_constructed (GObject *object)
-{
-  CcMicrophonePanel *self = CC_MICROPHONE_PANEL (object);
-  GtkWidget *box, *widget;
-
-  G_OBJECT_CLASS (cc_microphone_panel_parent_class)->constructed (object);
-
-  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-  widget = gtk_switch_new ();
-  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
-  gtk_box_append (GTK_BOX (box), widget);
-
-  g_settings_bind (self->privacy_settings, "disable-microphone",
-                   widget, "active",
-                   G_SETTINGS_BIND_INVERT_BOOLEAN);
-  g_object_bind_property_full  (widget, "active",
-                                self->stack, "visible-child-name",
-                                G_BINDING_SYNC_CREATE,
-                                to_child_name,
-                                NULL,
-                                NULL, NULL);
-
-  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)),
-                                   box,
-                                   GTK_POS_RIGHT);
-}
-
 static void
 cc_microphone_panel_class_init (CcMicrophonePanelClass *klass)
 {
@@ -403,10 +376,10 @@ cc_microphone_panel_class_init (CcMicrophonePanelClass *klass)
   panel_class->get_help_uri = cc_microphone_panel_get_help_uri;
 
   object_class->finalize = cc_microphone_panel_finalize;
-  object_class->constructed = cc_microphone_panel_constructed;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/microphone/cc-microphone-panel.ui");
 
+  gtk_widget_class_bind_template_child (widget_class, CcMicrophonePanel, main_switch);
   gtk_widget_class_bind_template_child (widget_class, CcMicrophonePanel, stack);
   gtk_widget_class_bind_template_child (widget_class, CcMicrophonePanel, microphone_apps_list_box);
 }
@@ -422,6 +395,20 @@ cc_microphone_panel_init (CcMicrophonePanel *self)
 
   self->privacy_settings = g_settings_new ("org.gnome.desktop.privacy");
 
+  g_settings_bind (self->privacy_settings,
+                   "disable-microphone",
+                   self->main_switch,
+                   "active",
+                   G_SETTINGS_BIND_INVERT_BOOLEAN);
+
+  g_object_bind_property_full  (self->main_switch,
+                                "active",
+                                self->stack,
+                                "visible-child-name",
+                                G_BINDING_SYNC_CREATE,
+                                to_child_name,
+                                NULL,
+                                NULL, NULL);
 
   self->microphone_app_switches = g_hash_table_new_full (g_str_hash,
                                                        g_str_equal,
diff --git a/panels/microphone/cc-microphone-panel.ui b/panels/microphone/cc-microphone-panel.ui
index 3fa41fe42..67c01a56a 100644
--- a/panels/microphone/cc-microphone-panel.ui
+++ b/panels/microphone/cc-microphone-panel.ui
@@ -1,6 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcMicrophonePanel" parent="CcPanel">
+
+    <child type="titlebar-end">
+      <object class="GtkSwitch" id="main_switch">
+        <property name="valign">center</property>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkStack" id="stack">
 
diff --git a/panels/mouse/cc-mouse-panel.c b/panels/mouse/cc-mouse-panel.c
index 90b01bd5f..cdd28ab31 100644
--- a/panels/mouse/cc-mouse-panel.c
+++ b/panels/mouse/cc-mouse-panel.c
@@ -343,19 +343,6 @@ test_button_toggled_cb (CcMousePanel *self)
     gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->preferences));
 }
 
-static void
-cc_mouse_panel_constructed (GObject *object)
-{
-  CcMousePanel *self = CC_MOUSE_PANEL (object);
-  CcShell *shell;
-
-  G_OBJECT_CLASS (cc_mouse_panel_parent_class)->constructed (object);
-
-  /* Add test area button to shell header. */
-  shell = cc_panel_get_shell (CC_PANEL (self));
-  cc_shell_embed_widget_in_header (shell, GTK_WIDGET (self->test_button), GTK_POS_RIGHT);
-}
-
 static void
 cc_mouse_panel_init (CcMousePanel *self)
 {
@@ -395,7 +382,6 @@ cc_mouse_panel_class_init (CcMousePanelClass *klass)
   panel_class->get_help_uri = cc_mouse_panel_get_help_uri;
 
   object_class->dispose = cc_mouse_panel_dispose;
-  object_class->constructed = cc_mouse_panel_constructed;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/mouse/cc-mouse-panel.ui");
 
diff --git a/panels/mouse/cc-mouse-panel.ui b/panels/mouse/cc-mouse-panel.ui
index dc1f95d64..4954e1884 100644
--- a/panels/mouse/cc-mouse-panel.ui
+++ b/panels/mouse/cc-mouse-panel.ui
@@ -1,6 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcMousePanel" parent="CcPanel">
+
+    <child type="titlebar-end">
+      <object class="GtkToggleButton" id="test_button">
+        <property name="use_underline">True</property>
+        <property name="valign">center</property>
+        <property name="label" translatable="yes">Test Your _Settings</property>
+        <signal name="toggled" handler="test_button_toggled_cb" object="CcMousePanel" swapped="yes"/>
+        <style>
+          <class name="text-button"/>
+        </style>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkStack" id="stack">
         <child>
@@ -164,15 +177,6 @@
       </object>
     </child>
   </template>
-  <object class="GtkToggleButton" id="test_button">
-    <property name="use_underline">True</property>
-    <property name="valign">center</property>
-    <property name="label" translatable="yes">Test Your _Settings</property>
-    <signal name="toggled" handler="test_button_toggled_cb" object="CcMousePanel" swapped="yes"/>
-    <style>
-      <class name="text-button"/>
-    </style>
-  </object>
   <object class="GtkAdjustment" id="mouse_speed_adjustment">
     <property name="lower">-1</property>
     <property name="upper">1</property>
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index 1501803a8..146124f84 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -900,28 +900,6 @@ cc_wifi_panel_get_help_uri (CcPanel *panel)
   return "help:gnome-help/net-wireless";
 }
 
-static GtkWidget *
-cc_wifi_panel_get_title_widget (CcPanel *panel)
-{
-  CcWifiPanel *self = CC_WIFI_PANEL (panel);
-
-  return GTK_WIDGET (self->center_stack);
-}
-
-static void
-cc_wifi_panel_constructed (GObject *object)
-{
-  CcWifiPanel *self;
-  CcShell *shell;
-
-  self = CC_WIFI_PANEL (object);
-  shell = cc_panel_get_shell (CC_PANEL (object));
-
-  G_OBJECT_CLASS (cc_wifi_panel_parent_class)->constructed (object);
-
-  cc_shell_embed_widget_in_header (shell, GTK_WIDGET (self->header_stack), GTK_POS_RIGHT);
-}
-
 static void
 cc_wifi_panel_finalize (GObject *object)
 {
@@ -1012,9 +990,7 @@ cc_wifi_panel_class_init (CcWifiPanelClass *klass)
   CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
 
   panel_class->get_help_uri = cc_wifi_panel_get_help_uri;
-  panel_class->get_title_widget = cc_wifi_panel_get_title_widget;
 
-  object_class->constructed = cc_wifi_panel_constructed;
   object_class->finalize = cc_wifi_panel_finalize;
   object_class->get_property = cc_wifi_panel_get_property;
   object_class->set_property = cc_wifi_panel_set_property;
diff --git a/panels/network/cc-wifi-panel.ui b/panels/network/cc-wifi-panel.ui
index 9722c5a07..1a1f44ff9 100644
--- a/panels/network/cc-wifi-panel.ui
+++ b/panels/network/cc-wifi-panel.ui
@@ -2,6 +2,45 @@
 <interface>
   <template class="CcWifiPanel" parent="CcPanel">
 
+    <child type="titlebar">
+      <object class="AdwHeaderBar" id="titlebar">
+        <property name="show-end-title-buttons">True</property>
+        <property name="show-start-title-buttons" bind-source="CcWifiPanel" bind-property="folded" 
bind-flags="default|sync-create" />
+        <child type="start">
+          <object class="GtkButton">
+            <property name="visible" bind-source="CcWifiPanel" bind-property="folded" 
bind-flags="default|sync-create" />
+            <property name="icon-name">go-previous-symbolic</property>
+          </object>
+        </child>
+
+        <!-- Center Widget -->
+        <property name="title-widget">
+          <object class="GtkStack" id="center_stack">
+            <property name="halign">center</property>
+            <property name="hhomogeneous">False</property>
+            <child>
+              <object class="GtkStackPage">
+                <property name="name">many</property>
+                <property name="child">
+                  <object class="GtkStackSwitcher">
+                    <property name="stack">stack</property>
+                  </object>
+                </property>
+              </object>
+            </child>
+          </object>
+        </property>
+
+        <!-- End Stack -->
+        <child type="end">
+          <object class="GtkStack" id="header_stack">
+            <property name="halign">end</property>
+          </object>
+        </child>
+
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkScrolledWindow">
         <property name="hscrollbar-policy">never</property>
@@ -277,25 +316,4 @@
       </object>
     </child>
   </template>
-
-  <!-- End Stack -->
-  <object class="GtkStack" id="header_stack">
-    <property name="halign">end</property>
-  </object>
-
-  <!-- Center Widget -->
-  <object class="GtkStack" id="center_stack">
-    <property name="halign">center</property>
-    <property name="hhomogeneous">False</property>
-    <child>
-      <object class="GtkStackPage">
-        <property name="name">many</property>
-        <property name="child">
-          <object class="GtkStackSwitcher">
-            <property name="stack">stack</property>
-          </object>
-        </property>
-      </object>
-    </child>
-  </object>
 </interface>
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 0ae9a5cdd..4337633f1 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -233,10 +233,6 @@ cc_printers_panel_constructed (GObject *object)
 
   shell = cc_panel_get_shell (CC_PANEL (self));
 
-  widget = (GtkWidget*)
-    gtk_builder_get_object (self->builder, "top-right-buttons");
-  cc_shell_embed_widget_in_header (shell, widget, GTK_POS_RIGHT);
-
   widget = (GtkWidget*)
     gtk_builder_get_object (self->builder, "search-bar");
   gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (widget),
@@ -1318,4 +1314,9 @@ Please check your installation");
 
   pp_cups_connection_test_async (self->cups, cc_panel_get_cancellable (CC_PANEL (self)), connection_test_cb, 
self);
   cc_panel_set_content (CC_PANEL (self), top_widget);
+
+  widget = (GtkWidget*)
+    gtk_builder_get_object (self->builder, "top-right-buttons");
+  adw_header_bar_pack_end (ADW_HEADER_BAR (cc_panel_get_titlebar (CC_PANEL (self))),
+                           widget);
 }
diff --git a/panels/search/cc-search-panel.c b/panels/search/cc-search-panel.c
index 2de905734..5d000e9d6 100644
--- a/panels/search/cc-search-panel.c
+++ b/panels/search/cc-search-panel.c
@@ -28,15 +28,16 @@
 
 struct _CcSearchPanel
 {
-  CcPanel     parent_instance;
+  CcPanel           parent_instance;
 
-  GtkWidget  *list_box;
-  GtkWidget  *search_vbox;
-  GtkWidget  *settings_button;
-  CcSearchPanelRow  *selected_row;
+  GtkWidget        *list_box;
+  GtkSwitch        *main_switch;
+  GtkWidget        *search_vbox;
+  GtkWidget        *settings_button;
+  CcSearchPanelRow *selected_row;
 
-  GSettings  *search_settings;
-  GHashTable *sort_order;
+  GSettings        *search_settings;
+  GHashTable       *sort_order;
 
   CcSearchLocationsDialog  *locations_dialog;
 };
@@ -619,35 +620,6 @@ cc_search_panel_finalize (GObject *object)
   G_OBJECT_CLASS (cc_search_panel_parent_class)->finalize (object);
 }
 
-static void
-cc_search_panel_constructed (GObject *object)
-{
-  CcSearchPanel *self = CC_SEARCH_PANEL (object);
-  GtkWidget *box, *widget;
-
-  G_OBJECT_CLASS (cc_search_panel_parent_class)->constructed (object);
-
-  /* add the disable all switch */
-  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-
-  widget = gtk_switch_new ();
-  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
-  gtk_box_append (GTK_BOX (box), widget);
-
-  g_settings_bind (self->search_settings, "disable-external",
-                   widget, "active",
-                   G_SETTINGS_BIND_DEFAULT |
-                   G_SETTINGS_BIND_INVERT_BOOLEAN);
-
-  g_object_bind_property (widget, "active",
-                          self->search_vbox, "sensitive",
-                          G_BINDING_DEFAULT |
-                          G_BINDING_SYNC_CREATE);
-
-  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)), self->settings_button, 
GTK_POS_LEFT);
-  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)), box, GTK_POS_RIGHT);
-}
-
 static void
 cc_search_panel_init (CcSearchPanel *self)
 {
@@ -661,6 +633,20 @@ cc_search_panel_init (CcSearchPanel *self)
   gtk_widget_set_sensitive (self->settings_button, cc_search_locations_dialog_is_available ());
 
   self->search_settings = g_settings_new ("org.gnome.desktop.search-providers");
+  g_settings_bind (self->search_settings,
+                   "disable-external",
+                   self->main_switch,
+                   "active",
+                   G_SETTINGS_BIND_DEFAULT |
+                   G_SETTINGS_BIND_INVERT_BOOLEAN);
+
+  g_object_bind_property (self->main_switch,
+                          "active",
+                          self->search_vbox,
+                          "sensitive",
+                          G_BINDING_DEFAULT |
+                          G_BINDING_SYNC_CREATE);
+
   self->sort_order = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                   g_free, NULL);
   g_signal_connect_swapped (self->search_settings, "changed::sort-order",
@@ -676,13 +662,13 @@ cc_search_panel_class_init (CcSearchPanelClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GObjectClass *oclass = G_OBJECT_CLASS (klass);
 
-  oclass->constructed = cc_search_panel_constructed;
   oclass->finalize = cc_search_panel_finalize;
 
   gtk_widget_class_set_template_from_resource (widget_class,
                                                "/org/gnome/control-center/search/cc-search-panel.ui");
 
   gtk_widget_class_bind_template_child (widget_class, CcSearchPanel, list_box);
+  gtk_widget_class_bind_template_child (widget_class, CcSearchPanel, main_switch);
   gtk_widget_class_bind_template_child (widget_class, CcSearchPanel, search_vbox);
   gtk_widget_class_bind_template_child (widget_class, CcSearchPanel, settings_button);
 
diff --git a/panels/search/cc-search-panel.ui b/panels/search/cc-search-panel.ui
index df07154c3..46488bf87 100644
--- a/panels/search/cc-search-panel.ui
+++ b/panels/search/cc-search-panel.ui
@@ -3,6 +3,21 @@
   <template class="CcSearchPanel" parent="CcPanel">
     <property name="visible">True</property>
 
+    <!-- Header widget -->
+    <child type="titlebar-start">
+      <object class="GtkButton" id="settings_button">
+        <property name="label" translatable="yes">Search Locations</property>
+        <signal name="clicked" handler="settings_button_clicked" object="CcSearchPanel" swapped="no"/>
+      </object>
+    </child>
+
+    <!-- Header widget -->
+    <child type="titlebar-end">
+      <object class="GtkSwitch" id="main_switch">
+        <property name="valign">center</property>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkScrolledWindow" id="search_vbox">
         <property name="visible">True</property>
@@ -47,10 +62,4 @@
     </child>
   </template>
 
-  <!-- Header widget -->
-  <object class="GtkButton" id="settings_button">
-    <property name="visible">True</property>
-    <property name="label" translatable="yes">Search Locations</property>
-    <signal name="clicked" handler="settings_button_clicked" object="CcSearchPanel" swapped="no"/>
-  </object>
 </interface>
diff --git a/panels/sharing/cc-sharing-panel.c b/panels/sharing/cc-sharing-panel.c
index 274ba754f..fb48c8b29 100644
--- a/panels/sharing/cc-sharing-panel.c
+++ b/panels/sharing/cc-sharing-panel.c
@@ -120,19 +120,6 @@ cc_sharing_panel_master_switch_notify (CcSharingPanel *self)
   gtk_widget_set_sensitive (self->main_list_box, active);
 }
 
-static void
-cc_sharing_panel_constructed (GObject *object)
-{
-  CcSharingPanel *self = CC_SHARING_PANEL (object);
-
-  G_OBJECT_CLASS (cc_sharing_panel_parent_class)->constructed (object);
-
-  /* add the master switch */
-  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (object)),
-                                   gtk_widget_get_parent (self->master_switch),
-                                   GTK_POS_RIGHT);
-}
-
 static void
 cc_sharing_panel_dispose (GObject *object)
 {
@@ -184,7 +171,6 @@ cc_sharing_panel_class_init (CcSharingPanelClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
 
-  object_class->constructed = cc_sharing_panel_constructed;
   object_class->dispose = cc_sharing_panel_dispose;
 
   panel_class->get_help_uri = cc_sharing_panel_get_help_uri;
@@ -195,6 +181,7 @@ cc_sharing_panel_class_init (CcSharingPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, hostname_entry);
   gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, screen_sharing_grid);
   gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, shared_folders_grid);
+  gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, master_switch);
   gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, main_list_box);
   gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_dialog);
   gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_headerbar);
@@ -1122,8 +1109,6 @@ sharing_proxy_ready (GObject      *source,
 static void
 cc_sharing_panel_init (CcSharingPanel *self)
 {
-  GtkWidget *box;
-
   g_resources_register (cc_sharing_get_resource ());
 
   gtk_widget_init_template (GTK_WIDGET (self));
@@ -1143,16 +1128,6 @@ cc_sharing_panel_init (CcSharingPanel *self)
   gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (self->main_list_box),
                                              TRUE);
 
-  /* create the master switch */
-  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-
-  self->master_switch = gtk_switch_new ();
-  gtk_widget_set_valign (self->master_switch, GTK_ALIGN_CENTER);
-  gtk_accessible_update_property (GTK_ACCESSIBLE (self->master_switch),
-                                  GTK_ACCESSIBLE_PROPERTY_LABEL, _("Sharing"),
-                                  -1);
-  gtk_box_append (GTK_BOX (box), self->master_switch);
-
   /* start the panel in the disabled state */
   gtk_switch_set_active (GTK_SWITCH (self->master_switch), FALSE);
   gtk_widget_set_sensitive (self->main_list_box, FALSE);
diff --git a/panels/sharing/cc-sharing-panel.ui b/panels/sharing/cc-sharing-panel.ui
index a8a957fc0..57bac425f 100644
--- a/panels/sharing/cc-sharing-panel.ui
+++ b/panels/sharing/cc-sharing-panel.ui
@@ -1,6 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcSharingPanel" parent="CcPanel">
+
+    <child type="titlebar-end">
+      <object class="GtkSwitch" id="master_switch">
+        <property name="valign">center</property>
+        <accessibility>
+          <property name="label" translatable="yes">Sharing</property>
+        </accessibility>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkScrolledWindow" id="sharing_panel">
         <property name="hscrollbar-policy">never</property>
diff --git a/panels/thunderbolt/cc-bolt-panel.c b/panels/thunderbolt/cc-bolt-panel.c
index 6585a933e..0ec005b68 100644
--- a/panels/thunderbolt/cc-bolt-panel.c
+++ b/panels/thunderbolt/cc-bolt-panel.c
@@ -889,13 +889,11 @@ cc_bolt_panel_constructed (GObject *object)
   GtkWindow *parent;
   CcShell *shell;
 
-  parent = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel))));
-  gtk_window_set_transient_for (GTK_WINDOW (panel->device_dialog), parent);
-
   G_OBJECT_CLASS (cc_bolt_panel_parent_class)->constructed (object);
 
   shell = cc_panel_get_shell (CC_PANEL (panel));
-  cc_shell_embed_widget_in_header (shell, GTK_WIDGET (panel->headerbar_box), GTK_POS_RIGHT);
+  parent = GTK_WINDOW (cc_shell_get_toplevel (shell));
+  gtk_window_set_transient_for (GTK_WINDOW (panel->device_dialog), parent);
 }
 
 static void
diff --git a/panels/thunderbolt/cc-bolt-panel.ui b/panels/thunderbolt/cc-bolt-panel.ui
index 9bb41156b..a0aee01f0 100644
--- a/panels/thunderbolt/cc-bolt-panel.ui
+++ b/panels/thunderbolt/cc-bolt-panel.ui
@@ -2,6 +2,19 @@
 <interface>
   <template class="CcBoltPanel" parent="CcPanel">
 
+    <!-- Headerbar entries -->
+    <child type="titlebar-end">
+      <object class="GtkBox" id="headerbar_box">
+        <property name="visible">False</property>
+        <property name="spacing">6</property>
+        <property name="halign">end</property>
+        <child>
+          <object class="GtkLockButton" id="lock_button">
+          </object>
+        </child>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkOverlay">
         <child type="overlay">
@@ -498,15 +511,4 @@
     </child>
   </template>
 
-  <!-- Headerbar entries -->
-  <object class="GtkBox" id="headerbar_box">
-    <property name="visible">False</property>
-    <property name="spacing">6</property>
-    <property name="halign">end</property>
-    <child>
-      <object class="GtkLockButton" id="lock_button">
-      </object>
-    </child>
-  </object>
-
 </interface>
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index 22192244a..f75e4baf8 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -478,7 +478,6 @@ static void
 cc_wacom_panel_constructed (GObject *object)
 {
        CcWacomPanel *self = CC_WACOM_PANEL (object);
-       GtkWidget *button;
        CcShell *shell;
 
        G_OBJECT_CLASS (cc_wacom_panel_parent_class)->constructed (object);
@@ -486,22 +485,6 @@ cc_wacom_panel_constructed (GObject *object)
        /* Add test area button to shell header. */
        shell = cc_panel_get_shell (CC_PANEL (self));
 
-       button = gtk_menu_button_new ();
-       gtk_menu_button_set_use_underline (GTK_MENU_BUTTON (button), TRUE);
-       gtk_menu_button_set_label (GTK_MENU_BUTTON (button), _("Test Your _Settings"));
-       gtk_widget_add_css_class (button, "text-button");
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-
-       cc_shell_embed_widget_in_header (shell, button, GTK_POS_RIGHT);
-
-       self->test_popover = gtk_popover_new ();
-       gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), self->test_popover);
-
-       self->test_draw_area = cc_drawing_area_new ();
-       gtk_widget_set_size_request (self->test_draw_area, 400, 300);
-       gtk_popover_set_child (GTK_POPOVER (self->test_popover), self->test_draw_area);
-       gtk_widget_show (self->test_draw_area);
-
        self->stylus_gesture = gtk_gesture_stylus_new ();
        g_signal_connect (self->stylus_gesture, "proximity",
                          G_CALLBACK (on_stylus_proximity_cb), self);
@@ -510,9 +493,6 @@ cc_wacom_panel_constructed (GObject *object)
 
        if (g_getenv ("UMOCKDEV_DIR") != NULL)
                self->mock_stylus_id = g_idle_add (show_mock_stylus_cb, self);
-
-       self->test_button = button;
-       update_test_button (self);
 }
 
 static const char *
@@ -521,14 +501,6 @@ cc_wacom_panel_get_help_uri (CcPanel *panel)
   return "help:gnome-help/wacom";
 }
 
-static GtkWidget *
-cc_wacom_panel_get_title_widget (CcPanel *panel)
-{
-       CcWacomPanel *self = CC_WACOM_PANEL (panel);
-
-       return self->switcher;
-}
-
 static void
 cc_wacom_panel_class_init (CcWacomPanelClass *klass)
 {
@@ -541,7 +513,6 @@ cc_wacom_panel_class_init (CcWacomPanelClass *klass)
        object_class->constructed = cc_wacom_panel_constructed;
 
        panel_class->get_help_uri = cc_wacom_panel_get_help_uri;
-       panel_class->get_title_widget = cc_wacom_panel_get_title_widget;
 
        g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
 }
@@ -695,6 +666,8 @@ on_stack_visible_child_notify_cb (CcWacomPanel *panel)
 static void
 cc_wacom_panel_init (CcWacomPanel *self)
 {
+  GtkWidget *titlebar;
+  GtkWidget *button;
        GtkWidget *widget;
        GsdDeviceManager *device_manager;
        g_autoptr(GList) devices = NULL;
@@ -800,6 +773,27 @@ cc_wacom_panel_init (CcWacomPanel *self)
                add_known_device (self, l->data);
 
        update_current_page (self);
+
+  /* Titlebar widgets */
+       button = gtk_menu_button_new ();
+       gtk_menu_button_set_use_underline (GTK_MENU_BUTTON (button), TRUE);
+       gtk_menu_button_set_label (GTK_MENU_BUTTON (button), _("Test Your _Settings"));
+       gtk_widget_add_css_class (button, "text-button");
+       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+
+       self->test_popover = gtk_popover_new ();
+       gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), self->test_popover);
+
+       self->test_draw_area = cc_drawing_area_new ();
+       gtk_widget_set_size_request (self->test_draw_area, 400, 300);
+       gtk_popover_set_child (GTK_POPOVER (self->test_popover), self->test_draw_area);
+
+       self->test_button = button;
+       update_test_button (self);
+
+  titlebar = cc_panel_get_titlebar (CC_PANEL (self));
+  adw_header_bar_set_title_widget (ADW_HEADER_BAR (titlebar), self->switcher);
+  adw_header_bar_pack_end (ADW_HEADER_BAR (titlebar), button);
 }
 
 GDBusProxy *
diff --git a/panels/wwan/cc-wwan-panel.c b/panels/wwan/cc-wwan-panel.c
index 1070a9e52..63f519d74 100644
--- a/panels/wwan/cc-wwan-panel.c
+++ b/panels/wwan/cc-wwan-panel.c
@@ -681,24 +681,6 @@ cc_wwan_panel_set_property (GObject      *object,
     }
 }
 
-static void
-cc_wwan_panel_constructed (GObject *object)
-{
-  CcWwanPanel *self = (CcWwanPanel *)object;
-
-  G_OBJECT_CLASS (cc_wwan_panel_parent_class)->constructed (object);
-
-       cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)),
-                                   GTK_WIDGET (self->enable_switch), GTK_POS_RIGHT);
-
-  if (self->nm_client)
-    {
-      g_object_bind_property (self->nm_client, "wwan-enabled",
-                              self->enable_switch, "active",
-                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-    }
-}
-
 static void
 cc_wwan_panel_dispose (GObject *object)
 {
@@ -730,7 +712,6 @@ cc_wwan_panel_class_init (CcWwanPanelClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->set_property = cc_wwan_panel_set_property;
-  object_class->constructed = cc_wwan_panel_constructed;
   object_class->dispose = cc_wwan_panel_dispose;
 
   g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
@@ -788,6 +769,13 @@ cc_wwan_panel_init (CcWwanPanel *self)
       g_warn_if_reached ();
     }
 
+  if (self->nm_client)
+    {
+      g_object_bind_property (self->nm_client, "wwan-enabled",
+                              self->enable_switch, "active",
+                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+    }
+
   if (cc_object_storage_has_object ("CcObjectStorage::mm-manager"))
     {
       self->mm_manager = cc_object_storage_get_object ("CcObjectStorage::mm-manager");
diff --git a/panels/wwan/cc-wwan-panel.ui b/panels/wwan/cc-wwan-panel.ui
index eb4cba107..cfb5229bc 100644
--- a/panels/wwan/cc-wwan-panel.ui
+++ b/panels/wwan/cc-wwan-panel.ui
@@ -3,6 +3,15 @@
   <requires lib="gtk" version="4.0"/>
   <template class="CcWwanPanel" parent="CcPanel">
 
+    <!-- Cellular panel on/off switch -->
+    <child type="titlebar-end">
+      <object class="GtkSwitch" id="enable_switch">
+        <accessibility>
+          <property name="label" translatable="yes">Enable Mobile Network</property>
+        </accessibility>
+      </object>
+    </child>
+
     <child type="content">
       <object class="GtkOverlay">
 
@@ -220,11 +229,4 @@
     </child>
 
   </template>
-
-  <!-- Cellular panel on/off switch -->
-  <object class="GtkSwitch" id="enable_switch">
-    <accessibility>
-      <property name="label" translatable="yes">Enable Mobile Network</property>
-    </accessibility>
-  </object>
 </interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]