Change the return type of psppire_delimited_text_new.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 8 Jun 2017 05:14:04 +0000 (07:14 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 8 Jun 2017 05:29:03 +0000 (07:29 +0200)
... and deal with the consequences.

src/ui/gui/psppire-delimited-text.c
src/ui/gui/psppire-delimited-text.h
src/ui/gui/psppire-import-assistant.c
src/ui/gui/psppire-import-assistant.h

index a63ccc25dc1852b05efd1022f706adfaca548685..dd13f1c384edf73a93f83027683a431ee39fe44c 100644 (file)
@@ -71,7 +71,7 @@ count_delims (PsppireDelimitedText *tf)
        for (p = line; ; p = g_utf8_find_next_char (p, NULL))
          {
            const gunichar c = g_utf8_get_char (p);
-           if (c == NULL)
+           if (c == 0)
              break;
            if (enc == -1)
              {
@@ -592,15 +592,13 @@ psppire_delimited_text_init (PsppireDelimitedText *text_file)
 }
 
 
-GtkTreeModel *
+PsppireDelimitedText *
 psppire_delimited_text_new (GtkTreeModel *child)
 {
-  PsppireDelimitedText *retval =
+  return
     g_object_new (PSPPIRE_TYPE_DELIMITED_TEXT,
                  "child", child,
                  NULL);
-
-  return GTK_TREE_MODEL (retval);
 }
 
 static void
index 56ee8f97e52a0985ba935afc522021d45c29e6fd..d18570a83fcf16d5c1510f6db9d801b3afa4b7ee 100644 (file)
@@ -81,7 +81,7 @@ typedef struct _PsppireDelimitedText       PsppireDelimitedText;
 typedef struct _PsppireDelimitedTextClass  PsppireDelimitedTextClass;
 
 GType psppire_delimited_text_get_type (void) G_GNUC_CONST;
-GtkTreeModel *psppire_delimited_text_new (GtkTreeModel *);
+PsppireDelimitedText *psppire_delimited_text_new (GtkTreeModel *);
 
 const gchar *psppire_delimited_text_get_header_title (PsppireDelimitedText *file, gint column);
 
index ab959211c0a399b52cbfb85df3c06e4499cba34b..f38438b37534e2b658951e8948526d9026208af3 100644 (file)
@@ -311,7 +311,8 @@ repopulate_delimiter_columns (PsppireImportAssistant *ia)
       gtk_tree_view_remove_column (GTK_TREE_VIEW (ia->fields_tree_view), tvc);
     }
 
-  gint n_fields = gtk_tree_model_get_n_columns (ia->delimiters_model);
+  gint n_fields =
+    gtk_tree_model_get_n_columns (GTK_TREE_MODEL (ia->delimiters_model));
 
   /* ... and put them back again. */
   gint f;
@@ -371,9 +372,10 @@ reset_tree_view_model (PsppireImportAssistant *ia)
 static void
 prepare_separators_page (PsppireImportAssistant *ia, GtkWidget *page)
 {
-  gtk_tree_view_set_model (GTK_TREE_VIEW (ia->fields_tree_view), ia->delimiters_model);
+  gtk_tree_view_set_model (GTK_TREE_VIEW (ia->fields_tree_view),
+                          GTK_TREE_MODEL (ia->delimiters_model));
 
-  g_signal_connect_swapped (ia->delimiters_model, "notify::delimiters",
+  g_signal_connect_swapped (GTK_TREE_MODEL (ia->delimiters_model), "notify::delimiters",
                        G_CALLBACK (reset_tree_view_model), ia);
 
 
@@ -821,7 +823,6 @@ render_text_preview_line (GtkTreeViewColumn *tree_column,
      Set the text  to a "insensitive" state if the row
      is greater than what the user declared to be the maximum.
   */
-  PsppireImportAssistant *ia = PSPPIRE_IMPORT_ASSISTANT (data);
   GtkTreePath *path = gtk_tree_model_get_path (tree_model, iter);
   gint *ii = gtk_tree_path_get_indices (path);
   gint max_lines;
@@ -1047,8 +1048,6 @@ set_quote_list (GtkComboBox *cb)
   gtk_combo_box_set_entry_text_column (cb, 0);
 }
 
-
-
 /* Chooses a name for each column on the separators page */
 static void
 choose_column_names (PsppireImportAssistant *ia)
@@ -1057,7 +1056,9 @@ choose_column_names (PsppireImportAssistant *ia)
   unsigned long int generated_name_count = 0;
   dict_clear (ia->dict);
 
-  for (i = 0; i < gtk_tree_model_get_n_columns (ia->delimiters_model) - 1; ++i)
+  for (i = 0;
+       i < gtk_tree_model_get_n_columns (GTK_TREE_MODEL (ia->delimiters_model)) - 1;
+       ++i)
     {
       const gchar *candidate_name = NULL;
 
@@ -1075,8 +1076,6 @@ choose_column_names (PsppireImportAssistant *ia)
     }
 }
 
-
-
 /* Called when the user toggles one of the separators
    checkboxes. */
 static void
@@ -1266,7 +1265,7 @@ foo (struct dictionary *dict, void *aux)
     }
 
 
-  gint n_rows = gtk_tree_model_iter_n_children (ia->delimiters_model, NULL);
+  gint n_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (ia->delimiters_model), NULL);
 
   struct casereader *reader =
     casereader_create_random (proto, n_rows, &my_casereader_class,  ia);
@@ -1300,18 +1299,18 @@ prepare_formats_page (PsppireImportAssistant *ia)
       fg[i] = fmt_guesser_create ();
     }
 
-  gint n_rows = gtk_tree_model_iter_n_children (ia->delimiters_model, NULL);
+  gint n_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (ia->delimiters_model), NULL);
 
   GtkTreeIter iter;
   gboolean ok;
-  for (ok = gtk_tree_model_get_iter_first (ia->delimiters_model, &iter);
+  for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ia->delimiters_model), &iter);
        ok;
-       ok = gtk_tree_model_iter_next (ia->delimiters_model, &iter))
+       ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (ia->delimiters_model), &iter))
     {
       for (i = 0 ; i < dict_get_var_cnt (ia->dict); ++i)
        {
          gchar *s = NULL;
-         gtk_tree_model_get (ia->delimiters_model, &iter, i+1, &s, -1);
+         gtk_tree_model_get (GTK_TREE_MODEL (ia->delimiters_model), &iter, i+1, &s, -1);
          if (s)
            fmt_guesser_add (fg[i], ss_cstr (s));
          free (s);
index 4288982f62b6d11e268d73f648395de716ab3042..cdcf8fb73ee48f274745eccffd547da248a28a01 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2015  Free Software Foundation
+   Copyright (C) 2015, 2017  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
 
 #include <gtk/gtk.h>
 
-#include "libpspp/str.h"
 #include "psppire-dict.h"
 #include "data/spreadsheet-reader.h"
 #include "psppire-text-file.h"
+#include "psppire-delimited-text.h"
 
 G_BEGIN_DECLS
 
@@ -113,7 +113,7 @@ struct _PsppireImportAssistant
   int response;
 
   PsppireTextFile *text_file;
-  GtkTreeModel *delimiters_model;
+  PsppireDelimitedText *delimiters_model;
 
   struct sheet_spec_page *sheet_spec;