X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpage-separators.c;h=4b9f184be7c81d0a57a23134c071ff18cd694ee0;hb=5206c60ba8beaddccdf571db65709b38dbadb3fd;hp=fee511e0c308c99d43dd019d3323daf9289ab851;hpb=6e29a48cd6e626fb2542d5babcbdcc7f67c071d3;p=pspp diff --git a/src/ui/gui/page-separators.c b/src/ui/gui/page-separators.c index fee511e0c3..4b9f184be7 100644 --- a/src/ui/gui/page-separators.c +++ b/src/ui/gui/page-separators.c @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -48,7 +47,6 @@ #include "ui/gui/psppire-encoding-selector.h" #include "ui/gui/psppire-empty-list-store.h" #include "ui/gui/psppire-var-sheet.h" -#include "ui/gui/psppire-var-store.h" #include "ui/gui/psppire-scanf.h" #include "ui/syntax-gen.h" @@ -75,7 +73,7 @@ struct separators_page GtkWidget *quote_combo; GtkEntry *quote_entry; GtkWidget *escape_cb; - GtkTreeView *fields_tree_view; + PsppSheetView *fields_tree_view; }; /* The "separators" page of the assistant. */ @@ -123,7 +121,7 @@ static const struct separator separators[] = #define SEPARATOR_CNT (sizeof separators / sizeof *separators) static void -set_quote_list (GtkComboBoxEntry *cb) +set_quote_list (GtkComboBox *cb) { GtkListStore *list = gtk_list_store_new (1, G_TYPE_STRING); GtkTreeIter iter; @@ -145,7 +143,7 @@ set_quote_list (GtkComboBoxEntry *cb) gtk_combo_box_set_model (GTK_COMBO_BOX (cb), GTK_TREE_MODEL (list)); g_object_unref (list); - gtk_combo_box_entry_set_text_column (cb, 0); + gtk_combo_box_set_entry_text_column (cb, 0); } /* Initializes IA's separators substructure. */ @@ -169,8 +167,8 @@ separators_page_create (struct import_assistant *ia) p->quote_cb = get_widget_assert (builder, "quote-cb"); p->escape_cb = get_widget_assert (builder, "escape"); - set_quote_list (GTK_COMBO_BOX_ENTRY (p->quote_combo)); - p->fields_tree_view = GTK_TREE_VIEW (get_widget_assert (builder, "fields")); + set_quote_list (GTK_COMBO_BOX (p->quote_combo)); + p->fields_tree_view = PSPP_SHEET_VIEW (get_widget_assert (builder, "fields")); g_signal_connect (p->quote_combo, "changed", G_CALLBACK (on_quote_combo_change), ia); g_signal_connect (p->quote_cb, "toggled", @@ -530,10 +528,8 @@ get_separators (struct import_assistant *ia) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (s->quote_cb))) { - gchar *text = gtk_combo_box_get_active_text ( - GTK_COMBO_BOX (s->quote_combo)); + const gchar *text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (s->quote_combo)))); ds_assign_cstr (&s->quotes, text); - g_free (text); } else ds_clear (&s->quotes); @@ -589,3 +585,28 @@ on_separator_toggle (GtkToggleButton *toggle UNUSED, revise_fields_preview (ia); } + + +void +separators_append_syntax (const struct import_assistant *ia, struct string *s) +{ + int i; + ds_put_cstr (s, " /DELIMITERS=\""); + if (ds_find_byte (&ia->separators->separators, '\t') != SIZE_MAX) + ds_put_cstr (s, "\\t"); + if (ds_find_byte (&ia->separators->separators, '\\') != SIZE_MAX) + ds_put_cstr (s, "\\\\"); + for (i = 0; i < ds_length (&ia->separators->separators); i++) + { + char c = ds_at (&ia->separators->separators, i); + if (c == '"') + ds_put_cstr (s, "\"\""); + else if (c != '\t' && c != '\\') + ds_put_byte (s, c); + } + ds_put_cstr (s, "\"\n"); + if (!ds_is_empty (&ia->separators->quotes)) + syntax_gen_pspp (s, " /QUALIFIER=%sq\n", ds_cstr (&ia->separators->quotes)); + if (!ds_is_empty (&ia->separators->quotes) && ia->separators->escape) + ds_put_cstr (s, " /ESCAPE\n"); +}