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.
This commit is contained in:
parent
0aad22079f
commit
93b14a4339
19 changed files with 100 additions and 221 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue