From: John Darrington Date: Sun, 3 Mar 2013 10:37:35 +0000 (+0100) Subject: Renamed the spreadsheet test file and put it noinst X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e49745e3d5dff8e5e8e1bf3dddd82fc54d9f4aa4;p=pspp Renamed the spreadsheet test file and put it noinst --- diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index e47996ea62..941a7fea1c 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -55,10 +55,10 @@ EXTRA_DIST += \ if HAVE_GUI bin_PROGRAMS += src/ui/gui/psppire -bin_PROGRAMS += src/ui/gui/spread-test +noinst_PROGRAMS += src/ui/gui/spreadsheet-test src_ui_gui_psppire_CFLAGS = $(GTK_CFLAGS) $(GTKSOURCEVIEW_CFLAGS) -Wall -DGDK_MULTIHEAD_SAFE=1 -src_ui_gui_spread_test_CFLAGS = $(GTK_CFLAGS) -Wall -DGDK_MULTIHEAD_SAFE=1 +src_ui_gui_spreadsheet_test_CFLAGS = $(GTK_CFLAGS) -Wall -DGDK_MULTIHEAD_SAFE=1 src_ui_gui_psppire_LDFLAGS = \ @@ -87,13 +87,13 @@ src_ui_gui_psppire_LDADD = \ $(GSL_LIBS) -src_ui_gui_spread_test_LDADD = \ +src_ui_gui_spreadsheet_test_LDADD = \ src/libpspp-core.la \ $(GTK_LIBS) \ $(GTHREAD_LIBS) -src_ui_gui_spread_test_SOURCES = src/ui/gui/sheet-test.c src/ui/gui/psppire-spreadsheet-model.c +src_ui_gui_spreadsheet_test_SOURCES = src/ui/gui/spreadsheet-test.c src/ui/gui/psppire-spreadsheet-model.c src_ui_gui_psppiredir = $(pkgdatadir) diff --git a/src/ui/gui/sheet-test.c b/src/ui/gui/sheet-test.c deleted file mode 100644 index 107e6583c6..0000000000 --- a/src/ui/gui/sheet-test.c +++ /dev/null @@ -1,176 +0,0 @@ -#include - -#include - -#include "psppire-spreadsheet-model.h" - -#include "data/gnumeric-reader.h" -#include "data/ods-reader.h" -#include "data/spreadsheet-reader.h" -#include "data/casereader.h" -#include "data/case.h" - -#if 0 -#define N 10 - - -static GtkListStore * -make_store () - { - int i; - GtkTreeIter iter; - - GtkListStore * list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING); - - for (i = 0; i < N; ++i) - { - gtk_list_store_append (list_store, &iter); - gtk_list_store_set (list_store, &iter, - 0, N - i, - 1, "xxx", - -1); - } - return list_store; - } -#endif - - -struct xxx -{ - struct spreadsheet *sp; - GtkWidget *combo_box; -}; - - - -static void -on_clicked (GtkButton *button, struct xxx *stuff) -{ - const struct caseproto *proto; - int nvals; - struct ccase *c; - gint x = gtk_combo_box_get_active (GTK_COMBO_BOX (stuff->combo_box)); - struct casereader *reader ; - struct spreadsheet_read_options opts; - - g_print( "%s %d\n", __FUNCTION__, x); - - opts.sheet_index = x + 1; - opts.cell_range = NULL; - opts.sheet_name = NULL; - opts.read_names = TRUE; - opts.asw = -1; - - reader = ods_make_reader (stuff->sp, &opts); - proto = casereader_get_proto (reader); - - nvals = caseproto_get_n_widths (proto); - - for (; - (c = casereader_read (reader)) != NULL; case_unref (c)) - { - int i; - - for (i = 0; i < nvals ; ++i) - { - const double val = case_data_idx (c, i)->f; - printf ("%g ", val); - } - printf ("\n"); - } - - casereader_destroy (reader); -} - - -int -main (int argc, char *argv[] ) -{ - GtkWidget *window; - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *treeview; - - GtkTreeModel *tm; - GtkWidget *button; - struct xxx stuff; - - gtk_init (&argc, &argv); - - if ( argc < 2) - g_error ("Usage: prog file\n"); - - stuff.sp = NULL; - -#if 0 - if (sp == NULL) - sp = gnumeric_probe (argv[1], false); -#endif - - if (stuff.sp == NULL) - stuff.sp = ods_probe (argv[1], false); - - if (stuff.sp == NULL) - { - g_error ("%s is neither a gnumeric nor a ods file\n", argv[1]); - return 0; - } - - tm = psppire_spreadsheet_model_new (stuff.sp); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - hbox = gtk_hbox_new (FALSE, 5); - vbox = gtk_vbox_new (FALSE, 5); - - button = gtk_button_new_with_label ("Test reader"); - g_signal_connect (button, "clicked", G_CALLBACK (on_clicked), &stuff); - - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - stuff.combo_box = gtk_combo_box_new(); - - { - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (stuff.combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (stuff.combo_box), renderer, - "text", 0, - NULL); - } - - gtk_combo_box_set_model (GTK_COMBO_BOX (stuff.combo_box), tm); - - gtk_combo_box_set_active (GTK_COMBO_BOX (stuff.combo_box), 0); - - treeview = gtk_tree_view_new_with_model (tm); - - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - 0, "sheet name", - gtk_cell_renderer_text_new (), - "text", 0, - NULL); - - - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - 1, "range", - gtk_cell_renderer_text_new (), - "text", 1, - NULL); - - - gtk_box_pack_start (GTK_BOX (hbox), treeview, TRUE, TRUE, 5); - - gtk_box_pack_start (GTK_BOX (vbox), stuff.combo_box, FALSE, FALSE, 5); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 5); - gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 5); - - gtk_container_add (GTK_CONTAINER (window), hbox); - - g_signal_connect (window, "destroy", gtk_main_quit, 0); - - gtk_widget_show_all (window); - - gtk_main (); - - // gnumeric_destroy (sp); - - return 0; -} diff --git a/src/ui/gui/spreadsheet-test.c b/src/ui/gui/spreadsheet-test.c new file mode 100644 index 0000000000..2e88402b52 --- /dev/null +++ b/src/ui/gui/spreadsheet-test.c @@ -0,0 +1,195 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2013 Free Software Foundation + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +/* This program is useful for testing the spreadsheet readers */ + +#include + +#include + +#include "psppire-spreadsheet-model.h" + +#include "data/gnumeric-reader.h" +#include "data/ods-reader.h" +#include "data/spreadsheet-reader.h" +#include "data/casereader.h" +#include "data/case.h" + +#if 0 +#define N 10 + + +static GtkListStore * +make_store () + { + int i; + GtkTreeIter iter; + + GtkListStore * list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING); + + for (i = 0; i < N; ++i) + { + gtk_list_store_append (list_store, &iter); + gtk_list_store_set (list_store, &iter, + 0, N - i, + 1, "xxx", + -1); + } + return list_store; + } +#endif + + +struct xxx +{ + struct spreadsheet *sp; + GtkWidget *combo_box; +}; + + + +static void +on_clicked (GtkButton *button, struct xxx *stuff) +{ + const struct caseproto *proto; + int nvals; + struct ccase *c; + gint x = gtk_combo_box_get_active (GTK_COMBO_BOX (stuff->combo_box)); + struct casereader *reader ; + struct spreadsheet_read_options opts; + + g_print( "%s %d\n", __FUNCTION__, x); + + opts.sheet_index = x + 1; + opts.cell_range = NULL; + opts.sheet_name = NULL; + opts.read_names = TRUE; + opts.asw = -1; + + reader = ods_make_reader (stuff->sp, &opts); + proto = casereader_get_proto (reader); + + nvals = caseproto_get_n_widths (proto); + + for (; + (c = casereader_read (reader)) != NULL; case_unref (c)) + { + int i; + + for (i = 0; i < nvals ; ++i) + { + const double val = case_data_idx (c, i)->f; + printf ("%g ", val); + } + printf ("\n"); + } + + casereader_destroy (reader); +} + + +int +main (int argc, char *argv[] ) +{ + GtkWidget *window; + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *treeview; + + GtkTreeModel *tm; + GtkWidget *button; + struct xxx stuff; + + gtk_init (&argc, &argv); + + if ( argc < 2) + g_error ("Usage: prog file\n"); + + stuff.sp = NULL; + +#if 0 + if (sp == NULL) + sp = gnumeric_probe (argv[1], false); +#endif + + if (stuff.sp == NULL) + stuff.sp = ods_probe (argv[1], false); + + if (stuff.sp == NULL) + { + g_error ("%s is neither a gnumeric nor a ods file\n", argv[1]); + return 0; + } + + tm = psppire_spreadsheet_model_new (stuff.sp); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + hbox = gtk_hbox_new (FALSE, 5); + vbox = gtk_vbox_new (FALSE, 5); + + button = gtk_button_new_with_label ("Test reader"); + g_signal_connect (button, "clicked", G_CALLBACK (on_clicked), &stuff); + + gtk_container_set_border_width (GTK_CONTAINER (window), 10); + + stuff.combo_box = gtk_combo_box_new(); + + { + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (stuff.combo_box), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (stuff.combo_box), renderer, + "text", 0, + NULL); + } + + gtk_combo_box_set_model (GTK_COMBO_BOX (stuff.combo_box), tm); + + gtk_combo_box_set_active (GTK_COMBO_BOX (stuff.combo_box), 0); + + treeview = gtk_tree_view_new_with_model (tm); + + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), + 0, "sheet name", + gtk_cell_renderer_text_new (), + "text", 0, + NULL); + + + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), + 1, "range", + gtk_cell_renderer_text_new (), + "text", 1, + NULL); + + + gtk_box_pack_start (GTK_BOX (hbox), treeview, TRUE, TRUE, 5); + + gtk_box_pack_start (GTK_BOX (vbox), stuff.combo_box, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 5); + + gtk_container_add (GTK_CONTAINER (window), hbox); + + g_signal_connect (window, "destroy", gtk_main_quit, 0); + + gtk_widget_show_all (window); + + gtk_main (); + + // gnumeric_destroy (sp); + + return 0; +}