Commit 8e16da38 authored by Almer. S. Tigelaar's avatar Almer. S. Tigelaar Committed by Almer S. Tigelaar
Browse files

New, low-level stf-export code.

2000-04-29  Almer. S. Tigelaar.  <almer1@dds.nl>

	* src/stf-export.[ch] : New,
	low-level stf-export code.

	* src/dialogs/dialog-stf-export.glade : New,
	stf export dialog.

	* src/dialogs/dialog-stf-export.glade.h : New,
	stf export dialog strings.

	* src/dialogs/dialog-stf-export.[ch] : New,
	top-level controlling code for the stf export dialog.

	* src/dialogs/dialog-stf-export-private.h : New,
	private declarations for the stf exporter.

	* src/dialogs/dialog-stf-export-format-page.c : New,
	controlling code for the format page of the stf export dialog

	* src/dialogs/dialog-stf-export-sheet-page.c : New,
	controlling code for the sheet page of the stf export dialog

	* src/Makefile.am : Updated to include new files

	* src/stf.c : Now also provides export for csv files
	using the new stf export dialog

	* src/dialogs/Makefile.am : Updated to include new files
parent c21b8572
2000-04-29 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-export.[ch] : New,
low-level stf-export code.
* src/dialogs/dialog-stf-export.glade : New,
stf export dialog.
* src/dialogs/dialog-stf-export.glade.h : New,
stf export dialog strings.
* src/dialogs/dialog-stf-export.[ch] : New,
top-level controlling code for the stf export dialog.
* src/dialogs/dialog-stf-export-private.h : New,
private declarations for the stf exporter.
* src/dialogs/dialog-stf-export-format-page.c : New,
controlling code for the format page of the stf export dialog
* src/dialogs/dialog-stf-export-sheet-page.c : New,
controlling code for the sheet page of the stf export dialog
* src/Makefile.am : Updated to include new files
* src/stf.c : Now also provides export for csv files
using the new stf export dialog
* src/dialogs/Makefile.am : Updated to include new files
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
......
2000-04-29 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-export.[ch] : New,
low-level stf-export code.
* src/dialogs/dialog-stf-export.glade : New,
stf export dialog.
* src/dialogs/dialog-stf-export.glade.h : New,
stf export dialog strings.
* src/dialogs/dialog-stf-export.[ch] : New,
top-level controlling code for the stf export dialog.
* src/dialogs/dialog-stf-export-private.h : New,
private declarations for the stf exporter.
* src/dialogs/dialog-stf-export-format-page.c : New,
controlling code for the format page of the stf export dialog
* src/dialogs/dialog-stf-export-sheet-page.c : New,
controlling code for the sheet page of the stf export dialog
* src/Makefile.am : Updated to include new files
* src/stf.c : Now also provides export for csv files
using the new stf export dialog
* src/dialogs/Makefile.am : Updated to include new files
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
......
2000-04-29 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-export.[ch] : New,
low-level stf-export code.
* src/dialogs/dialog-stf-export.glade : New,
stf export dialog.
* src/dialogs/dialog-stf-export.glade.h : New,
stf export dialog strings.
* src/dialogs/dialog-stf-export.[ch] : New,
top-level controlling code for the stf export dialog.
* src/dialogs/dialog-stf-export-private.h : New,
private declarations for the stf exporter.
* src/dialogs/dialog-stf-export-format-page.c : New,
controlling code for the format page of the stf export dialog
* src/dialogs/dialog-stf-export-sheet-page.c : New,
controlling code for the sheet page of the stf export dialog
* src/Makefile.am : Updated to include new files
* src/stf.c : Now also provides export for csv files
using the new stf export dialog
* src/dialogs/Makefile.am : Updated to include new files
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
......
2000-04-29 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-export.[ch] : New,
low-level stf-export code.
* src/dialogs/dialog-stf-export.glade : New,
stf export dialog.
* src/dialogs/dialog-stf-export.glade.h : New,
stf export dialog strings.
* src/dialogs/dialog-stf-export.[ch] : New,
top-level controlling code for the stf export dialog.
* src/dialogs/dialog-stf-export-private.h : New,
private declarations for the stf exporter.
* src/dialogs/dialog-stf-export-format-page.c : New,
controlling code for the format page of the stf export dialog
* src/dialogs/dialog-stf-export-sheet-page.c : New,
controlling code for the sheet page of the stf export dialog
* src/Makefile.am : Updated to include new files
* src/stf.c : Now also provides export for csv files
using the new stf export dialog
* src/dialogs/Makefile.am : Updated to include new files
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
......
2000-04-29 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-export.[ch] : New,
low-level stf-export code.
* src/dialogs/dialog-stf-export.glade : New,
stf export dialog.
* src/dialogs/dialog-stf-export.glade.h : New,
stf export dialog strings.
* src/dialogs/dialog-stf-export.[ch] : New,
top-level controlling code for the stf export dialog.
* src/dialogs/dialog-stf-export-private.h : New,
private declarations for the stf exporter.
* src/dialogs/dialog-stf-export-format-page.c : New,
controlling code for the format page of the stf export dialog
* src/dialogs/dialog-stf-export-sheet-page.c : New,
controlling code for the sheet page of the stf export dialog
* src/Makefile.am : Updated to include new files
* src/stf.c : Now also provides export for csv files
using the new stf export dialog
* src/dialogs/Makefile.am : Updated to include new files
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
......
2000-04-29 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-export.[ch] : New,
low-level stf-export code.
* src/dialogs/dialog-stf-export.glade : New,
stf export dialog.
* src/dialogs/dialog-stf-export.glade.h : New,
stf export dialog strings.
* src/dialogs/dialog-stf-export.[ch] : New,
top-level controlling code for the stf export dialog.
* src/dialogs/dialog-stf-export-private.h : New,
private declarations for the stf exporter.
* src/dialogs/dialog-stf-export-format-page.c : New,
controlling code for the format page of the stf export dialog
* src/dialogs/dialog-stf-export-sheet-page.c : New,
controlling code for the sheet page of the stf export dialog
* src/Makefile.am : Updated to include new files
* src/stf.c : Now also provides export for csv files
using the new stf export dialog
* src/dialogs/Makefile.am : Updated to include new files
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
......
2000-04-29 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-export.[ch] : New,
low-level stf-export code.
* src/dialogs/dialog-stf-export.glade : New,
stf export dialog.
* src/dialogs/dialog-stf-export.glade.h : New,
stf export dialog strings.
* src/dialogs/dialog-stf-export.[ch] : New,
top-level controlling code for the stf export dialog.
* src/dialogs/dialog-stf-export-private.h : New,
private declarations for the stf exporter.
* src/dialogs/dialog-stf-export-format-page.c : New,
controlling code for the format page of the stf export dialog
* src/dialogs/dialog-stf-export-sheet-page.c : New,
controlling code for the sheet page of the stf export dialog
* src/Makefile.am : Updated to include new files
* src/stf.c : Now also provides export for csv files
using the new stf export dialog
* src/dialogs/Makefile.am : Updated to include new files
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
......
......@@ -180,6 +180,8 @@ GNUMERIC_BASE_SOURCES = \
str.h \
stf.c \
stf.h \
stf-export.c \
stf-export.h \
stf-parse.c \
stf-parse.h \
style.c \
......
......@@ -52,6 +52,11 @@ libdialogs_a_SOURCES = \
dialog-stf-format-page.c \
dialog-stf-preview.c \
dialog-stf-preview.h \
dialog-stf-export.c \
dialog-stf-export.h \
dialog-stf-export-private.h \
dialog-stf-export-sheet-page.c \
dialog-stf-export-format-page.c \
dialog-summary.c \
dialog-workbook-attr.c \
dialog-zoom.c \
......@@ -87,6 +92,7 @@ glade_DATA = \
cell-format.glade \
cell-sort.glade \
dialog-stf.glade \
dialog-stf-export.glade \
plugin-manager.glade \
function-select.glade \
workbook-attr.glade
......@@ -117,6 +123,7 @@ glade_msgs = \
cell-format.glade.h \
cell-sort.glade.h \
dialog-stf.glade.h \
dialog-stf-export.glade.h \
plugin-manager.glade.h \
function-select.glade.h \
workbook-attr.glade.h
......
/*
* dialog-stf-format-page.c : controls the widgets on the format page
* of the export druid
*
* Almer. S. Tigelaar <almer1@dds.nl>
*
*/
#include "dialog-stf-export-private.h"
/*
* Index of "Custom" in the separator optionmenu
*/
#define CUSTOM_INDEX 9
/*************************************************************************************************
* MISC UTILITY FUNCTIONS
*************************************************************************************************/
/**
* stf_export_dialog_option_menu_index:
* @optionmenu: a gtkoptionmenu
*
* Tries to find out (in an ugly way) the selected
* item in @optionsmenu
*
* Return value: the selected index
**/
static int
stf_export_dialog_option_menu_index (GtkOptionMenu *optionmenu)
{
GtkMenu *menu;
GtkMenuItem *selected;
GList *iterator;
int index = -1;
int i = 0;
g_return_val_if_fail (optionmenu != NULL, -1);
menu = (GtkMenu *) gtk_option_menu_get_menu (optionmenu);
iterator = GTK_MENU_SHELL (menu)->children;
selected = (GtkMenuItem *) gtk_menu_get_active (menu);
while (iterator) {
if (iterator->data == selected) {
index = i;
break;
}
iterator = iterator->next;
i++;
}
return index;
}
/*************************************************************************************************
* SIGNAL HANDLERS
*************************************************************************************************/
/**
* sheet_page_separator_menu_deactivate:
* @shell: the gtkmenu associated with the option menu
* @data: format page data struct
*
* Triggered when the menu of the separator option menu is closed
**/
static void
sheet_page_separator_menu_deactivate (GtkMenuShell *shell, StfE_FormatPageData_t *data)
{
if (stf_export_dialog_option_menu_index (data->format_separator) == CUSTOM_INDEX) {
gtk_widget_set_sensitive (GTK_WIDGET (data->format_custom), TRUE);
gtk_widget_grab_focus (GTK_WIDGET (data->format_custom));
gtk_editable_select_region (GTK_EDITABLE (data->format_custom), 0, -1);
}
else {
gtk_widget_set_sensitive (GTK_WIDGET (data->format_custom), FALSE);
gtk_editable_select_region (GTK_EDITABLE (data->format_custom), 0, 0); /* If we don't use this the selection will remain blue */
}
}
/*************************************************************************************************
* MAIN EXPORTED FUNCTIONS
*************************************************************************************************/
/**
* stf_export_dialog_format_page_init
* @gui : The glade gui of the dialog
*
* This routine prepares/initializes all widgets on the format page of the
* Druid.
*
* returns : formatpagedata struct
**/
StfE_FormatPageData_t*
stf_export_dialog_format_page_init (GladeXML *gui)
{
StfE_FormatPageData_t *data;
GtkMenu *menu;
g_return_val_if_fail (gui != NULL, NULL);
data = g_new (StfE_FormatPageData_t, 1);
/* Create/get object and fill information struct */
data->format_termination = GTK_OPTION_MENU (glade_xml_get_widget (gui, "format_termination"));
data->format_separator = GTK_OPTION_MENU (glade_xml_get_widget (gui, "format_separator"));
data->format_custom = GTK_ENTRY (glade_xml_get_widget (gui, "format_custom"));
data->format_quote = GTK_OPTION_MENU (glade_xml_get_widget (gui, "format_quote"));
data->format_quotechar = GTK_COMBO (glade_xml_get_widget (gui, "format_quotechar"));
menu = (GtkMenu *) gtk_option_menu_get_menu (data->format_separator);
gtk_signal_connect (GTK_OBJECT (menu),
"deactivate",
GTK_SIGNAL_FUNC (sheet_page_separator_menu_deactivate),
data);
return data;
}
/**
* stf_export_dialog_sheet_page_result:
* @data: format page data
* @export_options: an export options struct
*
* Adjusts @export_options to reflect the options choosen on the
* format page
**/
void
stf_export_dialog_format_page_result (StfE_FormatPageData_t *data, StfExportOptions_t *export_options)
{
StfTerminatorType_t terminator;
StfQuotingMode_t quotingmode;
char *text;
char separator;
g_return_if_fail (data != NULL);
g_return_if_fail (export_options != NULL);
switch (stf_export_dialog_option_menu_index (data->format_termination)) {
case 0 : terminator = TERMINATOR_TYPE_LINEFEED; break;
case 1 : terminator = TERMINATOR_TYPE_RETURN; break;
case 2 : terminator = TERMINATOR_TYPE_RETURN_LINEFEED; break;
default :
terminator = TERMINATOR_TYPE_UNKNOWN;
break;
}
stf_export_options_set_terminator_type (export_options, terminator);
switch (stf_export_dialog_option_menu_index (data->format_quote)) {
case 0 : quotingmode = QUOTING_MODE_AUTO; break;
case 1 : quotingmode = QUOTING_MODE_ALWAYS; break;
case 2 : quotingmode = QUOTING_MODE_NEVER; break;
default :
quotingmode = QUOTING_MODE_UNKNOWN;
break;
}
stf_export_options_set_quoting_mode (export_options, quotingmode);
text = gtk_editable_get_chars (GTK_EDITABLE (data->format_quotechar->entry), 0, -1);
stf_export_options_set_quoting_char (export_options, text[0]);
g_free (text);
separator = '\0';
switch (stf_export_dialog_option_menu_index (data->format_separator)) {
case 0 : separator = ' '; break;
case 1 : separator = '\t'; break;
case 2 : separator = '!'; break;
case 3 : separator = ':'; break;
case 4 : separator = ','; break;
case 5 : separator = '-'; break;
case 6 : separator = '|'; break;
case 7 : separator = ';'; break;
case 8 : separator = '/'; break;
case 9 : {
text = gtk_editable_get_chars (GTK_EDITABLE (data->format_custom), 0, -1);
separator = text[0];
g_free (text);
break;
}
default :
g_warning ("Unknown separator");
break;
}
stf_export_options_set_cell_separator (export_options, separator);
}
/**
* stf_export_dialog_format_page_cleanup
* @data : formatpagedata struct
*
* Will cleanup format page run-time data
*
* returns : nothing
**/
void
stf_export_dialog_format_page_cleanup (StfE_FormatPageData_t *data)
{
g_return_if_fail (data != NULL);
g_free (data);
}
#ifndef GNUMERIC_DIALOG_STF_EXPORT_PRIVATE_H
#define GNUMERIC_DIALOG_STF_EXPORT_PRIVATE_H
#include <config.h>
#include <gnome.h>
#include <glade/glade.h>
#include "gnumeric-util.h"
#include "stf-export.h"
/* for the sheet page */
typedef struct {
GtkCList *sheet_avail;
GtkCList *sheet_export;
GtkButton *sheet_add;
GtkButton *sheet_remove;
GtkButton *sheet_addall;
GtkButton *sheet_removeall;
GtkButton *sheet_up;
GtkButton *sheet_down;
/* Run-time members */
int sheet_run_avail_index;
int sheet_run_export_index;
} StfE_SheetPageData_t;
/* for the format page */
typedef struct {
GtkOptionMenu *format_termination;
GtkOptionMenu *format_separator;
GtkEntry *format_custom;
GtkOptionMenu *format_quote;
GtkCombo *format_quotechar;
} StfE_FormatPageData_t;
/* Global stuff */
typedef enum {
DPG_SHEET,
DPG_FORMAT
} StfE_DruidPosition_t;
typedef struct {
StfE_DruidPosition_t active_page; /* The currently active page */
GtkWindow *window; /* The main window */
GnomeDruid *druid; /* The gnome druid */
GnomeDruidPage *sheet_page, *format_page; /* Rest of the pages */
StfE_FormatPageData_t *format_page_data;
StfE_SheetPageData_t *sheet_page_data;
gboolean canceled; /* Indicates weather the user canceled */
} StfE_DruidData_t;
/*
* INIT FUNCTIONS
*
* These are called when the Dialog is created and give
* each page the opportunity to connect signal handlers and set the contents
* of their Data_t record
*/
StfE_SheetPageData_t* stf_export_dialog_sheet_page_init (GladeXML *gui, Workbook *wb);
StfE_FormatPageData_t* stf_export_dialog_format_page_init (GladeXML *gui);
/*
* CAN CONTINUE FUNCTIONS
*
* These are called right before advancing to the next
* page in the druid. If they return FALSE the druid will
* not advance to the next page.
* This is to make sure that certain condition on a page
* are met.
*/
gboolean stf_export_dialog_sheet_page_can_continue (GtkWidget *window, StfE_SheetPageData_t *data);
/*
* RESULT FUNCTIONS
*
* Before the dialog is result these functions are called.
* They should modify the StfExportOptions_t struct to reflect
* the choices made by the user on the druidpage
*/
void stf_export_dialog_sheet_page_result (StfE_SheetPageData_t *data, StfExportOptions_t *export_options);
void stf_export_dialog_format_page_result (StfE_FormatPageData_t *data, StfExportOptions_t *export_options);
/*
* CLEANUP FUNCTIONS
*
* Called right before the druid is destroyed
*/
void stf_export_dialog_sheet_page_cleanup (StfE_SheetPageData_t *data);
void stf_export_dialog_format_page_cleanup (StfE_FormatPageData_t *data);
#endif
/*
* dialog-stf-sheet-page.c : controls the widgets on the sheet page
* of the export druid
*
* Almer. S. Tigelaar <almer1@dds.nl>
*
*/
#include "workbook.h"
#include "dialog-stf-export-private.h"
/*************************************************************************************************
* MISC UTILITY FUNCTIONS
*************************************************************************************************/
/**
* sheet_page_transfer_item:
* @source: source gtkclist
* @dest: destination gtklist
* @source_index: index of item in @source to transfer
*
* Transfers item @source_index from the @source gtkclist to the @dest
* gtkclist
*
* Return value: returns FALSE if the source list is empty, TRUE otherwise.
**/
static gboolean
sheet_page_transfer_item (GtkCList *source, GtkCList *dest, int source_index)
{
Sheet *sheet;
char *t[1];
int index;
g_return_val_if_fail (source != NULL, FALSE);
g_return_val_if_fail (dest != NULL, FALSE);
gtk_clist_get_text (source, source_index, 0, t);
sheet = gtk_clist_get_row_data (source, source_index);
index = gtk_clist_append (dest, t);