-static void
-set_quote_list (GtkComboBox *cb)
-{
- GtkListStore *list = gtk_list_store_new (1, G_TYPE_STRING);
- GtkTreeIter iter;
- gint i;
- const gchar *separator[3] = {"'\"", "\'", "\""};
-
- for (i = 0; i < 3; i++)
- {
- const gchar *s = separator[i];
-
- /* Add a new row to the model */
- gtk_list_store_append (list, &iter);
- gtk_list_store_set (list, &iter,
- 0, s,
- -1);
-
- }
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (cb), GTK_TREE_MODEL (list));
- g_object_unref (list);
-
- 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)
-{
- int i;
- unsigned long int generated_name_count = 0;
- dict_clear (ia->dict);
-
- g_print ("%s:%d XXX %d\n", __FILE__, __LINE__, gtk_tree_model_get_n_columns (ia->delimiters_model));
-
- for (i = 0; i < gtk_tree_model_get_n_columns (ia->delimiters_model) - 1; ++i)
- {
- const gchar *candidate_name = NULL;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->variable_names_cb)))
- {
- candidate_name = psppire_delimited_text_get_header_title (PSPPIRE_DELIMITED_TEXT (ia->delimiters_model), i);
- }
-
- g_print ("%s:%d CN is %s\n", __FILE__, __LINE__, candidate_name);
-
- char *name = dict_make_unique_var_name (ia->dict,
- candidate_name,
- &generated_name_count);
-
- dict_create_var_assert (ia->dict, name, 0);
- free (name);
- }
-}
-
-
-
-/* Called when the user toggles one of the separators
- checkboxes. */
-static void
-on_separator_toggle (GtkToggleButton *toggle UNUSED,
- PsppireImportAssistant *ia)
-{
- int i;
- GSList *delimiters = NULL;
- for (i = 0; i < SEPARATOR_CNT; i++)
- {
- const struct separator *s = &separators[i];
- GtkWidget *button = get_widget_assert (ia->builder, s->name);
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
- {
- delimiters = g_slist_prepend (delimiters, GINT_TO_POINTER (s->c));
- }
- }
-
- g_object_set (ia->delimiters_model, "delimiters", delimiters, NULL);
-
- revise_fields_preview (ia);
-}
-
-
-/* Called when the user changes the entry field for custom
- separators. */
-static void
-on_separators_custom_entry_notify (GObject *gobject UNUSED,
- GParamSpec *arg1 UNUSED,
- PsppireImportAssistant *ia)
-{
- revise_fields_preview (ia);
-}
-
-/* Called when the user toggles the checkbox that enables custom
- separators. */
-static void
-on_separators_custom_cb_toggle (GtkToggleButton *custom_cb,
- PsppireImportAssistant *ia)
-{
- bool is_active = gtk_toggle_button_get_active (custom_cb);
- gtk_widget_set_sensitive (ia->custom_entry, is_active);
- revise_fields_preview (ia);
-}
-
-/* Called when the user changes the selection in the combo box
- that selects a quote character. */
-static void
-on_quote_combo_change (GtkComboBox *combo, PsppireImportAssistant *ia)
-{
- // revise_fields_preview (ia);
-}
-
-/* Called when the user toggles the checkbox that enables
- quoting. */
-static void
-on_quote_cb_toggle (GtkToggleButton *quote_cb, PsppireImportAssistant *ia)
-{
- bool is_active = gtk_toggle_button_get_active (quote_cb);
- gtk_widget_set_sensitive (ia->quote_combo, is_active);
- revise_fields_preview (ia);
-}
-
-/* Initializes IA's separators substructure. */
-static void
-separators_page_create (PsppireImportAssistant *ia)
-{
- GtkBuilder *builder = ia->builder;
-
- size_t i;
-
- GtkWidget *w = get_widget_assert (builder, "Separators");
-
- g_object_set_data (G_OBJECT (w), "on-entering", prepare_separators_page);
- g_object_set_data (G_OBJECT (w), "on-reset", prepare_separators_page);
-
- add_page_to_assistant (ia, w, GTK_ASSISTANT_PAGE_CONTENT, _("Choose Separators"));
-
- ia->custom_cb = get_widget_assert (builder, "custom-cb");
- ia->custom_entry = get_widget_assert (builder, "custom-entry");
- ia->quote_combo = get_widget_assert (builder, "quote-combo");
- ia->quote_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (ia->quote_combo)));
- ia->quote_cb = get_widget_assert (builder, "quote-cb");
-
- set_quote_list (GTK_COMBO_BOX (ia->quote_combo));
-
- if (ia->fields_tree_view == NULL)
- {
- GtkWidget *scroller = get_widget_assert (ia->builder, "fields-scroller");
- ia->fields_tree_view = gtk_tree_view_new ();
- gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET (ia->fields_tree_view));
- gtk_widget_show_all (scroller);
- }
-
- g_signal_connect (ia->quote_combo, "changed",
- G_CALLBACK (on_quote_combo_change), ia);
- g_signal_connect (ia->quote_cb, "toggled",
- G_CALLBACK (on_quote_cb_toggle), ia);
- g_signal_connect (ia->custom_entry, "notify::text",
- G_CALLBACK (on_separators_custom_entry_notify), ia);
- g_signal_connect (ia->custom_cb, "toggled",
- G_CALLBACK (on_separators_custom_cb_toggle), ia);
- for (i = 0; i < SEPARATOR_CNT; i++)
- g_signal_connect (get_widget_assert (builder, separators[i].name),
- "toggled", G_CALLBACK (on_separator_toggle), ia);
-
-}
-
-
-
-\f
-
-
-static struct casereader_random_class my_casereader_class;
-
-static struct ccase *
-my_read (struct casereader *reader, void *aux, casenumber idx)
-{
- PsppireImportAssistant *ia = PSPPIRE_IMPORT_ASSISTANT (aux);
- GtkTreeModel *tm = GTK_TREE_MODEL (ia->delimiters_model);
-
- GtkTreePath *tp = gtk_tree_path_new_from_indices (idx, -1);
-
- const struct caseproto *proto = casereader_get_proto (reader);
-
- GtkTreeIter iter;
- struct ccase *c = NULL;
- if (gtk_tree_model_get_iter (tm, &iter, tp))
- {
- c = case_create (proto);
- int i;
- for (i = 0 ; i < caseproto_get_n_widths (proto); ++i)
- {
- GValue value = {0};
- gtk_tree_model_get_value (tm, &iter, i + 1, &value);
-
- const struct variable *var = dict_get_var (ia->dict, i);
-
- const gchar *ss = g_value_get_string (&value);
-
- union value *v = case_data_rw (c, var);
- char *xx = data_in (ss_cstr (ss),
- "UTF-8",
- var_get_write_format (var)->type,
- v, var_get_width (var), "UTF-8");
-
- /* if (xx) */
- /* g_print ("%s:%d Err %s\n", __FILE__, __LINE__, xx); */
- free (xx);
- g_value_unset (&value);
- }
- }
-
- gtk_tree_path_free (tp);
-
- return c;
-}
-
-static void
-my_destroy (struct casereader *reader, void *aux)
-{
- g_print ("%s:%d %p\n", __FILE__, __LINE__, reader);
-}
-
-static void
-my_advance (struct casereader *reader, void *aux, casenumber cnt)
-{
- g_print ("%s:%d\n", __FILE__, __LINE__);
-}
-
-static void
-foo (struct dictionary *dict, void *aux)
-{
- PsppireImportAssistant *ia = PSPPIRE_IMPORT_ASSISTANT (aux);
- g_print ("%s:%d\n", __FILE__, __LINE__);
-
- struct caseproto *proto = caseproto_create ();
-
- int i;
- for (i = 0 ; i < dict_get_var_cnt (ia->dict); ++i)
- {
- const struct variable *var = dict_get_var (ia->dict, i);
- proto = caseproto_add_width (proto, var_get_width (var));
- }
-
-
- gint n_rows = gtk_tree_model_iter_n_children (ia->delimiters_model, NULL);
-
- struct casereader *reader =
- casereader_create_random (proto, n_rows, &my_casereader_class, ia);
-
-
- PsppireDataStore *store = NULL;
-
- g_object_get (ia->data_sheet, "data-model", &store, NULL);
-
- psppire_data_store_set_reader (store, reader);
-}