[gnome-control-center/gbsneto/gtk4: 2/15] multitasking: Port to GTK4




commit 18aab99a762dec86d9a1a005c19cdcba1c6ee248
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Oct 20 23:42:46 2021 -0300

    multitasking: Port to GTK4

 panels/meson.build                           |   2 +-
 panels/multitasking/cc-multitasking-panel.c  |  21 ++-
 panels/multitasking/cc-multitasking-panel.ui |  97 +++++--------
 panels/multitasking/cc-multitasking-row.c    | 205 ++++++---------------------
 panels/multitasking/cc-multitasking-row.h    |   7 +-
 panels/multitasking/cc-multitasking-row.ui   |  28 +---
 shell/cc-panel-loader.c                      |   4 +-
 7 files changed, 100 insertions(+), 264 deletions(-)
---
diff --git a/panels/meson.build b/panels/meson.build
index 4d3ef476a..2108bd918 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -15,7 +15,7 @@ panels = [
   'lock',
   'microphone',
 #  'mouse',
-#  'multitasking',
+  'multitasking',
   'notifications',
 #  'online-accounts',
   'power',
diff --git a/panels/multitasking/cc-multitasking-panel.c b/panels/multitasking/cc-multitasking-panel.c
index 1523e35b1..0196cbf39 100644
--- a/panels/multitasking/cc-multitasking-panel.c
+++ b/panels/multitasking/cc-multitasking-panel.c
@@ -23,7 +23,6 @@
 
 #include "cc-multitasking-resources.h"
 #include "cc-multitasking-row.h"
-#include "list-box-helper.h"
 
 struct _CcMultitaskingPanel
 {
@@ -35,13 +34,13 @@ struct _CcMultitaskingPanel
   GSettings       *wm_settings;
 
   GtkSwitch       *active_screen_edges_switch;
-  GtkToggleButton *current_workspace_radio;
-  GtkToggleButton *dynamic_workspaces_radio;
-  GtkToggleButton *fixed_workspaces_radio;
+  GtkCheckButton  *current_workspace_radio;
+  GtkCheckButton  *dynamic_workspaces_radio;
+  GtkCheckButton  *fixed_workspaces_radio;
   GtkSwitch       *hot_corner_switch;
   GtkSpinButton   *number_of_workspaces_spin;
-  GtkToggleButton *workspaces_primary_display_radio;
-  GtkToggleButton *workspaces_span_displays_radio;
+  GtkCheckButton  *workspaces_primary_display_radio;
+  GtkCheckButton  *workspaces_span_displays_radio;
 };
 
 CC_PANEL_REGISTER (CcMultitaskingPanel, cc_multitasking_panel)
@@ -100,9 +99,9 @@ cc_multitasking_panel_init (CcMultitaskingPanel *self)
   self->mutter_settings = g_settings_new ("org.gnome.mutter");
 
   if (g_settings_get_boolean (self->mutter_settings, "workspaces-only-on-primary"))
-    gtk_toggle_button_set_active (self->workspaces_primary_display_radio, TRUE);
+    gtk_check_button_set_active (self->workspaces_primary_display_radio, TRUE);
   else
-    gtk_toggle_button_set_active (self->workspaces_span_displays_radio, TRUE);
+    gtk_check_button_set_active (self->workspaces_span_displays_radio, TRUE);
 
   g_settings_bind (self->mutter_settings,
                    "workspaces-only-on-primary",
@@ -116,9 +115,9 @@ cc_multitasking_panel_init (CcMultitaskingPanel *self)
                    G_SETTINGS_BIND_DEFAULT);
 
   if (g_settings_get_boolean (self->mutter_settings, "dynamic-workspaces"))
-    gtk_toggle_button_set_active (self->dynamic_workspaces_radio, TRUE);
+    gtk_check_button_set_active (self->dynamic_workspaces_radio, TRUE);
   else
-    gtk_toggle_button_set_active (self->fixed_workspaces_radio, TRUE);
+    gtk_check_button_set_active (self->fixed_workspaces_radio, TRUE);
 
   g_settings_bind (self->mutter_settings,
                    "dynamic-workspaces",
@@ -136,7 +135,7 @@ cc_multitasking_panel_init (CcMultitaskingPanel *self)
   self->shell_settings = g_settings_new ("org.gnome.shell.app-switcher");
 
   if (g_settings_get_boolean (self->shell_settings, "current-workspace-only"))
-    gtk_toggle_button_set_active (self->current_workspace_radio, TRUE);
+    gtk_check_button_set_active (self->current_workspace_radio, TRUE);
 
   g_settings_bind (self->shell_settings,
                    "current-workspace-only",
diff --git a/panels/multitasking/cc-multitasking-panel.ui b/panels/multitasking/cc-multitasking-panel.ui
index 5b5725038..19b9ac7f5 100644
--- a/panels/multitasking/cc-multitasking-panel.ui
+++ b/panels/multitasking/cc-multitasking-panel.ui
@@ -1,14 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcMultitaskingPanel" parent="CcPanel">
-    <property name="visible">True</property>
     <child>
       <object class="GtkScrolledWindow">
-        <property name="visible">true</property>
         <property name="hscrollbar-policy">never</property>
         <child>
-          <object class="HdyClamp">
-            <property name="visible">True</property>
+          <object class="AdwClamp">
             <property name="maximum-size">600</property>
             <property name="tightening-threshold">400</property>
             <property name="margin_top">32</property>
@@ -18,16 +15,12 @@
 
             <child>
               <object class="GtkBox">
-                <property name="visible">true</property>
-                <property name="can-focus">false</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">12</property>
 
                 <!-- General -->
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="label" translatable="yes">General</property>
                     <property name="xalign">0.0</property>
                     <attributes>
@@ -38,8 +31,6 @@
 
                 <child>
                   <object class="GtkListBox">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="selection-mode">none</property>
                     <property name="margin-bottom">24</property>
 
@@ -50,7 +41,6 @@
                     <!-- Hot Corner -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">hot_corner_switch</property>
                         <property name="title" translatable="yes">_Hot Corner</property>
@@ -58,18 +48,20 @@
                         <property name="use_underline">True</property>
                         <child>
                           <object class="GtkSwitch" id="hot_corner_switch">
-                            <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                           </object>
                         </child>
                         <child type="artwork">
-                          <object class="GtkImage">
-                            <property name="visible">True</property>
+                          <object class="GtkPicture">
                             <property name="hexpand">True</property>
                             <property name="halign">center</property>
-                            <property name="margin">18</property>
-                            <property 
name="resource">/org/gnome/control-center/multitasking/assets/hot-corner.svg</property>
+                            <property name="margin-top">18</property>
+                            <property name="margin-bottom">18</property>
+                            <property name="margin-start">18</property>
+                            <property name="margin-end">18</property>
+                            <property name="can-shrink">False</property>
+                            <property 
name="file">resource:///org/gnome/control-center/multitasking/assets/hot-corner.svg</property>
                           </object>
                         </child>
                       </object>
@@ -78,7 +70,6 @@
                     <!-- Active Screen Edges -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">active_screen_edges_switch</property>
                         <property name="title" translatable="yes">_Active Screen Edges</property>
@@ -86,18 +77,20 @@
                         <property name="use_underline">True</property>
                         <child>
                           <object class="GtkSwitch" id="active_screen_edges_switch">
-                            <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                           </object>
                         </child>
                         <child type="artwork">
-                          <object class="GtkImage">
-                            <property name="visible">True</property>
+                          <object class="GtkPicture">
                             <property name="hexpand">True</property>
                             <property name="halign">center</property>
-                            <property name="margin">18</property>
-                            <property 
name="resource">/org/gnome/control-center/multitasking/assets/active-screen-edges.svg</property>
+                            <property name="margin-top">18</property>
+                            <property name="margin-bottom">18</property>
+                            <property name="margin-start">18</property>
+                            <property name="margin-end">18</property>
+                            <property name="can-shrink">False</property>
+                            <property 
name="file">resource:///org/gnome/control-center/multitasking/assets/active-screen-edges.svg</property>
                           </object>
                         </child>
                       </object>
@@ -109,8 +102,6 @@
                 <!-- Workspaces -->
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="label" translatable="yes">Workspaces</property>
                     <property name="xalign">0.0</property>
                     <attributes>
@@ -121,8 +112,6 @@
 
                 <child>
                   <object class="GtkListBox">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="selection-mode">none</property>
                     <property name="margin-bottom">18</property>
 
@@ -133,15 +122,13 @@
                     <!-- Dynamic Workspaces -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">dynamic_workspaces_radio</property>
                         <property name="title" translatable="yes">_Dynamic workspaces</property>
                         <property name="subtitle" translatable="yes">Automatically removes empty 
workspaces.</property>
                         <property name="use_underline">True</property>
                         <child type="prefix">
-                          <object class="GtkRadioButton" id="dynamic_workspaces_radio">
-                            <property name="visible">True</property>
+                          <object class="GtkCheckButton" id="dynamic_workspaces_radio">
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                           </object>
@@ -152,15 +139,13 @@
                     <!-- Fixed Number of Workspaces -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">fixed_workspaces_radio</property>
                         <property name="title" translatable="yes">_Fixed number of workspaces</property>
                         <property name="subtitle" translatable="yes">Specify a number of permanent 
workspaces.</property>
                         <property name="use_underline">True</property>
                         <child type="prefix">
-                          <object class="GtkRadioButton" id="fixed_workspaces_radio">
-                            <property name="visible">True</property>
+                          <object class="GtkCheckButton" id="fixed_workspaces_radio">
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                             <property name="group">dynamic_workspaces_radio</property>
@@ -172,7 +157,6 @@
                     <!-- Number of Workspaces -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="sensitive" bind-source="fixed_workspaces_radio" 
bind-property="active" bind-flags="default|sync-create" />
                         <property name="activatable-widget">number_of_workspaces_spin</property>
@@ -180,7 +164,6 @@
                         <property name="use_underline">True</property>
                         <child>
                           <object class="GtkSpinButton" id="number_of_workspaces_spin">
-                            <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                             <property name="adjustment">workspaces_adjustment</property>
@@ -195,8 +178,6 @@
                 <!-- Multi-Monitor -->
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="label" translatable="yes">Multi-Monitor</property>
                     <property name="xalign">0.0</property>
                     <attributes>
@@ -207,8 +188,6 @@
 
                 <child>
                   <object class="GtkListBox">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="selection-mode">none</property>
                     <property name="margin-bottom">18</property>
 
@@ -219,25 +198,26 @@
                     <!-- Primary Display -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">workspaces_primary_display_radio</property>
                         <property name="title" translatable="yes">Workspaces on _primary display 
only</property>
                         <property name="use_underline">True</property>
                         <child type="prefix">
-                          <object class="GtkRadioButton" id="workspaces_primary_display_radio">
-                            <property name="visible">True</property>
+                          <object class="GtkCheckButton" id="workspaces_primary_display_radio">
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                           </object>
                         </child>
                         <child type="artwork">
-                          <object class="GtkImage">
-                            <property name="visible">True</property>
+                          <object class="GtkPicture">
                             <property name="hexpand">True</property>
                             <property name="halign">center</property>
-                            <property name="margin">18</property>
-                            <property 
name="resource">/org/gnome/control-center/multitasking/assets/workspaces-primary-display.svg</property>
+                            <property name="margin-top">18</property>
+                            <property name="margin-bottom">18</property>
+                            <property name="margin-start">18</property>
+                            <property name="margin-end">18</property>
+                            <property name="can-shrink">False</property>
+                            <property 
name="file">resource:///org/gnome/control-center/multitasking/assets/workspaces-primary-display.svg</property>
                           </object>
                         </child>
                       </object>
@@ -246,26 +226,27 @@
                     <!-- Span Displays -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">workspaces_span_displays_radio</property>
                         <property name="title" translatable="yes">Workspaces on all d_isplays</property>
                         <property name="use_underline">True</property>
                         <child type="prefix">
-                          <object class="GtkRadioButton" id="workspaces_span_displays_radio">
-                            <property name="visible">True</property>
+                          <object class="GtkCheckButton" id="workspaces_span_displays_radio">
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                             <property name="group">workspaces_primary_display_radio</property>
                           </object>
                         </child>
                         <child type="artwork">
-                          <object class="GtkImage">
-                            <property name="visible">True</property>
+                          <object class="GtkPicture">
                             <property name="hexpand">True</property>
                             <property name="halign">center</property>
-                            <property name="margin">18</property>
-                            <property 
name="resource">/org/gnome/control-center/multitasking/assets/workspaces-span-displays.svg</property>
+                            <property name="margin-top">18</property>
+                            <property name="margin-bottom">18</property>
+                            <property name="margin-start">18</property>
+                            <property name="margin-end">18</property>
+                            <property name="can-shrink">False</property>
+                            <property 
name="file">resource:///org/gnome/control-center/multitasking/assets/workspaces-span-displays.svg</property>
                           </object>
                         </child>
                       </object>
@@ -277,8 +258,6 @@
                 <!-- Application Switching -->
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="label" translatable="yes">Application Switching</property>
                     <property name="xalign">0.0</property>
                     <attributes>
@@ -289,8 +268,6 @@
 
                 <child>
                   <object class="GtkListBox">
-                    <property name="visible">true</property>
-                    <property name="can-focus">true</property>
                     <property name="selection-mode">none</property>
                     <property name="margin-bottom">18</property>
 
@@ -301,14 +278,12 @@
                     <!-- All Workspaces -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">all_workspaces_radio</property>
                         <property name="title" translatable="yes">Include applications from all 
_workspaces</property>
                         <property name="use_underline">True</property>
                         <child type="prefix">
-                          <object class="GtkRadioButton" id="all_workspaces_radio">
-                            <property name="visible">True</property>
+                          <object class="GtkCheckButton" id="all_workspaces_radio">
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                           </object>
@@ -319,14 +294,12 @@
                     <!-- Current Workspace -->
                     <child>
                       <object class="CcMultitaskingRow">
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="activatable-widget">current_workspace_radio</property>
                         <property name="title" translatable="yes">Include applications from the _current 
workspace only</property>
                         <property name="use_underline">True</property>
                         <child type="prefix">
-                          <object class="GtkRadioButton" id="current_workspace_radio">
-                            <property name="visible">True</property>
+                          <object class="GtkCheckButton" id="current_workspace_radio">
                             <property name="can_focus">True</property>
                             <property name="valign">center</property>
                             <property name="group">all_workspaces_radio</property>
diff --git a/panels/multitasking/cc-multitasking-row.c b/panels/multitasking/cc-multitasking-row.c
index 608e4c48f..007c9cba1 100644
--- a/panels/multitasking/cc-multitasking-row.c
+++ b/panels/multitasking/cc-multitasking-row.c
@@ -23,7 +23,7 @@
 
 struct _CcMultitaskingRow
 {
-  HdyPreferencesRow  parent;
+  AdwPreferencesRow  parent;
 
   GtkBox            *artwork_box;
   GtkBox            *header;
@@ -42,9 +42,11 @@ struct _CcMultitaskingRow
   GtkWidget         *activatable_widget;
 };
 
+static GtkBuildableIface *parent_buildable_iface;
+
 static void cc_multitasking_row_buildable_init (GtkBuildableIface *iface);
 
-G_DEFINE_TYPE_WITH_CODE (CcMultitaskingRow, cc_multitasking_row, HDY_TYPE_PREFERENCES_ROW,
+G_DEFINE_TYPE_WITH_CODE (CcMultitaskingRow, cc_multitasking_row, ADW_TYPE_PREFERENCES_ROW,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, cc_multitasking_row_buildable_init))
 
 enum
@@ -181,145 +183,10 @@ cc_multitasking_row_dispose (GObject *object)
     self->previous_parent = NULL;
   }
 
-  G_OBJECT_CLASS (cc_multitasking_row_parent_class)->dispose (object);
-}
-
-static void
-cc_multitasking_row_show_all (GtkWidget *widget)
-{
-  CcMultitaskingRow *self = CC_MULTITASKING_ROW (widget);
-
-  g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
-
-  gtk_container_foreach (GTK_CONTAINER (self->prefixes),
-                         (GtkCallback) gtk_widget_show_all,
-                         NULL);
-
-  gtk_container_foreach (GTK_CONTAINER (self->suffixes),
-                         (GtkCallback) gtk_widget_show_all,
-                         NULL);
-
-  GTK_WIDGET_CLASS (cc_multitasking_row_parent_class)->show_all (widget);
-}
-
-static void
-cc_multitasking_row_destroy (GtkWidget *widget)
-{
-  CcMultitaskingRow *self = CC_MULTITASKING_ROW (widget);
-
-  if (self->header)
-    {
-      gtk_widget_destroy (GTK_WIDGET (self->header));
-      self->header = NULL;
-    }
-
   cc_multitasking_row_set_activatable_widget (self, NULL);
+  g_clear_pointer ((GtkWidget**)&self->header, gtk_widget_unparent);
 
-  self->prefixes = NULL;
-  self->suffixes = NULL;
-
-  GTK_WIDGET_CLASS (cc_multitasking_row_parent_class)->destroy (widget);
-}
-
-static void
-cc_multitasking_row_add (GtkContainer *container,
-                    GtkWidget    *child)
-{
-  CcMultitaskingRow *self = CC_MULTITASKING_ROW (container);
-
-  /* When constructing the widget, we want the box to be added as the child of
-   * the GtkListBoxRow, as an implementation detail.
-   */
-  if (!self->header)
-    {
-      GTK_CONTAINER_CLASS (cc_multitasking_row_parent_class)->add (container, child);
-    }
-  else
-    {
-      gtk_container_add (GTK_CONTAINER (self->suffixes), child);
-      gtk_widget_show (GTK_WIDGET (self->suffixes));
-    }
-}
-
-static void
-cc_multitasking_row_remove (GtkContainer *container,
-                       GtkWidget    *child)
-{
-  CcMultitaskingRow *self = CC_MULTITASKING_ROW (container);
-
-  if (child == GTK_WIDGET (self->header))
-    GTK_CONTAINER_CLASS (cc_multitasking_row_parent_class)->remove (container, child);
-  else if (gtk_widget_get_parent (child) == GTK_WIDGET (self->prefixes))
-    gtk_container_remove (GTK_CONTAINER (self->prefixes), child);
-  else
-    gtk_container_remove (GTK_CONTAINER (self->suffixes), child);
-}
-
-typedef struct {
-  CcMultitaskingRow *row;
-  GtkCallback callback;
-  gpointer callback_data;
-} ForallData;
-
-static void
-for_non_internal_child (GtkWidget *widget,
-                        gpointer   callback_data)
-{
-  ForallData *data = callback_data;
-  CcMultitaskingRow *self = data->row;
-
-  if (widget != (GtkWidget *) self->image &&
-      widget != (GtkWidget *) self->prefixes &&
-      widget != (GtkWidget *) self->suffixes &&
-      widget != (GtkWidget *) self->title_box)
-    {
-      data->callback (widget, data->callback_data);
-    }
-}
-
-static void
-cc_multitasking_row_forall (GtkContainer *container,
-                       gboolean      include_internals,
-                       GtkCallback   callback,
-                       gpointer      callback_data)
-{
-  CcMultitaskingRow *self = CC_MULTITASKING_ROW (container);
-  ForallData data;
-
-  if (include_internals)
-    {
-      GTK_CONTAINER_CLASS (cc_multitasking_row_parent_class)->forall (GTK_CONTAINER (self),
-                                                                      include_internals,
-                                                                      callback,
-                                                                      callback_data);
-      return;
-    }
-
-  data.row = self;
-  data.callback = callback;
-  data.callback_data = callback_data;
-
-  if (self->prefixes)
-    {
-      GTK_CONTAINER_GET_CLASS (self->prefixes)->forall (GTK_CONTAINER (self->prefixes),
-                                                        include_internals,
-                                                        for_non_internal_child,
-                                                        &data);
-    }
-  if (self->suffixes)
-    {
-      GTK_CONTAINER_GET_CLASS (self->suffixes)->forall (GTK_CONTAINER (self->suffixes),
-                                                        include_internals,
-                                                        for_non_internal_child,
-                                                        &data);
-    }
-  if (self->header)
-    {
-      GTK_CONTAINER_GET_CLASS (self->header)->forall (GTK_CONTAINER (self->header),
-                                                      include_internals,
-                                                      for_non_internal_child,
-                                                      &data);
-    }
+  G_OBJECT_CLASS (cc_multitasking_row_parent_class)->dispose (object);
 }
 
 static void
@@ -327,19 +194,11 @@ cc_multitasking_row_class_init (CcMultitaskingRowClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-  GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
 
   object_class->get_property = cc_multitasking_row_get_property;
   object_class->set_property = cc_multitasking_row_set_property;
   object_class->dispose = cc_multitasking_row_dispose;
 
-  widget_class->destroy = cc_multitasking_row_destroy;
-  widget_class->show_all = cc_multitasking_row_show_all;
-
-  container_class->add = cc_multitasking_row_add;
-  container_class->remove = cc_multitasking_row_remove;
-  container_class->forall = cc_multitasking_row_forall;
-
   props[PROP_ICON_NAME] =
     g_param_spec_string ("icon-name",
                          "Icon name",
@@ -447,19 +306,25 @@ cc_multitasking_row_buildable_add_child (GtkBuildable *buildable,
 {
   CcMultitaskingRow *self = CC_MULTITASKING_ROW (buildable);
 
-  if (self->header == NULL || !type)
-    gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (child));
+  if (!self->header)
+    parent_buildable_iface->add_child (buildable, builder, child, type);
   else if (type && strcmp (type, "prefix") == 0)
     cc_multitasking_row_add_prefix (self, GTK_WIDGET (child));
   else if (type && strcmp (type, "artwork") == 0)
-    cc_multitasking_row_add_artwork(self, GTK_WIDGET (child));
+    cc_multitasking_row_add_artwork (self, GTK_WIDGET (child));
+  else if (!type && GTK_IS_WIDGET (child))
+    {
+      gtk_box_append (self->suffixes, GTK_WIDGET (child));
+      gtk_widget_show (GTK_WIDGET (self->suffixes));
+    }
   else
-    GTK_BUILDER_WARN_INVALID_CHILD_TYPE (self, type);
+    parent_buildable_iface->add_child (buildable, builder, child, type);
 }
 
 static void
 cc_multitasking_row_buildable_init (GtkBuildableIface *iface)
 {
+  parent_buildable_iface = g_type_interface_peek_parent (iface);
   iface->add_child = cc_multitasking_row_buildable_add_child;
 }
 
@@ -490,13 +355,9 @@ cc_multitasking_row_set_subtitle (CcMultitaskingRow *self,
 const gchar *
 cc_multitasking_row_get_icon_name (CcMultitaskingRow *self)
 {
-  const gchar *icon_name;
-
   g_return_val_if_fail (CC_IS_MULTITASKING_ROW (self), NULL);
 
-  gtk_image_get_icon_name (self->image, &icon_name, NULL);
-
-  return icon_name;
+  return gtk_image_get_icon_name (self->image);
 }
 
 void
@@ -507,11 +368,11 @@ cc_multitasking_row_set_icon_name (CcMultitaskingRow *self,
 
   g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
 
-  gtk_image_get_icon_name (self->image, &old_icon_name, NULL);
+  old_icon_name = gtk_image_get_icon_name (self->image);
   if (g_strcmp0 (old_icon_name, icon_name) == 0)
     return;
 
-  gtk_image_set_from_icon_name (self->image, icon_name, GTK_ICON_SIZE_INVALID);
+  gtk_image_set_from_icon_name (self->image, icon_name);
   gtk_widget_set_visible (GTK_WIDGET (self->image),
                           icon_name != NULL && g_strcmp0 (icon_name, "") != 0);
 
@@ -584,7 +445,7 @@ cc_multitasking_row_set_use_underline (CcMultitaskingRow *self,
     return;
 
   self->use_underline = use_underline;
-  hdy_preferences_row_set_use_underline (HDY_PREFERENCES_ROW (self), self->use_underline);
+  adw_preferences_row_set_use_underline (ADW_PREFERENCES_ROW (self), self->use_underline);
   gtk_label_set_use_underline (self->title, self->use_underline);
   gtk_label_set_use_underline (self->subtitle, self->use_underline);
   gtk_label_set_mnemonic_widget (self->title, GTK_WIDGET (self));
@@ -652,7 +513,7 @@ cc_multitasking_row_add_prefix (CcMultitaskingRow *self,
   g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
   g_return_if_fail (GTK_IS_WIDGET (self));
 
-  gtk_box_pack_start (self->prefixes, widget, FALSE, TRUE, 0);
+  gtk_box_append (self->prefixes, widget);
   gtk_widget_show (GTK_WIDGET (self->prefixes));
 }
 
@@ -668,7 +529,7 @@ cc_multitasking_row_add_artwork (CcMultitaskingRow *self,
    */
   gtk_widget_set_margin_top (GTK_WIDGET (self->header), 12);
 
-  gtk_box_pack_start (self->artwork_box, widget, FALSE, TRUE, 0);
+  gtk_box_append (self->artwork_box, widget);
   gtk_widget_show (GTK_WIDGET (self->artwork_box));
 }
 
@@ -682,3 +543,25 @@ cc_multitasking_row_activate (CcMultitaskingRow *self)
 
   g_signal_emit (self, signals[SIGNAL_ACTIVATED], 0);
 }
+
+void
+cc_multitasking_row_remove (CcMultitaskingRow *self,
+                            GtkWidget         *child)
+{
+  GtkWidget *parent;
+
+  g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+
+  parent = gtk_widget_get_parent (child);
+
+  if (parent == GTK_WIDGET (self->prefixes))
+    gtk_box_remove (self->prefixes, child);
+  else if (parent == GTK_WIDGET (self->suffixes))
+    gtk_box_remove (self->suffixes, child);
+  else if (parent == GTK_WIDGET (self->artwork_box))
+    gtk_box_remove (self->artwork_box, child);
+  else
+    g_warning ("%p is not a child of %p", child, self);
+}
+
diff --git a/panels/multitasking/cc-multitasking-row.h b/panels/multitasking/cc-multitasking-row.h
index c35d9d688..c70dd0848 100644
--- a/panels/multitasking/cc-multitasking-row.h
+++ b/panels/multitasking/cc-multitasking-row.h
@@ -21,12 +21,12 @@
 
 #pragma once
 
-#include <handy.h>
+#include <adwaita.h>
 
 G_BEGIN_DECLS
 
 #define CC_TYPE_MULTITASKING_ROW (cc_multitasking_row_get_type())
-G_DECLARE_FINAL_TYPE (CcMultitaskingRow, cc_multitasking_row, CC, MULTITASKING_ROW, HdyPreferencesRow)
+G_DECLARE_FINAL_TYPE (CcMultitaskingRow, cc_multitasking_row, CC, MULTITASKING_ROW, AdwPreferencesRow)
 
 const gchar *cc_multitasking_row_get_subtitle (CcMultitaskingRow *self);
 void         cc_multitasking_row_set_subtitle (CcMultitaskingRow *self,
@@ -60,4 +60,7 @@ void cc_multitasking_row_add_artwork (CcMultitaskingRow *self,
 
 void cc_multitasking_row_activate (CcMultitaskingRow *self);
 
+void cc_multitasking_row_remove (CcMultitaskingRow *self,
+                                 GtkWidget         *child);
+
 G_END_DECLS
diff --git a/panels/multitasking/cc-multitasking-row.ui b/panels/multitasking/cc-multitasking-row.ui
index dcb90e9d4..2e419517e 100644
--- a/panels/multitasking/cc-multitasking-row.ui
+++ b/panels/multitasking/cc-multitasking-row.ui
@@ -1,77 +1,62 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="CcMultitaskingRow" parent="HdyPreferencesRow">
+  <template class="CcMultitaskingRow" parent="AdwPreferencesRow">
     <property name="activatable">False</property>
     <accessibility>
-      <relation target="title" type="labelled-by"/>
+      <relation name="labelled-by">title</relation>
     </accessibility>
     <child>
       <object class="GtkBox" id="header">
-        <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="valign">center</property>
-        <property name="visible">True</property>
         <style>
           <class name="header"/>
         </style>
 
         <child>
           <object class="GtkBox">
-            <property name="can_focus">False</property>
             <property name="spacing">12</property>
             <property name="valign">center</property>
             <property name="vexpand">True</property>
-            <property name="visible">True</property>
 
             <child>
               <object class="GtkBox" id="prefixes">
-                <property name="can_focus">False</property>
-                <property name="no_show_all">True</property>
                 <property name="spacing">12</property>
                 <property name="visible">False</property>
               </object>
             </child>
             <child>
               <object class="GtkImage" id="image">
-                <property name="no_show_all">True</property>
                 <property name="pixel_size">32</property>
                 <property name="valign">center</property>
+                <property name="visible">False</property>
               </object>
             </child>
             <child>
               <object class="GtkBox" id="title_box">
-                <property name="can_focus">False</property>
                 <property name="halign">start</property>
-                <property name="no_show_all">True</property>
                 <property name="orientation">vertical</property>
                 <property name="valign">center</property>
-                <property name="visible">True</property>
                 <style>
                   <class name="title"/>
                 </style>
                 <child>
                   <object class="GtkLabel" id="title">
-                    <property name="can_focus">False</property>
                     <property name="ellipsize">end</property>
                     <property name="halign">start</property>
                     <property name="hexpand">True</property>
                     <property name="label" bind-source="CcMultitaskingRow" bind-property="title" 
bind-flags="sync-create"/>
                     <property name="lines">1</property>
-                    <property name="visible">True</property>
                     <property name="wrap">True</property>
                     <property name="wrap-mode">word-char</property>
                     <property name="xalign">0</property>
                     <style>
                       <class name="title"/>
                     </style>
-                    <accessibility>
-                      <relation target="CcMultitaskingRow" type="label-for"/>
-                    </accessibility>
                   </object>
                 </child>
                 <child>
                   <object class="GtkLabel" id="subtitle">
-                    <property name="can_focus">False</property>
                     <property name="ellipsize">end</property>
                     <property name="halign">start</property>
                     <property name="hexpand">True</property>
@@ -88,14 +73,9 @@
             </child>
             <child>
               <object class="GtkBox" id="suffixes">
-                <property name="can_focus">False</property>
-                <property name="no_show_all">True</property>
                 <property name="spacing">12</property>
                 <property name="visible">False</property>
               </object>
-              <packing>
-                <property name="pack-type">end</property>
-              </packing>
             </child>
 
           </object>
@@ -103,8 +83,6 @@
 
         <child>
           <object class="GtkBox" id="artwork_box">
-            <property name="can_focus">False</property>
-            <property name="no_show_all">True</property>
             <property name="visible">False</property>
             <property name="hexpand">True</property>
             <property name="margin-top">12</property>
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 9accbf248..1c8ea3d5d 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -43,7 +43,7 @@ extern GType cc_default_apps_panel_get_type (void);
 extern GType cc_info_overview_panel_get_type (void);
 //extern GType cc_keyboard_panel_get_type (void);
 //extern GType cc_mouse_panel_get_type (void);
-//extern GType cc_multitasking_panel_get_type (void);
+extern GType cc_multitasking_panel_get_type (void);
 #ifdef BUILD_NETWORK
 //extern GType cc_network_panel_get_type (void);
 //extern GType cc_wifi_panel_get_type (void);
@@ -114,7 +114,7 @@ static CcPanelLoaderVtable default_panels[] =
   PANEL_TYPE("lock",             cc_lock_panel_get_type,                 NULL),
   PANEL_TYPE("microphone",       cc_microphone_panel_get_type,           NULL),
   //PANEL_TYPE("mouse",            cc_mouse_panel_get_type,                NULL),
-  //PANEL_TYPE("multitasking",     cc_multitasking_panel_get_type,         NULL),
+  PANEL_TYPE("multitasking",     cc_multitasking_panel_get_type,         NULL),
 #ifdef BUILD_NETWORK
   //PANEL_TYPE("network",          cc_network_panel_get_type,              NULL),
   //PANEL_TYPE("wifi",             cc_wifi_panel_get_type,                 cc_wifi_panel_static_init_func),


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