[mutter] context: Add way to set plugin GType instead of name



commit d76743736fffded296094374d9e5e92bae9764db
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Mar 3 13:55:32 2021 +0100

    context: Add way to set plugin GType instead of name
    
    Will be used by gnome-shell.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 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 c28c03f3b4..12f8f9eab4 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 b872e1ca58..c45217839b 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);


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