]> saetta.ns0.it Git - libgdaex/commitdiff
Added function GdaExGridColumn::new_defaults.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 3 Oct 2013 07:20:03 +0000 (09:20 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 3 Oct 2013 07:20:03 +0000 (09:20 +0200)
src/gridcolumn.c
src/gridcolumn.h
tests/getsql.c
tests/grid.c
tests/grid.db

index 89670589eb9f28634d3b3fb2355fda522f3bb8e7..5d4f2f2b093034f0578f54a61677b2a1866f3196 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  gridcolumn.c
  *
- *  Copyright (C) 2010-2011 Andrea Zagli <azagli@libero.it>
+ *  Copyright (C) 2010-2013 Andrea Zagli <azagli@libero.it>
  *
  *  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)
 {
index 0131a43ed801ee3f45292ebd33d1fc6df872282f..8ab8c689aec95af355e554eda753cd0042af3796 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  gridcolumn.h
  *
- *  Copyright (C) 2010-2011 Andrea Zagli <azagli@libero.it>
+ *  Copyright (C) 2010-2013 Andrea Zagli <azagli@libero.it>
  *
  *  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);
 
index 02d397dcaf9f1bdb064e56626e926948960fe76b..1e6e04db9edaceda0e7a04e9f00a8407716753f7 100644 (file)
@@ -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");
index 997963a7b20f5ba44ed371a4ab79f955016abb8b..71186951ae009b51e1ec61d3f1a1b1f6fce3f267 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2011-2013 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
@@ -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);
index 146732ff241c3cddb763ca11ac67f21cae4f9585..abc326726d73d1644a721264e69033ea3d3952b4 100644 (file)
Binary files a/tests/grid.db and b/tests/grid.db differ