]> saetta.ns0.it Git - libzakcgi/commitdiff
Added ZakCgiTag::submit (refs #945).
authorAndrea Zagli <azagli@libero.it>
Mon, 27 Jul 2015 19:18:38 +0000 (21:18 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 27 Jul 2015 19:18:38 +0000 (21:18 +0200)
src/tag.c
src/tag.h
tests/tag.c

index 1abe847f85227e5b209849b7f19de764285b7850..2330778d780d7d5a6d098ce4caaf2b24ee27aa9d 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -168,7 +168,6 @@ gchar
 
 /**
  * zak_cgi_tag_img:
- * @name:
  * @id:
  *
  * Returns:
@@ -186,7 +185,6 @@ gchar
 
 /**
  * zak_cgi_tag_text:
- * @name:
  * @id:
  *
  * Returns:
@@ -209,7 +207,6 @@ gchar
 
 /**
  * zak_cgi_tag_file:
- * @name:
  * @id:
  *
  * Returns:
@@ -229,3 +226,25 @@ gchar
 
        return zak_cgi_tag_tag_attrs ("input", id, ar);
 }
+
+/**
+ * zak_cgi_tag_submit:
+ * @id:
+ *
+ * Returns:
+ */
+gchar
+*zak_cgi_tag_submit (const gchar *id,
+                                        ...)
+{
+       GPtrArray *ar;
+       va_list ap;
+
+       va_start (ap, id);
+
+       ar = zak_cgi_tag_valist_to_gptrarray (ap);
+       g_ptr_array_add (ar, "type");
+       g_ptr_array_add (ar, "submit");
+
+       return zak_cgi_tag_tag_attrs ("input", id, ar);
+}
index 3a22f70b749b6f3fd30526eedbd9ae948a9b38ad..3a49672bf4fed9e1250c77fc0cf5ad14ce961ba2 100644 (file)
--- a/src/tag.h
+++ b/src/tag.h
@@ -38,5 +38,8 @@ gchar *zak_cgi_tag_text (const gchar *id,
 gchar *zak_cgi_tag_file (const gchar *id,
                                                 ...);
 
+gchar *zak_cgi_tag_submit (const gchar *id,
+                                                  ...);
+
 
 #endif /* __ZAK_CGI_TAG_H__ */
index 2cbf68cdaea8cbf0b4e99f903b0e39ce7bfb2921..5030f2747da6702235ef6f8661eb29b0131a09be 100644 (file)
 int
 main (int argc, char *argv[])
 {
-       g_message ("%s", zak_cgi_tag_tag ("input", "text",
-                                                                         "type", "textarea",
+       GString *str;
+
+       str = g_string_new ("");
+
+       g_string_append_printf (str, "%s<br/>\n", zak_cgi_tag_tag ("input", "text",
+                                                                         "type", "text",
                                                                          "name", "myname",
+                                                                         "value", "the content of the text input",
+                                                                         NULL));
+
+       g_string_append_printf (str, "%s<br/>\n", zak_cgi_tag_tag ("textarea", "textarea",
                                                                          "content", "the content of the text area",
                                                                          NULL));
 
-       g_message ("%s", zak_cgi_tag_img ("theimage", "src", "pippo.png", NULL));
+       g_string_append_printf (str, "%s<br/>\n", zak_cgi_tag_img ("theimage", "src", "pippo.png", NULL));
+
+       g_string_append_printf (str, "%s<br/>\n", zak_cgi_tag_text ("thetext", NULL));
+
+       g_string_append_printf (str, "%s<br/>\n", zak_cgi_tag_submit ("submit", NULL));
 
-       g_message ("%s", zak_cgi_tag_text ("thetext", NULL));
+       zak_cgi_main_out (NULL, str->str);
 
        return 0;
 }