mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Added Open/Save/Save Results to sql window.
fixed man pages in rpm
This commit is contained in:
parent
b22b108014
commit
0d1073fd1e
@ -4,3 +4,10 @@ aclocal.m4
|
||||
configure
|
||||
config.log
|
||||
config.status
|
||||
autom4te-*.cache
|
||||
config.guess
|
||||
config.sub
|
||||
libtool
|
||||
ltmain.sh
|
||||
mdbtools.spec
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Converting DocBook to HTML (several small files)
|
||||
# http://www.freebsd.org/tutorials/docproj-primer/x3132.html#AEN3140
|
||||
# version: $Id: Makefile.am,v 1.2 2003/01/12 22:59:42 brianb Exp $
|
||||
# version: $Id: Makefile.am,v 1.3 2003/01/14 17:37:19 brianb Exp $
|
||||
SHELL = /bin/sh
|
||||
TXT2MAN = $(srcdir)/txt2man
|
||||
RELEASE = 0.5
|
||||
@ -8,7 +8,7 @@ PRODUCT = MDBTools
|
||||
|
||||
man_MANS = mdb-tables.1 mdb-ver.1 mdb-export.1 mdb-schema.1 mdb-sql.1
|
||||
|
||||
EXTRA_DIST = mdb-tables.txt mdb-ver.txt mdb-export.txt mdb-schema.txt mdb-sql.txt faq.html
|
||||
EXTRA_DIST = mdb-tables.txt mdb-ver.txt mdb-export.txt mdb-schema.txt mdb-sql.txt faq.html txt2man
|
||||
|
||||
html: install.tgz
|
||||
|
||||
|
@ -49,7 +49,7 @@ The mdbtools-gui package contains the gmdb2 graphical user interface for MDB Too
|
||||
%setup
|
||||
|
||||
%build
|
||||
%configure --with-unixodbc=/usr/local
|
||||
%configure --with-unixodbc=/usr/local
|
||||
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
|
||||
|
||||
%install
|
||||
@ -80,6 +80,8 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_bindir}/mdb-dump
|
||||
%{_bindir}/mdb-sql
|
||||
%{_bindir}/mdb-ver
|
||||
%{_bindir}/mdb-array
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%files devel
|
||||
%defattr (-,root,root)
|
||||
@ -88,6 +90,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files odbc
|
||||
%defattr(-,root,root)
|
||||
%{_libdir}/libmdbodbc.la
|
||||
%{_libdir}/libmdbodbc.a
|
||||
%{_libdir}/libmdbodbc.so*
|
||||
|
||||
|
@ -332,7 +332,7 @@ gchar *s;
|
||||
page = atol(gtk_entry_get_text(GTK_ENTRY(entry)));
|
||||
}
|
||||
if (page>gmdb_get_max_page(mdb) || page<0) {
|
||||
gmdb_info_msg("Page entered is outside valid page range.");
|
||||
gnome_warning_dialog("Page entered is outside valid page range.");
|
||||
}
|
||||
|
||||
/* add to the navigation list */
|
||||
|
@ -109,7 +109,7 @@ gmdb_file_open(gchar *file_path)
|
||||
gmdb_reset_widgets();
|
||||
mdb = mdb_open(file_path);
|
||||
if (!mdb) {
|
||||
gmdb_info_msg("Unable to open file.");
|
||||
gnome_warning_dialog("Unable to open file.");
|
||||
return;
|
||||
}
|
||||
gmdb_file_shuffle_recent(file_path);
|
||||
|
@ -3,6 +3,7 @@ gladedir = $(datadir)/gmdb/glade/
|
||||
glade_DATA = \
|
||||
gmdb.glade \
|
||||
gmdb-sql.glade \
|
||||
gmdb-sql-file.glade \
|
||||
gmdb-debug.glade \
|
||||
gmdb-export.glade \
|
||||
gmdb-schema.glade \
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<widget class="GtkDialog" id="export_dialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">dialog1</property>
|
||||
<property name="title" translatable="yes">Export Table Data</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
@ -22,11 +22,23 @@
|
||||
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="cancelbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-help</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="response_id">-11</property>
|
||||
<signal name="clicked" handler="gmdb_export_help_cb" after="yes" last_modification_time="Tue, 14 Jan 2003 14:53:11 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="export_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
@ -34,7 +46,7 @@
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="response_id">-6</property>
|
||||
<signal name="clicked" handler="gtk_widget_destroy" after="yes" object="export_dialog" last_modification_time="Mon, 30 Dec 2002 13:09:35 GMT"/>
|
||||
<signal name="clicked" handler="gtk_widget_destroy" object="export_dialog" last_modification_time="Tue, 14 Jan 2003 14:54:21 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
@ -45,10 +57,10 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="response_id">-5</property>
|
||||
<signal name="clicked" handler="gmdb_table_export_button_cb" last_modification_time="Mon, 30 Dec 2002 14:44:28 GMT"/>
|
||||
<signal name="clicked" handler="gmdb_table_export_button_cb" last_modification_time="Tue, 14 Jan 2003 14:54:10 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment1">
|
||||
<widget class="GtkAlignment" id="alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
@ -56,7 +68,7 @@
|
||||
<property name="yscale">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">2</property>
|
||||
@ -104,6 +116,17 @@
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="save_button">
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-save</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="response_id">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
@ -30,25 +30,38 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="label">gtk-help</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="response_id">-6</property>
|
||||
<signal name="clicked" handler="gtk_widget_destroy" object="schema_dialog" last_modification_time="Sun, 29 Dec 2002 20:59:22 GMT"/>
|
||||
<property name="response_id">-11</property>
|
||||
<signal name="clicked" handler="gmdb_schema_help_cb" last_modification_time="Tue, 14 Jan 2003 14:45:37 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="okbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="response_id">-6</property>
|
||||
<signal name="clicked" handler="gmdb_schema_export_cb" object="schema_dialog" last_modification_time="Sun, 29 Dec 2002 21:00:13 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="response_id">-5</property>
|
||||
<signal name="clicked" handler="gmdb_schema_export_cb" last_modification_time="Sun, 29 Dec 2002 21:00:13 GMT"/>
|
||||
<signal name="clicked" handler="gmdb_schema_export_cb" last_modification_time="Tue, 14 Jan 2003 14:46:39 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment1">
|
||||
<widget class="GtkAlignment" id="alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
@ -56,13 +69,13 @@
|
||||
<property name="yscale">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">2</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image1">
|
||||
<widget class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-convert</property>
|
||||
<property name="icon_size">4</property>
|
||||
@ -79,7 +92,7 @@
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<widget class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Export</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -39,36 +39,53 @@
|
||||
<widget class="GtkMenu" id="query1_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="new1">
|
||||
<widget class="GtkImageMenuItem" id="new_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_NEW_ITEM</property>
|
||||
<property name="label" translatable="yes">_New</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_new1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
|
||||
<signal name="activate" handler="gmdb_sql_new_cb" last_modification_time="Mon, 13 Jan 2003 13:33:58 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="open1">
|
||||
<widget class="GtkImageMenuItem" id="open_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_OPEN_ITEM</property>
|
||||
<signal name="activate" handler="on_open1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="save1">
|
||||
<widget class="GtkImageMenuItem" id="save_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_SAVE_ITEM</property>
|
||||
<signal name="activate" handler="on_save1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="save_as1">
|
||||
<widget class="GtkImageMenuItem" id="save_as_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock_item">GNOMEUIINFO_MENU_SAVE_AS_ITEM</property>
|
||||
<signal name="activate" handler="on_save_as1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="results_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Save _Results...</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-save-as</property>
|
||||
<property name="icon_size">1</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
@ -87,7 +104,7 @@
|
||||
<accelerator key="E" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image1">
|
||||
<widget class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-execute</property>
|
||||
<property name="icon_size">1</property>
|
||||
@ -196,16 +213,17 @@
|
||||
<property name="tooltips">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="button" id="button1">
|
||||
<widget class="button" id="new_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Start new query</property>
|
||||
<property name="label">gtk-new</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="gmdb_sql_new_cb" last_modification_time="Mon, 13 Jan 2003 13:35:04 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="button" id="button2">
|
||||
<widget class="button" id="open_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Load query from file</property>
|
||||
<property name="label">gtk-open</property>
|
||||
@ -214,11 +232,12 @@
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="button" id="button3">
|
||||
<widget class="button" id="results_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Save query to file</property>
|
||||
<property name="label">gtk-save</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="label" translatable="yes">Save Results</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_pixmap">gtk-save-as</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
|
@ -87,7 +87,6 @@ gmdb_help_cb(GtkWidget *button, gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
g_print("got here\n");
|
||||
gnome_help_display("gmdb.xml", NULL, &error);
|
||||
if (error != NULL) {
|
||||
g_warning (error->message);
|
||||
|
@ -50,7 +50,7 @@ char *the_relation;
|
||||
|
||||
printf("file path %s\n",file_path);
|
||||
if ((outfile=fopen(file_path, "w"))==NULL) {
|
||||
gmdb_info_msg("Unable to Open File!");
|
||||
gnome_warning_dialog("Unable to Open File!");
|
||||
return;
|
||||
}
|
||||
mdb_set_default_backend(mdb,backend);
|
||||
@ -119,7 +119,7 @@ char *the_relation;
|
||||
|
||||
fclose(outfile);
|
||||
sprintf(msg,"Schema exported successfully.\n");
|
||||
gmdb_info_msg(msg);
|
||||
gnome_ok_dialog(msg);
|
||||
}
|
||||
void
|
||||
gmdb_schema_export_cb(GtkWidget *w, gpointer data)
|
||||
@ -154,13 +154,25 @@ GtkWidget *schemawin, *combo, *checkbox, *entry;
|
||||
gtk_widget_destroy(schemawin);
|
||||
gmdb_schema_export();
|
||||
}
|
||||
void
|
||||
gmdb_schema_help_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
gnome_help_display("gmdb.xml", "gmdb-schema", &error);
|
||||
if (error != NULL) {
|
||||
g_warning (error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gmdb_schema_new_cb(GtkWidget *w, gpointer data) {
|
||||
GList *glist = NULL;
|
||||
GtkWidget *combo;
|
||||
MdbCatalogEntry *entry;
|
||||
int i;
|
||||
gmdb_schema_new_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
GList *glist = NULL;
|
||||
GtkWidget *combo;
|
||||
MdbCatalogEntry *entry;
|
||||
int i;
|
||||
|
||||
/* load the interface */
|
||||
schemawin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-schema.glade", NULL, NULL);
|
||||
|
339
src/gmdb2/sql.c
339
src/gmdb2/sql.c
@ -37,6 +37,7 @@ extern MdbHandle *mdb;
|
||||
extern MdbSQL *sql;
|
||||
|
||||
void gmdb_sql_tree_populate(MdbHandle *mdb, GladeXML *xml);
|
||||
void gmdb_sql_load_query(GladeXML *xml, gchar *file_path);
|
||||
|
||||
void
|
||||
gmdb_sql_close_all()
|
||||
@ -53,6 +54,199 @@ gmdb_sql_close_all()
|
||||
|
||||
/* callbacks */
|
||||
void
|
||||
gmdb_sql_write_rslt_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
gchar *file_path;
|
||||
GladeXML *sql_xml;
|
||||
GtkWidget *filesel;
|
||||
FILE *outfile;
|
||||
int i;
|
||||
int need_headers = 0;
|
||||
int need_quote = 0;
|
||||
gchar delimiter[11];
|
||||
gchar quotechar;
|
||||
gchar lineterm[5];
|
||||
gchar *str, *buf;
|
||||
int rows=0, n_columns;
|
||||
char msg[100];
|
||||
GtkWidget *treeview;
|
||||
GtkTreeViewColumn *col;
|
||||
GList *glist;
|
||||
GtkTreeStore *store;
|
||||
GtkTreeIter iter;
|
||||
GValue value = { 0, };
|
||||
|
||||
filesel = glade_xml_get_widget (xml, "export_dialog");
|
||||
sql_xml = g_object_get_data(G_OBJECT(filesel), "sql_xml");
|
||||
printf("sql_xml %lu\n",sql_xml);
|
||||
|
||||
gmdb_export_get_delimiter(xml, delimiter, 10);
|
||||
gmdb_export_get_lineterm(xml, lineterm, 5);
|
||||
need_quote = gmdb_export_get_quote(xml);
|
||||
quotechar = gmdb_export_get_quotechar(xml);
|
||||
need_headers = gmdb_export_get_headers(xml);
|
||||
file_path = gmdb_export_get_filepath(xml);
|
||||
|
||||
if ((outfile=fopen(file_path, "w"))==NULL) {
|
||||
gnome_warning_dialog("Unable to Open File!");
|
||||
return;
|
||||
}
|
||||
|
||||
treeview = glade_xml_get_widget (sql_xml, "sql_results");
|
||||
glist = gtk_tree_view_get_columns(treeview);
|
||||
i = 0;
|
||||
if (need_headers) {
|
||||
while (col = g_list_nth_data(glist, i)) {
|
||||
if (i>0) fprintf(outfile,delimiter);
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, gtk_tree_view_column_get_title(col));
|
||||
fprintf(outfile,"%s", gtk_tree_view_column_get_title(col));
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, gtk_tree_view_column_get_title(col));
|
||||
i++;
|
||||
}
|
||||
fprintf(outfile,lineterm);
|
||||
g_list_free(glist);
|
||||
}
|
||||
|
||||
store = (GtkTreeStore *) gtk_tree_view_get_model(treeview);
|
||||
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
|
||||
rows=0;
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
do {
|
||||
rows++;
|
||||
n_columns = gtk_tree_model_get_n_columns(store);
|
||||
for (i=0; i < n_columns; i++) {
|
||||
if (i>0) fprintf(outfile,delimiter);
|
||||
gtk_tree_model_get_value(GTK_TREE_MODEL(store),
|
||||
&iter, i, &value);
|
||||
str = (gchar *) g_value_get_string(&value);
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, str);
|
||||
fprintf(outfile,"%s", str);
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, str);
|
||||
g_value_unset(&value);
|
||||
}
|
||||
fprintf(outfile,lineterm);
|
||||
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
|
||||
|
||||
fclose(outfile);
|
||||
gtk_widget_destroy(filesel);
|
||||
sprintf(msg,"%d Rows exported successfully.\n", rows);
|
||||
gnome_ok_dialog(msg);
|
||||
}
|
||||
void
|
||||
gmdb_sql_write_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
gchar *file_path;
|
||||
GladeXML *sql_xml;
|
||||
GtkWidget *filesel;
|
||||
|
||||
filesel = glade_xml_get_widget (xml, "file_dialog");
|
||||
file_path = (gchar *) gtk_file_selection_get_filename (GTK_FILE_SELECTION(filesel));
|
||||
sql_xml = g_object_get_data(G_OBJECT(filesel), "sql_xml");
|
||||
gmdb_sql_save_query(sql_xml, file_path);
|
||||
|
||||
gtk_widget_destroy(filesel);
|
||||
}
|
||||
void
|
||||
gmdb_sql_load_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
gchar *file_path;
|
||||
GladeXML *sql_xml;
|
||||
GtkWidget *filesel;
|
||||
|
||||
filesel = glade_xml_get_widget (xml, "file_dialog");
|
||||
file_path = (gchar *) gtk_file_selection_get_filename (GTK_FILE_SELECTION(filesel));
|
||||
sql_xml = g_object_get_data(G_OBJECT(filesel), "sql_xml");
|
||||
gmdb_sql_load_query(sql_xml, file_path);
|
||||
|
||||
gtk_widget_destroy(filesel);
|
||||
}
|
||||
void
|
||||
gmdb_sql_results_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
GladeXML *dialog_xml;
|
||||
GtkWidget *but, *label;
|
||||
GtkWidget *filesel;
|
||||
gchar *str;
|
||||
|
||||
/* load the interface */
|
||||
dialog_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-export.glade", NULL, NULL);
|
||||
/* connect the signals in the interface */
|
||||
glade_xml_signal_autoconnect(dialog_xml);
|
||||
|
||||
filesel = glade_xml_get_widget (dialog_xml, "export_dialog");
|
||||
gtk_window_set_title(GTK_WINDOW(filesel), "Save Results As");
|
||||
|
||||
but = glade_xml_get_widget (dialog_xml, "export_button");
|
||||
gtk_widget_hide(but);
|
||||
|
||||
but = glade_xml_get_widget (dialog_xml, "save_button");
|
||||
gtk_widget_show(but);
|
||||
|
||||
gmdb_table_export_populate_dialog(dialog_xml);
|
||||
|
||||
but = glade_xml_get_widget (dialog_xml, "save_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_write_rslt_cb), dialog_xml);
|
||||
|
||||
g_object_set_data(G_OBJECT(filesel), "sql_xml", xml);
|
||||
}
|
||||
void
|
||||
gmdb_sql_save_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
GtkWidget *textview;
|
||||
gchar *str;
|
||||
|
||||
textview = glade_xml_get_widget (xml, "sql_textview");
|
||||
str = g_object_get_data(G_OBJECT(textview), "file_name");
|
||||
if (!str) {
|
||||
gmdb_sql_save_as_cb(w, xml);
|
||||
return;
|
||||
}
|
||||
gmdb_sql_save_query(xml, str);
|
||||
}
|
||||
void
|
||||
gmdb_sql_save_as_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
GladeXML *dialog_xml;
|
||||
GtkWidget *but;
|
||||
GtkWidget *filesel;
|
||||
gchar *str;
|
||||
|
||||
/* load the interface */
|
||||
dialog_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-sql-file.glade", NULL, NULL);
|
||||
/* connect the signals in the interface */
|
||||
glade_xml_signal_autoconnect(dialog_xml);
|
||||
|
||||
filesel = glade_xml_get_widget (dialog_xml, "file_dialog");
|
||||
gtk_window_set_title(GTK_WINDOW(filesel), "Save Query As");
|
||||
|
||||
but = glade_xml_get_widget (dialog_xml, "ok_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_write_cb), dialog_xml);
|
||||
|
||||
g_object_set_data(G_OBJECT(filesel), "sql_xml", xml);
|
||||
}
|
||||
void
|
||||
gmdb_sql_open_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
GladeXML *dialog_xml;
|
||||
GtkWidget *but;
|
||||
GtkWidget *filesel;
|
||||
gchar *str;
|
||||
|
||||
/* load the interface */
|
||||
dialog_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-sql-file.glade", NULL, NULL);
|
||||
/* connect the signals in the interface */
|
||||
glade_xml_signal_autoconnect(dialog_xml);
|
||||
|
||||
but = glade_xml_get_widget (dialog_xml, "ok_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_load_cb), dialog_xml);
|
||||
|
||||
filesel = glade_xml_get_widget (dialog_xml, "file_dialog");
|
||||
g_object_set_data(G_OBJECT(filesel), "sql_xml", xml);
|
||||
}
|
||||
void
|
||||
gmdb_sql_copy_cb(GtkWidget *w, GladeXML *xml)
|
||||
{
|
||||
GtkTextBuffer *txtbuffer;
|
||||
@ -119,7 +313,6 @@ GtkTreeIter iter2;
|
||||
|
||||
strcpy(tablename,name);
|
||||
g_free(name);
|
||||
printf("table %s\n",tablename);
|
||||
//strcpy(tablename, "Shippers");
|
||||
gtk_selection_data_set(
|
||||
selection_data,
|
||||
@ -151,15 +344,18 @@ GtkWidget *textview;
|
||||
}
|
||||
|
||||
void
|
||||
gmdb_sql_select_hist_cb(GtkList *list, GtkWidget *w, GMdbSQLWindow *sqlwin)
|
||||
gmdb_sql_select_hist_cb(GtkList *list, GladeXML *xml)
|
||||
{
|
||||
guint child_num;
|
||||
gchar *buf;
|
||||
GtkTextBuffer *txtbuffer;
|
||||
gchar *buf;
|
||||
GtkTextBuffer *txtbuffer;
|
||||
GtkWidget *combo, *textview;
|
||||
|
||||
child_num = gtk_list_child_position(list, w);
|
||||
buf = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(sqlwin->combo)->entry));
|
||||
txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sqlwin->textbox));
|
||||
combo = glade_xml_get_widget(xml, "sql_combo");
|
||||
if (!combo) return;
|
||||
buf = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
if (!buf) return;
|
||||
textview = glade_xml_get_widget(xml, "sql_textview");
|
||||
txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
|
||||
gtk_text_buffer_set_text(txtbuffer, buf, strlen(buf));
|
||||
}
|
||||
|
||||
@ -202,7 +398,7 @@ long row, maxrow;
|
||||
_mdb_sql(sql);
|
||||
if (yyparse()) {
|
||||
/* end unsafe */
|
||||
gmdb_info_msg("Couldn't parse SQL");
|
||||
gnome_warning_dialog("Couldn't parse SQL");
|
||||
mdb_sql_reset(sql);
|
||||
return;
|
||||
}
|
||||
@ -265,7 +461,7 @@ void
|
||||
gmdb_sql_new_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
GtkTargetEntry src;
|
||||
GtkWidget *mi, *but;
|
||||
GtkWidget *mi, *but, *combo;
|
||||
GladeXML *sqlwin_xml;
|
||||
|
||||
/* load the interface */
|
||||
@ -275,6 +471,38 @@ GladeXML *sqlwin_xml;
|
||||
|
||||
sql_list = g_list_append(sql_list, sqlwin_xml);
|
||||
|
||||
mi = glade_xml_get_widget (sqlwin_xml, "save_menu");
|
||||
g_signal_connect (G_OBJECT (mi), "activate",
|
||||
G_CALLBACK (gmdb_sql_save_cb), sqlwin_xml);
|
||||
|
||||
but = glade_xml_get_widget (sqlwin_xml, "save_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_save_cb), sqlwin_xml);
|
||||
|
||||
mi = glade_xml_get_widget (sqlwin_xml, "save_as_menu");
|
||||
g_signal_connect (G_OBJECT (mi), "activate",
|
||||
G_CALLBACK (gmdb_sql_save_as_cb), sqlwin_xml);
|
||||
|
||||
but = glade_xml_get_widget (sqlwin_xml, "save_as_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_save_as_cb), sqlwin_xml);
|
||||
|
||||
mi = glade_xml_get_widget (sqlwin_xml, "results_menu");
|
||||
g_signal_connect (G_OBJECT (mi), "activate",
|
||||
G_CALLBACK (gmdb_sql_results_cb), sqlwin_xml);
|
||||
|
||||
but = glade_xml_get_widget (sqlwin_xml, "results_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_results_cb), sqlwin_xml);
|
||||
|
||||
mi = glade_xml_get_widget (sqlwin_xml, "open_menu");
|
||||
g_signal_connect (G_OBJECT (mi), "activate",
|
||||
G_CALLBACK (gmdb_sql_open_cb), sqlwin_xml);
|
||||
|
||||
but = glade_xml_get_widget (sqlwin_xml, "open_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_open_cb), sqlwin_xml);
|
||||
|
||||
mi = glade_xml_get_widget (sqlwin_xml, "paste_menu");
|
||||
g_signal_connect (G_OBJECT (mi), "activate",
|
||||
G_CALLBACK (gmdb_sql_paste_cb), sqlwin_xml);
|
||||
@ -299,6 +527,10 @@ GladeXML *sqlwin_xml;
|
||||
g_signal_connect (G_OBJECT (mi), "activate",
|
||||
G_CALLBACK (gmdb_sql_execute_cb), sqlwin_xml);
|
||||
|
||||
combo = glade_xml_get_widget(sqlwin_xml, "sql_combo");
|
||||
g_signal_connect (G_OBJECT(GTK_COMBO(combo)->list), "selection-changed",
|
||||
G_CALLBACK (gmdb_sql_select_hist_cb), sqlwin_xml);
|
||||
|
||||
but = glade_xml_get_widget (sqlwin_xml, "execute_button");
|
||||
g_signal_connect (G_OBJECT (but), "clicked",
|
||||
G_CALLBACK (gmdb_sql_execute_cb), sqlwin_xml);
|
||||
@ -343,6 +575,91 @@ GladeXML *sqlwin_xml;
|
||||
}
|
||||
|
||||
/* functions */
|
||||
gchar *
|
||||
gmdb_sql_get_basename(char *file_path)
|
||||
{
|
||||
int i, len;
|
||||
gchar *basename;
|
||||
|
||||
for (i=strlen(file_path);i>=0 && file_path[i]!='/';i--);
|
||||
len = strlen(file_path) - i + 2;
|
||||
basename = g_malloc(len);
|
||||
if (file_path[i]=='/') {
|
||||
strncpy(basename,&file_path[i+1],len);
|
||||
} else {
|
||||
strncpy(basename,file_path,len);
|
||||
}
|
||||
basename[len]='\0';
|
||||
|
||||
return basename;
|
||||
}
|
||||
|
||||
void
|
||||
gmdb_sql_set_file(GladeXML *xml, gchar *file_name)
|
||||
{
|
||||
GtkWidget *window, *textview;
|
||||
gchar *title;
|
||||
gchar *basename;
|
||||
gchar *suffix = " - MDB Query Tool";
|
||||
|
||||
basename = gmdb_sql_get_basename(file_name);
|
||||
title = g_malloc(strlen(basename) + strlen(suffix) + 1);
|
||||
sprintf(title,"%s%s", basename, suffix);
|
||||
g_free(basename);
|
||||
window = glade_xml_get_widget(xml, "sql_window");
|
||||
gtk_window_set_title(GTK_WINDOW(window), title);
|
||||
g_free(title);
|
||||
textview = glade_xml_get_widget(xml, "sql_textview");
|
||||
g_object_set_data(G_OBJECT(textview), "file_name", file_name);
|
||||
}
|
||||
void
|
||||
gmdb_sql_save_query(GladeXML *xml, gchar *file_path)
|
||||
{
|
||||
FILE *out;
|
||||
GtkWidget *textview;
|
||||
GtkTextBuffer *txtbuffer;
|
||||
GtkTextIter start, end;
|
||||
gchar *buf;
|
||||
|
||||
if (!(out=fopen(file_path, "w"))) {
|
||||
gnome_warning_dialog("Unable to open file.");
|
||||
return;
|
||||
}
|
||||
textview = glade_xml_get_widget(xml, "sql_textview");
|
||||
txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
|
||||
gtk_text_buffer_get_start_iter(txtbuffer, &start);
|
||||
gtk_text_buffer_get_end_iter(txtbuffer, &end);
|
||||
buf = gtk_text_buffer_get_text(txtbuffer, &start, &end, FALSE);
|
||||
fprintf(out,"%s\n",buf);
|
||||
fclose(out);
|
||||
gmdb_sql_set_file(xml, file_path);
|
||||
}
|
||||
void
|
||||
gmdb_sql_load_query(GladeXML *xml, gchar *file_path)
|
||||
{
|
||||
FILE *in;
|
||||
char buf[256];
|
||||
GtkWidget *textview;
|
||||
GtkTextBuffer *txtbuffer;
|
||||
GtkTextIter start, end;
|
||||
int len;
|
||||
|
||||
if (!(in=fopen(file_path, "r"))) {
|
||||
gnome_warning_dialog("Unable to open file.");
|
||||
return;
|
||||
}
|
||||
textview = glade_xml_get_widget(xml, "sql_textview");
|
||||
txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
|
||||
gtk_text_buffer_get_start_iter(txtbuffer, &start);
|
||||
gtk_text_buffer_get_end_iter(txtbuffer, &end);
|
||||
gtk_text_buffer_delete(txtbuffer, &start, &end);
|
||||
while (len = fgets(buf, 255, in)) {
|
||||
gtk_text_buffer_get_end_iter(txtbuffer, &end);
|
||||
gtk_text_buffer_insert(txtbuffer, &end, buf, len);
|
||||
}
|
||||
fclose(in);
|
||||
gmdb_sql_set_file(xml, file_path);
|
||||
}
|
||||
void
|
||||
gmdb_sql_tree_populate(MdbHandle *mdb, GladeXML *xml)
|
||||
{
|
||||
@ -374,7 +691,7 @@ GtkTreeIter *iter2;
|
||||
void
|
||||
gmdb_sql_new_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
gmdb_info_msg("SQL support was not built in.\nRun configure with the --enable-sql option.");
|
||||
gnome_ok_dialog("SQL support was not built in.\nRun configure with the --enable-sql option.");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -52,6 +52,7 @@ int i,j;
|
||||
gchar *titles[] = { "", "Column", "Name", "Type", "Size", "Allow Nulls" };
|
||||
gchar *row[6];
|
||||
GMdbDefWindow *defw;
|
||||
GtkStyle *style;
|
||||
|
||||
/* do we have an active window for this object? if so raise it */
|
||||
for (i=0;i<g_list_length(window_list);i++) {
|
||||
@ -121,15 +122,21 @@ GMdbDefWindow *defw;
|
||||
}
|
||||
gtk_clist_append(GTK_CLIST(clist), row);
|
||||
}
|
||||
pixmap = gdk_pixmap_colormap_create_from_xpm_d( NULL,
|
||||
gtk_widget_get_colormap(app), &mask, NULL, pk_xpm);
|
||||
style = gtk_widget_get_style(clist);
|
||||
pixmap = gdk_pixmap_create_from_xpm(clist->window,
|
||||
&mask,
|
||||
&style->bg[GTK_STATE_NORMAL],
|
||||
GMDB_ICONDIR "pk.xpm");
|
||||
printf("pixmap %lu\n",pixmap);
|
||||
//pixmap = gdk_pixmap_colormap_create_from_xpm_d( NULL,
|
||||
//gtk_widget_get_colormap(app), &mask, NULL, pk_xpm);
|
||||
|
||||
mdb_read_indices(table);
|
||||
for (i=0;i<table->num_idxs;i++) {
|
||||
idx = g_ptr_array_index (table->indices, i);
|
||||
if (idx->index_type==1) {
|
||||
for (j=0;j<idx->num_keys;j++) {
|
||||
gtk_clist_set_pixmap(GTK_CLIST(clist), idx->key_col_num[j]-1,0, pixmap, mask);
|
||||
if (pixmap) gtk_clist_set_pixmap(GTK_CLIST(clist), idx->key_col_num[j]-1,0, pixmap, mask);
|
||||
}
|
||||
// } else {
|
||||
//for (j=0;j<idx->num_keys;j++) {
|
||||
|
@ -38,7 +38,7 @@ MdbCatalogEntry *cat_entry;
|
||||
#define AUTOMAT "Automatic (where necessary)"
|
||||
|
||||
void
|
||||
print_quote(FILE *outfile, int need_quote, char quotechar, char *colsep, char *str)
|
||||
gmdb_print_quote(FILE *outfile, int need_quote, char quotechar, char *colsep, char *str)
|
||||
{
|
||||
if (need_quote==1) {
|
||||
fprintf(outfile, "%c", quotechar);
|
||||
@ -49,6 +49,98 @@ print_quote(FILE *outfile, int need_quote, char quotechar, char *colsep, char *s
|
||||
}
|
||||
}
|
||||
|
||||
gmdb_export_get_delimiter(GladeXML *xml, gchar *delimiter, int max_buf)
|
||||
{
|
||||
GtkWidget *combo;
|
||||
gchar *str;
|
||||
|
||||
combo = glade_xml_get_widget(xml, "sep_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
if (!strcmp(str,COMMA)) { strcpy(delimiter, ","); }
|
||||
else if (!strcmp(str,TAB)) { strcpy(delimiter, "\t"); }
|
||||
else if (!strcmp(str,SPACE)) { strcpy(delimiter, " "); }
|
||||
else if (!strcmp(str,COLON)) { strcpy(delimiter, ":"); }
|
||||
else if (!strcmp(str,SEMICOLON)) { strcpy(delimiter, ";"); }
|
||||
else if (!strcmp(str,PIPE)) { strcpy(delimiter, "|"); }
|
||||
else {
|
||||
strncpy(delimiter,str, 10);
|
||||
delimiter[10]='\0';
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gmdb_export_get_lineterm(GladeXML *xml, gchar *lineterm, int max_buf)
|
||||
{
|
||||
GtkWidget *combo;
|
||||
gchar *str;
|
||||
|
||||
combo = glade_xml_get_widget(xml, "term_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
if (!strcmp(str,LF)) { strcpy(lineterm, "\n"); }
|
||||
else if (!strcmp(str,CR)) { strcpy(lineterm, "\r"); }
|
||||
else if (!strcmp(str,CRLF)) { strcpy(lineterm, "\r\n"); }
|
||||
}
|
||||
|
||||
int
|
||||
gmdb_export_get_quote(GladeXML *xml)
|
||||
{
|
||||
GtkWidget *combo;
|
||||
int need_quote = 0;
|
||||
gchar *str;
|
||||
|
||||
combo = glade_xml_get_widget(xml, "quote_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
if (!strcmp(str,ALWAYS)) { need_quote = 1; }
|
||||
else if (!strcmp(str,NEVER)) { need_quote = 0; }
|
||||
else if (!strcmp(str,AUTOMAT)) { need_quote = -1; }
|
||||
|
||||
return need_quote;
|
||||
}
|
||||
|
||||
char
|
||||
gmdb_export_get_quotechar(GladeXML *xml)
|
||||
{
|
||||
GtkWidget *combo;
|
||||
gchar *str;
|
||||
char quotechar;
|
||||
|
||||
combo = glade_xml_get_widget(xml, "qchar_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
quotechar = str[0];
|
||||
|
||||
return quotechar;
|
||||
}
|
||||
int
|
||||
gmdb_export_get_headers(GladeXML *xml)
|
||||
{
|
||||
GtkWidget *checkbox;
|
||||
|
||||
checkbox = glade_xml_get_widget(xml, "headers_checkbox");
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
gchar *
|
||||
gmdb_export_get_filepath(GladeXML *xml)
|
||||
{
|
||||
GtkWidget *fentry;
|
||||
|
||||
fentry = glade_xml_get_widget(xml, "filename_entry");
|
||||
return (gchar *) gtk_entry_get_text(GTK_ENTRY(fentry));
|
||||
}
|
||||
|
||||
void
|
||||
gmdb_export_help_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
gnome_help_display("gmdb.xml", "gmdb-table-export", &error);
|
||||
if (error != NULL) {
|
||||
g_warning (error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
void
|
||||
gmdb_table_export_button_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
@ -66,52 +158,19 @@ gchar lineterm[5];
|
||||
gchar *str;
|
||||
int rows=0;
|
||||
char msg[100];
|
||||
GtkWidget *combo, *fentry, *checkbox;
|
||||
GtkWidget *exportwin;
|
||||
|
||||
|
||||
combo = glade_xml_get_widget (exportwin_xml, "sep_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
if (!strcmp(str,COMMA)) { strcpy(delimiter, ","); }
|
||||
else if (!strcmp(str,TAB)) { strcpy(delimiter, "\t"); }
|
||||
else if (!strcmp(str,SPACE)) { strcpy(delimiter, " "); }
|
||||
else if (!strcmp(str,COLON)) { strcpy(delimiter, ":"); }
|
||||
else if (!strcmp(str,SEMICOLON)) { strcpy(delimiter, ";"); }
|
||||
else if (!strcmp(str,PIPE)) { strcpy(delimiter, "|"); }
|
||||
else {
|
||||
strncpy(delimiter,str, 10);
|
||||
delimiter[10]='\0';
|
||||
}
|
||||
|
||||
combo = glade_xml_get_widget (exportwin_xml, "term_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
if (!strcmp(str,LF)) { strcpy(lineterm, "\n"); }
|
||||
else if (!strcmp(str,CR)) { strcpy(lineterm, "\r"); }
|
||||
else if (!strcmp(str,CRLF)) { strcpy(lineterm, "\r\n"); }
|
||||
|
||||
combo = glade_xml_get_widget (exportwin_xml, "quote_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
if (!strcmp(str,ALWAYS)) { need_quote = 1; }
|
||||
else if (!strcmp(str,NEVER)) { need_quote = 0; }
|
||||
else if (!strcmp(str,AUTOMAT)) { need_quote = -1; }
|
||||
|
||||
combo = glade_xml_get_widget (exportwin_xml, "qchar_combo");
|
||||
str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
||||
quotechar = str[0];
|
||||
|
||||
/* headers */
|
||||
checkbox = glade_xml_get_widget (exportwin_xml, "header_checkbox");
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)))
|
||||
need_headers = 1;
|
||||
else
|
||||
need_headers = 0;
|
||||
|
||||
fentry = glade_xml_get_widget (exportwin_xml, "filename_entry");
|
||||
file_path = (gchar *) gtk_entry_get_text(GTK_ENTRY(fentry));
|
||||
gmdb_export_get_delimiter(exportwin_xml, delimiter, 10);
|
||||
gmdb_export_get_lineterm(exportwin_xml, lineterm, 5);
|
||||
need_quote = gmdb_export_get_quote(exportwin_xml);
|
||||
quotechar = gmdb_export_get_quotechar(exportwin_xml);
|
||||
need_headers = gmdb_export_get_headers(exportwin_xml);
|
||||
file_path = gmdb_export_get_filepath(exportwin_xml);
|
||||
|
||||
// printf("file path %s\n",file_path);
|
||||
if ((outfile=fopen(file_path, "w"))==NULL) {
|
||||
gmdb_info_msg("Unable to Open File!");
|
||||
gnome_warning_dialog("Unable to Open File!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -130,9 +189,9 @@ GtkWidget *exportwin;
|
||||
col=g_ptr_array_index(table->columns,i);
|
||||
if (need_headers) {
|
||||
if (i>0) fprintf(outfile,delimiter);
|
||||
print_quote(outfile, need_quote, quotechar, delimiter, col->name);
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, col->name);
|
||||
fprintf(outfile,"%s", col->name);
|
||||
print_quote(outfile, need_quote, quotechar, delimiter, col->name);
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, col->name);
|
||||
}
|
||||
}
|
||||
if (need_headers) fprintf(outfile,lineterm);
|
||||
@ -141,9 +200,9 @@ GtkWidget *exportwin;
|
||||
while(mdb_fetch_row(table)) {
|
||||
for (i=0;i<table->num_cols;i++) {
|
||||
if (i>0) fprintf(outfile,delimiter);
|
||||
print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]);
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]);
|
||||
fprintf(outfile,"%s", bound_data[i]);
|
||||
print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]);
|
||||
gmdb_print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]);
|
||||
}
|
||||
fprintf(outfile,lineterm);
|
||||
rows++;
|
||||
@ -158,14 +217,12 @@ GtkWidget *exportwin;
|
||||
exportwin = glade_xml_get_widget (exportwin_xml, "export_dialog");
|
||||
gtk_widget_destroy(exportwin);
|
||||
sprintf(msg,"%d Rows exported successfully.\n", rows);
|
||||
gmdb_info_msg(msg);
|
||||
gnome_ok_dialog(msg);
|
||||
}
|
||||
void gmdb_table_export(MdbCatalogEntry *entry)
|
||||
{
|
||||
GtkWidget *export_button;
|
||||
GtkWidget *close_button;
|
||||
GList *glist = NULL;
|
||||
GtkWidget *combo;
|
||||
|
||||
cat_entry = entry;
|
||||
|
||||
@ -173,17 +230,23 @@ GtkWidget *combo;
|
||||
exportwin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-export.glade", NULL, NULL);
|
||||
/* connect the signals in the interface */
|
||||
glade_xml_signal_autoconnect(exportwin_xml);
|
||||
|
||||
gmdb_table_export_populate_dialog(exportwin_xml);
|
||||
}
|
||||
void
|
||||
gmdb_table_export_populate_dialog(GladeXML *xml)
|
||||
{
|
||||
GList *glist = NULL;
|
||||
GtkWidget *combo;
|
||||
|
||||
/* Create the widgets */
|
||||
combo = glade_xml_get_widget (exportwin_xml, "term_combo");
|
||||
combo = glade_xml_get_widget (xml, "term_combo");
|
||||
glist = g_list_append(glist, LF);
|
||||
glist = g_list_append(glist, CR);
|
||||
glist = g_list_append(glist, CRLF);
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
|
||||
g_list_free(glist);
|
||||
|
||||
combo = glade_xml_get_widget (exportwin_xml, "sep_combo");
|
||||
combo = glade_xml_get_widget (xml, "sep_combo");
|
||||
glist = NULL;
|
||||
glist = g_list_append(glist, COMMA);
|
||||
glist = g_list_append(glist, TAB);
|
||||
@ -194,7 +257,7 @@ GtkWidget *combo;
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
|
||||
g_list_free(glist);
|
||||
|
||||
combo = glade_xml_get_widget (exportwin_xml, "quote_combo");
|
||||
combo = glade_xml_get_widget (xml, "quote_combo");
|
||||
glist = NULL;
|
||||
glist = g_list_append(glist, ALWAYS);
|
||||
glist = g_list_append(glist, NEVER);
|
||||
@ -202,7 +265,7 @@ GtkWidget *combo;
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
|
||||
g_list_free(glist);
|
||||
|
||||
combo = glade_xml_get_widget (exportwin_xml, "qchar_combo");
|
||||
combo = glade_xml_get_widget (xml, "qchar_combo");
|
||||
glist = NULL;
|
||||
glist = g_list_append(glist, "\"");
|
||||
glist = g_list_append(glist, "'");
|
||||
|
Loading…
Reference in New Issue
Block a user