From d76743736fffded296094374d9e5e92bae9764db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 3 Mar 2021 13:55:32 +0100 Subject: [PATCH] context: Add way to set plugin GType instead of name Will be used by gnome-shell. Part-of: --- src/core/meta-context.c | 23 +++++++++++++++++++++-- src/meta/meta-context.h | 4 ++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/core/meta-context.c b/src/core/meta-context.c index c28c03f3b..12f8f9eab 100644 --- a/src/core/meta-context.c +++ b/src/core/meta-context.c @@ -50,6 +50,7 @@ typedef struct _MetaContextPrivate { char *name; char *plugin_name; + GType plugin_gtype; GOptionContext *option_context; @@ -71,12 +72,25 @@ meta_context_add_option_entries (MetaContext *context, translation_domain); } +void +meta_context_set_plugin_gtype (MetaContext *context, + GType plugin_gtype) +{ + MetaContextPrivate *priv = meta_context_get_instance_private (context); + + g_return_if_fail (!priv->plugin_name); + + priv->plugin_gtype = plugin_gtype; +} + void meta_context_set_plugin_name (MetaContext *context, const char *plugin_name) { MetaContextPrivate *priv = meta_context_get_instance_private (context); + g_return_if_fail (priv->plugin_gtype == G_TYPE_NONE); + priv->plugin_name = g_strdup (plugin_name); } @@ -216,7 +230,7 @@ meta_context_setup (MetaContext *context, MetaContextPrivate *priv = meta_context_get_instance_private (context); MetaCompositorType compositor_type; - if (!priv->plugin_name) + if (!priv->plugin_name && priv->plugin_gtype == G_TYPE_NONE) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No compositor plugin set"); @@ -233,7 +247,10 @@ meta_context_setup (MetaContext *context, priv->name, VERSION, compositor_type_to_description (compositor_type)); - meta_plugin_manager_load (priv->plugin_name); + if (priv->plugin_name) + meta_plugin_manager_load (priv->plugin_name); + else + meta_plugin_manager_set_plugin_type (priv->plugin_gtype); init_introspection (context); @@ -438,6 +455,8 @@ meta_context_init (MetaContext *context) g_assert (!_context_temporary); _context_temporary = context; + priv->plugin_gtype = G_TYPE_NONE; + if (!setlocale (LC_ALL, "")) g_warning ("Locale not understood by C library"); bindtextdomain (GETTEXT_PACKAGE, MUTTER_LOCALEDIR); diff --git a/src/meta/meta-context.h b/src/meta/meta-context.h index b872e1ca5..c45217839 100644 --- a/src/meta/meta-context.h +++ b/src/meta/meta-context.h @@ -38,6 +38,10 @@ void meta_context_add_option_entries (MetaContext *context, const GOptionEntry *entries, const char *translation_domain); +META_EXPORT +void meta_context_set_plugin_gtype (MetaContext *context, + GType plugin_gtype); + META_EXPORT void meta_context_set_plugin_name (MetaContext *context, const char *plugin_name);