From 2e5c5026bcf4d8d8977bd717aa87dd2b8f788c32 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 7 Feb 2010 17:00:08 +0100 Subject: [PATCH] Only set config properties which are present in the config file --- midori/main.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/midori/main.c b/midori/main.c index db008aa9..b8480b6d 100644 --- a/midori/main.c +++ b/midori/main.c @@ -104,46 +104,40 @@ settings_new_from_file (const gchar* filename, pspec = pspecs[i]; if (!(pspec->flags & G_PARAM_WRITABLE)) continue; + type = G_PARAM_SPEC_TYPE (pspec); property = g_param_spec_get_name (pspec); + if (!g_key_file_has_key (key_file, "settings", property, NULL)) + continue; + if (type == G_TYPE_PARAM_STRING) { - str = sokoke_key_file_get_string_default (key_file, - "settings", property, - G_PARAM_SPEC_STRING (pspec)->default_value, NULL); + str = g_key_file_get_string (key_file, "settings", property, NULL); g_object_set (settings, property, str, NULL); g_free (str); } else if (type == G_TYPE_PARAM_INT) { - integer = sokoke_key_file_get_integer_default (key_file, - "settings", property, - G_PARAM_SPEC_INT (pspec)->default_value, NULL); + integer = g_key_file_get_integer (key_file, "settings", property, NULL); g_object_set (settings, property, integer, NULL); } else if (type == G_TYPE_PARAM_FLOAT) { - number = sokoke_key_file_get_double_default (key_file, - "settings", property, - G_PARAM_SPEC_FLOAT (pspec)->default_value, NULL); + number = g_key_file_get_double (key_file, "settings", property, NULL); g_object_set (settings, property, number, NULL); } else if (type == G_TYPE_PARAM_BOOLEAN) { - boolean = sokoke_key_file_get_boolean_default (key_file, - "settings", property, - G_PARAM_SPEC_BOOLEAN (pspec)->default_value, NULL); + boolean = g_key_file_get_boolean (key_file, "settings", property, NULL); g_object_set (settings, property, boolean, NULL); } else if (type == G_TYPE_PARAM_ENUM) { GEnumClass* enum_class = G_ENUM_CLASS ( - g_type_class_ref (pspec->value_type)); - GEnumValue* enum_value = g_enum_get_value (enum_class, - G_PARAM_SPEC_ENUM (pspec)->default_value); - str = sokoke_key_file_get_string_default (key_file, - "settings", property, - enum_value->value_name, NULL); + g_type_class_peek (pspec->value_type)); + GEnumValue* enum_value; + + str = g_key_file_get_string (key_file, "settings", property, NULL); enum_value = g_enum_get_value_by_name (enum_class, str); if (enum_value) g_object_set (settings, property, enum_value->value, NULL); -- 2.39.5