tests/grid
tests/grid_from_xml
tests/grid_tree
+tests/grid_html_from_xml
test-driver
*.gir
*.typelib
\ No newline at end of file
return gdaex_grid_fill_from_sqlbuilder_with_missing_func (grid, gdaex, builder, NULL, NULL, error);
}
+
+/**
+ * gdaex_grid_html_get_header:
+ * @grid: a #GdaExGrid object.
+ *
+ * Returns: the table header (only the tr tag).
+ */
+gchar
+*gdaex_grid_html_get_header (GdaExGrid *grid)
+{
+ GdaExGridPrivate *priv;
+
+ GdaExGridColumn *gcolumn;
+
+ guint col;
+
+ GString *str;
+
+ gchar *ret;
+
+ g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
+
+ priv = gdaex_grid_get_instance_private (grid);
+
+ str = g_string_new ("<tr>\n");
+
+ for (col = 0; col < priv->columns->len; col++)
+ {
+ gcolumn = (GdaExGridColumn *)g_ptr_array_index (priv->columns, col);
+ g_string_append_printf (str,
+ "\t<th>%s</th>\n",
+ gdaex_grid_column_get_title (gcolumn));
+ }
+
+ g_string_append (str, "</tr>\n");
+
+ ret = g_strdup (str->str);
+ g_string_free (str, TRUE);
+
+ return ret;
+}
+
/* PRIVATE */
static void
gdaex_grid_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
/*
* grid.h
*
- * Copyright (C) 2010-2020 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2021 Andrea Zagli <azagli@libero.it>
*
* This file is part of libgdaexgrid.
*
gboolean gdaex_grid_fill_from_sqlbuilder (GdaExGrid *grid, GdaEx *gdaex, GdaExSqlBuilder *builder, GError **error);
+gchar *gdaex_grid_html_get_header (GdaExGrid *grid);
+
+
G_END_DECLS
#endif /* __GDAEX_GRID_H__ */
noinst_PROGRAMS = \
grid \
grid_from_xml \
- grid_tree
+ grid_tree \
+ grid_html_from_xml
LDADD = $(top_builddir)/src/libgdaexgrid.la
--- /dev/null
+/*
+ * Copyright (C) 2021 Andrea Zagli <azagli@libero.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <glib/gprintf.h>
+
+#include <libgdaex/libgdaex.h>
+
+#include "grid.h"
+#include "gridcolumn.h"
+
+int
+main (int argc, char **argv)
+{
+ GdaEx *gdaex;
+
+ GdaExGrid *grid;
+
+ gtk_init (&argc, &argv);
+
+ gdaex = gdaex_new_from_string (g_strdup_printf ("SQLite://DB_DIR=%s;DB_NAME=grid.db", TESTSDIR));
+ if (gdaex == NULL)
+ {
+ g_error ("Unable to connect to the db.");
+ }
+
+ grid = gdaex_grid_new_from_file (argv[1]);
+
+ g_printf ("%s\n\n", gdaex_grid_html_get_header (grid));
+
+ return 0;
+}