From: Andrea Zagli Date: Thu, 3 Oct 2013 07:20:03 +0000 (+0200) Subject: Added function GdaExGridColumn::new_defaults. X-Git-Tag: 0.4.0~17 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=b588f8416e519498327379a9a83cda6e677cfd58;p=libgdaex Added function GdaExGridColumn::new_defaults. --- diff --git a/src/gridcolumn.c b/src/gridcolumn.c index 8967058..5d4f2f2 100644 --- a/src/gridcolumn.c +++ b/src/gridcolumn.c @@ -1,7 +1,7 @@ /* * gridcolumn.c * - * Copyright (C) 2010-2011 Andrea Zagli + * Copyright (C) 2010-2013 Andrea Zagli * * This file is part of libgdaex_grid_column. * @@ -112,6 +112,21 @@ GdaExGridColumn return gdaex_grid_column; } +GdaExGridColumn +*gdaex_grid_column_new_defaults (const gchar *title, + const gchar *field_name, + GType type) +{ + return gdaex_grid_column_new (title, + field_name, + type, + TRUE, + TRUE, + TRUE, + TRUE, + type == G_TYPE_FLOAT || type == G_TYPE_DOUBLE ? 2 : 0); +} + void gdaex_grid_column_set_title (GdaExGridColumn *column, const gchar *title) { diff --git a/src/gridcolumn.h b/src/gridcolumn.h index 0131a43..8ab8c68 100644 --- a/src/gridcolumn.h +++ b/src/gridcolumn.h @@ -1,7 +1,7 @@ /* * gridcolumn.h * - * Copyright (C) 2010-2011 Andrea Zagli + * Copyright (C) 2010-2013 Andrea Zagli * * This file is part of libgdaex. * @@ -65,6 +65,10 @@ GdaExGridColumn *gdaex_grid_column_new (const gchar *title, gboolean reorderable, gint decimals); +GdaExGridColumn *gdaex_grid_column_new_defaults (const gchar *title, + const gchar *field_name, + GType type); + void gdaex_grid_column_set_title (GdaExGridColumn *column, const gchar *title); const gchar *gdaex_grid_column_get_title (GdaExGridColumn *column); diff --git a/tests/getsql.c b/tests/getsql.c index 02d397d..1e6e04d 100644 --- a/tests/getsql.c +++ b/tests/getsql.c @@ -29,6 +29,7 @@ main (int argc, char **argv) GValue *gval; GDate *gdate; + GDateTime *gdatetime; gtk_init (&argc, &argv); @@ -101,6 +102,12 @@ main (int argc, char **argv) g_value_set_boxed (gval, gdate); g_hash_table_insert (ht_fields, "birthday", gval); + gval = g_new0 (GValue, 1); + g_value_init (gval, G_TYPE_DATE_TIME); + gdatetime = g_date_time_new_now_local (); + g_value_set_boxed (gval, gdatetime); + g_hash_table_insert (ht_fields, "oggi", gval); + gval = g_new0 (GValue, 1); g_value_init (gval, G_TYPE_STRING); g_value_set_string (gval, "5th avenue, 44"); diff --git a/tests/grid.c b/tests/grid.c index 997963a..7118695 100644 --- a/tests/grid.c +++ b/tests/grid.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Andrea Zagli + * Copyright (C) 2011-2013 Andrea Zagli * * 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 @@ -40,6 +40,10 @@ main (int argc, char **argv) w = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (w), 550, 350); + g_signal_connect (w, "delete-event", + G_CALLBACK (gtk_false), NULL); + g_signal_connect (w, "destroy", + G_CALLBACK (gtk_main_quit), NULL); scrolledw = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (w), scrolledw); @@ -52,16 +56,16 @@ main (int argc, char **argv) gcol = gdaex_grid_column_new ("Name", "name", G_TYPE_STRING, TRUE, TRUE, TRUE, TRUE, -1); gdaex_grid_add_column (grid, gcol); - gcol = gdaex_grid_column_new ("Surname", "surname", G_TYPE_STRING, TRUE, TRUE, TRUE, TRUE, -1); + gcol = gdaex_grid_column_new_defaults ("Surname", "surname", G_TYPE_STRING); gdaex_grid_add_column (grid, gcol); - gcol = gdaex_grid_column_new ("Age", "age", G_TYPE_INT, TRUE, TRUE, TRUE, TRUE, -1); + gcol = gdaex_grid_column_new_defaults ("Age", "age", G_TYPE_INT); gdaex_grid_add_column (grid, gcol); gcol = gdaex_grid_column_new ("Birthday", "birthday", G_TYPE_DATE, TRUE, TRUE, TRUE, TRUE, -1); gdaex_grid_add_column (grid, gcol); - gcol = gdaex_grid_column_new ("Incoming", "incoming", G_TYPE_DOUBLE, TRUE, TRUE, TRUE, TRUE, 2); + gcol = gdaex_grid_column_new_defaults ("Incoming", "incoming", G_TYPE_DOUBLE); gdaex_grid_add_column (grid, gcol); gcol = gdaex_grid_column_new ("Married", "married", G_TYPE_BOOLEAN, TRUE, TRUE, TRUE, TRUE, -1); diff --git a/tests/grid.db b/tests/grid.db index 146732f..abc3267 100644 Binary files a/tests/grid.db and b/tests/grid.db differ