diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
index 2226e70..243729f 100644
--- a/glib/gkeyfile.c
+++ b/glib/gkeyfile.c
@@ -1074,6 +1074,43 @@ g_key_file_to_data (GKeyFile  *key_file,
 }
 
 /**
+ * g_key_file_to_file:
+ * @key_file: a #GKeyFile
+ * @file: the path of a filename to load, in the Gliub filename encoding
+ * @error: return location for a #GError, or %NULL
+ *
+ * Saves a key file to the specified filename.
+ *
+ * Return value: %TRUE if the file was successfully written
+ *
+ * Since: 2.24
+ **/
+gboolean
+g_key_file_to_file (GKeyFile*    key_file,
+                    const gchar* file,
+                    GError**     error)
+{
+    gchar* data;
+    FILE* fp;
+
+    data = g_key_file_to_data (key_file, NULL, NULL);
+    if (!data)
+        return FALSE;
+
+    if (!(fp = fopen (file, "w")))
+    {
+        if (error)
+            *error = g_error_new (G_FILE_ERROR, G_FILE_ERROR_ACCES,
+                                  _("Writing failed."));
+        return FALSE;
+    }
+    fputs (data, fp);
+    fclose (fp);
+    g_free (data);
+    return TRUE;
+}
+
+/**
  * g_key_file_get_keys:
  * @key_file: a #GKeyFile
  * @group_name: a group name
diff --git a/glib/gkeyfile.h b/glib/gkeyfile.h
index b19124c..89cb137 100644
--- a/glib/gkeyfile.h
+++ b/glib/gkeyfile.h
@@ -81,6 +81,9 @@ gboolean g_key_file_load_from_data_dirs     (GKeyFile             *key_file,
 gchar    *g_key_file_to_data                (GKeyFile             *key_file,
 					     gsize                *length,
 					     GError              **error) G_GNUC_MALLOC;
+gboolean g_key_file_to_file                 (GKeyFile             *key_file,
+                                             const gchar          *file,
+                                             GError              **error);
 gchar    *g_key_file_get_start_group        (GKeyFile             *key_file) G_GNUC_MALLOC;
 gchar   **g_key_file_get_groups             (GKeyFile             *key_file,
 					     gsize                *length) G_GNUC_MALLOC;
diff --git a/glib/glib.symbols b/glib/glib.symbols
index ee9da31..82012a9 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -565,6 +565,7 @@ g_key_file_set_string
 g_key_file_set_string_list
 g_key_file_set_value
 g_key_file_to_data G_GNUC_MALLOC
+g_key_file_to_file
 #endif
 #endif
 
