Commit 2bdefefa authored by Michael Meeks's avatar Michael Meeks Committed by Michael Meeks
Browse files

Patch from Dom Lachowicz <dominicl@seas.upenn.edu>:

	Make the plugin registration process nicer and add user readable
descriptions;

Also:

2000-02-24  Michael Meeks  <michael@helixcode.com>

	* src/plugin.c (plugin_close): expand.

2000-02-23  Dom Lachowicz <dominicl@seas.upenn.edu>

	* src/widgets/widget-color-combo.[ch]:
	In function color_table_construct() - moved tool_tip in order to
	plug memory leak(called gtk_tooltips_new() too many times)

	* src/functions/fn-database.c (gnumeric_daverage): add error for
	-'ive count
parent 3327007c
2000-02-24 Michael Meeks <michael@helixcode.com>
* src/plugin.c (plugin_close): expand.
2000-02-23 Dom Lachowicz <dominicl@seas.upenn.edu>
* src/widgets/widget-color-combo.[ch]:
In function color_table_construct() - moved tool_tip in order to
plug memory leak(called gtk_tooltips_new() too many times)
* src/functions/fn-database.c (gnumeric_daverage): add error for
-'ive count
2000-02-23 Dom Lachowicz <dominicl@seas.upenn.edu>
* src/plugin.[ch]: Additions to API -- Made struct _PluginData private
Added field 'initialized' to PluginData to keep track of whether
the plugin has gone through init yet or not
Added field 'descr' - a paragraph description of the plugin
plugin_load() - Updated to use initialized field
New function: static void plugin_close() - shuts down plugin
Updated plugin_load() and plugin_unload() to use plugin_close() --
lots of duplicated code
New functions to reflect new privateness of PluginData struct:
plugin_data_init()
plugin_data_get_filename()
plugin_data_get_title()
plugin_data_get_descr()
plugin_data_set_private_data()
plugin_data_get_private_data()
* plugins/dif/dif.c
* plugins/ff-csv/csv-io.c
* plugins/ff-stf/stf.c
* plugins/gda/plugin-gda.c
* plugins/html/boot.c
* plugins/lotus-123/boot.c
* plugins/oleo/boot.c
* plugins/plan-perfect/pln.c
* plugins/sample/plugin-sample.c
* plugins/sc/sc.c
* plugins/sylk/sylk.c
* plugins/text/text-io.c
* plugins/xbase/boot.c:
Changed init_plugin() in each to use new plugin API, specifically
They all call plugin_data_init() now
Changed the respective cleanup functions to not g_free() the title or
descriptions
* plugins/gb/plugin.c: in addition to the above statement, I changed
cleanup() and init_plugin() to use plugin_data_[get|set]_private_data
* plugins/guile/plugin.c
* plugins/perl/perl.c
* plugins/python/python.c: added function no_cleanup_for_me() which
does absolutely nothing for completeness
* src/dialogs/dialog-plugin-manager.c: Changed add_to_clist() to use
new plugin_data_get_XXX() methods
2000-02-23 Matthias Warkus <mawa@iname.com>
* gnome-spreadsheet.png, gnome-xls.png: Removed. They have been
......
2000-02-24 Michael Meeks <michael@helixcode.com>
* src/plugin.c (plugin_close): expand.
2000-02-23 Dom Lachowicz <dominicl@seas.upenn.edu>
* src/widgets/widget-color-combo.[ch]:
In function color_table_construct() - moved tool_tip in order to
plug memory leak(called gtk_tooltips_new() too many times)
* src/functions/fn-database.c (gnumeric_daverage): add error for
-'ive count
2000-02-23 Dom Lachowicz <dominicl@seas.upenn.edu>
* src/plugin.[ch]: Additions to API -- Made struct _PluginData private
Added field 'initialized' to PluginData to keep track of whether
the plugin has gone through init yet or not
Added field 'descr' - a paragraph description of the plugin
plugin_load() - Updated to use initialized field
New function: static void plugin_close() - shuts down plugin
Updated plugin_load() and plugin_unload() to use plugin_close() --
lots of duplicated code
New functions to reflect new privateness of PluginData struct:
plugin_data_init()
plugin_data_get_filename()
plugin_data_get_title()
plugin_data_get_descr()
plugin_data_set_private_data()
plugin_data_get_private_data()
* plugins/dif/dif.c
* plugins/ff-csv/csv-io.c
* plugins/ff-stf/stf.c
* plugins/gda/plugin-gda.c
* plugins/html/boot.c
* plugins/lotus-123/boot.c
* plugins/oleo/boot.c
* plugins/plan-perfect/pln.c
* plugins/sample/plugin-sample.c
* plugins/sc/sc.c
* plugins/sylk/sylk.c
* plugins/text/text-io.c
* plugins/xbase/boot.c:
Changed init_plugin() in each to use new plugin API, specifically
They all call plugin_data_init() now
Changed the respective cleanup functions to not g_free() the title or
descriptions
* plugins/gb/plugin.c: in addition to the above statement, I changed
cleanup() and init_plugin() to use plugin_data_[get|set]_private_data
* plugins/guile/plugin.c
* plugins/perl/perl.c
* plugins/python/python.c: added function no_cleanup_for_me() which
does absolutely nothing for completeness
* src/dialogs/dialog-plugin-manager.c: Changed add_to_clist() to use
new plugin_data_get_XXX() methods
2000-02-23 Matthias Warkus <mawa@iname.com>
* gnome-spreadsheet.png, gnome-xls.png: Removed. They have been
......
......@@ -453,9 +453,10 @@ dif_cleanup_plugin (PluginData *pd)
{
file_format_unregister_open (NULL, dif_read_workbook);
file_format_unregister_save (dif_write_workbook);
g_free (pd->title);
}
#define DIF_TITLE _("Data Interchange Format (CSV) module")
#define DIF_DESCR _("This plugin can read and write information stored in the Data Interchange Format (*.dif)")
PluginInitResult
init_plugin (CommandContext *context, PluginData * pd)
......@@ -471,10 +472,9 @@ init_plugin (CommandContext *context, PluginData * pd)
desc = _("Data Interchange Format (*.dif)");
file_format_register_save (".dif", desc, dif_write_workbook);
desc = _("Data Interchange Format (CSV) module");
pd->title = g_strdup (desc);
pd->can_unload = dif_can_unload;
pd->cleanup_plugin = dif_cleanup_plugin;
return PLUGIN_OK;
if (plugin_data_init (pd, dif_can_unload, dif_cleanup_plugin,
DIF_TITLE, DIF_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
}
......@@ -306,9 +306,10 @@ csv_cleanup_plugin (PluginData *pd)
{
file_format_unregister_open (NULL, csv_read_workbook);
file_format_unregister_save (csv_write_workbook);
g_free (pd->title);
}
#define CSV_TITLE _("Comma Separated Value (CSV) module")
#define CSV_DESCR _("This plugin reads and writes comma separated value formatted data (*.csv)")
PluginInitResult
init_plugin (CommandContext *context, PluginData *pd)
......@@ -325,9 +326,10 @@ init_plugin (CommandContext *context, PluginData *pd)
file_format_register_save (".csv", desc, csv_write_workbook);
desc = _("Comma Separated Value (CSV) module");
pd->title = g_strdup (desc);
pd->can_unload = csv_can_unload;
pd->cleanup_plugin = csv_cleanup_plugin;
return PLUGIN_OK;
if (plugin_data_init (pd, csv_can_unload, csv_cleanup_plugin,
CSV_TITLE, CSV_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
}
......@@ -311,6 +311,9 @@ stf_cleanup_plugin (PluginData *pd)
/* file_format_unregister_save (stf_write_workbook); */
}
#define STF_TITLE _("Structured Text File (STF) module")
#define STF_DESCR _("This plugin reads sheets using CSV/Fixed encoding while allowing fine-tuning of the import process")
/**
* init_plugin
* @pd : a plugin data struct
......@@ -333,14 +336,15 @@ init_plugin (CommandContext *context, PluginData *pd)
file_format_register_open (1, desc, NULL, stf_read_workbook);
/* desc = _("Structured Text File format (*.stf)");
file_format_register_save (".stf", desc, stf_write_workbook);*/
desc = _("Structured Text File (STF) module");
pd->title = g_strdup (desc);
pd->can_unload = stf_can_unload;
pd->cleanup_plugin = stf_cleanup_plugin;
file_format_register_save (".stf", desc, stf_write_workbook); */
glade_gnome_init ();
if (plugin_data_init (pd, stf_can_unload, stf_cleanup_plugin,
STF_TITLE, STF_DESCR))
{
glade_gnome_init();
return PLUGIN_OK;
}
else
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -548,7 +548,10 @@ gnumeric_daverage (FunctionEvalInfo *ei, Value **argv)
g_slist_free(cells);
free_criterias(criterias);
return value_new_float (sum / count);
if ( count > 0 )
return value_new_float (sum / count);
else
return value_new_error (ei->pos, gnumeric_err_NUM);
}
/***************************************************************************/
......
2000-02-24 Michael Meeks <michael@helixcode.com>
* plugin.c (cleanup): fiddle.
2000-02-23 Michael Meeks <michael@helixcode.com>
* plugin.c (parse_file): fixup.
......
......@@ -106,9 +106,11 @@ dont_unload (PluginData *pd)
static void
cleanup (PluginData *pd)
{
if (pd->private_data)
gbrun_context_destroy (pd->private_data);
pd->private_data = NULL;
void *user_data;
if ((user_data = plugin_data_get_user_data (pd)))
gbrun_context_destroy (user_data);
plugin_data_set_user_data (pd, NULL);
gbrun_shutdown ();
gb_shutdown ();
......@@ -240,6 +242,9 @@ cb_register_functions (gpointer key, gpointer value, gpointer user_data)
function_def_set_user_data (fndef, fd);
}
#define GB_TITLE _("Gnome Basic Plugin")
#define GB_DESCR _("This plugin enables Gnome Basic support in Gnumeric")
PluginInitResult
init_plugin (CommandContext *context, PluginData *pd)
{
......@@ -266,10 +271,13 @@ init_plugin (CommandContext *context, PluginData *pd)
}
g_free (fname);
pd->can_unload = dont_unload;
pd->cleanup_plugin = cleanup;
pd->title = g_strdup(_("Gnome Basic Plugin"));
pd->private_data = c.rc;
plugin_data_set_user_data (pd, c.rc);
if (plugin_data_init (pd, dont_unload, cleanup,
GB_TITLE, GB_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -241,13 +241,15 @@ cleanup_plugin (PluginData *pd)
{
Symbol *sym;
g_free (pd->title);
sym = symbol_lookup (global_symbol_table, "execSQL");
if (sym)
symbol_unref(sym);
}
#define GDA_TITLE _("Database Access")
#define GDA_DESCR _("This plugin allows for database access in Gnumeric")
PluginInitResult
init_plugin (CommandContext *context, PluginData* pd)
{
......@@ -257,9 +259,11 @@ init_plugin (CommandContext *context, PluginData* pd)
return PLUGIN_QUIET_ERROR;
install_symbols(plugin_functionp, "GDA Plugin");
pd->can_unload = can_unload;
pd->cleanup_plugin = cleanup_plugin;
pd->title = g_strdup("Database Access");
return PLUGIN_OK;
if (plugin_data_init (pd, can_unload, cleanup_plugin,
GDA_TITLE, GDA_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
}
......@@ -110,7 +110,7 @@ value_to_scm (Value *val, CellRef cell_ref)
ls = gh_eval_str("'()");
for(i = 0; i < y; i++)
for(ii = 0; i < x; i++)
for (ii = 0; i < x; i++)
ls = scm_cons(val->v.array.vals[ii][i], ls);
return ls;
}
......@@ -445,6 +445,15 @@ no_unloading_for_me (PluginData *pd)
return 0;
}
static void
no_cleanup_for_me (PluginData *pd)
{
return;
}
#define GUILE_TITLE _("Guile Plugin")
#define GUILE_DESCR _("This plugin enables Guile(scheme) support in Gnumeric")
PluginInitResult
init_plugin (CommandContext *context, PluginData *pd)
{
......@@ -461,9 +470,6 @@ init_plugin (CommandContext *context, PluginData *pd)
function_add_nodes (cat, "scm_apply", 0, "symbol", NULL, func_scm_apply);
pd->can_unload = no_unloading_for_me;
pd->title = g_strdup(_("Guile Plugin"));
scm_make_gsubr ("cell-value", 1, 0, 0, scm_cell_value);
scm_make_gsubr ("cell-expr", 1, 0, 0, scm_cell_expr);
scm_make_gsubr ("set-cell-string!", 2, 0, 0, scm_set_cell_string);
......@@ -478,5 +484,9 @@ init_plugin (CommandContext *context, PluginData *pd)
scm_cons (scm_makfrom0str (init_file_name), SCM_EOL),
SCM_EOL);
if (!plugin_data_init (pd, no_unloading_for_me, no_cleanup_for_me,
GUILE_TITLE, GUILE_DESCR))
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -29,7 +29,7 @@
#include "epsf.h"
/*
* Q: what's that for?
* We can unload
*/
static int
html_can_unload (PluginData *pd)
......@@ -53,8 +53,6 @@ html_cleanup_plugin (PluginData *pd)
file_format_unregister_save (html_write_wb_roff);
file_format_unregister_save (epsf_write_wb);
file_format_unregister_open (NULL,html_read);
g_free (pd->title);
}
/*
......@@ -64,25 +62,32 @@ static void
html_init (void)
{
char *desc;
desc = _("HTML 3.2 file format (*.html)");
file_format_register_save (".html", desc, html_write_wb_html32);
desc = _("HTML 4.0 file format (*.html)");
file_format_register_save (".html", desc, html_write_wb_html40);
desc = _("HTML file made by gnumeric");
/* Register file format with priority 100 */
file_format_register_open (100, desc, NULL, html_read);
desc = _("LaTeX file format (*.tex)");
file_format_register_save (".tex", desc, html_write_wb_latex);
desc = _("LaTeX2e file format (*.tex)");
file_format_register_save (".tex", desc, html_write_wb_latex2e);
desc = _("PS file format (via groff)");
file_format_register_save (".ps", desc, html_write_wb_roff_ps);
desc = _("DVI TeX file format (via groff)");
file_format_register_save (".dvi", desc, html_write_wb_roff_dvi);
desc = _("TROFF file format (*.me)");
file_format_register_save (".me", desc, html_write_wb_roff);
desc = _("PDF file format (via groff/gs)");
file_format_register_save (".pdf", desc, html_write_wb_roff_pdf);
......@@ -90,6 +95,9 @@ html_init (void)
file_format_register_save (".eps", desc, epsf_write_wb);
}
#define HTML_TITLE _("HTML (simple html import/export plugin)")
#define HTML_DESCR _("This plugin allows for import/export of HTML, PS, DVI, TeX, and other formats")
/*
* called by gnumeric to load the plugin
*/
......@@ -101,10 +109,11 @@ init_plugin (CommandContext *context, PluginData *pd)
html_init ();
pd->can_unload = html_can_unload;
pd->cleanup_plugin = html_cleanup_plugin;
pd->title = g_strdup (_("HTML (simple html export/import plugin)"));
if (plugin_data_init (pd, html_can_unload, html_cleanup_plugin,
HTML_TITLE, HTML_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -81,9 +81,11 @@ static void
lotus_cleanup_plugin (PluginData *pd)
{
file_format_unregister_open (lotus_probe, lotus_load);
g_free (pd->title);
}
#define LOTUS_TITLE _("Lotus 123 file import/export plugin")
#define LOTUS_DESCR _("This plugin is used for Lotus 123 file import/export")
PluginInitResult
init_plugin (CommandContext *context, PluginData *pd)
{
......@@ -94,9 +96,10 @@ init_plugin (CommandContext *context, PluginData *pd)
file_format_register_open (50, descr, lotus_probe, lotus_load);
pd->can_unload = lotus_can_unload;
pd->cleanup_plugin = lotus_cleanup_plugin;
pd->title = g_strdup (_("Lotus 123 file import/export plugin"));
if (plugin_data_init (pd, lotus_can_unload, lotus_cleanup_plugin,
LOTUS_TITLE, LOTUS_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -81,9 +81,11 @@ static void
oleo_cleanup_plugin (PluginData *pd)
{
file_format_unregister_open (oleo_probe, oleo_load);
g_free (pd->title);
}
#define OLEO_TITLE _("GNU Oleo import plugin")
#define OLEO_DESCR _("This plugin enables importion of GNU Oleo documents")
PluginInitResult
init_plugin (CommandContext *context, PluginData *pd)
{
......@@ -94,9 +96,10 @@ init_plugin (CommandContext *context, PluginData *pd)
file_format_register_open (100, descr, oleo_probe, oleo_load);
pd->can_unload = oleo_can_unload;
pd->cleanup_plugin = oleo_cleanup_plugin;
pd->title = g_strdup (_("GNU Oleo import plugin"));
if (plugin_data_init (pd, oleo_can_unload, oleo_cleanup_plugin,
OLEO_TITLE, OLEO_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -24,6 +24,15 @@ no_unloading_for_me (PluginData *pd)
return 0;
}
static void
no_cleanup_for_me (PluginData *pd)
{
return;
}
#define PERL_TITLE _("Perl Plugin")
#define PERL_DESCR _("This plugin enables PERL support in Gnumeric")
PluginInitResult
init_plugin (CommandContext *context, PluginData *pd)
{
......@@ -33,10 +42,6 @@ init_plugin (CommandContext *context, PluginData *pd)
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return PLUGIN_QUIET_ERROR;
/* Initialize Gnumeric plugin information. */
pd->can_unload = no_unloading_for_me;
pd->title = "Perl Plugin";
/* Initialize the Perl interpreter. */
arg = gnome_unconditional_datadir_file("gnumeric/perl/lib");
argv[1] = g_strconcat("-I", arg, NULL);
......@@ -47,5 +52,10 @@ init_plugin (CommandContext *context, PluginData *pd)
perl_parse(gnumeric_perl_interp, xs_init, 3, argv, NULL);
perl_run(gnumeric_perl_interp);
return PLUGIN_OK;
if (plugin_data_init (pd, no_unloading_for_me, no_cleanup_for_me,
PERL_TITLE, PERL_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
}
......@@ -938,6 +938,8 @@ pln_cleanup_plugin (PluginData *pd)
file_format_unregister_open (NULL, pln_read_workbook);
}
#define PLN_TITLE _("Plan Perfect Format (PLN) module")
#define PLN_DESCR _("This plugin handles Plan Perfect Formatted Documents")
PluginInitResult
init_plugin (CommandContext *context, PluginData * pd)
......@@ -950,10 +952,10 @@ init_plugin (CommandContext *context, PluginData * pd)
desc = _("Plan Perfect Format (PLN) import");
file_format_register_open (1, desc, NULL, pln_read_workbook);
desc = _("Plan Perfect Format (PLN) module");
pd->title = g_strdup (desc);
pd->can_unload = pln_can_unload;
pd->cleanup_plugin = pln_cleanup_plugin;
if (plugin_data_init (pd, pln_can_unload, pln_cleanup_plugin,
PLN_TITLE, PLN_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -291,6 +291,15 @@ no_unloading_for_me (PluginData *pd)
return 0;
}
static void
no_cleanup_for_me (PluginData *pd)
{
return;
}
#define PY_TITLE _("Python Plugin")
#define PY_DESCR _("This plugin provides for rudimentary Python language support in Gnumeric")
PluginInitResult
init_plugin (CommandContext *context, PluginData * pd)
{
......@@ -299,9 +308,6 @@ init_plugin (CommandContext *context, PluginData * pd)
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return PLUGIN_QUIET_ERROR;
pd->can_unload = no_unloading_for_me;
pd->title = g_strdup (_("Python Plugin"));
/* initialize the python interpreter */
Py_SetProgramName ("gnumeric");
Py_Initialize ();
......@@ -333,5 +339,10 @@ init_plugin (CommandContext *context, PluginData * pd)
g_free(name);
}
return PLUGIN_OK;
if (plugin_data_init (pd, no_unloading_for_me, no_cleanup_for_me,
PY_TITLE, PY_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
}
......@@ -32,12 +32,14 @@ cleanup_plugin (PluginData *pd)
{
Symbol *sym;
g_free (pd->title);
sym = symbol_lookup (global_symbol_table, "plusone");
if (sym)
symbol_unref (sym);
}
#define SAMPLE_TITLE _("PlusOne Plugin")
#define SAMPLE_DESCR _("Sample Gnumeric Plugin")
PluginInitResult
init_plugin (CommandContext *context, PluginData *pd)
{
......@@ -49,10 +51,11 @@ init_plugin (CommandContext *context, PluginData *pd)
cat = function_get_category (_("Sample Plugin"));
function_add_args (cat, "plusone", "f", "number", NULL, func_plusone);
pd->can_unload = can_unload;
pd->cleanup_plugin = cleanup_plugin;
pd->title = g_strdup ("PlusOne Plugin");
if (plugin_data_init (pd, can_unload, cleanup_plugin,
SAMPLE_TITLE, SAMPLE_DESCR))
return PLUGIN_OK;
else
return PLUGIN_ERROR;
return PLUGIN_OK;
}
......@@ -444,9 +444,10 @@ sc_cleanup_plugin (PluginData *pd)
g_return_if_fail (pd);