Added option to choose how to export blobs

Supported modes are:
- strip (don't export)
- raw (compatibility)
- octal (export as \ooo)

Note that gmdb2 dialog where updated, but not the code. Many fixes to do
there first :/
This commit is contained in:
Nirgal Vourgère
2012-12-02 20:52:21 +01:00
parent 473d820239
commit a66531c74a
6 changed files with 110 additions and 30 deletions

View File

@@ -13,7 +13,7 @@
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="border_width">30</property>
<property name="n_rows">6</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">30</property>
<property name="row_spacing">8</property>
@@ -93,8 +93,8 @@
<property name="use_markup">True</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -112,8 +112,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -176,6 +176,32 @@
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Binaries:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="bin_combo">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>

View File

@@ -88,6 +88,7 @@ void gmdb_export_get_delimiter(GladeXML *xml, gchar *delimiter, int max_buf);
void gmdb_export_get_lineterm(GladeXML *xml, gchar *lineterm, int max_buf);
int gmdb_export_get_quote(GladeXML *xml);
char gmdb_export_get_quotechar(GladeXML *xml);
int gmdb_export_get_binmode(GladeXML *xml);
int gmdb_export_get_headers(GladeXML *xml);
gchar *gmdb_export_get_filepath(GladeXML *xml);

View File

@@ -60,6 +60,7 @@ gmdb_sql_write_rslt_cb(GtkWidget *w, GladeXML *xml)
int need_quote = 0;
gchar delimiter[11];
gchar quotechar;
//TODO int binmode;
gchar lineterm[5];
gchar *str;
int rows=0, n_columns;
@@ -78,6 +79,7 @@ gmdb_sql_write_rslt_cb(GtkWidget *w, GladeXML *xml)
gmdb_export_get_lineterm(xml, lineterm, 5);
need_quote = gmdb_export_get_quote(xml);
quotechar = gmdb_export_get_quotechar(xml);
//TODO binmode = gmdb_export_get_binmode(xml);
need_headers = gmdb_export_get_headers(xml);
file_path = gmdb_export_get_filepath(xml);

View File

@@ -42,6 +42,10 @@ MdbCatalogEntry *cat_entry;
#define NEVER "Never"
#define AUTOMAT "Automatic (where necessary)"
#define BIN_STRIP "Strip"
#define BIN_RAW "Raw"
#define BIN_OCTAL "Octal"
void
gmdb_print_quote(FILE *outfile, int need_quote, char quotechar, char *colsep, char *str)
{
@@ -116,6 +120,22 @@ gmdb_export_get_quotechar(GladeXML *xml)
return quotechar;
}
int
gmdb_export_get_binmode(GladeXML *xml)
{
GtkComboBox *combobox;
gchar *str;
combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "bin_combo"));
str = gtk_combo_box_get_active_text (combobox);
if (!strcmp(str,BIN_STRIP)) return 1;
else if (!strcmp(str,BIN_OCTAL)) return 2;
else return 0;
}
int
gmdb_export_get_headers(GladeXML *xml)
{
@@ -161,6 +181,7 @@ int need_quote = 0;
gchar delimiter[11];
gchar quotechar;
gchar lineterm[5];
int binmode = 1;
int rows=0;
GtkWidget *exportwin, *dlg;
@@ -170,6 +191,7 @@ int rows=0;
need_quote = gmdb_export_get_quote(exportwin_xml);
quotechar = gmdb_export_get_quotechar(exportwin_xml);
need_headers = gmdb_export_get_headers(exportwin_xml);
binmode = gmdb_export_get_binmode(exportwin_xml);
file_path = gmdb_export_get_filepath(exportwin_xml);
// printf("file path %s\n",file_path);
@@ -271,4 +293,10 @@ gmdb_table_export_populate_dialog(GladeXML *xml)
gtk_combo_box_append_text(combobox, "'");
gtk_combo_box_append_text(combobox, "`");
gtk_combo_box_set_active(combobox, 0);
combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "bin_combo"));
gtk_combo_box_append_text(combobox, BIN_STRIP);
gtk_combo_box_append_text(combobox, BIN_RAW);
gtk_combo_box_append_text(combobox, BIN_OCTAL);
gtk_combo_box_set_active(combobox, 1);
}