X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fspreadsheet-test.c;h=8c96ec96a886607beedc0a010be7837dc9e17ebb;hb=refs%2Fbuilds%2F20130810030958%2Fpspp;hp=c0608886a4a61544645b97e7ac89f28cee4cff27;hpb=79014c200effb8a2e1ad22da7f985bb80da2369a;p=pspp diff --git a/src/ui/gui/spreadsheet-test.c b/src/ui/gui/spreadsheet-test.c index c0608886a4..8c96ec96a8 100644 --- a/src/ui/gui/spreadsheet-test.c +++ b/src/ui/gui/spreadsheet-test.c @@ -28,31 +28,11 @@ #include "data/spreadsheet-reader.h" #include "data/casereader.h" #include "data/case.h" -#include "gl/xalloc.h" - -#if 0 -#define N 10 - +#include "data/settings.h" +#include "libpspp/message.h" +#include "libpspp/i18n.h" -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 +#include "gl/xalloc.h" struct xxx @@ -75,11 +55,16 @@ on_clicked (GtkButton *button, struct xxx *stuff) opts.sheet_index = -1; opts.cell_range = spreadsheet_get_sheet_range (stuff->sp, x); - opts.sheet_name = spreadsheet_get_sheet_name (stuff->sp, x); + opts.sheet_name = CONST_CAST (char *, + spreadsheet_get_sheet_name (stuff->sp, x)); opts.read_names = TRUE; opts.asw = -1; reader = spreadsheet_make_reader (stuff->sp, &opts); + + if (reader == NULL) + return; + proto = casereader_get_proto (reader); nvals = caseproto_get_n_widths (proto); @@ -97,7 +82,7 @@ on_clicked (GtkButton *button, struct xxx *stuff) else { char *ss = xzalloc (width + 1); - strncpy (ss, value_str (val, width), width); + memcpy (ss, value_str (val, width), width); printf ("%s ", ss); free (ss); @@ -109,6 +94,12 @@ on_clicked (GtkButton *button, struct xxx *stuff) casereader_destroy (reader); } +static void +print_msg (const struct msg *m, void *aux UNUSED) +{ + fprintf (stderr, "%s\n", m->text); +} + int main (int argc, char *argv[] ) @@ -122,11 +113,16 @@ main (int argc, char *argv[] ) GtkWidget *button; struct xxx stuff; + i18n_init (); + settings_init (); + gtk_init (&argc, &argv); if ( argc < 2) g_error ("Usage: prog file\n"); + msg_set_handler (print_msg, 0); + stuff.sp = NULL; if (stuff.sp == NULL) @@ -143,8 +139,8 @@ main (int argc, char *argv[] ) 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); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); button = gtk_button_new_with_label ("Test reader"); g_signal_connect (button, "clicked", G_CALLBACK (on_clicked), &stuff);