-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;
- gint content_width, header_width;
- PsppSheetViewColumn *tree_column;
- char *name;
-
- if (input)
- column = &ia->columns[dict_idx];
- else
- var = dict_get_var (ia->dict, dict_idx);
-
- 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,
- name);
-
- tree_column = pspp_sheet_view_column_new ();
- g_object_set_data (G_OBJECT (tree_column), "column-number",
- GINT_TO_POINTER (dict_idx));
- pspp_sheet_view_column_set_title (tree_column, name);
- pspp_sheet_view_column_pack_start (tree_column, ia->fixed_renderer,
- FALSE);
- pspp_sheet_view_column_set_cell_data_func (
- tree_column, ia->fixed_renderer,
- input ? render_input_cell : render_output_cell, ia, NULL);
- pspp_sheet_view_column_set_fixed_width (tree_column, MAX (content_width,
- header_width));
-
- free (name);
-
- return tree_column;
-}
-
-
-static GtkWidget *
-create_data_tree_view (gboolean input, GtkContainer *parent,
- PsppireImportAssistant *ia)
-{
- gint i;
- 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);
-
- for (i = 0; i < ia->column_cnt; i++)
- {
- PsppSheetViewColumn *w = make_data_column (ia, tree_view, input, i);
-
- pspp_sheet_view_append_column (PSPP_SHEET_VIEW (tree_view), w);
- }
-
- g_object_set (G_OBJECT (tree_view), "has-tooltip", TRUE, (void *) NULL);
- g_signal_connect (tree_view, "query-tooltip",
- G_CALLBACK (input ? on_query_input_tooltip
- : on_query_output_tooltip), ia);
-
- GtkWidget *child = gtk_bin_get_child (GTK_BIN (parent));
- if (child)
- {
- g_object_ref (child);
- gtk_container_remove (parent, child);
- }
- gtk_container_add (parent, tree_view);
- if (child)
- g_object_unref (child);
-
- gtk_widget_show (tree_view);
-
- return tree_view;
-}
-