settings: Convert to the singleton pattern
We only have a single source of settings, so we should reflect that by using a singleton. This also reduces our LoC. This doesn't impair our ability to run tests because there we run with GSETTINGS_BACKEND=memory
This commit is contained in:
@@ -195,14 +195,21 @@ calls_settings_init (CallsSettings *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_settings_new:
|
||||
* calls_settings_get_default:
|
||||
*
|
||||
* Returns: (transfer full): A #CallsSettings.
|
||||
* Returns: (transfer none): A #CallsSettings.
|
||||
*/
|
||||
CallsSettings *
|
||||
calls_settings_new (void)
|
||||
calls_settings_get_default (void)
|
||||
{
|
||||
return g_object_new (CALLS_TYPE_SETTINGS, NULL);
|
||||
static CallsSettings *instance = NULL;
|
||||
|
||||
if (!instance) {
|
||||
instance = g_object_new (CALLS_TYPE_SETTINGS, NULL);
|
||||
g_object_add_weak_pointer (G_OBJECT (instance), (gpointer *)&instance);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user