clutter/context: Create a Settings when constructed

Instead of removing Settings.get_default, we mark it as deprecated
as a lot of extensions seems to use it

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
This commit is contained in:
Bilal Elmoussaoui 2024-08-20 21:48:34 +02:00
parent 8013049130
commit 1abbfb5ed2
3 changed files with 7 additions and 7 deletions

View File

@ -98,6 +98,7 @@ clutter_context_dispose (GObject *object)
g_clear_pointer (&context->events_queue, g_async_queue_unref); g_clear_pointer (&context->events_queue, g_async_queue_unref);
g_clear_pointer (&context->backend, clutter_backend_destroy); g_clear_pointer (&context->backend, clutter_backend_destroy);
g_clear_object (&context->stage_manager); g_clear_object (&context->stage_manager);
g_clear_object (&context->settings);
G_OBJECT_CLASS (clutter_context_parent_class)->dispose (object); G_OBJECT_CLASS (clutter_context_parent_class)->dispose (object);
} }
@ -268,7 +269,7 @@ clutter_context_new (ClutterBackendConstructor backend_constructor,
context->show_fps = clutter_show_fps; context->show_fps = clutter_show_fps;
context->backend = backend_constructor (context, user_data); context->backend = backend_constructor (context, user_data);
context->settings = clutter_settings_get_default (); context->settings = g_object_new (CLUTTER_TYPE_SETTINGS, NULL);
_clutter_settings_set_backend (context->settings, _clutter_settings_set_backend (context->settings,
context->backend); context->backend);

View File

@ -901,16 +901,15 @@ clutter_settings_init (ClutterSettings *self)
* Return value: (transfer none): the instance of #ClutterSettings. The * Return value: (transfer none): the instance of #ClutterSettings. The
* returned object is owned by Clutter and it should not be unreferenced * returned object is owned by Clutter and it should not be unreferenced
* directly * directly
*
* Deprecated: Use [method@Clutter.Context.get_settings] instead
*/ */
ClutterSettings * ClutterSettings *
clutter_settings_get_default (void) clutter_settings_get_default (void)
{ {
static ClutterSettings *settings = NULL; ClutterContext *context = _clutter_context_get_default ();
if (G_UNLIKELY (settings == NULL)) return clutter_context_get_settings (context);
settings = g_object_new (CLUTTER_TYPE_SETTINGS, NULL);
return settings;
} }
void void

View File

@ -15,7 +15,7 @@ G_DECLARE_FINAL_TYPE (ClutterSettings, clutter_settings,
CLUTTER, SETTINGS, CLUTTER, SETTINGS,
GObject) GObject)
CLUTTER_EXPORT CLUTTER_DEPRECATED_FOR (clutter_context_get_settings)
ClutterSettings *clutter_settings_get_default (void); ClutterSettings *clutter_settings_get_default (void);
G_END_DECLS G_END_DECLS