X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-import-assistant.c;h=9374f7f68e15fbb2ecc4d4c94e30ab3deddeeb26;hb=4246294842a8abedecaaf55aa87507225f03f58c;hp=d3131a3a2ca795b6dc38965e1d87606988587931;hpb=55c55aa33d0f90d1b3b58f8b33b3fc54062c553e;p=pspp diff --git a/src/ui/gui/psppire-import-assistant.c b/src/ui/gui/psppire-import-assistant.c index d3131a3a2c..9374f7f68e 100644 --- a/src/ui/gui/psppire-import-assistant.c +++ b/src/ui/gui/psppire-import-assistant.c @@ -42,15 +42,12 @@ #include "builder-wrapper.h" #include "helper.h" -#include "pspp-sheet-view.h" -#include "pspp-sheet-selection.h" #include "psppire-import-assistant.h" #include "psppire-scanf.h" #include "psppire-dialog.h" #include "psppire-empty-list-store.h" #include "psppire-encoding-selector.h" #include "psppire-spreadsheet-model.h" -#include "psppire-var-sheet.h" #include "ui/syntax-gen.h" #include @@ -201,6 +198,7 @@ on_paste (GtkButton *button, PsppireImportAssistant *ia) close_assistant (ia, PSPPIRE_RESPONSE_PASTE); } + /* Revises the contents of the fields tree view based on the currently chosen set of separators. */ static void @@ -598,6 +596,8 @@ process_file (PsppireImportAssistant *ia) return TRUE; } +#if SHEET_MERGE + static void render_line_number (PsppSheetViewColumn *tree_column, @@ -615,7 +615,6 @@ render_line_number (PsppSheetViewColumn *tree_column, } - static gint get_string_width (GtkWidget *treeview, GtkCellRenderer *renderer, const char *string) @@ -663,7 +662,7 @@ add_line_number_column (const PsppireImportAssistant *ia, static void -set_model_on_treeview (const PsppireImportAssistant *ia, GtkWidget *tree_view, size_t first_line) +set_model_on_treeview (PsppireImportAssistant *ia, GtkWidget *tree_view, size_t first_line) { GtkTreeModel *model = GTK_TREE_MODEL (psppire_empty_list_store_new (ia->line_cnt - first_line)); @@ -687,6 +686,8 @@ make_tree_view (const PsppireImportAssistant *ia) return tree_view; } +#endif + static GtkWidget * add_page_to_assistant (PsppireImportAssistant *ia, GtkWidget *page, GtkAssistantPageType type, const gchar *); @@ -724,7 +725,6 @@ prepare_sheet_spec_page (PsppireImportAssistant *ia) } - /* Initializes IA's sheet_spec substructure. */ static void sheet_spec_page_create (PsppireImportAssistant *ia) @@ -748,7 +748,6 @@ sheet_spec_page_create (PsppireImportAssistant *ia) g_object_set_data (G_OBJECT (page), "on-entering", prepare_sheet_spec_page); } - static void on_chosen (PsppireImportAssistant *ia, GtkWidget *page) { @@ -803,6 +802,8 @@ on_map (PsppireImportAssistant *ia, GtkWidget *page) on_chosen (ia, page); } + + static void chooser_page_enter (PsppireImportAssistant *ia, GtkWidget *page) { @@ -835,6 +836,8 @@ chooser_page_reset (PsppireImportAssistant *ia, GtkWidget *page) on_chosen (ia, page); } + + static void chooser_page_create (PsppireImportAssistant *ia) { @@ -909,6 +912,7 @@ chooser_page_create (PsppireImportAssistant *ia) } + static void psppire_import_assistant_init (PsppireImportAssistant *ia) { @@ -990,6 +994,8 @@ on_intro_amount_changed (PsppireImportAssistant *p) } +#if SHEET_MERGE + static void render_line (PsppSheetViewColumn *tree_column, GtkCellRenderer *cell, @@ -1006,17 +1012,19 @@ render_line (PsppSheetViewColumn *tree_column, g_object_set (cell, "text", ds_cstr (&lines[row]), NULL); } +#endif + /* Sets the widgets to match IA's first_line substructure. */ static void set_first_line (PsppireImportAssistant *ia) { GtkTreePath *path = gtk_tree_path_new_from_indices (ia->skip_lines, -1); - +#if SHEET_MERGE set_model_on_treeview (ia, ia->tree_view, 0); - pspp_sheet_view_set_cursor (PSPP_SHEET_VIEW (ia->tree_view), path, NULL, false); +#endif gtk_tree_path_free (path); gtk_toggle_button_set_active ( @@ -1026,6 +1034,7 @@ set_first_line (PsppireImportAssistant *ia) ia->skip_lines > 0); } +#if SHEET_MERGE /* Creates and returns a tree view that contains each of the lines in IA's file as a row. */ @@ -1071,6 +1080,7 @@ create_lines_tree_view (GtkContainer *parent, PsppireImportAssistant *ia) } + /* Sets IA's first_line substructure to match the widgets. */ static void set_first_line_options (PsppireImportAssistant *ia) @@ -1094,6 +1104,8 @@ set_first_line_options (PsppireImportAssistant *ia) gtk_widget_set_sensitive (ia->variable_names_cb, ia->skip_lines > 0); } + + static void reset_first_line_page (PsppireImportAssistant *ia) { @@ -1103,7 +1115,7 @@ reset_first_line_page (PsppireImportAssistant *ia) gtk_widget_set_sensitive (ia->variable_names_cb, FALSE); } - +#endif /* Initializes IA's first_line substructure. */ static void first_line_page_create (PsppireImportAssistant *ia) @@ -1115,6 +1127,8 @@ first_line_page_create (PsppireImportAssistant *ia) add_page_to_assistant (ia, w, GTK_ASSISTANT_PAGE_CONTENT, _("Select the First Line")); +#if SHEET_MERGE + ia->tree_view = GTK_WIDGET (create_lines_tree_view ( GTK_CONTAINER (get_widget_assert (ia->builder, "first-line-scroller")), ia)); ia->variable_names_cb = get_widget_assert (ia->builder, "variable-names"); @@ -1132,9 +1146,12 @@ first_line_page_create (PsppireImportAssistant *ia) g_object_set_data (G_OBJECT (w), "on-reset", reset_first_line_page); +#endif } + + static void intro_on_enter (PsppireImportAssistant *ia) { @@ -1263,6 +1280,8 @@ psppire_import_assistant_new (GtkWindow *toplevel) NULL)); } + + struct column @@ -1303,6 +1322,8 @@ destroy_columns (PsppireImportAssistant *ia) free (ia->columns); } +#if SHEET_MERGE + /* Called to render one of the cells in the fields preview tree view. */ static void @@ -1336,6 +1357,7 @@ render_input_cell (PsppSheetViewColumn *tree_column, GtkCellRenderer *cell, (void *) NULL); } +#endif /* Parses the contents of the field at (ROW,COLUMN) according to its variable format. If OUTPUTP is non-null, then *OUTPUTP @@ -1395,6 +1417,7 @@ parse_field (PsppireImportAssistant *ia, return ok; } +#if SHEET_MERGE /* Called to render one of the cells in the data preview tree view. */ @@ -1465,6 +1488,7 @@ get_tooltip_location (GtkWidget *widget, gint wx, gint wy, } + @@ -1513,7 +1537,7 @@ on_query_output_tooltip (GtkWidget *widget, gint wx, gint wy, free (text); return TRUE; } - +#endif @@ -1708,24 +1732,32 @@ split_fields (PsppireImportAssistant *ia) } } + +#if SHEET_MERGE static PsppSheetViewColumn * make_data_column (PsppireImportAssistant *ia, GtkWidget *tree_view, bool input, gint dict_idx) { struct variable *var = NULL; struct column *column = NULL; - size_t char_cnt; + size_t char_cnt = 0; gint content_width, header_width; PsppSheetViewColumn *tree_column; - char *name; + char *name = NULL; if (input) - column = &ia->columns[dict_idx]; + { + column = &ia->columns[dict_idx]; + name = escape_underscores (column->name); + char_cnt = column->width; + } else - var = dict_get_var (ia->dict, dict_idx); + { + var = dict_get_var (ia->dict, dict_idx); + name = escape_underscores (var_get_name (var)); + char_cnt = var_get_print_format (var)->w; + } - name = escape_underscores (input ? column->name : var_get_name (var)); - char_cnt = input ? column->width : var_get_print_format (var)->w; content_width = get_monospace_width (tree_view, ia->fixed_renderer, char_cnt); header_width = get_string_width (tree_view, ia->prop_renderer, @@ -1748,15 +1780,19 @@ make_data_column (PsppireImportAssistant *ia, GtkWidget *tree_view, return tree_column; } +#endif static GtkWidget * create_data_tree_view (gboolean input, GtkContainer *parent, PsppireImportAssistant *ia) { gint i; +#if SHEET_MERGE GtkWidget *tree_view = make_tree_view (ia); set_model_on_treeview (ia, tree_view, ia->skip_lines); + + pspp_sheet_selection_set_mode (pspp_sheet_view_get_selection (PSPP_SHEET_VIEW (tree_view)), PSPP_SHEET_SELECTION_NONE); @@ -1786,9 +1822,11 @@ create_data_tree_view (gboolean input, GtkContainer *parent, gtk_widget_show (tree_view); return tree_view; +#endif } + /* Chooses a name for each column on the separators page */ static void choose_column_names (PsppireImportAssistant *ia) @@ -1905,6 +1943,9 @@ separators_page_create (PsppireImportAssistant *ia) + +#if SHEET_MERGE + /* Called when the user changes one of the variables in the dictionary. */ static void @@ -1943,7 +1984,7 @@ on_variable_change (PsppireDict *dict, int dict_idx, pop_watch_cursor (ia); } - +#endif /* Called just before the formats page of the assistant is @@ -2165,11 +2206,13 @@ sheet_spec_gen_syntax (PsppireImportAssistant *ia) return ds_cstr (&s); } + gchar * psppire_import_assistant_generate_syntax (PsppireImportAssistant *ia) { struct string s = DS_EMPTY_INITIALIZER; +#if SHEET_MERGE if (!ia->spreadsheet) { if (ia->file_name == NULL) @@ -2198,6 +2241,8 @@ psppire_import_assistant_generate_syntax (PsppireImportAssistant *ia) { return sheet_spec_gen_syntax (ia); } + +#endif return ds_cstr (&s); }