#include "data/file-handle-def.h"
#include "data/dataset.h"
#include "libpspp/version.h"
-#include "output/group-item.h"
+#include "output/output-item.h"
#include "output/pivot-table.h"
#include "output/spv/spv.h"
-#include "output/spv/spv-output.h"
-#include "output/spv/spv-select.h"
#include "helper.h"
#include "psppire-data-window.h"
#include "psppire-syntax-window.h"
#include "psppire-window-register.h"
-static void psppire_window_base_init (PsppireWindowClass *class);
static void psppire_window_class_init (PsppireWindowClass *class);
static void psppire_window_init (PsppireWindow *window);
-
static GObjectClass *parent_class;
-GType
-psppire_window_get_type (void)
-{
- static GType psppire_window_type = 0;
-
- if (!psppire_window_type)
- {
- static const GTypeInfo psppire_window_info =
- {
- sizeof (PsppireWindowClass),
- (GBaseInitFunc) psppire_window_base_init,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) psppire_window_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (PsppireWindow),
- 0,
- (GInstanceInitFunc) psppire_window_init,
- };
-
- psppire_window_type =
- g_type_register_static (PSPPIRE_TYPE_WINDOW_BASE, "PsppireWindow",
- &psppire_window_info, G_TYPE_FLAG_ABSTRACT);
- }
-
- return psppire_window_type;
-}
-
+G_DEFINE_ABSTRACT_TYPE (PsppireWindow, psppire_window, PSPPIRE_TYPE_WINDOW_BASE)
/* Properties */
enum
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = psppire_window_finalize;
+
GParamSpec *description_spec =
null_if_empty_param ("description",
"Description",
}
-static void
-psppire_window_base_init (PsppireWindowClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- object_class->finalize = psppire_window_finalize;
-}
-
-
-
static void
insert_menuitem_into_menu (PsppireWindow *window, gpointer key)
{
g_signal_connect_swapped (window, "delete-event", G_CALLBACK (on_delete), window);
- g_object_set (window, "icon-name", "pspp", NULL);
+ g_object_set (window, "icon-name", "org.gnu.pspp", NULL);
}
/*
description);
g_free (description);
- g_object_set (dialog, "icon-name", "pspp", NULL);
+ g_object_set (dialog, "icon-name", "org.gnu.pspp", NULL);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("If you don't save, changes from the last %ld seconds will be permanently lost."),
- timespan / G_TIME_SPAN_SECOND);
+ (long int) (timespan / G_TIME_SPAN_SECOND));
gtk_dialog_add_button (GTK_DIALOG (dialog),
_("Close _without saving"),
NULL, /* class_data */
0,
0, /* n_preallocs */
- NULL
+ NULL,
+ NULL /* value_table */
};
window_model_type =
return dialog;
}
-struct item_path
- {
- const struct spv_item **nodes;
- size_t n;
-
-#define N_STUB 10
- const struct spv_item *stub[N_STUB];
- };
-
-static void
-swap_nodes (const struct spv_item **a, const struct spv_item **b)
-{
- const struct spv_item *tmp = *a;
- *a = *b;
- *b = tmp;
-}
-
-static void
-get_path (const struct spv_item *item, struct item_path *path)
-{
- size_t allocated = 10;
- path->nodes = path->stub;
- path->n = 0;
-
- while (item)
- {
- if (path->n >= allocated)
- {
- if (path->nodes == path->stub)
- path->nodes = xmemdup (path->stub, sizeof path->stub);
- path->nodes = x2nrealloc (path->nodes, &allocated,
- sizeof *path->nodes);
- }
- path->nodes[path->n++] = item;
- item = item->parent;
- }
-
- for (size_t i = 0; i < path->n / 2; i++)
- swap_nodes (&path->nodes[i], &path->nodes[path->n - i - 1]);
-}
-
-static void
-free_path (struct item_path *path)
-{
- if (path && path->nodes != path->stub)
- free (path->nodes);
-}
-
-static void
-dump_heading_transition (const struct spv_item *old,
- const struct spv_item *new)
-{
- if (old == new)
- return;
-
- struct item_path old_path, new_path;
- get_path (old, &old_path);
- get_path (new, &new_path);
-
- size_t common = 0;
- for (; common < old_path.n && common < new_path.n; common++)
- if (old_path.nodes[common] != new_path.nodes[common])
- break;
-
- for (size_t i = common; i < old_path.n; i++)
- group_close_item_submit (group_close_item_create ());
- for (size_t i = common; i < new_path.n; i++)
- group_open_item_submit (group_open_item_create (
- new_path.nodes[i]->command_id));
-
- free_path (&old_path);
- free_path (&new_path);
-}
-
void
read_spv_file (const char *filename)
{
- struct spv_reader *spv;
- char *error = spv_open (filename, &spv);
+ struct output_item *root;
+ char *error = spv_read (filename, &root, NULL);
if (error)
{
/* XXX */
return;
}
- struct spv_item **items;
- size_t n_items;
- spv_select (spv, NULL, 0, &items, &n_items);
- struct spv_item *prev_heading = spv_get_root (spv);
- for (size_t i = 0; i < n_items; i++)
- {
- struct spv_item *heading
- = items[i]->type == SPV_ITEM_HEADING ? items[i] : items[i]->parent;
- dump_heading_transition (prev_heading, heading);
- if (items[i]->type == SPV_ITEM_TEXT)
- spv_text_submit (items[i]);
- else if (items[i]->type == SPV_ITEM_TABLE)
- pivot_table_submit (spv_item_get_table (items[i]));
- prev_heading = heading;
- }
- dump_heading_transition (prev_heading, spv_get_root (spv));
- free (items);
- spv_close (spv);
+ output_item_submit_children (root);
}
/* Callback for the file_open action.
g_free (uri);
}
-