/** * csv_page_global_change * @widget : the widget which emitted the signal * @data : mother struct * * This will update the preview based on the state of * the widgets on the csv page * * returns : nothing **/ static void csv_page_global_change (G_GNUC_UNUSED GtkWidget *widget, StfDialogData *pagedata) { StfParseOptions_t *parseoptions = pagedata->parseoptions; RenderData_t *renderdata = pagedata->csv.renderdata; GSList *sepstr; GString *sepc = g_string_new (NULL); GStringChunk *lines_chunk; GPtrArray *lines; StfTrimType_t trim; sepstr = NULL; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_custom))) { char *csvcustomtext = gtk_editable_get_chars (GTK_EDITABLE (pagedata->csv.csv_customseparator), 0, -1); if (strcmp (csvcustomtext, "") != 0) sepstr = g_slist_append (sepstr, csvcustomtext); else g_free (csvcustomtext); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_tab))) g_string_append_c (sepc, '\t'); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_colon))) g_string_append_c (sepc, ':'); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_comma))) g_string_append_c (sepc, ','); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_space))) g_string_append_c (sepc, ' '); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_semicolon))) g_string_append_c (sepc, ';'); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_hyphen))) g_string_append_c (sepc, '-'); stf_parse_options_csv_set_separators (parseoptions, strcmp (sepc->str, "") == 0 ? NULL : sepc->str, sepstr); g_string_free (sepc, TRUE); go_slist_free_custom (sepstr, g_free); stf_parse_options_csv_set_duplicates (parseoptions, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_duplicates))); stf_parse_options_csv_set_trim_seps (parseoptions, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_trim_seps))); lines_chunk = g_string_chunk_new (100 * 1024); /* Don't trim on this page. */ trim = parseoptions->trim_spaces; stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER); lines = stf_parse_general (parseoptions, lines_chunk, pagedata->cur, pagedata->cur_end); stf_parse_options_set_trim_spaces (parseoptions, trim); stf_preview_set_lines (renderdata, lines_chunk, lines); }
static void format_page_trim_menu_changed (G_GNUC_UNUSED GtkMenu *menu, StfDialogData *data) { StfTrimType_t trim; int trimtype = gtk_combo_box_get_active (GTK_COMBO_BOX (data->format.format_trim)); switch (trimtype) { case -1: case 0: trim = TRIM_TYPE_LEFT | TRIM_TYPE_RIGHT; break; default: g_warning ("Unknown trim type selected (%d)", trimtype); /* Fall through. */ case 1: trim = TRIM_TYPE_NEVER; break; case 2: trim = TRIM_TYPE_LEFT; break; case 3: trim = TRIM_TYPE_RIGHT; break; } stf_parse_options_set_trim_spaces (data->parseoptions, trim); format_page_update_preview (data); }
/** * fixed_page_update_preview * @pagedata: mother struct * * Will simply update the preview * * returns : nothing **/ static void fixed_page_update_preview (StfDialogData *pagedata) { StfParseOptions_t *parseoptions = pagedata->parseoptions; RenderData_t *renderdata = pagedata->fixed.renderdata; int i; GStringChunk *lines_chunk; GPtrArray *lines; StfTrimType_t trim; lines_chunk = g_string_chunk_new (100 * 1024); /* Don't trim on this page. */ trim = parseoptions->trim_spaces; stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER); lines = stf_parse_general (parseoptions, lines_chunk, pagedata->cur, pagedata->cur_end); stf_parse_options_set_trim_spaces (parseoptions, trim); stf_preview_set_lines (renderdata, lines_chunk, lines); for (i = 0; i < renderdata->colcount; i++) { GtkTreeViewColumn *column = stf_preview_get_column (renderdata, i); GtkCellRenderer *cell = stf_preview_get_cell_renderer (renderdata, i); GtkWidget *button = gtk_tree_view_column_get_button (column); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); g_object_set (G_OBJECT (cell), "family", "monospace", NULL); g_object_set_data (G_OBJECT (button), "fixed-data", pagedata); g_object_set (G_OBJECT (column), "clickable", TRUE, NULL); g_signal_connect (button, "button_press_event", G_CALLBACK (cb_col_button_press), GINT_TO_POINTER (i)); g_signal_connect (button, "key_press_event", G_CALLBACK (cb_col_key_press), GINT_TO_POINTER (i)); } }
/** * stf_dialog_fixed_page_prepare * @pagedata: mother struct * * Will prepare the fixed page **/ void stf_dialog_fixed_page_prepare (StfDialogData *pagedata) { stf_parse_options_set_trim_spaces (pagedata->parseoptions, TRIM_TYPE_NEVER); fixed_page_update_preview (pagedata); }