mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
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>
This commit is contained in:
parent
fe0ce2814e
commit
d76743736f
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user