/** * glide_document_write_json: * @document: A #GlideDocument * * Saves the JSON file for @document in the working path of * @document. */ void glide_document_write_json (GlideDocument *document) { GError *e = NULL; JsonNode *node; JsonGenerator *gen; gchar *json_path; g_return_if_fail (GLIDE_IS_DOCUMENT (document)); node = glide_document_serialize (document); gen = json_generator_new (); g_object_set (gen, "pretty", TRUE, NULL); json_generator_set_root (gen, node); if (!document->priv->working_path) glide_document_make_working_dir (document); json_path = g_strdup_printf("%s/document.json",document->priv->working_path); // TODO: Error json_generator_to_file (gen, json_path, &e); if (e) { g_warning ("Failed to write JSON to file (%s): %s", json_path, e->message); g_error_free (e); } g_object_unref (G_OBJECT (gen)); g_free (json_path); }
static void glide_window_save_document_real (GlideWindow *w, const gchar *filename) { JsonNode *node; JsonGenerator *gen; node = glide_document_serialize (w->priv->document); gen = json_generator_new (); g_object_set (gen, "pretty", TRUE, NULL); json_generator_set_root (gen, node); // TODO: Error json_generator_to_file (gen, filename, NULL); glide_document_set_dirty (w->priv->document, FALSE); glide_document_set_path (w->priv->document, filename); // Maybe gets called twice? glide_window_update_title (w); }