From 33ce974bb6b41f736a4c6b3dd302418c49aaeb48 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 9 Aug 2020 11:04:15 +0200 Subject: [PATCH] Added functions ::get|set_filename. --- src/form.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/form.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/src/form.c b/src/form.c index a26fa0b..cdea69c 100644 --- a/src/form.c +++ b/src/form.c @@ -220,6 +220,49 @@ ZakFormJsonProvider return zak_form_json_provider; } +void +zak_form_json_provider_set_filename (ZakFormJsonProvider *provider, const gchar *filename) +{ + gchar *_filename; + + ZakFormJsonProviderPrivate *priv = zak_form_json_provider_get_instance_private (provider); + + if (filename == NULL) + { + if (priv->filename != NULL) + { + g_free (priv->filename); + } + + priv->filename = NULL; + } + else + { + _filename = g_strstrip (g_strdup (filename)); + if (g_strcmp0 (_filename, "") == 0) + { + if (priv->filename != NULL) + { + g_free (priv->filename); + } + + priv->filename = NULL; + } + } +} + +const gchar +*zak_form_json_provider_get_filename (ZakFormJsonProvider *provider) +{ + const gchar *ret; + + ZakFormJsonProviderPrivate *priv = zak_form_json_provider_get_instance_private (provider); + + ret = g_strdup (priv->filename); + + return ret; +} + /* PRIVATE */ static void zak_form_json_provider_set_property (GObject *object, diff --git a/src/form.h b/src/form.h index c65f347..5be56e6 100644 --- a/src/form.h +++ b/src/form.h @@ -35,6 +35,8 @@ G_DECLARE_FINAL_TYPE (ZakFormJsonProvider, zak_form_json_provider, ZAK_FORM_JSON ZakFormJsonProvider *zak_form_json_provider_new_from_file (const gchar *filename); ZakFormJsonProvider *zak_form_json_provider_new_from_data (const gchar *data, gssize length); +void zak_form_json_provider_set_filename (ZakFormJsonProvider *provider, const gchar *filename); +const gchar *zak_form_json_provider_get_filename (ZakFormJsonProvider *provider); G_END_DECLS -- 2.49.0