[clutter] Allow overriding the list of Cogl drivers via configuration file



commit 407d7ca436842b5461828066d8aecf86ff826f12
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Dec 10 16:52:45 2015 +0000

    Allow overriding the list of Cogl drivers via configuration file
    
    Clutter has a configuration file that can be used to override
    various settings, including the ones from environment variables.

 clutter/clutter-backend-private.h |    1 +
 clutter/clutter-backend.c         |    8 +++++++-
 clutter/clutter-main.c            |   11 +++++++++++
 3 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/clutter/clutter-backend-private.h b/clutter/clutter-backend-private.h
index 6e1e7ec..eb44941 100644
--- a/clutter/clutter-backend-private.h
+++ b/clutter/clutter-backend-private.h
@@ -153,6 +153,7 @@ PangoDirection          _clutter_backend_get_keymap_direction           (Clutter
 
 void                    _clutter_backend_reset_cogl_framebuffer         (ClutterBackend         *backend);
 
+void                    clutter_set_allowed_drivers                     (const char             *drivers);
 
 G_END_DECLS
 
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
index 71710e3..d9ce53f 100644
--- a/clutter/clutter-backend.c
+++ b/clutter/clutter-backend.c
@@ -373,7 +373,7 @@ static const struct {
   { "any", "Default Cogl driver", COGL_DRIVER_ANY },
 };
 
-static char *allowed_drivers;
+static const char *allowed_drivers;
 
 static gboolean
 clutter_backend_real_create_context (ClutterBackend  *backend,
@@ -1509,3 +1509,9 @@ _clutter_backend_reset_cogl_framebuffer (ClutterBackend *backend)
 
   cogl_set_framebuffer (COGL_FRAMEBUFFER (backend->dummy_onscreen));
 }
+
+void
+clutter_set_allowed_drivers (const char *drivers)
+{
+  allowed_drivers = g_strdup (drivers);
+}
diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c
index 3d2130c..e9cf9b0 100644
--- a/clutter/clutter-main.c
+++ b/clutter/clutter-main.c
@@ -221,6 +221,17 @@ clutter_config_read_from_key_file (GKeyFile *keyfile)
   if (!g_key_file_has_group (keyfile, ENVIRONMENT_GROUP))
     return;
 
+  str_value =
+    g_key_file_get_string (keyfile, ENVIRONMENT_GROUP,
+                           "Drivers",
+                           &key_error);
+  if (key_error != NULL)
+    g_clear_error (&key_error);
+  else
+    clutter_set_allowed_drivers (str_value);
+
+  g_free (str_value);
+
   bool_value =
     g_key_file_get_boolean (keyfile, ENVIRONMENT_GROUP,
                             "ShowFps",


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