Dissolve keyfile "default" wrappers into Midori.Extension
This commit is contained in:
parent
f715e11ebf
commit
1ad675e24e
3 changed files with 18 additions and 122 deletions
|
@ -341,29 +341,32 @@ midori_extension_activate_cb (MidoriExtension* extension,
|
||||||
if (setting->type == G_TYPE_BOOLEAN)
|
if (setting->type == G_TYPE_BOOLEAN)
|
||||||
{
|
{
|
||||||
MESettingBoolean* setting_ = (MESettingBoolean*)setting;
|
MESettingBoolean* setting_ = (MESettingBoolean*)setting;
|
||||||
if (extension->priv->key_file)
|
if (extension->priv->key_file
|
||||||
setting_->value = sokoke_key_file_get_boolean_default (
|
&& g_key_file_has_key (extension->priv->key_file, "settings", setting_->name, NULL))
|
||||||
extension->priv->key_file,
|
setting_->value = g_key_file_get_boolean (extension->priv->key_file,
|
||||||
"settings", setting->name, setting_->default_value, NULL);
|
"settings", setting->name, NULL);
|
||||||
else
|
else
|
||||||
setting_->value = setting_->default_value;
|
setting_->value = setting_->default_value;
|
||||||
}
|
}
|
||||||
else if (setting->type == G_TYPE_INT)
|
else if (setting->type == G_TYPE_INT)
|
||||||
{
|
{
|
||||||
MESettingInteger* setting_ = (MESettingInteger*)setting;
|
MESettingInteger* setting_ = (MESettingInteger*)setting;
|
||||||
if (extension->priv->key_file)
|
if (extension->priv->key_file
|
||||||
setting_->value = sokoke_key_file_get_integer_default (
|
&& g_key_file_has_key (extension->priv->key_file, "settings", setting_->name, NULL))
|
||||||
extension->priv->key_file,
|
setting_->value = g_key_file_get_integer (extension->priv->key_file,
|
||||||
"settings", setting->name, setting_->default_value, NULL);
|
"settings", setting_->name, NULL);
|
||||||
else
|
else
|
||||||
setting_->value = setting_->default_value;
|
setting_->value = setting_->default_value;
|
||||||
}
|
}
|
||||||
else if (setting->type == G_TYPE_STRING)
|
else if (setting->type == G_TYPE_STRING)
|
||||||
{
|
{
|
||||||
if (extension->priv->key_file)
|
if (extension->priv->key_file)
|
||||||
setting->value = sokoke_key_file_get_string_default (
|
{
|
||||||
extension->priv->key_file,
|
setting->value = g_key_file_get_string (
|
||||||
"settings", setting->name, setting->default_value, NULL);
|
extension->priv->key_file, "settings", setting->name, NULL);
|
||||||
|
if (setting->value == NULL)
|
||||||
|
setting->value = setting->default_value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
setting->value = g_strdup (setting->default_value);
|
setting->value = g_strdup (setting->default_value);
|
||||||
}
|
}
|
||||||
|
@ -372,10 +375,10 @@ midori_extension_activate_cb (MidoriExtension* extension,
|
||||||
MESettingStringList* setting_ = (MESettingStringList*)setting;
|
MESettingStringList* setting_ = (MESettingStringList*)setting;
|
||||||
if (extension->priv->key_file)
|
if (extension->priv->key_file)
|
||||||
{
|
{
|
||||||
setting_->value = sokoke_key_file_get_string_list_default (
|
setting_->value = g_key_file_get_string_list (extension->priv->key_file,
|
||||||
extension->priv->key_file,
|
"settings", setting->name, &setting_->length, NULL);
|
||||||
"settings", setting->name, &setting_->length,
|
if (setting_->value == NULL)
|
||||||
setting_->default_value, &setting_->default_length, NULL);
|
setting_->value = g_strdupv (setting_->default_value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setting_->value = g_strdupv (setting_->default_value);
|
setting_->value = g_strdupv (setting_->default_value);
|
||||||
|
|
|
@ -785,72 +785,6 @@ sokoke_xfce_header_new (const gchar* icon,
|
||||||
return NULL;
|
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
|
gboolean
|
||||||
sokoke_key_file_save_to_file (GKeyFile* key_file,
|
sokoke_key_file_save_to_file (GKeyFile* key_file,
|
||||||
const gchar* filename,
|
const gchar* filename,
|
||||||
|
|
|
@ -72,47 +72,6 @@ GtkWidget*
|
||||||
sokoke_xfce_header_new (const gchar* icon,
|
sokoke_xfce_header_new (const gchar* icon,
|
||||||
const gchar* title);
|
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
|
gboolean
|
||||||
sokoke_key_file_save_to_file (GKeyFile* key_file,
|
sokoke_key_file_save_to_file (GKeyFile* key_file,
|
||||||
const gchar* filename,
|
const gchar* filename,
|
||||||
|
|
Loading…
Reference in a new issue