[gnome-control-center] panel: Move shared GCancellable code into panel class



commit 93b14a43394680d4f13b69da4381ef8f43974159
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Jan 31 10:30:10 2020 +1300

    panel: Move shared GCancellable code into panel class
    
    Make the panel class provide a cancellable that will be cancelled when the panel
    is destroyed. Panel implementations can use this and not have to mangage the
    cancellable themselves. Consolidate cases where panels had multiple cancellables
    that were all being used for this behaviour.

 panels/applications/cc-applications-panel.c   | 17 ++++--------
 panels/bluetooth/cc-bluetooth-panel.c         | 11 ++------
 panels/camera/cc-camera-panel.c               | 12 +++------
 panels/color/cc-color-panel.c                 | 30 +++++++++------------
 panels/display/cc-display-panel.c             |  8 ++----
 panels/location/cc-location-panel.c           | 11 +++-----
 panels/microphone/cc-microphone-panel.c       | 12 +++------
 panels/network/cc-wifi-panel.c                |  9 ++-----
 panels/notifications/cc-notifications-panel.c | 13 ++++-----
 panels/power/cc-power-panel.c                 | 21 ++++++---------
 panels/printers/cc-printers-panel.c           | 38 +++++----------------------
 panels/region/cc-region-panel.c               | 24 +++++++----------
 panels/search/cc-search-panel.c               | 18 +------------
 panels/sharing/cc-sharing-panel.c             | 33 ++++-------------------
 panels/thunderbolt/cc-bolt-panel.c            | 14 +++-------
 panels/user-accounts/cc-user-panel.c          |  9 ++-----
 panels/wacom/cc-wacom-panel.c                 |  8 +-----
 shell/cc-panel.c                              | 21 +++++++++++++--
 shell/cc-panel.h                              | 12 +++++----
 19 files changed, 100 insertions(+), 221 deletions(-)
---
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index 989c1cfda..450c2c9d9 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -62,8 +62,6 @@ struct _CcApplicationsPanel
   GAppInfoMonitor *monitor;
   gulong           monitor_id;
 
-  GCancellable    *cancellable;
-
   gchar           *current_app_id;
   gchar           *current_portal_app_id;
 
@@ -673,7 +671,7 @@ add_snap_permissions (CcApplicationsPanel *self,
           g_ptr_array_add (available_slots, g_object_ref (slot));
         }
 
-      row = cc_snap_row_new (self->cancellable, plug, available_slots);
+      row = cc_snap_row_new (cc_panel_get_cancellable (CC_PANEL (self)), plug, available_slots);
       gtk_widget_show (GTK_WIDGET (row));
       gtk_list_box_insert (GTK_LIST_BOX (self->permission_list), GTK_WIDGET (row), index);
       index++;
@@ -1435,7 +1433,7 @@ update_cache_row (CcApplicationsPanel *self,
 {
   g_autoptr(GFile) dir = get_flatpak_app_dir (app_id, "cache");
   g_object_set (self->cache, "info", "...", NULL);
-  file_size_async (dir, self->cancellable, set_cache_size, self);
+  file_size_async (dir, cc_panel_get_cancellable (CC_PANEL (self)), set_cache_size, self);
 }
 
 static void
@@ -1469,7 +1467,7 @@ update_data_row (CcApplicationsPanel *self,
   g_autoptr(GFile) dir = get_flatpak_app_dir (app_id, "data");
 
   g_object_set (self->data, "info", "...", NULL);
-  file_size_async (dir, self->cancellable, set_data_size, self);
+  file_size_async (dir, cc_panel_get_cancellable (CC_PANEL (self)), set_data_size, self);
 }
 
 static void
@@ -1499,7 +1497,7 @@ clear_cache_cb (CcApplicationsPanel *self)
     return;
 
   dir = get_flatpak_app_dir (self->current_app_id, "cache");
-  file_remove_async (dir, self->cancellable, cache_cleared, self);
+  file_remove_async (dir, cc_panel_get_cancellable (CC_PANEL (self)), cache_cleared, self);
 }
 
 static void
@@ -1747,8 +1745,6 @@ cc_applications_panel_dispose (GObject *object)
   g_clear_object (&self->monitor);
   g_clear_object (&self->perm_store);
 
-  g_cancellable_cancel (self->cancellable);
-
   G_OBJECT_CLASS (cc_applications_panel_parent_class)->dispose (object);
 }
 
@@ -1761,7 +1757,6 @@ cc_applications_panel_finalize (GObject *object)
   g_clear_object (&self->location_settings);
   g_clear_object (&self->privacy_settings);
   g_clear_object (&self->search_settings);
-  g_clear_object (&self->cancellable);
 
   g_free (self->current_app_id);
   g_free (self->current_portal_app_id);
@@ -1924,8 +1919,6 @@ cc_applications_panel_init (CcApplicationsPanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  self->cancellable = g_cancellable_new ();
-
   provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
   gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider),
                                        "/org/gnome/control-center/applications/cc-applications-panel.css");
@@ -1986,7 +1979,7 @@ cc_applications_panel_init (CcApplicationsPanel *self)
                             "org.freedesktop.impl.portal.PermissionStore",
                             "/org/freedesktop/impl/portal/PermissionStore",
                             "org.freedesktop.impl.portal.PermissionStore",
-                            self->cancellable,
+                            cc_panel_get_cancellable (CC_PANEL (self)),
                             on_perm_store_ready,
                             self);
 
diff --git a/panels/bluetooth/cc-bluetooth-panel.c b/panels/bluetooth/cc-bluetooth-panel.c
index d654b2d9c..5985ab055 100644
--- a/panels/bluetooth/cc-bluetooth-panel.c
+++ b/panels/bluetooth/cc-bluetooth-panel.c
@@ -41,8 +41,6 @@ struct _CcBluetoothPanel {
        BluetoothSettingsWidget *settings_widget;
        GtkStack                *stack;
 
-       GCancellable            *cancellable;
-
        /* Killswitch */
        GDBusProxy              *rfkill;
        GDBusProxy              *properties;
@@ -67,9 +65,6 @@ cc_bluetooth_panel_finalize (GObject *object)
 
        self = CC_BLUETOOTH_PANEL (object);
 
-       g_cancellable_cancel (self->cancellable);
-       g_clear_object (&self->cancellable);
-
        g_clear_object (&self->properties);
        g_clear_object (&self->rfkill);
 
@@ -101,7 +96,7 @@ enable_switch_changed_cb (CcBluetoothPanel *self)
                                                 g_variant_new_boolean (!state)),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
-                          self->cancellable,
+                          cc_panel_get_cancellable (CC_PANEL (self)),
                           NULL, NULL);
 }
 
@@ -193,7 +188,7 @@ airplane_mode_off_button_clicked_cb (CcBluetoothPanel *self)
                                                 g_variant_new_boolean (FALSE)),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
-                          self->cancellable,
+                          cc_panel_get_cancellable (CC_PANEL (self)),
                           NULL, NULL);
 }
 
@@ -246,8 +241,6 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
 
        gtk_widget_init_template (GTK_WIDGET (self));
 
-       self->cancellable = g_cancellable_new ();
-
        /* RFKill */
        self->rfkill = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SESSION,
                                                                 G_DBUS_PROXY_FLAGS_NONE,
diff --git a/panels/camera/cc-camera-panel.c b/panels/camera/cc-camera-panel.c
index 9dee58d4d..516aae02f 100644
--- a/panels/camera/cc-camera-panel.c
+++ b/panels/camera/cc-camera-panel.c
@@ -38,8 +38,6 @@ struct _CcCameraPanel
 
   GSettings    *privacy_settings;
 
-  GCancellable *cancellable;
-
   GDBusProxy   *perm_store;
   GVariant     *camera_apps_perms;
   GVariant     *camera_apps_data;
@@ -145,7 +143,7 @@ on_camera_app_state_set (GtkSwitch *widget,
                      params,
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      on_perm_store_set_done,
                      data);
 
@@ -353,7 +351,7 @@ on_perm_store_ready (GObject      *source_object,
                      params,
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      on_perm_store_lookup_done,
                      self);
 }
@@ -363,9 +361,7 @@ cc_camera_panel_finalize (GObject *object)
 {
   CcCameraPanel *self = CC_CAMERA_PANEL (object);
 
-  g_cancellable_cancel (self->cancellable);
   g_clear_object (&self->privacy_settings);
-  g_clear_object (&self->cancellable);
   g_clear_object (&self->perm_store);
   g_clear_object (&self->camera_icon_size_group);
   g_clear_pointer (&self->camera_apps_perms, g_variant_unref);
@@ -437,8 +433,6 @@ cc_camera_panel_init (CcCameraPanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  self->cancellable = g_cancellable_new ();
-
   gtk_list_box_set_header_func (self->camera_apps_list_box,
                                 cc_list_box_update_header_func,
                                 NULL,
@@ -459,7 +453,7 @@ cc_camera_panel_init (CcCameraPanel *self)
                             "org.freedesktop.impl.portal.PermissionStore",
                             "/org/freedesktop/impl/portal/PermissionStore",
                             "org.freedesktop.impl.portal.PermissionStore",
-                            self->cancellable,
+                            cc_panel_get_cancellable (CC_PANEL (self)),
                             on_perm_store_ready,
                             self);
 }
diff --git a/panels/color/cc-color-panel.c b/panels/color/cc-color-panel.c
index 49ca35220..c87bac04d 100644
--- a/panels/color/cc-color-panel.c
+++ b/panels/color/cc-color-panel.c
@@ -43,7 +43,6 @@ struct _CcColorPanel
   CdDevice      *current_device;
   GPtrArray     *devices;
   GPtrArray     *sensors;
-  GCancellable  *cancellable;
   GDBusProxy    *proxy;
   GSettings     *settings;
   GSettings     *settings_colord;
@@ -218,7 +217,7 @@ gcm_prefs_default_cb (GtkWidget *widget, CcColorPanel *prefs)
 
   /* install somewhere out of $HOME */
   ret = cd_profile_install_system_wide_sync (profile,
-                                             prefs->cancellable,
+                                             cc_panel_get_cancellable (CC_PANEL (prefs)),
                                              &error);
   if (!ret)
     g_warning ("failed to set profile system-wide: %s",
@@ -733,7 +732,7 @@ gcm_prefs_add_profiles_suitable_for_devices (CcColorPanel *prefs,
 
   /* get profiles */
   profile_array = cd_client_get_profiles_sync (prefs->client,
-                                               prefs->cancellable,
+                                               cc_panel_get_cancellable (CC_PANEL (prefs)),
                                                &error);
   if (profile_array == NULL)
     {
@@ -749,7 +748,7 @@ gcm_prefs_add_profiles_suitable_for_devices (CcColorPanel *prefs,
 
       /* get properties */
       ret = cd_profile_connect_sync (profile_tmp,
-                                     prefs->cancellable,
+                                     cc_panel_get_cancellable (CC_PANEL (prefs)),
                                      &error);
       if (!ret)
         {
@@ -967,7 +966,7 @@ gcm_prefs_profile_remove_cb (GtkWidget *widget, CcColorPanel *prefs)
   /* just remove it, the list store will get ::changed */
   ret = cd_device_remove_profile_sync (prefs->current_device,
                                        profile,
-                                       prefs->cancellable,
+                                       cc_panel_get_cancellable (CC_PANEL (prefs)),
                                        &error);
   if (!ret)
     g_warning ("failed to remove profile: %s", error->message);
@@ -1020,7 +1019,7 @@ gcm_prefs_device_profile_enable_cb (GtkWidget *widget, CcColorPanel *prefs)
            cd_device_get_id (prefs->current_device));
   cd_device_make_profile_default (prefs->current_device,
                                   profile,
-                                  prefs->cancellable,
+                                  cc_panel_get_cancellable (CC_PANEL (prefs)),
                                   (GAsyncReadyCallback) gcm_prefs_make_profile_default_cb,
                                   prefs);
 }
@@ -1133,7 +1132,7 @@ gcm_prefs_button_assign_ok_cb (GtkWidget *widget, CcColorPanel *prefs)
     {
       ret = cd_device_set_enabled_sync (prefs->current_device,
                                         TRUE,
-                                        prefs->cancellable,
+                                        cc_panel_get_cancellable (CC_PANEL (prefs)),
                                         &error);
       if (!ret)
         {
@@ -1146,7 +1145,7 @@ gcm_prefs_button_assign_ok_cb (GtkWidget *widget, CcColorPanel *prefs)
   ret = cd_device_add_profile_sync (prefs->current_device,
                                     CD_DEVICE_RELATION_HARD,
                                     profile,
-                                    prefs->cancellable,
+                                    cc_panel_get_cancellable (CC_PANEL (prefs)),
                                     &error);
   if (!ret)
     {
@@ -1157,7 +1156,7 @@ gcm_prefs_button_assign_ok_cb (GtkWidget *widget, CcColorPanel *prefs)
   /* make it default */
   cd_device_make_profile_default (prefs->current_device,
                                   profile,
-                                  prefs->cancellable,
+                                  cc_panel_get_cancellable (CC_PANEL (prefs)),
                                   (GAsyncReadyCallback) gcm_prefs_make_profile_default_cb,
                                   prefs);
 }
@@ -1368,7 +1367,7 @@ gcm_prefs_button_assign_import_cb (GtkWidget *widget,
 #if CD_CHECK_VERSION(0,1,12)
   profile = cd_client_import_profile_sync (prefs->client,
                                            file,
-                                           prefs->cancellable,
+                                           cc_panel_get_cancellable (CC_PANEL (prefs)),
                                            &error);
   if (profile == NULL)
     {
@@ -1440,7 +1439,7 @@ gcm_prefs_add_device_profile (CcColorPanel *prefs,
 
   /* get properties */
   ret = cd_profile_connect_sync (profile,
-                                 prefs->cancellable,
+                                 cc_panel_get_cancellable (CC_PANEL (prefs)),
                                  &error);
   if (!ret)
     {
@@ -1636,7 +1635,7 @@ gcm_prefs_add_device (CcColorPanel *prefs, CdDevice *device)
   GtkWidget *widget;
 
   /* get device properties */
-  ret = cd_device_connect_sync (device, prefs->cancellable, &error);
+  ret = cd_device_connect_sync (device, cc_panel_get_cancellable (CC_PANEL (prefs)), &error);
   if (!ret)
     {
       g_warning ("failed to connect to the device: %s", error->message);
@@ -1852,7 +1851,7 @@ gcm_prefs_connect_cb (GObject *object,
 
   /* get devices */
   cd_client_get_devices (prefs->client,
-                         prefs->cancellable,
+                         cc_panel_get_cancellable (CC_PANEL (prefs)),
                          gcm_prefs_get_devices_cb,
                          prefs);
 }
@@ -1955,10 +1954,8 @@ cc_color_panel_dispose (GObject *object)
       g_clear_pointer (&prefs->devices, g_ptr_array_unref);
     }
 
-  g_cancellable_cancel (prefs->cancellable);
   g_clear_object (&prefs->settings);
   g_clear_object (&prefs->settings_colord);
-  g_clear_object (&prefs->cancellable);
   g_clear_object (&prefs->client);
   g_clear_object (&prefs->current_device);
   g_clear_object (&prefs->calibrate);
@@ -2097,7 +2094,6 @@ cc_color_panel_init (CcColorPanel *prefs)
 
   gtk_widget_init_template (GTK_WIDGET (prefs));
 
-  prefs->cancellable = g_cancellable_new ();
   prefs->devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
 
   /* can do native display calibration using colord-session */
@@ -2303,7 +2299,7 @@ cc_color_panel_init (CcColorPanel *prefs)
 
   /* connect to colord */
   cd_client_connect (prefs->client,
-                     prefs->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (prefs)),
                      gcm_prefs_connect_cb,
                      prefs);
 
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 843116d34..7f64a31a1 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -83,7 +83,6 @@ struct _CcDisplayPanel
   gboolean lid_is_closed;
 
   GDBusProxy *shell_proxy;
-  GCancellable *shell_cancellable;
 
   guint       sensor_watch_id;
   GDBusProxy *iio_sensor_proxy;
@@ -431,8 +430,6 @@ cc_display_panel_dispose (GObject *object)
   g_clear_object (&self->current_config);
   g_clear_object (&self->up_client);
 
-  g_cancellable_cancel (self->shell_cancellable);
-  g_clear_object (&self->shell_cancellable);
   g_clear_object (&self->shell_proxy);
 
   g_clear_pointer ((GtkWidget **) &self->night_light_dialog, gtk_widget_destroy);
@@ -1244,7 +1241,6 @@ cc_display_panel_init (CcDisplayPanel *self)
 
   g_signal_connect (self, "map", G_CALLBACK (mapped_cb), NULL);
 
-  self->shell_cancellable = g_cancellable_new ();
   cc_object_storage_create_dbus_proxy (G_BUS_TYPE_SESSION,
                                        G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
                                        G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
@@ -1252,12 +1248,12 @@ cc_display_panel_init (CcDisplayPanel *self)
                                        "org.gnome.Shell",
                                        "/org/gnome/Shell",
                                        "org.gnome.Shell",
-                                       self->shell_cancellable,
+                                       cc_panel_get_cancellable (CC_PANEL (self)),
                                        (GAsyncReadyCallback) shell_proxy_ready,
                                        self);
 
   g_bus_get (G_BUS_TYPE_SESSION,
-             self->shell_cancellable,
+             cc_panel_get_cancellable (CC_PANEL (self)),
              (GAsyncReadyCallback) session_bus_ready,
              self);
 
diff --git a/panels/location/cc-location-panel.c b/panels/location/cc-location-panel.c
index dc8f3773f..cca3346ed 100644
--- a/panels/location/cc-location-panel.c
+++ b/panels/location/cc-location-panel.c
@@ -39,8 +39,6 @@ struct _CcLocationPanel
 
   GSettings    *location_settings;
 
-  GCancellable *cancellable;
-
   GDBusProxy   *perm_store;
   GVariant     *location_apps_perms;
   GVariant     *location_apps_data;
@@ -137,7 +135,7 @@ on_location_app_state_set (GtkSwitch *widget,
                      params,
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      on_perm_store_set_done,
                      data);
 
@@ -363,7 +361,7 @@ on_perm_store_ready (GObject      *source_object,
                      params,
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      on_perm_store_lookup_done,
                      self);
 }
@@ -373,9 +371,7 @@ cc_location_panel_finalize (GObject *object)
 {
   CcLocationPanel *self = CC_LOCATION_PANEL (object);
 
-  g_cancellable_cancel (self->cancellable);
   g_clear_object (&self->location_settings);
-  g_clear_object (&self->cancellable);
   g_clear_object (&self->perm_store);
   g_clear_object (&self->location_icon_size_group);
   g_clear_pointer (&self->location_apps_perms, g_variant_unref);
@@ -455,7 +451,6 @@ cc_location_panel_init (CcLocationPanel *self)
   gtk_list_box_set_header_func (self->location_apps_list_box,
                                 cc_list_box_update_header_func,
                                 NULL, NULL);
-  self->cancellable = g_cancellable_new ();
   self->location_icon_size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
   self->location_settings = g_settings_new ("org.gnome.system.location");
 
@@ -470,7 +465,7 @@ cc_location_panel_init (CcLocationPanel *self)
                             "org.freedesktop.impl.portal.PermissionStore",
                             "/org/freedesktop/impl/portal/PermissionStore",
                             "org.freedesktop.impl.portal.PermissionStore",
-                            self->cancellable,
+                            cc_panel_get_cancellable (CC_PANEL (self)),
                             on_perm_store_ready,
                             self);
 }
diff --git a/panels/microphone/cc-microphone-panel.c b/panels/microphone/cc-microphone-panel.c
index 7168786e2..8e115c06d 100644
--- a/panels/microphone/cc-microphone-panel.c
+++ b/panels/microphone/cc-microphone-panel.c
@@ -38,8 +38,6 @@ struct _CcMicrophonePanel
 
   GSettings    *privacy_settings;
 
-  GCancellable *cancellable;
-
   GDBusProxy   *perm_store;
   GVariant     *microphone_apps_perms;
   GVariant     *microphone_apps_data;
@@ -138,7 +136,7 @@ on_microphone_app_state_set (GtkSwitch *widget,
                      params,
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      on_perm_store_set_done,
                      data);
 
@@ -347,7 +345,7 @@ on_perm_store_ready (GObject      *source_object,
                      params,
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      on_perm_store_lookup_done,
                      self);
 }
@@ -357,9 +355,7 @@ cc_microphone_panel_finalize (GObject *object)
 {
   CcMicrophonePanel *self = CC_MICROPHONE_PANEL (object);
 
-  g_cancellable_cancel (self->cancellable);
   g_clear_object (&self->privacy_settings);
-  g_clear_object (&self->cancellable);
   g_clear_object (&self->perm_store);
   g_clear_object (&self->microphone_icon_size_group);
   g_clear_pointer (&self->microphone_apps_perms, g_variant_unref);
@@ -431,8 +427,6 @@ cc_microphone_panel_init (CcMicrophonePanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  self->cancellable = g_cancellable_new ();
-
   gtk_list_box_set_header_func (self->microphone_apps_list_box,
                                 cc_list_box_update_header_func,
                                 NULL, NULL);
@@ -452,7 +446,7 @@ cc_microphone_panel_init (CcMicrophonePanel *self)
                             "org.freedesktop.impl.portal.PermissionStore",
                             "/org/freedesktop/impl/portal/PermissionStore",
                             "org.freedesktop.impl.portal.PermissionStore",
-                            self->cancellable,
+                            cc_panel_get_cancellable (CC_PANEL (self)),
                             on_perm_store_ready,
                             self);
 }
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index da2625c1e..2080475b7 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -59,7 +59,6 @@ struct _CcWifiPanel
   GPtrArray          *devices;
 
   GBinding           *spinner_binding;
-  GCancellable       *cancellable;
 
   /* Command-line arguments */
   CmdlineOperation    arg_operation;
@@ -524,7 +523,7 @@ rfkill_switch_notify_activate_cb (GtkSwitch   *rfkill_switch,
                                            g_variant_new_boolean (enable)),
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      NULL,
                      NULL);
 }
@@ -592,9 +591,6 @@ cc_wifi_panel_finalize (GObject *object)
 {
   CcWifiPanel *self = (CcWifiPanel *)object;
 
-  g_cancellable_cancel (self->cancellable);
-
-  g_clear_object (&self->cancellable);
   g_clear_object (&self->client);
   g_clear_object (&self->rfkill_proxy);
 
@@ -710,7 +706,6 @@ cc_wifi_panel_init (CcWifiPanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  self->cancellable = g_cancellable_new ();
   self->devices = g_ptr_array_new ();
 
   /* Create and store a NMClient instance if it doesn't exist yet */
@@ -750,7 +745,7 @@ cc_wifi_panel_init (CcWifiPanel *self)
                                        "org.gnome.SettingsDaemon.Rfkill",
                                        "/org/gnome/SettingsDaemon/Rfkill",
                                        "org.gnome.SettingsDaemon.Rfkill",
-                                       self->cancellable,
+                                       cc_panel_get_cancellable (CC_PANEL (self)),
                                        rfkill_proxy_acquired_cb,
                                        self);
 
diff --git a/panels/notifications/cc-notifications-panel.c b/panels/notifications/cc-notifications-panel.c
index e630619e6..1d8f831f7 100644
--- a/panels/notifications/cc-notifications-panel.c
+++ b/panels/notifications/cc-notifications-panel.c
@@ -47,7 +47,7 @@ struct _CcNotificationsPanel {
 
   GSettings         *master_settings;
 
-  GCancellable      *apps_load_cancellable;
+  GCancellable      *cancellable;
 
   GHashTable        *known_applications;
 
@@ -89,8 +89,6 @@ cc_notifications_panel_dispose (GObject *object)
   g_clear_pointer (&panel->sections, g_list_free);
   g_clear_pointer (&panel->sections_reverse, g_list_free);
 
-  g_cancellable_cancel (panel->apps_load_cancellable);
-
   G_OBJECT_CLASS (cc_notifications_panel_parent_class)->dispose (object);
 }
 
@@ -99,7 +97,6 @@ cc_notifications_panel_finalize (GObject *object)
 {
   CcNotificationsPanel *panel = CC_NOTIFICATIONS_PANEL (object);
 
-  g_clear_object (&panel->apps_load_cancellable);
   g_clear_object (&panel->perm_store);
 
   G_OBJECT_CLASS (cc_notifications_panel_parent_class)->finalize (object);
@@ -211,7 +208,7 @@ cc_notifications_panel_init (CcNotificationsPanel *panel)
                             "org.freedesktop.impl.portal.PermissionStore",
                             "/org/freedesktop/impl/portal/PermissionStore",
                             "org.freedesktop.impl.portal.PermissionStore",
-                            panel->apps_load_cancellable,
+                            cc_panel_get_cancellable (CC_PANEL (panel)),
                             on_perm_store_ready,
                             panel);
 }
@@ -396,7 +393,7 @@ queued_app_info (gpointer data)
   app = data;
   panel = g_steal_pointer (&app->panel);
 
-  if (g_cancellable_is_cancelled (panel->apps_load_cancellable) ||
+  if (g_cancellable_is_cancelled (panel->cancellable) ||
       g_hash_table_contains (panel->known_applications,
                              app->canonical_app_id))
     return FALSE;
@@ -503,8 +500,8 @@ load_apps_async (CcNotificationsPanel *panel)
 {
   g_autoptr(GTask) task = NULL;
 
-  panel->apps_load_cancellable = g_cancellable_new ();
-  task = g_task_new (panel, panel->apps_load_cancellable, NULL, NULL);
+  panel->cancellable = cc_panel_get_cancellable (CC_PANEL (panel)); // FIXME: Storing reference to 
cancellable because it will be accessed inside the thread
+  task = g_task_new (panel, cc_panel_get_cancellable (CC_PANEL (panel)), NULL, NULL);
   g_task_run_in_thread (task, load_apps_thread);
 }
 
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 843eefe20..7624dcd3f 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -59,7 +59,6 @@ struct _CcPowerPanel
 
   GSettings     *gsd_settings;
   GSettings     *session_settings;
-  GCancellable  *cancellable;
   GtkWidget     *main_scroll;
   GtkWidget     *main_box;
   GtkWidget     *vbox_power;
@@ -145,8 +144,6 @@ cc_power_panel_dispose (GObject *object)
   g_clear_pointer (&self->chassis_type, g_free);
   g_clear_object (&self->gsd_settings);
   g_clear_object (&self->session_settings);
-  g_cancellable_cancel (self->cancellable);
-  g_clear_object (&self->cancellable);
   g_clear_pointer (&self->automatic_suspend_dialog, gtk_widget_destroy);
   g_clear_object (&self->screen_proxy);
   g_clear_object (&self->kbd_proxy);
@@ -1077,7 +1074,7 @@ brightness_slider_value_changed_cb (GtkRange *range, gpointer user_data)
                      g_variant_ref_sink (variant),
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
-                     self->cancellable,
+                     cc_panel_get_cancellable (CC_PANEL (self)),
                      set_brightness_cb,
                      user_data);
 }
@@ -1392,7 +1389,7 @@ bt_set_powered (CcPowerPanel *self,
                                           g_variant_new_boolean (!powered)),
                     G_DBUS_CALL_FLAGS_NONE,
                     -1,
-                    self->cancellable,
+                    cc_panel_get_cancellable (CC_PANEL (self)),
                     NULL, NULL);
 }
 
@@ -1981,7 +1978,7 @@ add_power_saving_section (CcPowerPanel *self)
   if (cc_object_storage_has_object (CC_OBJECT_NMCLIENT))
     setup_nm_client (self, cc_object_storage_get_object (CC_OBJECT_NMCLIENT));
   else
-    nm_client_new_async (self->cancellable, nm_client_ready_cb, self);
+    nm_client_new_async (cc_panel_get_cancellable (CC_PANEL (self)), nm_client_ready_cb, self);
 
   g_signal_connect (G_OBJECT (self->wifi_switch), "notify::active",
                     G_CALLBACK (wifi_switch_changed), self);
@@ -2194,7 +2191,7 @@ can_suspend_or_hibernate (CcPowerPanel *self,
   const char *s;
 
   connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
-                               self->cancellable,
+                               cc_panel_get_cancellable (CC_PANEL (self)),
                                &error);
   if (!connection)
     {
@@ -2212,7 +2209,7 @@ can_suspend_or_hibernate (CcPowerPanel *self,
                                          NULL,
                                          G_DBUS_CALL_FLAGS_NONE,
                                          -1,
-                                         self->cancellable,
+                                         cc_panel_get_cancellable (CC_PANEL (self)),
                                          &error);
 
   if (!variant)
@@ -2511,14 +2508,12 @@ cc_power_panel_init (CcPowerPanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  self->cancellable = g_cancellable_new ();
-
   cc_object_storage_create_dbus_proxy (G_BUS_TYPE_SESSION,
                                        G_DBUS_PROXY_FLAGS_NONE,
                                        "org.gnome.SettingsDaemon.Power",
                                        "/org/gnome/SettingsDaemon/Power",
                                        "org.gnome.SettingsDaemon.Power.Screen",
-                                       self->cancellable,
+                                       cc_panel_get_cancellable (CC_PANEL (self)),
                                        got_screen_proxy_cb,
                                        self);
   cc_object_storage_create_dbus_proxy (G_BUS_TYPE_SESSION,
@@ -2526,11 +2521,11 @@ cc_power_panel_init (CcPowerPanel *self)
                                        "org.gnome.SettingsDaemon.Power",
                                        "/org/gnome/SettingsDaemon/Power",
                                        "org.gnome.SettingsDaemon.Power.Keyboard",
-                                       self->cancellable,
+                                       cc_panel_get_cancellable (CC_PANEL (self)),
                                        got_kbd_proxy_cb,
                                        self);
 
-  self->chassis_type = get_chassis_type (self->cancellable);
+  self->chassis_type = get_chassis_type (cc_panel_get_cancellable (CC_PANEL (self)));
 
   self->up_client = up_client_new ();
 
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index da2f6916f..8ee4cbf1c 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -92,11 +92,6 @@ struct _CcPrintersPanel
 
   GtkRevealer  *notification;
   PPDList      *all_ppds_list;
-  GCancellable *get_all_ppds_cancellable;
-  GCancellable *subscription_renew_cancellable;
-  GCancellable *actualize_printers_list_cancellable;
-  GCancellable *cups_status_check_cancellable;
-  GCancellable *get_job_attributes_cancellable;
 
   gchar    *new_printer_name;
   gchar    *new_printer_location;
@@ -277,12 +272,6 @@ cc_printers_panel_dispose (GObject *object)
 {
   CcPrintersPanel *self = CC_PRINTERS_PANEL (object);
 
-  g_cancellable_cancel (self->subscription_renew_cancellable);
-  g_cancellable_cancel (self->actualize_printers_list_cancellable);
-  g_cancellable_cancel (self->cups_status_check_cancellable);
-  g_cancellable_cancel (self->get_all_ppds_cancellable);
-  g_cancellable_cancel (self->get_job_attributes_cancellable);
-
   detach_from_cups_notifier (CC_PRINTERS_PANEL (object));
 
   if (self->deleted_printer_name != NULL)
@@ -303,18 +292,13 @@ cc_printers_panel_dispose (GObject *object)
   g_clear_object (&self->builder);
   g_clear_object (&self->lockdown_settings);
   g_clear_object (&self->permission);
-  g_clear_object (&self->subscription_renew_cancellable);
-  g_clear_object (&self->actualize_printers_list_cancellable);
-  g_clear_object (&self->cups_status_check_cancellable);
   g_clear_handle_id (&self->cups_status_check_id, g_source_remove);
   g_clear_handle_id (&self->remove_printer_timeout_id, g_source_remove);
-  g_clear_object (&self->get_all_ppds_cancellable);
   g_clear_pointer (&self->deleted_printer_name, g_free);
   g_clear_pointer (&self->action, g_variant_unref);
   g_clear_pointer (&self->printer_entries, g_hash_table_destroy);
   g_clear_pointer (&self->all_ppds_list, ppd_list_free);
   free_dests (self);
-  g_clear_object (&self->get_job_attributes_cancellable);
 
   G_OBJECT_CLASS (cc_printers_panel_parent_class)->dispose (object);
 }
@@ -471,7 +455,7 @@ on_cups_notification (GDBusConnection *connection,
       job = g_object_new (PP_TYPE_JOB, "id", job_id, NULL);
       pp_job_get_attributes_async (job,
                                    requested_attrs,
-                                   self->get_job_attributes_cancellable,
+                                   cc_panel_get_cancellable (CC_PANEL (self)),
                                    on_get_job_attributes_cb,
                                    self);
     }
@@ -513,7 +497,7 @@ renew_subscription (gpointer data)
                                     self->subscription_id,
                                     subscription_events,
                                     SUBSCRIPTION_DURATION,
-                                    self->subscription_renew_cancellable,
+                                    cc_panel_get_cancellable (CC_PANEL (self)),
                                     renew_subscription_cb,
                                     data);
 
@@ -581,7 +565,7 @@ attach_to_cups_notifier (gpointer data)
                                     self->subscription_id,
                                     subscription_events,
                                     SUBSCRIPTION_DURATION,
-                                    self->subscription_renew_cancellable,
+                                    cc_panel_get_cancellable (CC_PANEL (self)),
                                     attach_to_cups_notifier_cb,
                                     data);
 }
@@ -886,7 +870,7 @@ actualize_printers_list (CcPrintersPanel *self)
 
   cups = pp_cups_new ();
   pp_cups_get_dests_async (cups,
-                           self->actualize_printers_list_cancellable,
+                           cc_panel_get_cancellable (CC_PANEL (self)),
                            actualize_printers_list_cb,
                            self);
 }
@@ -1134,9 +1118,6 @@ get_all_ppds_async_cb (PPDList  *ppds,
   if (self->pp_new_printer_dialog)
     pp_new_printer_dialog_set_ppd_list (self->pp_new_printer_dialog,
                                         self->all_ppds_list);
-
-  g_object_unref (self->get_all_ppds_cancellable);
-  self->get_all_ppds_cancellable = NULL;
 }
 
 static gboolean
@@ -1223,10 +1204,6 @@ cc_printers_panel_init (CcPrintersPanel *self)
   self->entries_filled = FALSE;
   self->action = NULL;
 
-  self->actualize_printers_list_cancellable = g_cancellable_new ();
-  self->cups_status_check_cancellable = g_cancellable_new ();
-  self->get_job_attributes_cancellable = g_cancellable_new ();
-
   g_type_ensure (CC_TYPE_PERMISSION_INFOBAR);
 
   builder_result = gtk_builder_add_objects_from_resource (self->builder,
@@ -1307,20 +1284,17 @@ cc_printers_panel_init (CcPrintersPanel *self)
 \"org.opensuse.cupspkhelper.mechanism.all-edit\" installed. \
 Please check your installation");
 
-  self->subscription_renew_cancellable = g_cancellable_new ();
-
   self->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
   actualize_printers_list (self);
   attach_to_cups_notifier (self);
 
-  self->get_all_ppds_cancellable = g_cancellable_new ();
-  get_all_ppds_async (self->get_all_ppds_cancellable,
+  get_all_ppds_async (cc_panel_get_cancellable (CC_PANEL (self)),
                       get_all_ppds_async_cb,
                       self);
 
   cups = pp_cups_new ();
-  pp_cups_connection_test_async (cups, self->cups_status_check_cancellable, connection_test_cb, self);
+  pp_cups_connection_test_async (cups, cc_panel_get_cancellable (CC_PANEL (self)), connection_test_cb, self);
   gtk_container_add (GTK_CONTAINER (self), top_widget);
   gtk_widget_show_all (GTK_WIDGET (self));
 }
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index e0604b8c3..9b59b23c4 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -89,7 +89,6 @@ struct _CcRegionPanel {
         GPermission *permission;
         GDBusProxy  *localed;
         GDBusProxy  *session;
-        GCancellable *cancellable;
 
         ActUserManager *user_manager;
         ActUser        *user;
@@ -144,9 +143,6 @@ cc_region_panel_finalize (GObject *object)
         CcRegionPanel *self = CC_REGION_PANEL (object);
         GtkWidget *chooser;
 
-        g_cancellable_cancel (self->cancellable);
-        g_clear_object (&self->cancellable);
-
         if (self->user_manager) {
                 g_signal_handlers_disconnect_by_data (self->user_manager, self);
                 self->user_manager = NULL;
@@ -345,7 +341,7 @@ maybe_notify (CcRegionPanel *self,
                            g_variant_new ("(i)", category),
                            G_DBUS_CALL_FLAGS_NONE,
                            -1,
-                           self->cancellable,
+                           cc_panel_get_cancellable (CC_PANEL (self)),
                            maybe_notify_finish,
                            mnd);
 }
@@ -535,7 +531,7 @@ activate_language_row (CcRegionPanel *self,
                         show_language_chooser (self);
                 } else if (g_permission_get_can_acquire (self->permission)) {
                         g_permission_acquire_async (self->permission,
-                                                    self->cancellable,
+                                                    cc_panel_get_cancellable (CC_PANEL (self)),
                                                     choose_language_permission_cb,
                                                     self);
                 }
@@ -544,7 +540,7 @@ activate_language_row (CcRegionPanel *self,
                         show_region_chooser (self);
                 } else if (g_permission_get_can_acquire (self->permission)) {
                         g_permission_acquire_async (self->permission,
-                                                    self->cancellable,
+                                                    cc_panel_get_cancellable (CC_PANEL (self)),
                                                     choose_region_permission_cb,
                                                     self);
                 }
@@ -697,7 +693,7 @@ fetch_ibus_engines (CcRegionPanel *self)
 {
         ibus_bus_list_engines_async (self->ibus,
                                      -1,
-                                     self->cancellable,
+                                     cc_panel_get_cancellable (CC_PANEL (self)),
                                      (GAsyncReadyCallback)fetch_ibus_engines_result,
                                      self);
 
@@ -1019,7 +1015,7 @@ add_input (CcRegionPanel *self)
                 show_input_chooser (self);
         } else if (g_permission_get_can_acquire (self->permission)) {
                 g_permission_acquire_async (self->permission,
-                                            self->cancellable,
+                                            cc_panel_get_cancellable (CC_PANEL (self)),
                                             add_input_permission_cb,
                                             self);
         }
@@ -1082,7 +1078,7 @@ remove_input (CcRegionPanel *self, CcInputRow *row)
                 do_remove_input (self, row);
         } else if (g_permission_get_can_acquire (self->permission)) {
                 g_permission_acquire_async (self->permission,
-                                            self->cancellable,
+                                            cc_panel_get_cancellable (CC_PANEL (self)),
                                             remove_input_permission_cb,
                                             row_data_new (self, row, NULL));
         }
@@ -1124,7 +1120,7 @@ move_input (CcRegionPanel *self,
                 do_move_input (self, source, dest);
         } else if (g_permission_get_can_acquire (self->permission)) {
                 g_permission_acquire_async (self->permission,
-                                            self->cancellable,
+                                            cc_panel_get_cancellable (CC_PANEL (self)),
                                             move_input_permission_cb,
                                             row_data_new (self, source, dest));
         }
@@ -1504,7 +1500,7 @@ setup_login_button (CcRegionPanel *self)
                           "org.freedesktop.locale1",
                           "/org/freedesktop/locale1",
                           "org.freedesktop.locale1",
-                          self->cancellable,
+                          cc_panel_get_cancellable (CC_PANEL (self)),
                           (GAsyncReadyCallback) localed_proxy_ready,
                           self);
 
@@ -1597,15 +1593,13 @@ cc_region_panel_init (CcRegionPanel *self)
 
         self->user_manager = act_user_manager_get_default ();
 
-        self->cancellable = g_cancellable_new ();
-
         g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                                   G_DBUS_PROXY_FLAGS_NONE,
                                   NULL,
                                   "org.gnome.SessionManager",
                                   "/org/gnome/SessionManager",
                                   "org.gnome.SessionManager",
-                                  self->cancellable,
+                                  cc_panel_get_cancellable (CC_PANEL (self)),
                                   session_proxy_ready,
                                   self);
 
diff --git a/panels/search/cc-search-panel.c b/panels/search/cc-search-panel.c
index e7095d8cb..b0d4d42d6 100644
--- a/panels/search/cc-search-panel.c
+++ b/panels/search/cc-search-panel.c
@@ -37,7 +37,6 @@ struct _CcSearchPanel
   GtkWidget  *settings_button;
   CcSearchPanelRow  *selected_row;
 
-  GCancellable *load_cancellable;
   GSettings  *search_settings;
   GHashTable *sort_order;
 
@@ -511,8 +510,6 @@ search_providers_discover_ready (GObject *source,
   if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
     return;
 
-  g_clear_object (&self->load_cancellable);
-
   if (providers == NULL)
     {
       search_panel_set_no_providers (self);
@@ -608,23 +605,11 @@ populate_search_providers (CcSearchPanel *self)
 {
   g_autoptr(GTask) task = NULL;
 
-  self->load_cancellable = g_cancellable_new ();
-  task = g_task_new (self, self->load_cancellable,
+  task = g_task_new (self, cc_panel_get_cancellable (CC_PANEL (self)),
                      search_providers_discover_ready, self);
   g_task_run_in_thread (task, search_providers_discover_thread);
 }
 
-static void
-cc_search_panel_dispose (GObject *object)
-{
-  CcSearchPanel *self = CC_SEARCH_PANEL (object);
-
-  g_cancellable_cancel (self->load_cancellable);
-  g_clear_object (&self->load_cancellable);
-
-  G_OBJECT_CLASS (cc_search_panel_parent_class)->dispose (object);
-}
-
 static void
 cc_search_panel_finalize (GObject *object)
 {
@@ -700,7 +685,6 @@ cc_search_panel_class_init (CcSearchPanelClass *klass)
   GObjectClass *oclass = G_OBJECT_CLASS (klass);
 
   oclass->constructed = cc_search_panel_constructed;
-  oclass->dispose = cc_search_panel_dispose;
   oclass->finalize = cc_search_panel_finalize;
 
   gtk_widget_class_set_template_from_resource (widget_class,
diff --git a/panels/sharing/cc-sharing-panel.c b/panels/sharing/cc-sharing-panel.c
index 25c1ce7a2..bbcc9a80c 100644
--- a/panels/sharing/cc-sharing-panel.c
+++ b/panels/sharing/cc-sharing-panel.c
@@ -98,12 +98,8 @@ struct _CcSharingPanel
   GtkWidget *shared_folders_listbox;
   GtkWidget *show_password_checkbutton;
 
-  GCancellable *sharing_proxy_cancellable;
   GDBusProxy *sharing_proxy;
 
-  GCancellable *remote_login_cancellable;
-  GCancellable *hostname_cancellable;
-
   guint remote_desktop_name_watch;
 };
 
@@ -167,18 +163,6 @@ cc_sharing_panel_dispose (GObject *object)
       self->personal_file_sharing_dialog = NULL;
     }
 
-  if (self->remote_login_cancellable)
-    {
-      g_cancellable_cancel (self->remote_login_cancellable);
-      g_clear_object (&self->remote_login_cancellable);
-    }
-
-  if (self->hostname_cancellable)
-    {
-      g_cancellable_cancel (self->hostname_cancellable);
-      g_clear_object (&self->hostname_cancellable);
-    }
-
   if (self->remote_login_dialog)
     {
       gtk_widget_destroy (self->remote_login_dialog);
@@ -191,8 +175,6 @@ cc_sharing_panel_dispose (GObject *object)
       self->screen_sharing_dialog = NULL;
     }
 
-  g_cancellable_cancel (self->sharing_proxy_cancellable);
-  g_clear_object (&self->sharing_proxy_cancellable);
   g_clear_object (&self->sharing_proxy);
 
   G_OBJECT_CLASS (cc_sharing_panel_parent_class)->dispose (object);
@@ -825,7 +807,7 @@ cc_sharing_panel_bus_ready (GObject         *object,
                           (GVariantType*)"(s)",
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
-                          data->panel->hostname_cancellable,
+                          cc_panel_get_cancellable (CC_PANEL (data->panel)),
                           cc_sharing_panel_get_host_name_fqdn_done,
                           data);
   g_steal_pointer (&data);
@@ -865,7 +847,7 @@ cc_sharing_panel_setup_label_with_hostname (CcSharingPanel *self,
   get_hostname_data->panel = self;
   get_hostname_data->label = label;
   g_bus_get (G_BUS_TYPE_SYSTEM,
-             self->hostname_cancellable,
+             cc_panel_get_cancellable (CC_PANEL (self)),
              cc_sharing_panel_bus_ready,
              get_hostname_data);
 }
@@ -948,7 +930,7 @@ remote_login_switch_activate (GtkSwitch      *remote_login_switch,
                               GParamSpec     *pspec,
                               CcSharingPanel *self)
 {
-  cc_remote_login_set_enabled (self->remote_login_cancellable, remote_login_switch);
+  cc_remote_login_set_enabled (cc_panel_get_cancellable (CC_PANEL (self)), remote_login_switch);
 }
 
 static void
@@ -963,7 +945,7 @@ cc_sharing_panel_setup_remote_login_dialog (CcSharingPanel *self)
                     G_CALLBACK (remote_login_switch_activate), self);
   gtk_widget_set_sensitive (self->remote_login_switch, FALSE);
 
-  cc_remote_login_get_enabled (self->remote_login_cancellable,
+  cc_remote_login_get_enabled (cc_panel_get_cancellable (CC_PANEL (self)),
                                GTK_SWITCH (self->remote_login_switch),
                                self->remote_login_button);
 }
@@ -1271,10 +1253,6 @@ cc_sharing_panel_init (CcSharingPanel *self)
   g_signal_connect (self->main_list_box, "row-activated",
                     G_CALLBACK (cc_sharing_panel_main_list_box_row_activated), self);
 
-  self->hostname_cancellable = g_cancellable_new ();
-
-  self->remote_login_cancellable = g_cancellable_new ();
-
   g_signal_connect (self->media_sharing_dialog, "response",
                     G_CALLBACK (gtk_widget_hide), NULL);
   g_signal_connect (self->personal_file_sharing_dialog, "response",
@@ -1306,12 +1284,11 @@ cc_sharing_panel_init (CcSharingPanel *self)
   g_signal_connect (self->master_switch, "notify::active",
                     G_CALLBACK (cc_sharing_panel_master_switch_notify), self);
 
-  self->sharing_proxy_cancellable = g_cancellable_new ();
   gsd_sharing_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                                  G_DBUS_PROXY_FLAGS_NONE,
                                  "org.gnome.SettingsDaemon.Sharing",
                                  "/org/gnome/SettingsDaemon/Sharing",
-                                 self->sharing_proxy_cancellable,
+                                 cc_panel_get_cancellable (CC_PANEL (self)),
                                  sharing_proxy_ready,
                                  self);
 
diff --git a/panels/thunderbolt/cc-bolt-panel.c b/panels/thunderbolt/cc-bolt-panel.c
index 805666ed6..9004c3c9b 100644
--- a/panels/thunderbolt/cc-bolt-panel.c
+++ b/panels/thunderbolt/cc-bolt-panel.c
@@ -40,7 +40,6 @@ struct _CcBoltPanel
   CcPanel             parent;
 
   BoltClient         *client;
-  GCancellable       *cancel;
 
   /* headerbar menu */
   GtkBox             *headerbar_box;
@@ -280,7 +279,7 @@ devices_table_synchronize (CcBoltPanel *panel)
   g_autoptr(GError) err = NULL;
   guint i;
 
-  devices = bolt_client_list_devices (panel->client, panel->cancel, &err);
+  devices = bolt_client_list_devices (panel->client, cc_panel_get_cancellable (CC_PANEL (panel)), &err);
 
   if (!devices)
     {
@@ -533,7 +532,7 @@ cc_bolt_panel_name_owner_changed (CcBoltPanel *panel)
     {
       polkit_permission_new ("org.freedesktop.bolt.manage",
                              NULL,
-                             panel->cancel,
+                             cc_panel_get_cancellable (CC_PANEL (panel)),
                              on_permission_ready,
                              g_object_ref (panel));
     }
@@ -566,7 +565,7 @@ on_bolt_device_added_cb (BoltClient  *cli,
     return;
 
   bus = g_dbus_proxy_get_connection (G_DBUS_PROXY (panel->client));
-  dev = bolt_device_new_for_object_path (bus, path, panel->cancel, &err);
+  dev = bolt_device_new_for_object_path (bus, path, cc_panel_get_cancellable (CC_PANEL (panel)), &err);
 
   if (!dev)
     {
@@ -898,10 +897,6 @@ cc_bolt_panel_dispose (GObject *object)
 {
   CcBoltPanel *panel = CC_BOLT_PANEL (object);
 
-  /* cancel any ongoing operation */
-  g_cancellable_cancel (panel->cancel);
-  g_clear_object (&panel->cancel);
-
   /* Must be destroyed in dispose, not finalize. */
   g_clear_pointer ((GtkWidget **) &panel->device_dialog, gtk_widget_destroy);
 
@@ -994,7 +989,6 @@ cc_bolt_panel_init (CcBoltPanel *panel)
                            G_CALLBACK (on_device_dialog_delete_event_cb),
                            panel, 0);
 
-  panel->cancel = g_cancellable_new ();
-  bolt_client_new_async (panel->cancel, bolt_client_ready, g_object_ref (panel));
+  bolt_client_new_async (cc_panel_get_cancellable (CC_PANEL (panel)), bolt_client_ready, g_object_ref 
(panel));
 
 }
diff --git a/panels/user-accounts/cc-user-panel.c b/panels/user-accounts/cc-user-panel.c
index 49eea54bf..c2af402a1 100644
--- a/panels/user-accounts/cc-user-panel.c
+++ b/panels/user-accounts/cc-user-panel.c
@@ -62,7 +62,6 @@ struct _CcUserPanel {
         CcPanel parent_instance;
 
         ActUserManager *um;
-        GCancellable  *cancellable;
         GSettings *login_screen_settings;
 
         GtkBox          *accounts_box;
@@ -548,7 +547,7 @@ enterprise_user_uncached (GObject           *source,
         act_user_manager_uncache_user_finish (manager, res, &error);
         if (error == NULL) {
                 /* Find realm manager */
-                cc_realm_manager_new (self->cancellable, realm_manager_found, data);
+                cc_realm_manager_new (cc_panel_get_cancellable (CC_PANEL (self)), realm_manager_found, data);
         }
         else {
                 show_error_dialog (self, _("Failed to revoke remotely managed user"), error);
@@ -576,7 +575,7 @@ delete_enterprise_user_response (GtkWidget          *dialog,
 
         data = g_slice_new (AsyncDeleteData);
         data->self = g_object_ref (self);
-        data->cancellable = g_object_ref (self->cancellable);
+        data->cancellable = g_object_ref (cc_panel_get_cancellable (CC_PANEL (self)));
         data->login = g_strdup (act_user_get_user_name (user));
 
         /* Uncache the user account from the accountsservice */
@@ -1457,7 +1456,6 @@ cc_user_panel_init (CcUserPanel *self)
         gtk_widget_init_template (GTK_WIDGET (self));
 
         self->um = act_user_manager_get_default ();
-        self->cancellable = g_cancellable_new ();
 
         provider = gtk_css_provider_new ();
         gtk_css_provider_load_from_resource (provider, 
"/org/gnome/control-center/user-accounts/user-accounts-dialog.css");
@@ -1477,9 +1475,6 @@ cc_user_panel_dispose (GObject *object)
 {
         CcUserPanel *self = CC_USER_PANEL (object);
 
-        g_cancellable_cancel (self->cancellable);
-        g_clear_object (&self->cancellable);
-
         g_clear_object (&self->login_screen_settings);
 
         g_clear_pointer ((GtkWidget **)&self->language_chooser, gtk_widget_destroy);
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index c0c15b3aa..4c9208fc3 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -63,7 +63,6 @@ struct _CcWacomPanel
        CcTabletToolMap  *tablet_tool_map;
 
        /* DBus */
-       GCancellable  *cancellable;
        GDBusProxy    *proxy;
 };
 
@@ -253,7 +252,6 @@ cc_wacom_panel_dispose (GObject *object)
        }
 
        g_clear_pointer (&self->devices, g_hash_table_unref);
-       g_clear_object (&self->cancellable);
        g_clear_object (&self->proxy);
        g_clear_pointer (&self->pages, g_hash_table_unref);
        g_clear_pointer (&self->stylus_pages, g_hash_table_unref);
@@ -694,8 +692,6 @@ got_osd_proxy_cb (GObject      *source_object,
        self = CC_WACOM_PANEL (data);
        self->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
 
-       g_clear_object (&self->cancellable);
-
        if (self->proxy == NULL) {
                g_printerr ("Error creating proxy: %s\n", error->message);
                return;
@@ -762,15 +758,13 @@ cc_wacom_panel_init (CcWacomPanel *self)
 
        self->tablet_tool_map = cc_tablet_tool_map_new ();
 
-       self->cancellable = g_cancellable_new ();
-
        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                                  G_DBUS_PROXY_FLAGS_NONE,
                                  NULL,
                                  "org.gnome.Shell",
                                  "/org/gnome/Shell/Wacom",
                                  "org.gnome.Shell.Wacom.PadOsd",
-                                 self->cancellable,
+                                 cc_panel_get_cancellable (CC_PANEL (self)),
                                  got_osd_proxy_cb,
                                  self);
 
diff --git a/shell/cc-panel.c b/shell/cc-panel.c
index e3ae384fb..e14bd0f5c 100644
--- a/shell/cc-panel.c
+++ b/shell/cc-panel.c
@@ -47,8 +47,9 @@ typedef struct
   gchar    *category;
   gchar    *current_location;
 
-  gboolean  is_active;
-  CcShell  *shell;
+  gboolean      is_active;
+  CcShell      *shell;
+  GCancellable *cancellable;
 } CcPanelPrivate;
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (CcPanel, cc_panel, GTK_TYPE_BIN)
@@ -148,6 +149,9 @@ cc_panel_finalize (GObject *object)
   g_clear_pointer (&priv->id, g_free);
   g_clear_pointer (&priv->display_name, g_free);
 
+  g_cancellable_cancel (priv->cancellable);
+  g_clear_object (&priv->cancellable);
+
   G_OBJECT_CLASS (cc_panel_parent_class)->finalize (object);
 }
 
@@ -247,3 +251,16 @@ cc_panel_get_sidebar_widget (CcPanel *panel)
 
   return NULL;
 }
+
+GCancellable *
+cc_panel_get_cancellable (CcPanel *panel)
+{
+  CcPanelPrivate *priv = cc_panel_get_instance_private (panel);
+
+  g_return_val_if_fail (CC_IS_PANEL (panel), NULL);
+
+  if (priv->cancellable == NULL)
+    priv->cancellable = g_cancellable_new ();
+
+  return priv->cancellable;
+}
diff --git a/shell/cc-panel.h b/shell/cc-panel.h
index 545d6af5c..35cb9c4eb 100644
--- a/shell/cc-panel.h
+++ b/shell/cc-panel.h
@@ -84,15 +84,17 @@ struct _CcPanelClass
   GtkWidget*   (*get_sidebar_widget) (CcPanel *panel);
 };
 
-CcShell*     cc_panel_get_shell          (CcPanel     *panel);
+CcShell*      cc_panel_get_shell          (CcPanel     *panel);
 
-GPermission* cc_panel_get_permission     (CcPanel     *panel);
+GPermission*  cc_panel_get_permission     (CcPanel     *panel);
 
-const gchar* cc_panel_get_help_uri       (CcPanel     *panel);
+const gchar*  cc_panel_get_help_uri       (CcPanel     *panel);
 
-GtkWidget*   cc_panel_get_title_widget   (CcPanel     *panel);
+GtkWidget*    cc_panel_get_title_widget   (CcPanel     *panel);
 
-GtkWidget*   cc_panel_get_sidebar_widget (CcPanel     *panel);
+GtkWidget*    cc_panel_get_sidebar_widget (CcPanel     *panel);
+
+GCancellable *cc_panel_get_cancellable    (CcPanel     *panel);
 
 G_END_DECLS
 


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