void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data) { BillImportGui *gui = data; gchar *temp; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), gui->regexp->str); if (temp) { g_string_assign (gui->regexp, temp); g_free (temp); gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui); } }
/******************************************************* * csv_import_sep_cb * * call back for type of separartor required *******************************************************/ void csv_import_sep_cb (GtkWidget *radio, gpointer user_data ) { CsvImportInfo *info = user_data; const gchar *name; gchar *temp; if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) { LEAVE("1st callback of pair. Defer to 2nd callback."); return; } name = gtk_buildable_get_name(GTK_BUILDABLE(radio)); if (g_strcmp0(name, g_strdup("radio_semi")) == 0) g_string_assign (info->regexp, "^(?<type>[^;]*);(?<full_name>[^;]*);(?<name>[^;]*);(?<code>[^;]*);?(?<description>[^;]*);?(?<color>[^;]*);?(?<notes>[^;]*);?(?<commoditym>[^;]*);?(?<commodityn>[^;]*);?(?<hidden>[^;]*);?(?<tax>[^;]*);?(?<place_holder>[^;]*)$"); if (g_strcmp0(name, g_strdup("radio_comma")) == 0) g_string_assign (info->regexp, "^(?<type>[^,]*),(?<full_name>[^,]*),(?<name>[^,]*),(?<code>[^,]*),?(?<description>[^,]*),?(?<color>[^,]*),?(?<notes>[^,]*),?(?<commoditym>[^,]*),?(?<commodityn>[^,]*),?(?<hidden>[^,]*),?(?<tax>[^,]*),?(?<place_holder>[^,]*)$"); if (g_strcmp0(name, g_strdup("radio_semiq")) == 0) g_string_assign (info->regexp, "^((?<type>[^\";]*)|\"(?<type>[^\"]*)\");((?<full_name>[^\";]*)|\"(?<full_name>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<code>[^\";]*)|\"(?<code>[^\"]*)\");((?<description>[^\";]*)|\"(?<description>[^\"]*)\");((?<color>[^\";]*)|\"(?<color>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<commoditym>[^\";]*)|\"(?<commoditym>[^\"]*)\");((?<commodityn>[^\";]*)|\"(?<commodityn>[^\"]*)\");((?<hidden>[^\";]*)|\"(?<hidden>[^\"]*)\");((?<tax>[^\";]*)|\"(?<tax>[^\"]*)\");((?<place_holder>[^\";]*)|\"(?<place_holder>[^\"]*)\")$"); if (g_strcmp0(name, g_strdup("radio_commaq")) == 0) g_string_assign (info->regexp, "^((?<type>[^\",]*)|\"(?<type>[^\"]*)\"),((?<full_name>[^\",]*)|\"(?<full_name>[^\"]*)\"),((?<name>[^\",]*)|\"(?<name>[^\"]*)\"),((?<code>[^\",]*)|\"(?<code>[^\"]*)\"),((?<description>[^\",]*)|\"(?<description>[^\"]*)\"),((?<color>[^\",]*)|\"(?<color>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<commoditym>[^\",]*)|\"(?<commoditym>[^\"]*)\"),((?<commodityn>[^\",]*)|\"(?<commodityn>[^\"]*)\"),((?<hidden>[^\",]*)|\"(?<hidden>[^\"]*)\"),((?<tax>[^\",]*)|\"(?<tax>[^\"]*)\"),((?<place_holder>[^\",]*)|\"(?<place_holder>[^\"]*)\")$"); if (g_strcmp0(name, g_strdup("radio_custom")) == 0) { temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), info->regexp->str); if (temp) { g_string_assign (info->regexp, temp); g_free (temp); } } /* Generate preview */ gtk_list_store_clear (info->store); if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11 ) == MATCH_FOUND) gtk_widget_set_sensitive (info->header_row_spin, TRUE); else gtk_widget_set_sensitive (info->header_row_spin, FALSE); /* Reset Header spin to 0 */ gtk_spin_button_set_value( GTK_SPIN_BUTTON(info->header_row_spin), 0 ); }
/******************************************************* * csv_import_sep_cb * * call back for type of separartor required *******************************************************/ void csv_import_sep_cb (GtkWidget *radio, gpointer user_data) { CsvImportInfo *info = user_data; const gchar *name; gchar *temp; gchar *sep = NULL; if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(radio))) { LEAVE("1st callback of pair. Defer to 2nd callback."); return; } name = gtk_buildable_get_name (GTK_BUILDABLE(radio)); if (g_strcmp0 (name, "radio_semi") == 0) sep = ";"; else if (g_strcmp0 (name, "radio_colon") == 0) sep = ":"; else sep = ","; /* Use as default as well */ create_regex (info->regexp, sep); if (g_strcmp0 (name, "radio_custom") == 0) { temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), info->regexp->str); if (temp) { g_string_assign (info->regexp, temp); g_free (temp); } } /* Generate preview */ gtk_list_store_clear (info->store); if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11) == MATCH_FOUND) gtk_widget_set_sensitive (info->header_row_spin, TRUE); else gtk_widget_set_sensitive (info->header_row_spin, FALSE); /* Reset Header spin to 0 */ gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->header_row_spin), 0); }