7 #include "psppire-spreadsheet-model.h"
9 #include "data/gnumeric-reader.h"
10 #include "data/spreadsheet-reader.h"
11 #include "data/casereader.h"
12 #include "data/case.h"
23 GtkListStore * list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
25 for (i = 0; i < N; ++i)
27 gtk_list_store_append (list_store, &iter);
28 gtk_list_store_set (list_store, &iter,
37 struct spreadsheet *sp = NULL;
41 on_clicked (GtkButton *button, gpointer data)
44 gint x = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
45 struct casereader *reader ;
46 struct spreadsheet_read_options opts;
48 g_print( "%s %d\n", __FUNCTION__, x);
50 opts.sheet_index = x + 1;
51 opts.cell_range = NULL;
52 opts.sheet_name = NULL;
53 opts.read_names = TRUE;
56 reader = gnumeric_make_reader (sp, &opts);
58 (c = casereader_read (reader)) != NULL; case_unref (c))
60 const double val = case_data_idx (c, 0)->f;
66 main (int argc, char *argv[] )
76 gtk_init (&argc, &argv);
79 g_error ("Usage: prog file\n");
84 sp = gnumeric_probe (argv[1], false);
87 sp = ods_probe (argv[1], false);
91 g_error ("%s is neither a gnumeric nor a ods file\n", argv[1]);
95 tm = psppire_spreadsheet_model_new (sp);
96 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
97 hbox = gtk_hbox_new (FALSE, 5);
98 vbox = gtk_vbox_new (FALSE, 5);
100 button = gtk_button_new_with_label ("Test reader");
101 g_signal_connect (button, "clicked", G_CALLBACK (on_clicked), NULL);
103 gtk_container_set_border_width (GTK_CONTAINER (window), 10);
105 combo_box = gtk_combo_box_new();
108 GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
109 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
110 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
115 gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), tm);
117 gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
119 treeview = gtk_tree_view_new_with_model (tm);
121 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
123 gtk_cell_renderer_text_new (),
128 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
130 gtk_cell_renderer_text_new (),
135 gtk_box_pack_start (GTK_BOX (hbox), treeview, TRUE, TRUE, 5);
137 gtk_box_pack_start (GTK_BOX (vbox), combo_box, FALSE, FALSE, 5);
138 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 5);
139 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 5);
141 gtk_container_add (GTK_CONTAINER (window), hbox);
143 g_signal_connect (window, "destroy", gtk_main_quit, 0);
145 gtk_widget_show_all (window);
149 // gnumeric_destroy (sp);