#include "ui/gui/text-data-import-dialog.h"
#include <errno.h>
-#include <gtk-contrib/psppire-sheet.h>
+#include <fcntl.h>
#include <gtk/gtk.h>
#include <limits.h>
#include <stdlib.h>
#include "language/lexer/lexer.h"
#include "libpspp/assertion.h"
#include "libpspp/i18n.h"
+#include "libpspp/line-reader.h"
#include "libpspp/message.h"
+#include "ui/gui/builder-wrapper.h"
#include "ui/gui/checkbox-treeview.h"
#include "ui/gui/dialog-common.h"
#include "ui/gui/executor.h"
#include "ui/gui/helper.h"
-#include "ui/gui/builder-wrapper.h"
+#include "ui/gui/pspp-sheet-selection.h"
+#include "ui/gui/pspp-sheet-view.h"
#include "ui/gui/psppire-data-window.h"
#include "ui/gui/psppire-dialog.h"
+#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/gui/psppire-var-sheet.h"
#include "ui/syntax-gen.h"
#include "gl/error.h"
struct file
{
char *file_name; /* File name. */
+ gchar *encoding; /* Encoding. */
unsigned long int total_lines; /* Number of lines in file. */
bool total_is_exact; /* Is total_lines exact (or an estimate)? */
bool variable_names; /* Variable names above first line of data? */
GtkWidget *page;
- GtkTreeView *tree_view;
+ PsppSheetView *tree_view;
GtkWidget *variable_names_cb;
};
static void init_first_line_page (struct import_assistant *);
GtkWidget *quote_combo;
GtkEntry *quote_entry;
GtkWidget *escape_cb;
- GtkTreeView *fields_tree_view;
+ PsppSheetView *fields_tree_view;
};
/* The columns that the separators divide the data into. */
struct column
struct dictionary *dict;
GtkWidget *page;
- GtkTreeView *data_tree_view;
+ PsppSheetView *data_tree_view;
PsppireDict *psppire_dict;
struct variable **modified_vars;
size_t modified_var_cnt;
size_t *row, size_t *column);
static void make_tree_view (const struct import_assistant *ia,
size_t first_line,
- GtkTreeView **tree_view);
+ PsppSheetView **tree_view);
static void add_line_number_column (const struct import_assistant *,
- GtkTreeView *);
-static gint get_monospace_width (GtkTreeView *, GtkCellRenderer *,
+ PsppSheetView *);
+static gint get_monospace_width (PsppSheetView *, GtkCellRenderer *,
size_t char_cnt);
-static gint get_string_width (GtkTreeView *, GtkCellRenderer *,
+static gint get_string_width (PsppSheetView *, GtkCellRenderer *,
const char *string);
-static GtkTreeViewColumn *make_data_column (struct import_assistant *,
- GtkTreeView *, bool input,
+static PsppSheetViewColumn *make_data_column (struct import_assistant *,
+ PsppSheetView *, bool input,
gint column_idx);
-static GtkTreeView *create_data_tree_view (bool input, GtkContainer *parent,
+static PsppSheetView *create_data_tree_view (bool input, GtkContainer *parent,
struct import_assistant *);
static void push_watch_cursor (struct import_assistant *);
static void pop_watch_cursor (struct import_assistant *);
" /TYPE=TXT\n"
" /FILE=%sq\n",
ia->file.file_name);
+ if (ia->file.encoding && strcmp (ia->file.encoding, "Auto"))
+ syntax_gen_pspp (&s, " /ENCODING=%sq\n", ia->file.encoding);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
ia->intro.n_cases_button)))
ds_put_format (&s, " /IMPORTCASES=FIRST %d\n",
\f
/* Choosing a file and reading it. */
-static char *choose_file (GtkWindow *parent_window);
+static char *choose_file (GtkWindow *parent_window, gchar **encodingp);
/* Obtains the file to import from the user and initializes IA's
file substructure. PARENT_WINDOW must be the window to use
struct file *file = &ia->file;
enum { MAX_PREVIEW_LINES = 1000 }; /* Max number of lines to read. */
enum { MAX_LINE_LEN = 16384 }; /* Max length of an acceptable line. */
- FILE *stream;
+ struct line_reader *reader;
+ struct string input;
- file->file_name = choose_file (parent_window);
+ file->file_name = choose_file (parent_window, &file->encoding);
if (file->file_name == NULL)
return false;
- stream = fopen (file->file_name, "r");
- if (stream == NULL)
+ reader = line_reader_for_file (file->encoding, file->file_name, O_RDONLY);
+ if (reader == NULL)
{
msg (ME, _("Could not open `%s': %s"),
file->file_name, strerror (errno));
return false;
}
+ ds_init_empty (&input);
file->lines = xnmalloc (MAX_PREVIEW_LINES, sizeof *file->lines);
for (; file->line_cnt < MAX_PREVIEW_LINES; file->line_cnt++)
{
- struct string *line = &file->lines[file->line_cnt];
-
- ds_init_empty (line);
- if (!ds_read_line (line, stream, MAX_LINE_LEN))
+ ds_clear (&input);
+ if (!line_reader_read (reader, &input, MAX_LINE_LEN + 1)
+ || ds_length (&input) > MAX_LINE_LEN)
{
- if (feof (stream))
+ if (line_reader_eof (reader))
break;
- else if (ferror (stream))
+ else if (line_reader_error (reader))
msg (ME, _("Error reading `%s': %s"),
- file->file_name, strerror (errno));
+ file->file_name, strerror (line_reader_error (reader)));
else
msg (ME, _("Failed to read `%s', because it contains a line "
"over %d bytes long and therefore appears not to be "
"a text file."),
file->file_name, MAX_LINE_LEN);
- fclose (stream);
+ line_reader_close (reader);
destroy_file (ia);
+ ds_destroy (&input);
return false;
}
- ds_chomp_byte (line, '\n');
- ds_chomp_byte (line, '\r');
+
+ ds_init_cstr (&file->lines[file->line_cnt],
+ recode_string ("UTF-8", line_reader_get_encoding (reader),
+ ds_cstr (&input), ds_length (&input)));
}
+ ds_destroy (&input);
if (file->line_cnt == 0)
{
msg (ME, _("`%s' is empty."), file->file_name);
- fclose (stream);
+ line_reader_close (reader);
destroy_file (ia);
return false;
}
else
{
struct stat s;
- off_t position = ftello (stream);
- if (fstat (fileno (stream), &s) == 0 && position > 0)
+ off_t position = line_reader_tell (reader);
+ if (fstat (line_reader_fileno (reader), &s) == 0 && position > 0)
file->total_lines = (double) file->line_cnt / position * s.st_size;
else
file->total_lines = 0;
}
+ line_reader_close (reader);
+
return true;
}
ds_destroy (&f->lines[i]);
free (f->lines);
g_free (f->file_name);
+ g_free (f->encoding);
}
-/* Obtains the file to read from the user and returns the name of
- the file as a string that must be freed with g_free if
- successful, otherwise a null pointer. PARENT_WINDOW must be
- the window to use as the file chooser window's parent. */
+/* Obtains the file to read from the user. If successful, returns the name of
+ the file and stores the user's chosen encoding for the file into *ENCODINGP.
+ The caller must free each of these strings with g_free().
+
+ On failure, stores a null pointer and stores NULL in *ENCODINGP.
+
+ PARENT_WINDOW must be the window to use as the file chooser window's
+ parent. */
static char *
-choose_file (GtkWindow *parent_window)
+choose_file (GtkWindow *parent_window, gchar **encodingp)
{
char *file_name;
GtkFileFilter *filter = NULL;
gtk_file_filter_add_mime_type (filter, "text/tab-separated-values");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ gtk_file_chooser_set_extra_widget (
+ GTK_FILE_CHOOSER (dialog), psppire_encoding_selector_new ("Auto", true));
+
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All Files"));
gtk_file_filter_add_pattern (filter, "*");
{
case GTK_RESPONSE_ACCEPT:
file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ *encodingp = psppire_encoding_selector_get_encoding (
+ gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog)));
break;
default:
file_name = NULL;
+ *encodingp = NULL;
break;
}
gtk_widget_destroy (dialog);
\f
/* The "first line" page of the assistant. */
-static GtkTreeView *create_lines_tree_view (GtkContainer *parent_window,
+static PsppSheetView *create_lines_tree_view (GtkContainer *parent_window,
struct import_assistant *);
-static void on_first_line_change (GtkTreeSelection *,
+static void on_first_line_change (PsppSheetSelection *,
struct import_assistant *);
static void on_variable_names_cb_toggle (GtkToggleButton *,
struct import_assistant *);
p->tree_view = create_lines_tree_view (
GTK_CONTAINER (get_widget_assert (builder, "first-line-scroller")), ia);
p->variable_names_cb = get_widget_assert (builder, "variable-names");
- gtk_tree_selection_set_mode (
- gtk_tree_view_get_selection (GTK_TREE_VIEW (p->tree_view)),
- GTK_SELECTION_BROWSE);
+ pspp_sheet_selection_set_mode (
+ pspp_sheet_view_get_selection (PSPP_SHEET_VIEW (p->tree_view)),
+ PSPP_SHEET_SELECTION_BROWSE);
+ pspp_sheet_view_set_rubber_banding (PSPP_SHEET_VIEW (p->tree_view), TRUE);
set_first_line (ia);
- g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (p->tree_view)),
+ g_signal_connect (pspp_sheet_view_get_selection (PSPP_SHEET_VIEW (p->tree_view)),
"changed", G_CALLBACK (on_first_line_change), ia);
g_signal_connect (p->variable_names_cb, "toggled",
G_CALLBACK (on_variable_names_cb_toggle), ia);
}
static void
-render_line (GtkTreeViewColumn *tree_column,
+render_line (PsppSheetViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
/* Creates and returns a tree view that contains each of the
lines in IA's file as a row. */
-static GtkTreeView *
+static PsppSheetView *
create_lines_tree_view (GtkContainer *parent, struct import_assistant *ia)
{
- GtkTreeView *tree_view;
- GtkTreeViewColumn *column;
+ PsppSheetView *tree_view;
+ PsppSheetViewColumn *column;
size_t max_line_length;
gint content_width, header_width;
size_t i;
make_tree_view (ia, 0, &tree_view);
- column = gtk_tree_view_column_new_with_attributes (
- title, ia->asst.fixed_renderer, (void *) NULL);
- gtk_tree_view_column_set_cell_data_func (column, ia->asst.fixed_renderer,
+ column = pspp_sheet_view_column_new_with_attributes (
+ title, ia->asst.fixed_renderer, (void *) NULL);
+ pspp_sheet_view_column_set_cell_data_func (column, ia->asst.fixed_renderer,
render_line, NULL, NULL);
- gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
+ pspp_sheet_view_column_set_resizable (column, TRUE);
max_line_length = 0;
for (i = 0; i < ia->file.line_cnt; i++)
content_width = get_monospace_width (tree_view, ia->asst.fixed_renderer,
max_line_length);
header_width = get_string_width (tree_view, ia->asst.prop_renderer, title);
- gtk_tree_view_column_set_fixed_width (column, MAX (content_width,
+ pspp_sheet_view_column_set_fixed_width (column, MAX (content_width,
header_width));
- gtk_tree_view_append_column (tree_view, column);
-
- gtk_tree_view_set_fixed_height_mode (tree_view, true);
+ pspp_sheet_view_append_column (tree_view, column);
gtk_container_add (parent, GTK_WIDGET (tree_view));
gtk_widget_show (GTK_WIDGET (tree_view));
/* Called when the line selected in the first_line tree view
changes. */
static void
-on_first_line_change (GtkTreeSelection *selection UNUSED,
+on_first_line_change (PsppSheetSelection *selection UNUSED,
struct import_assistant *ia)
{
get_first_line (ia);
GtkTreePath *path;
path = gtk_tree_path_new_from_indices (ia->first_line.skip_lines, -1);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (ia->first_line.tree_view),
+ pspp_sheet_view_set_cursor (PSPP_SHEET_VIEW (ia->first_line.tree_view),
path, NULL, false);
gtk_tree_path_free (path);
static void
get_first_line (struct import_assistant *ia)
{
- GtkTreeSelection *selection;
+ PsppSheetSelection *selection;
GtkTreeIter iter;
GtkTreeModel *model;
- selection = gtk_tree_view_get_selection (ia->first_line.tree_view);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ selection = pspp_sheet_view_get_selection (ia->first_line.tree_view);
+ if (pspp_sheet_selection_get_selected (selection, &model, &iter))
{
GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
int row = gtk_tree_path_get_indices (path)[0];
static void on_quote_cb_toggle (GtkToggleButton *quote_cb,
struct import_assistant *);
static void on_separator_toggle (GtkToggleButton *, struct import_assistant *);
-static void render_input_cell (GtkTreeViewColumn *tree_column,
+static void render_input_cell (PsppSheetViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter,
gpointer ia);
set_separators (ia);
set_quote_list (GTK_COMBO_BOX_ENTRY (p->quote_combo));
- p->fields_tree_view = GTK_TREE_VIEW (get_widget_assert (builder, "fields"));
+ 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",
/* Called to render one of the cells in the fields preview tree
view. */
static void
-render_input_cell (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
+render_input_cell (PsppSheetViewColumn *tree_column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter,
gpointer ia_)
{
p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Formats"),
GTK_ASSISTANT_PAGE_CONFIRM);
- p->data_tree_view = GTK_TREE_VIEW (get_widget_assert (builder, "data"));
+ p->data_tree_view = PSPP_SHEET_VIEW (get_widget_assert (builder, "data"));
p->modified_vars = NULL;
p->modified_var_cnt = 0;
p->dict = NULL;
if (p->psppire_dict != NULL)
{
- /* This destroys p->dict also. */
+ dict_destroy (p->psppire_dict->dict);
g_object_unref (p->psppire_dict);
}
clear_modified_vars (ia);
{
struct dictionary *dict;
PsppireDict *psppire_dict;
- PsppireVarStore *var_store;
GtkBin *vars_scroller;
GtkWidget *old_var_sheet;
PsppireVarSheet *var_sheet;
psppire_dict for now, but it should. After it does, we
should g_object_ref the psppire_dict here, since we also
hold a reference via ia->formats.dict. */
- var_store = psppire_var_store_new (psppire_dict);
- g_object_set (var_store,
- "format-type", PSPPIRE_VAR_STORE_INPUT_FORMATS,
- (void *) NULL);
var_sheet = PSPPIRE_VAR_SHEET (psppire_var_sheet_new ());
g_object_set (var_sheet,
- "model", var_store,
+ "dictionary", psppire_dict,
"may-create-vars", FALSE,
+ "may-delete-vars", FALSE,
+ "format-use", FMT_FOR_INPUT,
+ "enable-grid-lines", PSPP_SHEET_VIEW_GRID_LINES_BOTH,
(void *) NULL);
vars_scroller = GTK_BIN (get_widget_assert (ia->asst.builder, "vars-scroller"));
struct import_assistant *ia)
{
struct formats_page *p = &ia->formats;
- GtkTreeView *tv = ia->formats.data_tree_view;
+ PsppSheetView *tv = ia->formats.data_tree_view;
gint column_idx = dict_idx + 1;
push_watch_cursor (ia);
/* Remove previous column and replace with new column. */
- gtk_tree_view_remove_column (tv, gtk_tree_view_get_column (tv, column_idx));
- gtk_tree_view_insert_column (tv, make_data_column (ia, tv, false, dict_idx),
+ pspp_sheet_view_remove_column (tv, pspp_sheet_view_get_column (tv, column_idx));
+ pspp_sheet_view_insert_column (tv, make_data_column (ia, tv, false, dict_idx),
column_idx);
/* Save a copy of the modified variable in modified_vars, so
{
char *error;
- error = data_in (field, C_ENCODING, in->type, &val, var_get_width (var),
+ error = data_in (field, "UTF-8", in->type, &val, var_get_width (var),
dict_get_encoding (ia->formats.dict));
if (error != NULL)
{
/* Called to render one of the cells in the data preview tree
view. */
static void
-render_output_cell (GtkTreeViewColumn *tree_column,
+render_output_cell (PsppSheetViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *model,
GtkTreeIter *iter,
const struct import_assistant *ia,
size_t *row, size_t *column)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
+ PsppSheetView *tree_view = PSPP_SHEET_VIEW (widget);
gint bx, by;
GtkTreePath *path;
GtkTreeIter iter;
- GtkTreeViewColumn *tree_column;
+ PsppSheetViewColumn *tree_column;
GtkTreeModel *tree_model;
bool ok;
if (!gtk_widget_get_mapped (widget))
return FALSE;
- gtk_tree_view_convert_widget_to_bin_window_coords (tree_view,
+ pspp_sheet_view_convert_widget_to_bin_window_coords (tree_view,
wx, wy, &bx, &by);
- if (!gtk_tree_view_get_path_at_pos (tree_view, bx, by,
+ if (!pspp_sheet_view_get_path_at_pos (tree_view, bx, by,
&path, &tree_column, NULL, NULL))
return FALSE;
*column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_column),
"column-number"));
- tree_model = gtk_tree_view_get_model (tree_view);
+ tree_model = pspp_sheet_view_get_model (tree_view);
ok = gtk_tree_model_get_iter (tree_model, &iter, path);
gtk_tree_path_free (path);
if (!ok)
static void
make_tree_view (const struct import_assistant *ia,
size_t first_line,
- GtkTreeView **tree_view)
+ PsppSheetView **tree_view)
{
GtkTreeModel *model;
- *tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
+ *tree_view = PSPP_SHEET_VIEW (pspp_sheet_view_new ());
+ pspp_sheet_view_set_grid_lines (*tree_view, PSPP_SHEET_VIEW_GRID_LINES_BOTH);
model = GTK_TREE_MODEL (psppire_empty_list_store_new (
ia->file.line_cnt - first_line));
g_object_set_data (G_OBJECT (model), "lines", ia->file.lines + first_line);
g_object_set_data (G_OBJECT (model), "first-line",
GINT_TO_POINTER (first_line));
- gtk_tree_view_set_model (*tree_view, model);
+ pspp_sheet_view_set_model (*tree_view, model);
g_object_unref (model);
add_line_number_column (ia, *tree_view);
}
static void
-render_line_number (GtkTreeViewColumn *tree_column,
+render_line_number (PsppSheetViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
static void
add_line_number_column (const struct import_assistant *ia,
- GtkTreeView *treeview)
+ PsppSheetView *treeview)
{
- GtkTreeViewColumn *column;
+ PsppSheetViewColumn *column;
- column = gtk_tree_view_column_new_with_attributes (
+ column = pspp_sheet_view_column_new_with_attributes (
_("Line"), ia->asst.prop_renderer, (void *) NULL);
- gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width (
+ pspp_sheet_view_column_set_fixed_width (
column, get_monospace_width (treeview, ia->asst.prop_renderer, 5));
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, ia->asst.prop_renderer,
- render_line_number, NULL, NULL);
- gtk_tree_view_append_column (treeview, column);
+ pspp_sheet_view_column_set_resizable (column, TRUE);
+ pspp_sheet_view_column_set_cell_data_func (column, ia->asst.prop_renderer,
+ render_line_number, NULL, NULL);
+ pspp_sheet_view_append_column (treeview, column);
}
static gint
-get_monospace_width (GtkTreeView *treeview, GtkCellRenderer *renderer,
+get_monospace_width (PsppSheetView *treeview, GtkCellRenderer *renderer,
size_t char_cnt)
{
struct string s;
}
static gint
-get_string_width (GtkTreeView *treeview, GtkCellRenderer *renderer,
+get_string_width (PsppSheetView *treeview, GtkCellRenderer *renderer,
const char *string)
{
gint width;
return width;
}
-static GtkTreeViewColumn *
-make_data_column (struct import_assistant *ia, GtkTreeView *tree_view,
+static PsppSheetViewColumn *
+make_data_column (struct import_assistant *ia, PsppSheetView *tree_view,
bool input, gint dict_idx)
{
struct variable *var = NULL;
struct column *column = NULL;
size_t char_cnt;
gint content_width, header_width;
- GtkTreeViewColumn *tree_column;
+ PsppSheetViewColumn *tree_column;
char *name;
if (input)
header_width = get_string_width (tree_view, ia->asst.prop_renderer,
name);
- tree_column = gtk_tree_view_column_new ();
+ tree_column = pspp_sheet_view_column_new ();
g_object_set_data (G_OBJECT (tree_column), "column-number",
GINT_TO_POINTER (dict_idx));
- gtk_tree_view_column_set_title (tree_column, name);
- gtk_tree_view_column_pack_start (tree_column, ia->asst.fixed_renderer,
+ pspp_sheet_view_column_set_title (tree_column, name);
+ pspp_sheet_view_column_pack_start (tree_column, ia->asst.fixed_renderer,
FALSE);
- gtk_tree_view_column_set_cell_data_func (
+ pspp_sheet_view_column_set_cell_data_func (
tree_column, ia->asst.fixed_renderer,
input ? render_input_cell : render_output_cell, ia, NULL);
- gtk_tree_view_column_set_sizing (tree_column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width (tree_column, MAX (content_width,
+ pspp_sheet_view_column_set_fixed_width (tree_column, MAX (content_width,
header_width));
+ pspp_sheet_view_column_set_resizable (tree_column, TRUE);
free (name);
return tree_column;
}
-static GtkTreeView *
+static PsppSheetView *
create_data_tree_view (bool input, GtkContainer *parent,
struct import_assistant *ia)
{
- GtkTreeView *tree_view;
+ PsppSheetView *tree_view;
gint i;
make_tree_view (ia, ia->first_line.skip_lines, &tree_view);
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (tree_view),
- GTK_SELECTION_NONE);
+ pspp_sheet_selection_set_mode (pspp_sheet_view_get_selection (tree_view),
+ PSPP_SHEET_SELECTION_NONE);
for (i = 0; i < ia->separators.column_cnt; i++)
- gtk_tree_view_append_column (tree_view,
+ pspp_sheet_view_append_column (tree_view,
make_data_column (ia, tree_view, input, i));
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);
- gtk_tree_view_set_fixed_height_mode (tree_view, true);
gtk_container_add (parent, GTK_WIDGET (tree_view));
gtk_widget_show (GTK_WIDGET (tree_view));