]> saetta.ns0.it Git - libgdaex/commitdiff
Implemented boolean column.
authorAndrea Zagli <azagli@libero.it>
Sat, 4 Jun 2011 09:48:19 +0000 (11:48 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 4 Jun 2011 09:48:19 +0000 (11:48 +0200)
src/grid.c
src/gridcolumn.c
tests/grid.c
tests/grid.db

index 57736188f2c70448d1ae33784c7fcd1e662b9c14..f4d9304e088a8ccabb958b4c80ca980d4db220f0 100644 (file)
@@ -375,7 +375,15 @@ static GtkTreeView
                                                {
                                                        cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (vcolumn));
                                                        cells = g_list_first (cells);
-                                                       gtk_tree_view_column_add_attribute (vcolumn, (GtkCellRenderer *)cells->data, "text", col);
+
+                                                       if (gdaex_grid_column_get_gtype (gcolumn) == G_TYPE_BOOLEAN)
+                                                               {
+                                                                       gtk_tree_view_column_add_attribute (vcolumn, (GtkCellRenderer *)cells->data, "active", col);
+                                                               }
+                                                       else
+                                                               {
+                                                                       gtk_tree_view_column_add_attribute (vcolumn, (GtkCellRenderer *)cells->data, "text", col);
+                                                               }
 
                                                        gtk_tree_view_append_column (GTK_TREE_VIEW (view), vcolumn);
                                                }
index 75a9532d980546cebf980c997e639826c64227d7..8926c6a833240ab49c5dd6714b27bd4e4318f5cb 100644 (file)
@@ -307,6 +307,11 @@ GtkTreeViewColumn
                                }
                        gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
                }
+       else if (priv->type == G_TYPE_BOOLEAN)
+               {
+                       renderer = gtk_cell_renderer_toggle_new ();
+                       gtk_cell_renderer_set_alignment (renderer, 0.5, 0.5);
+               }
        else
                {
                        g_warning ("Error on creating the renderer for column «%s».", priv->title);
index ea5ed43ca51d86eecb8cc43795f65c1b6c0ec1a7..997963a7b20f5ba44ed371a4ab79f955016abb8b 100644 (file)
@@ -64,6 +64,9 @@ main (int argc, char **argv)
        gcol = gdaex_grid_column_new ("Incoming", "incoming", G_TYPE_DOUBLE, TRUE, TRUE, TRUE, TRUE, 2);
        gdaex_grid_add_column (grid, gcol);
 
+       gcol = gdaex_grid_column_new ("Married", "married", G_TYPE_BOOLEAN, TRUE, TRUE, TRUE, TRUE, -1);
+       gdaex_grid_add_column (grid, gcol);
+
        wgrid = gdaex_grid_get_widget (grid);
        gtk_container_add (GTK_CONTAINER (scrolledw), wgrid);
 
index fd7f26f57a8b4a933d3ab3ae7167e3402f3768a8..146732ff241c3cddb763ca11ac67f21cae4f9585 100644 (file)
Binary files a/tests/grid.db and b/tests/grid.db differ