]> saetta.ns0.it Git - zakform/json/commitdiff
Added functions ::get|set_filename.
authorAndrea Zagli <azagli@libero.it>
Sun, 9 Aug 2020 09:04:15 +0000 (11:04 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 9 Aug 2020 09:04:15 +0000 (11:04 +0200)
src/form.c
src/form.h

index a26fa0bde4b355e1ec0722b0ea7ba94fa7a4d31b..cdea69cfd1531e6f8fa0d886ccc06db79babed7a 100644 (file)
@@ -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,
index c65f347c57d785134a3697e1378dc2e0673a356f..5be56e63df3ffca82f0717fc8b790b71a62f522c 100644 (file)
@@ -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