gui: Fix icon names.
[pspp] / src / ui / gui / psppire-window.c
index 99da30fa3eac4772b15983a705c603a474dbb697..60f265e4437a85a3feebdfc599091d2a8e702207 100644 (file)
 #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"
@@ -396,7 +394,7 @@ psppire_window_init (PsppireWindow *window)
 
   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);
 }
 
 /*
@@ -431,7 +429,7 @@ psppire_window_query_save (PsppireWindow *se)
                            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."),
@@ -698,85 +696,11 @@ psppire_window_file_chooser_dialog (PsppireWindow *toplevel)
   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 */
@@ -784,24 +708,7 @@ read_spv_file (const char *filename)
       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 (pivot_table_ref (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.