]> spindle.queued.net Git - midori/commitdiff
Dissolve keyfile "default" wrappers into Midori.Extension
authorChristian Dywan <christian@twotoasts.de>
Sun, 9 Sep 2012 19:40:46 +0000 (21:40 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 9 Sep 2012 20:34:33 +0000 (22:34 +0200)
midori/midori-extension.c
midori/sokoke.c
midori/sokoke.h

index fe52679b76057f0e9a60cf8cd15b831ad353bd78..88344f532ed34aa4b1fe951cc37fcc8d464effff 100644 (file)
@@ -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);
index 8bca3e269dc8063813f30d3701c498b1025fe722..f476f3c1d149656e24c945f8a41fc4480a10eb47 100644 (file)
@@ -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,
index 9a25ad648893dd19f2628d08c2850d75f88bed8c..ca411c542bbdab2c0737a70858c1ba85d2f5098b 100644 (file)
@@ -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,