Commit 33d35aa2 authored by Chyla Zbigniew's avatar Chyla Zbigniew

Cleaned up file i/o interface.


Cleaned up file i/o interface.

* src/Makefile.am: Added file-priv.h.

* src/file.[ch]:
Made GnumFileOpener and GnumFileSaver GtkObjects with virtual probe,
open and save methods.
New GnumFileOpener methods: get_id.
New GnumFileSaver methods: get_id, fix_file_name.
New functions: register_file_opener, register_file_opener_as_importer,
unregister_file_opener, unregister_file_opener_as_importer,
register_file_saver, register_file_saver_as_default,
unregister_file_saver, get_default_file_saver,
get_file_opener_by_id, get_file_saver_by_id,
get_file_savers, get_file_openers, get_file_importers.

* src/file-priv.h: New file with definitions of structs:
_GnumFileOpener, _GnumFileOpenerClass, _GnumFileSaver,
_GnumFileSaverClass.

* src/workbook.h
(struct _Workbook): Added file_saver_sig_id field.
s/FileSaver/GnumFileSaver/
(workbook_get_file_saver): New accessor function.

* src/workbook.c
(cb_saver_destroy_event, workbook_destroy, workbook_set_saveinfo):
When setting new file_saver, connect to its "destroy" signal and
set file_saver to NULL in signal handler. Disconnect when changing file
saver or destroying the workbook.
(workbook_get_file_saver): New accessor function.

* src/workbook-view.[ch]
(wb_view_set_attributev): Renamed to wb_view_set_attribute_list and
simplified.
(wb_view_save_as, wb_view_save, wb_view_open, wb_view_open_custom): New
methods (some code moved from file.c).

* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped):
Use wb_view_open() instead of workbook_try_read()+file_finish_load().

* src/gui-file.c
(gui_file_import): Use get_file_importers(). Use
wb_view_open_custom() instead of file_opener_open() + manual creation
of wb_view, error checking, etc.
(is_saver_registered): Removed.
(saver_activate): Don't check if saver is really registered.
(file_saver_is_default_format): Use get_default_file_saver() instead
of strcmp(extension, "gnumeric") hack.
(do_save_as): Use gnum_file_saver_fix_file_name().
Adjusted everything to file.h, workbook.h, workbook-control.h.

* src/gui-file.h (gui_file_import): Signature change, now function
returns gboolean.

* src/gutils.[ch] (g_list_index_custom): New function.

* src/history.c (file_history_cmd), src/main.c (gnumeric_main),
src/workbook-control-gui.c (cb_file_open): Use wb_view_open()
instead of workbook_read().

* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
s/FileSaver/GnumFileSaver/

* src/plugin-service
Created GnumPluginFileOpener and GnumPluginFileSaver classes (derived
from GnumFileOpener and GnumFileSaver respectively). Moved contents of
plugin_service_file_opener_probe_func,
plugin_service_file_opener_open_func,
plugin_service_file_saver_save_func into
gnum_plugin_file_opener_probe, gnum_plugin_file_opener_open,
gnum_plugin_file_saver_save methods (slightly modified).
(plugin_service_file_opener_read): Read "open" and "import" attributes
of <service> tag.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file opener (GnumPluginFileOpener object) as normal opener and/or
importer depending on "open" and "import" XML attributes.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file saver (GnumPluginFileSaver object).

* src/plugin-service.h
(struct _PluginServiceFileOpener):
Added can_open and can_import fields.
s/FileOpener/GnumFileOpener/
(struct _PluginServiceFileSaver):
s/FileSaver/GnumFileSaver/

* src/plugin-loader-module.c
(struct ServiceLoaderDataFileOpener, struct ServiceLoaderDataFileSaver),
gnumeric_plugin_loader_module_func_file_probe,
gnumeric_plugin_loader_module_func_file_open,
gnumeric_plugin_loader_module_func_file_save):
s/FileOpener/GnumFileOpener/
s/FileSaver/GnumFileSaver/

* src/stf.c
(stf_read_workbook, stf_write_workbook): Signature change
(don't return gboolean).
(stf_init): Adjusted to file i/o interface changes.

src/xml-io.[ch]
(gnumeric_xml_get_opener, xml_probe):
s/FileOpener/GnumFileOpener/
(gnumeric_xml_get_opener):
s/FileSaver/GnumFileSaver/
(gnumeric_xml_read_workbook, gnumeric_xml_write_workbook): Signature
change (don't return gboolean).
(xml_init): Adjusted to file i/o interface changes.
parent 95fc0f27
2001-05-21 Zbigniew Chyla <cyba@gnome.pl>
Cleaned up file i/o interface.
* src/Makefile.am: Added file-priv.h.
* src/file.[ch]:
Made GnumFileOpener and GnumFileSaver GtkObjects with virtual probe,
open and save methods.
New GnumFileOpener methods: get_id.
New GnumFileSaver methods: get_id, fix_file_name.
New functions: register_file_opener, register_file_opener_as_importer,
unregister_file_opener, unregister_file_opener_as_importer,
register_file_saver, register_file_saver_as_default,
unregister_file_saver, get_default_file_saver,
get_file_opener_by_id, get_file_saver_by_id,
get_file_savers, get_file_openers, get_file_importers.
* src/file-priv.h: New file with definitions of structs:
_GnumFileOpener, _GnumFileOpenerClass, _GnumFileSaver,
_GnumFileSaverClass.
* src/workbook.h
(struct _Workbook): Added file_saver_sig_id field.
s/FileSaver/GnumFileSaver/
(workbook_get_file_saver): New accessor function.
* src/workbook.c
(cb_saver_destroy_event, workbook_destroy, workbook_set_saveinfo):
When setting new file_saver, connect to its "destroy" signal and
set file_saver to NULL in signal handler. Disconnect when changing file
saver or destroying the workbook.
(workbook_get_file_saver): New accessor function.
* src/workbook-view.[ch]
(wb_view_set_attributev): Renamed to wb_view_set_attribute_list and
simplified.
(wb_view_save_as, wb_view_save, wb_view_open, wb_view_open_custom): New
methods (some code moved from file.c).
* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped):
Use wb_view_open() instead of workbook_try_read()+file_finish_load().
* src/gui-file.c
(gui_file_import): Use get_file_importers(). Use
wb_view_open_custom() instead of file_opener_open() + manual creation
of wb_view, error checking, etc.
(is_saver_registered): Removed.
(saver_activate): Don't check if saver is really registered.
(file_saver_is_default_format): Use get_default_file_saver() instead
of strcmp(extension, "gnumeric") hack.
(do_save_as): Use gnum_file_saver_fix_file_name().
Adjusted everything to file.h, workbook.h, workbook-control.h.
* src/gui-file.h (gui_file_import): Signature change, now function
returns gboolean.
* src/gutils.[ch] (g_list_index_custom): New function.
* src/history.c (file_history_cmd), src/main.c (gnumeric_main),
src/workbook-control-gui.c (cb_file_open): Use wb_view_open()
instead of workbook_read().
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
s/FileSaver/GnumFileSaver/
* src/plugin-service
Created GnumPluginFileOpener and GnumPluginFileSaver classes (derived
from GnumFileOpener and GnumFileSaver respectively). Moved contents of
plugin_service_file_opener_probe_func,
plugin_service_file_opener_open_func,
plugin_service_file_saver_save_func into
gnum_plugin_file_opener_probe, gnum_plugin_file_opener_open,
gnum_plugin_file_saver_save methods (slightly modified).
(plugin_service_file_opener_read): Read "open" and "import" attributes
of <service> tag.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file opener (GnumPluginFileOpener object) as normal opener and/or
importer depending on "open" and "import" XML attributes.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file saver (GnumPluginFileSaver object).
* src/plugin-service.h
(struct _PluginServiceFileOpener):
Added can_open and can_import fields.
s/FileOpener/GnumFileOpener/
(struct _PluginServiceFileSaver):
s/FileSaver/GnumFileSaver/
* src/plugin-loader-module.c
(struct ServiceLoaderDataFileOpener, struct ServiceLoaderDataFileSaver),
gnumeric_plugin_loader_module_func_file_probe,
gnumeric_plugin_loader_module_func_file_open,
gnumeric_plugin_loader_module_func_file_save):
s/FileOpener/GnumFileOpener/
s/FileSaver/GnumFileSaver/
* src/stf.c
(stf_read_workbook, stf_write_workbook): Signature change
(don't return gboolean).
(stf_init): Adjusted to file i/o interface changes.
src/xml-io.[ch]
(gnumeric_xml_get_opener, xml_probe):
s/FileOpener/GnumFileOpener/
(gnumeric_xml_get_opener):
s/FileSaver/GnumFileSaver/
(gnumeric_xml_read_workbook, gnumeric_xml_write_workbook): Signature
change (don't return gboolean).
(xml_init): Adjusted to file i/o interface changes.
2001-05-20 Chema Celorio <chema@celorio.com>
* src/sheet-control-gui.c (set_acetate_coords): make sure the accetate
......
2001-05-21 Zbigniew Chyla <cyba@gnome.pl>
Cleaned up file i/o interface.
* src/Makefile.am: Added file-priv.h.
* src/file.[ch]:
Made GnumFileOpener and GnumFileSaver GtkObjects with virtual probe,
open and save methods.
New GnumFileOpener methods: get_id.
New GnumFileSaver methods: get_id, fix_file_name.
New functions: register_file_opener, register_file_opener_as_importer,
unregister_file_opener, unregister_file_opener_as_importer,
register_file_saver, register_file_saver_as_default,
unregister_file_saver, get_default_file_saver,
get_file_opener_by_id, get_file_saver_by_id,
get_file_savers, get_file_openers, get_file_importers.
* src/file-priv.h: New file with definitions of structs:
_GnumFileOpener, _GnumFileOpenerClass, _GnumFileSaver,
_GnumFileSaverClass.
* src/workbook.h
(struct _Workbook): Added file_saver_sig_id field.
s/FileSaver/GnumFileSaver/
(workbook_get_file_saver): New accessor function.
* src/workbook.c
(cb_saver_destroy_event, workbook_destroy, workbook_set_saveinfo):
When setting new file_saver, connect to its "destroy" signal and
set file_saver to NULL in signal handler. Disconnect when changing file
saver or destroying the workbook.
(workbook_get_file_saver): New accessor function.
* src/workbook-view.[ch]
(wb_view_set_attributev): Renamed to wb_view_set_attribute_list and
simplified.
(wb_view_save_as, wb_view_save, wb_view_open, wb_view_open_custom): New
methods (some code moved from file.c).
* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped):
Use wb_view_open() instead of workbook_try_read()+file_finish_load().
* src/gui-file.c
(gui_file_import): Use get_file_importers(). Use
wb_view_open_custom() instead of file_opener_open() + manual creation
of wb_view, error checking, etc.
(is_saver_registered): Removed.
(saver_activate): Don't check if saver is really registered.
(file_saver_is_default_format): Use get_default_file_saver() instead
of strcmp(extension, "gnumeric") hack.
(do_save_as): Use gnum_file_saver_fix_file_name().
Adjusted everything to file.h, workbook.h, workbook-control.h.
* src/gui-file.h (gui_file_import): Signature change, now function
returns gboolean.
* src/gutils.[ch] (g_list_index_custom): New function.
* src/history.c (file_history_cmd), src/main.c (gnumeric_main),
src/workbook-control-gui.c (cb_file_open): Use wb_view_open()
instead of workbook_read().
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
s/FileSaver/GnumFileSaver/
* src/plugin-service
Created GnumPluginFileOpener and GnumPluginFileSaver classes (derived
from GnumFileOpener and GnumFileSaver respectively). Moved contents of
plugin_service_file_opener_probe_func,
plugin_service_file_opener_open_func,
plugin_service_file_saver_save_func into
gnum_plugin_file_opener_probe, gnum_plugin_file_opener_open,
gnum_plugin_file_saver_save methods (slightly modified).
(plugin_service_file_opener_read): Read "open" and "import" attributes
of <service> tag.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file opener (GnumPluginFileOpener object) as normal opener and/or
importer depending on "open" and "import" XML attributes.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file saver (GnumPluginFileSaver object).
* src/plugin-service.h
(struct _PluginServiceFileOpener):
Added can_open and can_import fields.
s/FileOpener/GnumFileOpener/
(struct _PluginServiceFileSaver):
s/FileSaver/GnumFileSaver/
* src/plugin-loader-module.c
(struct ServiceLoaderDataFileOpener, struct ServiceLoaderDataFileSaver),
gnumeric_plugin_loader_module_func_file_probe,
gnumeric_plugin_loader_module_func_file_open,
gnumeric_plugin_loader_module_func_file_save):
s/FileOpener/GnumFileOpener/
s/FileSaver/GnumFileSaver/
* src/stf.c
(stf_read_workbook, stf_write_workbook): Signature change
(don't return gboolean).
(stf_init): Adjusted to file i/o interface changes.
src/xml-io.[ch]
(gnumeric_xml_get_opener, xml_probe):
s/FileOpener/GnumFileOpener/
(gnumeric_xml_get_opener):
s/FileSaver/GnumFileSaver/
(gnumeric_xml_read_workbook, gnumeric_xml_write_workbook): Signature
change (don't return gboolean).
(xml_init): Adjusted to file i/o interface changes.
2001-05-20 Chema Celorio <chema@celorio.com>
* src/sheet-control-gui.c (set_acetate_coords): make sure the accetate
......
2001-05-21 Zbigniew Chyla <cyba@gnome.pl>
Cleaned up file i/o interface.
* src/Makefile.am: Added file-priv.h.
* src/file.[ch]:
Made GnumFileOpener and GnumFileSaver GtkObjects with virtual probe,
open and save methods.
New GnumFileOpener methods: get_id.
New GnumFileSaver methods: get_id, fix_file_name.
New functions: register_file_opener, register_file_opener_as_importer,
unregister_file_opener, unregister_file_opener_as_importer,
register_file_saver, register_file_saver_as_default,
unregister_file_saver, get_default_file_saver,
get_file_opener_by_id, get_file_saver_by_id,
get_file_savers, get_file_openers, get_file_importers.
* src/file-priv.h: New file with definitions of structs:
_GnumFileOpener, _GnumFileOpenerClass, _GnumFileSaver,
_GnumFileSaverClass.
* src/workbook.h
(struct _Workbook): Added file_saver_sig_id field.
s/FileSaver/GnumFileSaver/
(workbook_get_file_saver): New accessor function.
* src/workbook.c
(cb_saver_destroy_event, workbook_destroy, workbook_set_saveinfo):
When setting new file_saver, connect to its "destroy" signal and
set file_saver to NULL in signal handler. Disconnect when changing file
saver or destroying the workbook.
(workbook_get_file_saver): New accessor function.
* src/workbook-view.[ch]
(wb_view_set_attributev): Renamed to wb_view_set_attribute_list and
simplified.
(wb_view_save_as, wb_view_save, wb_view_open, wb_view_open_custom): New
methods (some code moved from file.c).
* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped):
Use wb_view_open() instead of workbook_try_read()+file_finish_load().
* src/gui-file.c
(gui_file_import): Use get_file_importers(). Use
wb_view_open_custom() instead of file_opener_open() + manual creation
of wb_view, error checking, etc.
(is_saver_registered): Removed.
(saver_activate): Don't check if saver is really registered.
(file_saver_is_default_format): Use get_default_file_saver() instead
of strcmp(extension, "gnumeric") hack.
(do_save_as): Use gnum_file_saver_fix_file_name().
Adjusted everything to file.h, workbook.h, workbook-control.h.
* src/gui-file.h (gui_file_import): Signature change, now function
returns gboolean.
* src/gutils.[ch] (g_list_index_custom): New function.
* src/history.c (file_history_cmd), src/main.c (gnumeric_main),
src/workbook-control-gui.c (cb_file_open): Use wb_view_open()
instead of workbook_read().
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
s/FileSaver/GnumFileSaver/
* src/plugin-service
Created GnumPluginFileOpener and GnumPluginFileSaver classes (derived
from GnumFileOpener and GnumFileSaver respectively). Moved contents of
plugin_service_file_opener_probe_func,
plugin_service_file_opener_open_func,
plugin_service_file_saver_save_func into
gnum_plugin_file_opener_probe, gnum_plugin_file_opener_open,
gnum_plugin_file_saver_save methods (slightly modified).
(plugin_service_file_opener_read): Read "open" and "import" attributes
of <service> tag.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file opener (GnumPluginFileOpener object) as normal opener and/or
importer depending on "open" and "import" XML attributes.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file saver (GnumPluginFileSaver object).
* src/plugin-service.h
(struct _PluginServiceFileOpener):
Added can_open and can_import fields.
s/FileOpener/GnumFileOpener/
(struct _PluginServiceFileSaver):
s/FileSaver/GnumFileSaver/
* src/plugin-loader-module.c
(struct ServiceLoaderDataFileOpener, struct ServiceLoaderDataFileSaver),
gnumeric_plugin_loader_module_func_file_probe,
gnumeric_plugin_loader_module_func_file_open,
gnumeric_plugin_loader_module_func_file_save):
s/FileOpener/GnumFileOpener/
s/FileSaver/GnumFileSaver/
* src/stf.c
(stf_read_workbook, stf_write_workbook): Signature change
(don't return gboolean).
(stf_init): Adjusted to file i/o interface changes.
src/xml-io.[ch]
(gnumeric_xml_get_opener, xml_probe):
s/FileOpener/GnumFileOpener/
(gnumeric_xml_get_opener):
s/FileSaver/GnumFileSaver/
(gnumeric_xml_read_workbook, gnumeric_xml_write_workbook): Signature
change (don't return gboolean).
(xml_init): Adjusted to file i/o interface changes.
2001-05-20 Chema Celorio <chema@celorio.com>
* src/sheet-control-gui.c (set_acetate_coords): make sure the accetate
......
2001-05-21 Zbigniew Chyla <cyba@gnome.pl>
Cleaned up file i/o interface.
* src/Makefile.am: Added file-priv.h.
* src/file.[ch]:
Made GnumFileOpener and GnumFileSaver GtkObjects with virtual probe,
open and save methods.
New GnumFileOpener methods: get_id.
New GnumFileSaver methods: get_id, fix_file_name.
New functions: register_file_opener, register_file_opener_as_importer,
unregister_file_opener, unregister_file_opener_as_importer,
register_file_saver, register_file_saver_as_default,
unregister_file_saver, get_default_file_saver,
get_file_opener_by_id, get_file_saver_by_id,
get_file_savers, get_file_openers, get_file_importers.
* src/file-priv.h: New file with definitions of structs:
_GnumFileOpener, _GnumFileOpenerClass, _GnumFileSaver,
_GnumFileSaverClass.
* src/workbook.h
(struct _Workbook): Added file_saver_sig_id field.
s/FileSaver/GnumFileSaver/
(workbook_get_file_saver): New accessor function.
* src/workbook.c
(cb_saver_destroy_event, workbook_destroy, workbook_set_saveinfo):
When setting new file_saver, connect to its "destroy" signal and
set file_saver to NULL in signal handler. Disconnect when changing file
saver or destroying the workbook.
(workbook_get_file_saver): New accessor function.
* src/workbook-view.[ch]
(wb_view_set_attributev): Renamed to wb_view_set_attribute_list and
simplified.
(wb_view_save_as, wb_view_save, wb_view_open, wb_view_open_custom): New
methods (some code moved from file.c).
* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped):
Use wb_view_open() instead of workbook_try_read()+file_finish_load().
* src/gui-file.c
(gui_file_import): Use get_file_importers(). Use
wb_view_open_custom() instead of file_opener_open() + manual creation
of wb_view, error checking, etc.
(is_saver_registered): Removed.
(saver_activate): Don't check if saver is really registered.
(file_saver_is_default_format): Use get_default_file_saver() instead
of strcmp(extension, "gnumeric") hack.
(do_save_as): Use gnum_file_saver_fix_file_name().
Adjusted everything to file.h, workbook.h, workbook-control.h.
* src/gui-file.h (gui_file_import): Signature change, now function
returns gboolean.
* src/gutils.[ch] (g_list_index_custom): New function.
* src/history.c (file_history_cmd), src/main.c (gnumeric_main),
src/workbook-control-gui.c (cb_file_open): Use wb_view_open()
instead of workbook_read().
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
s/FileSaver/GnumFileSaver/
* src/plugin-service
Created GnumPluginFileOpener and GnumPluginFileSaver classes (derived
from GnumFileOpener and GnumFileSaver respectively). Moved contents of
plugin_service_file_opener_probe_func,
plugin_service_file_opener_open_func,
plugin_service_file_saver_save_func into
gnum_plugin_file_opener_probe, gnum_plugin_file_opener_open,
gnum_plugin_file_saver_save methods (slightly modified).
(plugin_service_file_opener_read): Read "open" and "import" attributes
of <service> tag.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file opener (GnumPluginFileOpener object) as normal opener and/or
importer depending on "open" and "import" XML attributes.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file saver (GnumPluginFileSaver object).
* src/plugin-service.h
(struct _PluginServiceFileOpener):
Added can_open and can_import fields.
s/FileOpener/GnumFileOpener/
(struct _PluginServiceFileSaver):
s/FileSaver/GnumFileSaver/
* src/plugin-loader-module.c
(struct ServiceLoaderDataFileOpener, struct ServiceLoaderDataFileSaver),
gnumeric_plugin_loader_module_func_file_probe,
gnumeric_plugin_loader_module_func_file_open,
gnumeric_plugin_loader_module_func_file_save):
s/FileOpener/GnumFileOpener/
s/FileSaver/GnumFileSaver/
* src/stf.c
(stf_read_workbook, stf_write_workbook): Signature change
(don't return gboolean).
(stf_init): Adjusted to file i/o interface changes.
src/xml-io.[ch]
(gnumeric_xml_get_opener, xml_probe):
s/FileOpener/GnumFileOpener/
(gnumeric_xml_get_opener):
s/FileSaver/GnumFileSaver/
(gnumeric_xml_read_workbook, gnumeric_xml_write_workbook): Signature
change (don't return gboolean).
(xml_init): Adjusted to file i/o interface changes.
2001-05-20 Chema Celorio <chema@celorio.com>
* src/sheet-control-gui.c (set_acetate_coords): make sure the accetate
......
2001-05-21 Zbigniew Chyla <cyba@gnome.pl>
Cleaned up file i/o interface.
* src/Makefile.am: Added file-priv.h.
* src/file.[ch]:
Made GnumFileOpener and GnumFileSaver GtkObjects with virtual probe,
open and save methods.
New GnumFileOpener methods: get_id.
New GnumFileSaver methods: get_id, fix_file_name.
New functions: register_file_opener, register_file_opener_as_importer,
unregister_file_opener, unregister_file_opener_as_importer,
register_file_saver, register_file_saver_as_default,
unregister_file_saver, get_default_file_saver,
get_file_opener_by_id, get_file_saver_by_id,
get_file_savers, get_file_openers, get_file_importers.
* src/file-priv.h: New file with definitions of structs:
_GnumFileOpener, _GnumFileOpenerClass, _GnumFileSaver,
_GnumFileSaverClass.
* src/workbook.h
(struct _Workbook): Added file_saver_sig_id field.
s/FileSaver/GnumFileSaver/
(workbook_get_file_saver): New accessor function.
* src/workbook.c
(cb_saver_destroy_event, workbook_destroy, workbook_set_saveinfo):
When setting new file_saver, connect to its "destroy" signal and
set file_saver to NULL in signal handler. Disconnect when changing file
saver or destroying the workbook.
(workbook_get_file_saver): New accessor function.
* src/workbook-view.[ch]
(wb_view_set_attributev): Renamed to wb_view_set_attribute_list and
simplified.
(wb_view_save_as, wb_view_save, wb_view_open, wb_view_open_custom): New
methods (some code moved from file.c).
* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped):
Use wb_view_open() instead of workbook_try_read()+file_finish_load().
* src/gui-file.c
(gui_file_import): Use get_file_importers(). Use
wb_view_open_custom() instead of file_opener_open() + manual creation
of wb_view, error checking, etc.
(is_saver_registered): Removed.
(saver_activate): Don't check if saver is really registered.
(file_saver_is_default_format): Use get_default_file_saver() instead
of strcmp(extension, "gnumeric") hack.
(do_save_as): Use gnum_file_saver_fix_file_name().
Adjusted everything to file.h, workbook.h, workbook-control.h.
* src/gui-file.h (gui_file_import): Signature change, now function
returns gboolean.
* src/gutils.[ch] (g_list_index_custom): New function.
* src/history.c (file_history_cmd), src/main.c (gnumeric_main),
src/workbook-control-gui.c (cb_file_open): Use wb_view_open()
instead of workbook_read().
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
s/FileSaver/GnumFileSaver/
* src/plugin-service
Created GnumPluginFileOpener and GnumPluginFileSaver classes (derived
from GnumFileOpener and GnumFileSaver respectively). Moved contents of
plugin_service_file_opener_probe_func,
plugin_service_file_opener_open_func,
plugin_service_file_saver_save_func into
gnum_plugin_file_opener_probe, gnum_plugin_file_opener_open,
gnum_plugin_file_saver_save methods (slightly modified).
(plugin_service_file_opener_read): Read "open" and "import" attributes
of <service> tag.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file opener (GnumPluginFileOpener object) as normal opener and/or
importer depending on "open" and "import" XML attributes.
(plugin_service_file_opener_initialize,
plugin_service_file_opener_cleanup): Register/unregister created
file saver (GnumPluginFileSaver object).
* src/plugin-service.h
(struct _PluginServiceFileOpener):
Added can_open and can_import fields.
s/FileOpener/GnumFileOpener/
(struct _PluginServiceFileSaver):
s/FileSaver/GnumFileSaver/
* src/plugin-loader-module.c
(struct ServiceLoaderDataFileOpener, struct ServiceLoaderDataFileSaver),
gnumeric_plugin_loader_module_func_file_probe,
gnumeric_plugin_loader_module_func_file_open,
gnumeric_plugin_loader_module_func_file_save):
s/FileOpener/GnumFileOpener/
s/FileSaver/GnumFileSaver/
* src/stf.c
(stf_read_workbook, stf_write_workbook): Signature change
(don't return gboolean).
(stf_init): Adjusted to file i/o interface changes.
src/xml-io.[ch]
(gnumeric_xml_get_opener, xml_probe):
s/FileOpener/GnumFileOpener/
(gnumeric_xml_get_opener):
s/FileSaver/GnumFileSaver/
(gnumeric_xml_read_workbook, gnumeric_xml_write_workbook): Signature
change (don't return gboolean).
(xml_init): Adjusted to file i/o interface changes.
2001-05-20 Chema Celorio <chema@celorio.com>
* src/sheet-control-gui.c (set_acetate_coords): make sure the accetate
......
......@@ -94,6 +94,7 @@ GNUMERIC_BASE_SOURCES = \
expr-name.h \
file.c \
file.h \
file-priv.h \
file-autoft.c \
file-autoft.h \
format-template.h \
......
#ifndef GNUMERIC_FILE_PRIV_H
#define GNUMERIC_FILE_PRIV_H
/*
* GnumFileOpener
*/
#define GNUM_FILE_OPENER_METHOD(obj,name) \
((GNUM_FILE_OPENER_CLASS (GTK_OBJECT (obj)->klass))->name)
struct _GnumFileOpenerClass {
GtkObjectClass parent_class;
gboolean (*probe) (GnumFileOpener const *fo,
const gchar *file_name);
void (*open) (GnumFileOpener const *fo,
IOContext *io_context,
WorkbookView *wbv,
const gchar *file_name);
};
struct _GnumFileOpener {
GtkObject parent;
gchar *id;
gchar *description;
GnumFileOpenerProbeFunc probe_func;
GnumFileOpenerOpenFunc open_func;
};
/*
* GnumFileSaver
*/
#define GNUM_FILE_SAVER_METHOD(obj,name) \
((GNUM_FILE_SAVER_CLASS (GTK_OBJECT (obj)->klass))->name)
struct _GnumFileSaverClass {
GtkObjectClass parent_class;
void (*save) (GnumFileSaver const *fs,
IOContext *io_context,
WorkbookView *wbv,
const gchar *file_name);
};
struct _GnumFileSaver {
GtkObject parent;
gchar *id;
gchar *extension;
gchar *description;
FileFormatLevel format_level;
GnumFileSaverSaveFunc save_func;
};
#endif /* GNUMERIC_FILE_PRIV_H */
This diff is collapsed.
#ifndef GNUMERIC_FILE_H
#define GNUMERIC_FILE_H
#include <gtk/gtktypeutils.h>
#include "gnumeric.h"
typedef struct _FileOpener FileOpener;
typedef struct _FileSaver FileSaver;
/*
* File format levels. They are ordered. When we save a file, we
* remember the name, but not if we already have a name at a higher level.
* When created, workbooks are assigned a name at level FILE_FL_NEW.
*/
typedef enum {
FILE_FL_NONE, /* No name assigned, won't happen */
FILE_FL_WRITE_ONLY, /* Postscript etc, won't be remembered */
FILE_FL_NEW, /* Wb just created */
FILE_FL_MANUAL, /* Save gets punted to save as */
FILE_FL_NONE, /* No name assigned, won't happen */
FILE_FL_WRITE_ONLY, /* PostScript etc, won't be remembered */
FILE_FL_NEW, /* Wb just created */
FILE_FL_MANUAL, /* Save gets punted to save as */
FILE_FL_MANUAL_REMEMBER, /* Ditto, but remember in history */
FILE_FL_AUTO /* Save will save to this filename */
FILE_FL_AUTO, /* Save will save to this filename */
FILE_FL_LAST
} FileFormatLevel;
typedef gboolean (*FileFormatProbe) (FileOpener const *fo,
const gchar *file_name);
typedef gboolean (*FileFormatOpen) (FileOpener const *fo,
IOContext *context,
WorkbookView *wb_view,
const gchar *file_name);
typedef gboolean (*FileFormatSave) (FileSaver const *fs,
IOContext *context,
WorkbookView *wb_view,
const gchar *file_name);
const gchar *file_opener_get_format_description (FileOpener const *fo);
gboolean file_opener_has_probe (FileOpener const *fo);
gboolean file_opener_probe (FileOpener const *fo, const gchar *file_name);
gboolean file_opener_open (FileOpener const *fo, IOContext *context,
WorkbookView *wb_view, const gchar *file_name);
void file_opener_set_user_data (FileOpener *fo, gpointer user_data);
gpointer file_opener_get_user_data (FileOpener const *fo);
const gchar *file_saver_get_extension (FileSaver const *fs);
const gchar *file_saver_get_format_description (FileSaver const *fs);
gboolean file_saver_save (FileSaver const *fs, IOContext *context,
WorkbookView *wb_view, const gchar *file_name);
void file_saver_set_user_data (FileSaver *fs, gpointer user_data);
gpointer file_saver_get_user_data (FileSaver const *fs);
FileOpener *file_format_register_open (gint priority,
const gchar *format_description,
FileFormatProbe probe_fn,
FileFormatOpen open_fn);
void file_format_unregister_open (FileOpener *fo);
FileSaver *file_format_register_save (gchar *extension,
const gchar *format_description,
FileFormatLevel level,
FileFormatSave save_fn);
void file_format_unregister_save (FileSaver *fs);
GList *file_format_get_savers (void);
GList *file_format_get_openers (void);
gboolean workbook_save_as (WorkbookControl *wbcg, WorkbookView *,
const char *name, FileSaver *saver);
gboolean workbook_save (WorkbookControl *wbc, WorkbookView *);
WorkbookView *workbook_read (WorkbookControl *context, const char *fname);
WorkbookView *workbook_try_read (WorkbookControl *context, const char *fname);
int workbook_load_from (WorkbookControl *context, WorkbookView *wbv,
const char *fname);
WorkbookView *file_finish_load (WorkbookControl *wbc, WorkbookView *new_wbv);
/*
* GnumFileOpener
*/
typedef struct _GnumFileOpener GnumFileOpener;
typedef struct _GnumFileOpenerClass GnumFileOpenerClass;
#define TYPE_GNUM_FILE_OPENER (gnum_file_opener_get_type ())
#define GNUM_FILE_OPENER(obj) (GTK_CHECK_CAST ((obj), TYPE_GNUM_FILE_OPENER, GnumFileOpener))
#define GNUM_FILE_OPENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_GNUM_FILE_OPENER, GnumFileOpenerClass))
#define IS_GNUM_FILE_OPENER(obj) (GTK_CHECK_TYPE ((obj), TYPE_GNUM_FILE_OPENER))
#define IS_GNUM_FILE_OPENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_GNUM_FILE_OPENER))
typedef gboolean (*GnumFileOpenerProbeFunc) (GnumFileOpener const *fo,
const gchar *file_name);
typedef void (*GnumFileOpenerOpenFunc) (GnumFileOpener const *fo,
IOContext *io_context,
WorkbookView *wbv,
const gchar *file_name);
GtkType gnum_file_opener_get_type (void);
GnumFileOpener *gnum_file_opener_new (const gchar *id,
const gchar *description,
GnumFileOpenerProbeFunc probe_func,
GnumFileOpenerOpenFunc open_func);
void gnum_file_opener_setup (GnumFileOpener *fo, const gchar *id,
const gchar *description,
GnumFileOpenerProbeFunc probe_func,
GnumFileOpenerOpenFunc open_func);
gboolean gnum_file_opener_probe (GnumFileOpener const *fo, const gchar *file_name);
void gnum_file_opener_open (GnumFileOpener const *fo, IOContext *io_context,