From: Christian Dywan Date: Sun, 9 Sep 2012 19:40:46 +0000 (+0200) Subject: Dissolve keyfile "default" wrappers into Midori.Extension X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ad675e24ed02cacea7aa00fead8e9f4f1941d67;p=midori Dissolve keyfile "default" wrappers into Midori.Extension --- diff --git a/midori/midori-extension.c b/midori/midori-extension.c index fe52679b..88344f53 100644 --- a/midori/midori-extension.c +++ b/midori/midori-extension.c @@ -341,29 +341,32 @@ midori_extension_activate_cb (MidoriExtension* extension, if (setting->type == G_TYPE_BOOLEAN) { MESettingBoolean* setting_ = (MESettingBoolean*)setting; - if (extension->priv->key_file) - setting_->value = sokoke_key_file_get_boolean_default ( - extension->priv->key_file, - "settings", setting->name, setting_->default_value, NULL); + if (extension->priv->key_file + && g_key_file_has_key (extension->priv->key_file, "settings", setting_->name, NULL)) + setting_->value = g_key_file_get_boolean (extension->priv->key_file, + "settings", setting->name, NULL); else setting_->value = setting_->default_value; } else if (setting->type == G_TYPE_INT) { MESettingInteger* setting_ = (MESettingInteger*)setting; - if (extension->priv->key_file) - setting_->value = sokoke_key_file_get_integer_default ( - extension->priv->key_file, - "settings", setting->name, setting_->default_value, NULL); + if (extension->priv->key_file + && g_key_file_has_key (extension->priv->key_file, "settings", setting_->name, NULL)) + setting_->value = g_key_file_get_integer (extension->priv->key_file, + "settings", setting_->name, NULL); else setting_->value = setting_->default_value; } else if (setting->type == G_TYPE_STRING) { if (extension->priv->key_file) - setting->value = sokoke_key_file_get_string_default ( - extension->priv->key_file, - "settings", setting->name, setting->default_value, NULL); + { + setting->value = g_key_file_get_string ( + extension->priv->key_file, "settings", setting->name, NULL); + if (setting->value == NULL) + setting->value = setting->default_value; + } else setting->value = g_strdup (setting->default_value); } @@ -372,10 +375,10 @@ midori_extension_activate_cb (MidoriExtension* extension, MESettingStringList* setting_ = (MESettingStringList*)setting; if (extension->priv->key_file) { - setting_->value = sokoke_key_file_get_string_list_default ( - extension->priv->key_file, - "settings", setting->name, &setting_->length, - setting_->default_value, &setting_->default_length, NULL); + setting_->value = g_key_file_get_string_list (extension->priv->key_file, + "settings", setting->name, &setting_->length, NULL); + if (setting_->value == NULL) + setting_->value = g_strdupv (setting_->default_value); } else setting_->value = g_strdupv (setting_->default_value); diff --git a/midori/sokoke.c b/midori/sokoke.c index 8bca3e26..f476f3c1 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -785,72 +785,6 @@ sokoke_xfce_header_new (const gchar* icon, return NULL; } -gchar* -sokoke_key_file_get_string_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - const gchar* default_value, - GError** error) -{ - gchar* value = g_key_file_get_string (key_file, group, key, error); - return value == NULL ? g_strdup (default_value) : value; -} - -gint -sokoke_key_file_get_integer_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - const gint default_value, - GError** error) -{ - if (!g_key_file_has_key (key_file, group, key, NULL)) - return default_value; - return g_key_file_get_integer (key_file, group, key, error); -} - -gdouble -sokoke_key_file_get_double_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - const gdouble default_value, - GError** error) -{ - if (!g_key_file_has_key (key_file, group, key, NULL)) - return default_value; - return g_key_file_get_double (key_file, group, key, error); -} - -gboolean -sokoke_key_file_get_boolean_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - const gboolean default_value, - GError** error) -{ - if (!g_key_file_has_key (key_file, group, key, NULL)) - return default_value; - return g_key_file_get_boolean (key_file, group, key, error); -} - -gchar** -sokoke_key_file_get_string_list_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - gsize* length, - gchar** default_value, - gsize* default_length, - GError* error) -{ - gchar** value = g_key_file_get_string_list (key_file, group, key, length, NULL); - if (!value) - { - value = g_strdupv (default_value); - if (length) - *length = *default_length; - } - return value; -} - gboolean sokoke_key_file_save_to_file (GKeyFile* key_file, const gchar* filename, diff --git a/midori/sokoke.h b/midori/sokoke.h index 9a25ad64..ca411c54 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -72,47 +72,6 @@ GtkWidget* sokoke_xfce_header_new (const gchar* icon, const gchar* title); -void -sokoke_entry_set_default_text (GtkEntry* entry, - const gchar* default_text); - -gchar* -sokoke_key_file_get_string_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - const gchar* default_value, - GError** error); - -gint -sokoke_key_file_get_integer_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - const gint default_value, - GError** error); - -gdouble -sokoke_key_file_get_double_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - gdouble default_value, - GError** error); - -gboolean -sokoke_key_file_get_boolean_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - gboolean default_value, - GError** error); - -gchar** -sokoke_key_file_get_string_list_default (GKeyFile* key_file, - const gchar* group, - const gchar* key, - gsize* length, - gchar** default_value, - gsize* default_length, - GError* error); - gboolean sokoke_key_file_save_to_file (GKeyFile* key_file, const gchar* filename,