[Xfce4-commits] <midori:master> Dissolve keyfile "default" wrappers into Midori.Extension
Christian Dywan
noreply at xfce.org
Sun Sep 9 22:36:07 CEST 2012
Updating branch refs/heads/master
to 1ad675e24ed02cacea7aa00fead8e9f4f1941d67 (commit)
from f715e11ebfb7ae9e761999312f15577cd436a428 (commit)
commit 1ad675e24ed02cacea7aa00fead8e9f4f1941d67
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Sep 9 21:40:46 2012 +0200
Dissolve keyfile "default" wrappers into Midori.Extension
midori/midori-extension.c | 33 ++++++++++++----------
midori/sokoke.c | 66 ---------------------------------------------
midori/sokoke.h | 41 ----------------------------
3 files changed, 18 insertions(+), 122 deletions(-)
diff --git a/midori/midori-extension.c b/midori/midori-extension.c
index fe52679..88344f5 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 8bca3e2..f476f3c 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 9a25ad6..ca411c5 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,
More information about the Xfce4-commits
mailing list