[mutter/wip/carlosg/clutter-settings-gsettings: 2/2] clutter: Do not read settings from ini file
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/clutter-settings-gsettings: 2/2] clutter: Do not read settings from ini file
- Date: Fri, 29 Jan 2021 01:12:51 +0000 (UTC)
commit d1c62d882ab8e90219b69a10d7b4df339d58e967
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jan 28 20:44:04 2021 +0100
clutter: Do not read settings from ini file
We've inherited, and still keep in place, code that reads ini files
at ~/.config/clutter-1.0/settings.ini and /etc/clutter-1.0/settings.ini
to tweak different aspects of Clutter.
Some of these should use GSettings instead, some others are exposed
nowadays differently for our purposes (e.g. envvars, looking glass, ...).
Overall seems like an unexpected entry point nowadays, so remove the
parsing of these .ini files altogether.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1693>
clutter/clutter/clutter-main.c | 199 -----------------------------
clutter/clutter/clutter-settings-private.h | 2 -
clutter/clutter/clutter-settings.c | 103 ---------------
3 files changed, 304 deletions(-)
---
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index c1fc47e57e..aa297e8554 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -131,199 +131,6 @@ static const GDebugKey clutter_paint_debug_keys[] = {
{ "damage-region", CLUTTER_DEBUG_PAINT_DAMAGE_REGION },
};
-#define ENVIRONMENT_GROUP "Environment"
-#define DEBUG_GROUP "Debug"
-
-static void
-clutter_config_read_from_key_file (GKeyFile *keyfile)
-{
- GError *key_error = NULL;
- gboolean bool_value;
- gint int_value;
- gchar *str_value;
-
- 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",
- &key_error);
-
- if (key_error != NULL)
- g_clear_error (&key_error);
- else
- clutter_show_fps = bool_value;
-
- bool_value =
- g_key_file_get_boolean (keyfile, ENVIRONMENT_GROUP,
- "DisableMipmappedText",
- &key_error);
-
- if (key_error != NULL)
- g_clear_error (&key_error);
- else
- clutter_disable_mipmap_text = bool_value;
-
- bool_value =
- g_key_file_get_boolean (keyfile, ENVIRONMENT_GROUP,
- "EnableAccessibility",
- &key_error);
-
- if (key_error != NULL)
- g_clear_error (&key_error);
- else
- clutter_enable_accessibility = bool_value;
-
- int_value =
- g_key_file_get_integer (keyfile, ENVIRONMENT_GROUP,
- "DefaultFps",
- &key_error);
-
- if (key_error != NULL)
- g_clear_error (&key_error);
- else
- clutter_default_fps = int_value;
-
- str_value =
- g_key_file_get_string (keyfile, ENVIRONMENT_GROUP,
- "TextDirection",
- &key_error);
-
- if (key_error != NULL)
- g_clear_error (&key_error);
- else
- {
- if (g_strcmp0 (str_value, "rtl") == 0)
- clutter_text_direction = CLUTTER_TEXT_DIRECTION_RTL;
- else
- clutter_text_direction = CLUTTER_TEXT_DIRECTION_LTR;
- }
-
- g_free (str_value);
-}
-
-#ifdef CLUTTER_ENABLE_DEBUG
-static void
-clutter_debug_read_from_key_file (GKeyFile *keyfile)
-{
- GError *key_error = NULL;
- gchar *value;
-
- if (!g_key_file_has_group (keyfile, DEBUG_GROUP))
- return;
-
- value = g_key_file_get_value (keyfile, DEBUG_GROUP,
- "Debug",
- &key_error);
- if (key_error == NULL)
- {
- clutter_debug_flags |=
- g_parse_debug_string (value,
- clutter_debug_keys,
- G_N_ELEMENTS (clutter_debug_keys));
- }
- else
- g_clear_error (&key_error);
-
- g_free (value);
-
- value = g_key_file_get_value (keyfile, DEBUG_GROUP,
- "PaintDebug",
- &key_error);
- if (key_error == NULL)
- {
- clutter_paint_debug_flags |=
- g_parse_debug_string (value,
- clutter_paint_debug_keys,
- G_N_ELEMENTS (clutter_paint_debug_keys));
- }
- else
- g_clear_error (&key_error);
-
- g_free (value);
-
- value = g_key_file_get_value (keyfile, DEBUG_GROUP,
- "PickDebug",
- &key_error);
- if (key_error == NULL)
- {
- clutter_pick_debug_flags |=
- g_parse_debug_string (value,
- clutter_pick_debug_keys,
- G_N_ELEMENTS (clutter_pick_debug_keys));
- }
- else
- g_clear_error (&key_error);
-
- g_free (value);
-}
-#endif
-
-static void
-clutter_config_read_from_file (const gchar *config_path)
-{
- ClutterSettings *settings = clutter_settings_get_default ();
- GKeyFile *key_file = g_key_file_new ();
- GError *error = NULL;
-
- g_key_file_load_from_file (key_file, config_path, G_KEY_FILE_NONE, &error);
- if (error == NULL)
- {
- CLUTTER_NOTE (MISC, "Reading configuration from '%s'", config_path);
-
- clutter_config_read_from_key_file (key_file);
-#ifdef CLUTTER_ENABLE_DEBUG
- clutter_debug_read_from_key_file (key_file);
-#endif
- _clutter_settings_read_from_key_file (settings, key_file);
- }
- else
- {
- g_warning ("Unable to read configuration settings from '%s': %s",
- config_path,
- error->message);
- g_error_free (error);
- }
-
- g_key_file_free (key_file);
-}
-
-static void
-clutter_config_read (void)
-{
- gchar *config_path;
-
- config_path = g_build_filename (CLUTTER_SYSCONFDIR,
- "clutter-1.0",
- "settings.ini",
- NULL);
- if (g_file_test (config_path, G_FILE_TEST_EXISTS))
- clutter_config_read_from_file (config_path);
-
- g_free (config_path);
-
- config_path = g_build_filename (g_get_user_config_dir (),
- "clutter-1.0",
- "settings.ini",
- NULL);
- if (g_file_test (config_path, G_FILE_TEST_EXISTS))
- clutter_config_read_from_file (config_path);
-
- g_free (config_path);
-}
-
gboolean
_clutter_context_get_show_fps (void)
{
@@ -679,12 +486,6 @@ _clutter_context_get_default (void)
{
ClutterMainContext *ctx;
- /* Read the configuration file, if any, before we set up the
- * whole thing, so that we can override things like the backend
- * and the driver
- */
- clutter_config_read ();
-
ClutterCntx = ctx = g_new0 (ClutterMainContext, 1);
ctx->is_initialized = FALSE;
diff --git a/clutter/clutter/clutter-settings-private.h b/clutter/clutter/clutter-settings-private.h
index 244122c1f7..7df4fccf18 100644
--- a/clutter/clutter/clutter-settings-private.h
+++ b/clutter/clutter/clutter-settings-private.h
@@ -8,8 +8,6 @@ G_BEGIN_DECLS
void _clutter_settings_set_backend (ClutterSettings *settings,
ClutterBackend *backend);
-void _clutter_settings_read_from_key_file (ClutterSettings *settings,
- GKeyFile *key_file);
void clutter_settings_set_property_internal (ClutterSettings *settings,
const char *property,
diff --git a/clutter/clutter/clutter-settings.c b/clutter/clutter/clutter-settings.c
index 260a74a886..e80dd2450f 100644
--- a/clutter/clutter/clutter-settings.c
+++ b/clutter/clutter/clutter-settings.c
@@ -958,106 +958,3 @@ _clutter_settings_set_backend (ClutterSettings *settings,
load_initial_settings (settings);
}
-
-#define SETTINGS_GROUP "Settings"
-
-void
-_clutter_settings_read_from_key_file (ClutterSettings *settings,
- GKeyFile *keyfile)
-{
- GObjectClass *settings_class;
- GObject *settings_obj;
- GParamSpec **pspecs;
- guint n_pspecs, i;
-
- if (!g_key_file_has_group (keyfile, SETTINGS_GROUP))
- return;
-
- settings_obj = G_OBJECT (settings);
- settings_class = G_OBJECT_GET_CLASS (settings);
- pspecs = g_object_class_list_properties (settings_class, &n_pspecs);
-
- for (i = 0; i < n_pspecs; i++)
- {
- GParamSpec *pspec = pspecs[i];
- const gchar *p_name = pspec->name;
- GType p_type = G_TYPE_FUNDAMENTAL (pspec->value_type);
- GValue value = G_VALUE_INIT;
- GError *key_error = NULL;
-
- g_value_init (&value, p_type);
-
- switch (p_type)
- {
- case G_TYPE_INT:
- case G_TYPE_UINT:
- {
- gint val;
-
- val = g_key_file_get_integer (keyfile,
- SETTINGS_GROUP, p_name,
- &key_error);
- if (p_type == G_TYPE_INT)
- g_value_set_int (&value, val);
- else
- g_value_set_uint (&value, val);
- }
- break;
-
- case G_TYPE_BOOLEAN:
- {
- gboolean val;
-
- val = g_key_file_get_boolean (keyfile,
- SETTINGS_GROUP, p_name,
- &key_error);
- g_value_set_boolean (&value, val);
- }
- break;
-
- case G_TYPE_FLOAT:
- case G_TYPE_DOUBLE:
- {
- gdouble val;
-
- val = g_key_file_get_double (keyfile,
- SETTINGS_GROUP, p_name,
- &key_error);
- if (p_type == G_TYPE_FLOAT)
- g_value_set_float (&value, val);
- else
- g_value_set_double (&value, val);
- }
- break;
-
- case G_TYPE_STRING:
- {
- gchar *val;
-
- val = g_key_file_get_string (keyfile,
- SETTINGS_GROUP, p_name,
- &key_error);
- g_value_take_string (&value, val);
- }
- break;
- }
-
- if (key_error != NULL &&
- key_error->domain != G_KEY_FILE_ERROR &&
- key_error->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND)
- {
- g_critical ("Unable to read the value for setting '%s': %s",
- p_name,
- key_error->message);
- }
-
- if (key_error == NULL)
- g_object_set_property (settings_obj, p_name, &value);
- else
- g_error_free (key_error);
-
- g_value_unset (&value);
- }
-
- g_free (pspecs);
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]