From b588f8416e519498327379a9a83cda6e677cfd58 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 3 Oct 2013 09:20:03 +0200 Subject: [PATCH] Added function GdaExGridColumn::new_defaults. --- src/gridcolumn.c | 17 ++++++++++++++++- src/gridcolumn.h | 6 +++++- tests/getsql.c | 7 +++++++ tests/grid.c | 12 ++++++++---- tests/grid.db | Bin 2048 -> 2048 bytes 5 files changed, 36 insertions(+), 6 deletions(-) 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 146732ff241c3cddb763ca11ac67f21cae4f9585..abc326726d73d1644a721264e69033ea3d3952b4 100644 GIT binary patch delta 88 zcmZn=Xb_kn&B!-V#+jdwLHCgqF9QPuBXbl3bJS)*mN!h3qnKCmurL=gFyCU{!raAN q2o!Z=o*c$5Eh)~z!6+%t1XRwFn^;m>oS2iEo0}?{&N#V?y$k?ah7^PV delta 69 zcmZn=Xb_kn&B!}Z#+jd&LHCgyF9QPuBXbl3bJS)*mN!h3qnKB5F*A2DFyCU{!rTQE Xb7P(y!Y(_pL4?%^sFY!H7ke219~lq$ -- 2.49.0