mirror of https://github.com/GNOME/gimp.git
app/core/gimpmoduleinfo.[ch] separated module query from type registration
2002-10-20 Michael Natterer <mitch@gimp.org> * app/core/gimpmoduleinfo.[ch] * libgimp/gimpmodule.h: separated module query from type registration by adding a separate "gimp_module_query" function which must be implemented by modules. Make local copies of the strings returned by the query function. * app/core/gimpmodules.c * app/gui/module-browser.c: changed accordingly. * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * modules/colorsel_triangle.c * modules/colorsel_water.c: added the gimp_module_query() functions.
This commit is contained in:
parent
079b768ea7
commit
4cb04533e4
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2002-10-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpmoduleinfo.[ch]
|
||||
* libgimp/gimpmodule.h: separated module query from type
|
||||
registration by adding a separate "gimp_module_query" function
|
||||
which must be implemented by modules. Make local copies of the
|
||||
strings returned by the query function.
|
||||
|
||||
* app/core/gimpmodules.c
|
||||
* app/gui/module-browser.c: changed accordingly.
|
||||
|
||||
* modules/cdisplay_gamma.c
|
||||
* modules/cdisplay_highcontrast.c
|
||||
* modules/colorsel_triangle.c
|
||||
* modules/colorsel_water.c: added the gimp_module_query() functions.
|
||||
|
||||
2002-10-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell-filter.[ch]: removed the
|
||||
|
|
|
@ -286,23 +286,23 @@ print_module_info (gpointer data,
|
|||
g_print ("\n%s: %i\n",
|
||||
i->filename,
|
||||
i->state /* statename[i->state] */);
|
||||
g_print (" module:%p lasterr:%s register:%p\n",
|
||||
|
||||
g_print (" module:%p lasterr:%s query:%p register:%p\n",
|
||||
i->module,
|
||||
i->last_module_error? i->last_module_error : "NONE",
|
||||
i->last_module_error ? i->last_module_error : "NONE",
|
||||
i->query_module,
|
||||
i->register_module);
|
||||
if (i->info)
|
||||
{
|
||||
g_print (" purpose: %s\n"
|
||||
" author: %s\n"
|
||||
" version: %s\n"
|
||||
" copyright: %s\n"
|
||||
" date: %s\n",
|
||||
i->info->purpose,
|
||||
i->info->author,
|
||||
i->info->version,
|
||||
i->info->copyright,
|
||||
i->info->date);
|
||||
}
|
||||
|
||||
g_print (" purpose: %s\n"
|
||||
" author: %s\n"
|
||||
" version: %s\n"
|
||||
" copyright: %s\n"
|
||||
" date: %s\n",
|
||||
i->info.purpose ? i->info.purpose : "NONE",
|
||||
i->info.author ? i->info.author : "NONE",
|
||||
i->info.version ? i->info.version : "NONE",
|
||||
i->info.copyright ? i->info.copyright : "NONE",
|
||||
i->info.date ? i->info.date : "NONE");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -125,7 +125,6 @@ gimp_module_info_init (GimpModuleInfoObj *module_info)
|
|||
module_info->load_inhibit = FALSE;
|
||||
|
||||
module_info->module = NULL;
|
||||
module_info->info = NULL;
|
||||
module_info->last_module_error = NULL;
|
||||
|
||||
module_info->register_module = NULL;
|
||||
|
@ -156,9 +155,10 @@ gimp_module_info_finalize (GObject *object)
|
|||
static gboolean
|
||||
gimp_module_info_load (GTypeModule *module)
|
||||
{
|
||||
GimpModuleInfoObj *module_info;
|
||||
gpointer symbol;
|
||||
gboolean retval;
|
||||
GimpModuleInfoObj *module_info;
|
||||
const GimpModuleInfo *info;
|
||||
gpointer symbol;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_MODULE_INFO (module), FALSE);
|
||||
|
||||
|
@ -184,7 +184,58 @@ gimp_module_info_load (GTypeModule *module)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* find the module_init symbol */
|
||||
/* find the gimp_module_query symbol */
|
||||
if (! g_module_symbol (module_info->module, "gimp_module_query", &symbol))
|
||||
{
|
||||
module_info->state = GIMP_MODULE_STATE_ERROR;
|
||||
|
||||
gimp_module_info_set_last_error (module_info,
|
||||
_("Missing gimp_module_query() symbol"));
|
||||
|
||||
if (module_info->verbose)
|
||||
g_message (_("Module '%s' load error:\n%s"),
|
||||
module_info->filename, module_info->last_module_error);
|
||||
g_module_close (module_info->module);
|
||||
module_info->module = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
module_info->query_module = symbol;
|
||||
|
||||
info = module_info->query_module (module);
|
||||
|
||||
if (! info)
|
||||
{
|
||||
module_info->state = GIMP_MODULE_STATE_ERROR;
|
||||
|
||||
gimp_module_info_set_last_error (module_info,
|
||||
_("gimp_module_query() returned NULL"));
|
||||
|
||||
if (module_info->verbose)
|
||||
g_message (_("Module '%s' load error:\n%s"),
|
||||
module_info->filename, module_info->last_module_error);
|
||||
g_module_close (module_info->module);
|
||||
module_info->module = NULL;
|
||||
module_info->query_module = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free ((gchar *) module_info->info.purpose);
|
||||
module_info->info.purpose = g_strdup (info->purpose);
|
||||
|
||||
g_free ((gchar *) module_info->info.author);
|
||||
module_info->info.author = g_strdup (info->author);
|
||||
|
||||
g_free ((gchar *) module_info->info.version);
|
||||
module_info->info.version = g_strdup (info->version);
|
||||
|
||||
g_free ((gchar *) module_info->info.copyright);
|
||||
module_info->info.copyright = g_strdup (info->copyright);
|
||||
|
||||
g_free ((gchar *) module_info->info.date);
|
||||
module_info->info.date = g_strdup (info->date);
|
||||
|
||||
/* find the gimp_module_register symbol */
|
||||
if (! g_module_symbol (module_info->module, "gimp_module_register", &symbol))
|
||||
{
|
||||
module_info->state = GIMP_MODULE_STATE_ERROR;
|
||||
|
@ -202,7 +253,7 @@ gimp_module_info_load (GTypeModule *module)
|
|||
|
||||
module_info->register_module = symbol;
|
||||
|
||||
retval = module_info->register_module (module, &module_info->info);
|
||||
retval = module_info->register_module (module);
|
||||
|
||||
if (retval)
|
||||
module_info->state = GIMP_MODULE_STATE_LOADED_OK;
|
||||
|
@ -225,7 +276,7 @@ gimp_module_info_unload (GTypeModule *module)
|
|||
|
||||
g_module_close (module_info->module); /* FIXME: error handling */
|
||||
module_info->module = NULL;
|
||||
module_info->info = NULL;
|
||||
module_info->query_module = NULL;
|
||||
module_info->register_module = NULL;
|
||||
|
||||
module_info->state = GIMP_MODULE_STATE_UNLOADED_OK;
|
||||
|
|
|
@ -58,11 +58,11 @@ struct _GimpModuleInfoObj
|
|||
|
||||
/* stuff from now on may be NULL depending on the state the module is in */
|
||||
GModule *module; /* handle on the module */
|
||||
GimpModuleInfo *info; /* returned values from module_register */
|
||||
GimpModuleInfo info; /* returned values from module_query */
|
||||
gchar *last_module_error;
|
||||
|
||||
gboolean (* register_module) (GTypeModule *module,
|
||||
GimpModuleInfo **module_info);
|
||||
const GimpModuleInfo * (* query_module) (GTypeModule *module);
|
||||
gboolean (* register_module) (GTypeModule *module);
|
||||
};
|
||||
|
||||
struct _GimpModuleInfoObjClass
|
||||
|
|
|
@ -286,23 +286,23 @@ print_module_info (gpointer data,
|
|||
g_print ("\n%s: %i\n",
|
||||
i->filename,
|
||||
i->state /* statename[i->state] */);
|
||||
g_print (" module:%p lasterr:%s register:%p\n",
|
||||
|
||||
g_print (" module:%p lasterr:%s query:%p register:%p\n",
|
||||
i->module,
|
||||
i->last_module_error? i->last_module_error : "NONE",
|
||||
i->last_module_error ? i->last_module_error : "NONE",
|
||||
i->query_module,
|
||||
i->register_module);
|
||||
if (i->info)
|
||||
{
|
||||
g_print (" purpose: %s\n"
|
||||
" author: %s\n"
|
||||
" version: %s\n"
|
||||
" copyright: %s\n"
|
||||
" date: %s\n",
|
||||
i->info->purpose,
|
||||
i->info->author,
|
||||
i->info->version,
|
||||
i->info->copyright,
|
||||
i->info->date);
|
||||
}
|
||||
|
||||
g_print (" purpose: %s\n"
|
||||
" author: %s\n"
|
||||
" version: %s\n"
|
||||
" copyright: %s\n"
|
||||
" date: %s\n",
|
||||
i->info.purpose ? i->info.purpose : "NONE",
|
||||
i->info.author ? i->info.author : "NONE",
|
||||
i->info.version ? i->info.version : "NONE",
|
||||
i->info.copyright ? i->info.copyright : "NONE",
|
||||
i->info.date ? i->info.date : "NONE");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -386,13 +386,13 @@ browser_info_update (GimpModuleInfoObj *mod,
|
|||
return;
|
||||
}
|
||||
|
||||
if (mod->info)
|
||||
if (mod->info.purpose)
|
||||
{
|
||||
text[0] = mod->info->purpose;
|
||||
text[1] = mod->info->author;
|
||||
text[2] = mod->info->version;
|
||||
text[3] = mod->info->copyright;
|
||||
text[4] = mod->info->date;
|
||||
text[0] = mod->info.purpose;
|
||||
text[1] = mod->info.author;
|
||||
text[2] = mod->info.version;
|
||||
text[3] = mod->info.copyright;
|
||||
text[4] = mod->info.date;
|
||||
text[5] = mod->on_disk ? _("On disk") : _("Only in memory");
|
||||
}
|
||||
else
|
||||
|
|
|
@ -386,13 +386,13 @@ browser_info_update (GimpModuleInfoObj *mod,
|
|||
return;
|
||||
}
|
||||
|
||||
if (mod->info)
|
||||
if (mod->info.purpose)
|
||||
{
|
||||
text[0] = mod->info->purpose;
|
||||
text[1] = mod->info->author;
|
||||
text[2] = mod->info->version;
|
||||
text[3] = mod->info->copyright;
|
||||
text[4] = mod->info->date;
|
||||
text[0] = mod->info.purpose;
|
||||
text[1] = mod->info.author;
|
||||
text[2] = mod->info.version;
|
||||
text[3] = mod->info.copyright;
|
||||
text[4] = mod->info.date;
|
||||
text[5] = mod->on_disk ? _("On disk") : _("Only in memory");
|
||||
}
|
||||
else
|
||||
|
|
|
@ -40,8 +40,8 @@ struct _GimpModuleInfo
|
|||
};
|
||||
|
||||
|
||||
typedef gboolean (* GimpModuleRegisterFunc) (GTypeModule *module,
|
||||
GimpModuleInfo **module_info);
|
||||
typedef const GimpModuleInfo * (* GimpModuleQueryFunc) (GTypeModule *module);
|
||||
typedef gboolean (* GimpModuleRegisterFunc) (GTypeModule *module);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -125,7 +125,6 @@ gimp_module_info_init (GimpModuleInfoObj *module_info)
|
|||
module_info->load_inhibit = FALSE;
|
||||
|
||||
module_info->module = NULL;
|
||||
module_info->info = NULL;
|
||||
module_info->last_module_error = NULL;
|
||||
|
||||
module_info->register_module = NULL;
|
||||
|
@ -156,9 +155,10 @@ gimp_module_info_finalize (GObject *object)
|
|||
static gboolean
|
||||
gimp_module_info_load (GTypeModule *module)
|
||||
{
|
||||
GimpModuleInfoObj *module_info;
|
||||
gpointer symbol;
|
||||
gboolean retval;
|
||||
GimpModuleInfoObj *module_info;
|
||||
const GimpModuleInfo *info;
|
||||
gpointer symbol;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_MODULE_INFO (module), FALSE);
|
||||
|
||||
|
@ -184,7 +184,58 @@ gimp_module_info_load (GTypeModule *module)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* find the module_init symbol */
|
||||
/* find the gimp_module_query symbol */
|
||||
if (! g_module_symbol (module_info->module, "gimp_module_query", &symbol))
|
||||
{
|
||||
module_info->state = GIMP_MODULE_STATE_ERROR;
|
||||
|
||||
gimp_module_info_set_last_error (module_info,
|
||||
_("Missing gimp_module_query() symbol"));
|
||||
|
||||
if (module_info->verbose)
|
||||
g_message (_("Module '%s' load error:\n%s"),
|
||||
module_info->filename, module_info->last_module_error);
|
||||
g_module_close (module_info->module);
|
||||
module_info->module = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
module_info->query_module = symbol;
|
||||
|
||||
info = module_info->query_module (module);
|
||||
|
||||
if (! info)
|
||||
{
|
||||
module_info->state = GIMP_MODULE_STATE_ERROR;
|
||||
|
||||
gimp_module_info_set_last_error (module_info,
|
||||
_("gimp_module_query() returned NULL"));
|
||||
|
||||
if (module_info->verbose)
|
||||
g_message (_("Module '%s' load error:\n%s"),
|
||||
module_info->filename, module_info->last_module_error);
|
||||
g_module_close (module_info->module);
|
||||
module_info->module = NULL;
|
||||
module_info->query_module = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free ((gchar *) module_info->info.purpose);
|
||||
module_info->info.purpose = g_strdup (info->purpose);
|
||||
|
||||
g_free ((gchar *) module_info->info.author);
|
||||
module_info->info.author = g_strdup (info->author);
|
||||
|
||||
g_free ((gchar *) module_info->info.version);
|
||||
module_info->info.version = g_strdup (info->version);
|
||||
|
||||
g_free ((gchar *) module_info->info.copyright);
|
||||
module_info->info.copyright = g_strdup (info->copyright);
|
||||
|
||||
g_free ((gchar *) module_info->info.date);
|
||||
module_info->info.date = g_strdup (info->date);
|
||||
|
||||
/* find the gimp_module_register symbol */
|
||||
if (! g_module_symbol (module_info->module, "gimp_module_register", &symbol))
|
||||
{
|
||||
module_info->state = GIMP_MODULE_STATE_ERROR;
|
||||
|
@ -202,7 +253,7 @@ gimp_module_info_load (GTypeModule *module)
|
|||
|
||||
module_info->register_module = symbol;
|
||||
|
||||
retval = module_info->register_module (module, &module_info->info);
|
||||
retval = module_info->register_module (module);
|
||||
|
||||
if (retval)
|
||||
module_info->state = GIMP_MODULE_STATE_LOADED_OK;
|
||||
|
@ -225,7 +276,7 @@ gimp_module_info_unload (GTypeModule *module)
|
|||
|
||||
g_module_close (module_info->module); /* FIXME: error handling */
|
||||
module_info->module = NULL;
|
||||
module_info->info = NULL;
|
||||
module_info->query_module = NULL;
|
||||
module_info->register_module = NULL;
|
||||
|
||||
module_info->state = GIMP_MODULE_STATE_UNLOADED_OK;
|
||||
|
|
|
@ -58,11 +58,11 @@ struct _GimpModuleInfoObj
|
|||
|
||||
/* stuff from now on may be NULL depending on the state the module is in */
|
||||
GModule *module; /* handle on the module */
|
||||
GimpModuleInfo *info; /* returned values from module_register */
|
||||
GimpModuleInfo info; /* returned values from module_query */
|
||||
gchar *last_module_error;
|
||||
|
||||
gboolean (* register_module) (GTypeModule *module,
|
||||
GimpModuleInfo **module_info);
|
||||
const GimpModuleInfo * (* query_module) (GTypeModule *module);
|
||||
gboolean (* register_module) (GTypeModule *module);
|
||||
};
|
||||
|
||||
struct _GimpModuleInfoObjClass
|
||||
|
|
|
@ -286,23 +286,23 @@ print_module_info (gpointer data,
|
|||
g_print ("\n%s: %i\n",
|
||||
i->filename,
|
||||
i->state /* statename[i->state] */);
|
||||
g_print (" module:%p lasterr:%s register:%p\n",
|
||||
|
||||
g_print (" module:%p lasterr:%s query:%p register:%p\n",
|
||||
i->module,
|
||||
i->last_module_error? i->last_module_error : "NONE",
|
||||
i->last_module_error ? i->last_module_error : "NONE",
|
||||
i->query_module,
|
||||
i->register_module);
|
||||
if (i->info)
|
||||
{
|
||||
g_print (" purpose: %s\n"
|
||||
" author: %s\n"
|
||||
" version: %s\n"
|
||||
" copyright: %s\n"
|
||||
" date: %s\n",
|
||||
i->info->purpose,
|
||||
i->info->author,
|
||||
i->info->version,
|
||||
i->info->copyright,
|
||||
i->info->date);
|
||||
}
|
||||
|
||||
g_print (" purpose: %s\n"
|
||||
" author: %s\n"
|
||||
" version: %s\n"
|
||||
" copyright: %s\n"
|
||||
" date: %s\n",
|
||||
i->info.purpose ? i->info.purpose : "NONE",
|
||||
i->info.author ? i->info.author : "NONE",
|
||||
i->info.version ? i->info.version : "NONE",
|
||||
i->info.copyright ? i->info.copyright : "NONE",
|
||||
i->info.date ? i->info.date : "NONE");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ static void gamma_configure_cancel_callback (GtkWidget *widget,
|
|||
CdisplayGamma *gamma);
|
||||
|
||||
|
||||
static GimpModuleInfo cdisplay_gamma_info =
|
||||
static const GimpModuleInfo cdisplay_gamma_info =
|
||||
{
|
||||
N_("Gamma color display filter"),
|
||||
"Manish Singh <yosh@gimp.org>",
|
||||
|
@ -106,15 +106,17 @@ static GType cdisplay_gamma_type = 0;
|
|||
static GimpColorDisplayClass *parent_class = NULL;
|
||||
|
||||
|
||||
G_MODULE_EXPORT const GimpModuleInfo *
|
||||
gimp_module_query (GTypeModule *module)
|
||||
{
|
||||
return &cdisplay_gamma_info;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT gboolean
|
||||
gimp_module_register (GTypeModule *module,
|
||||
GimpModuleInfo **inforet)
|
||||
gimp_module_register (GTypeModule *module)
|
||||
{
|
||||
cdisplay_gamma_get_type (module);
|
||||
|
||||
if (inforet)
|
||||
*inforet = &cdisplay_gamma_info;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ static void contrast_configure_cancel_callback (GtkWidget *widget,
|
|||
CdisplayContrast *contrast);
|
||||
|
||||
|
||||
static GimpModuleInfo cdisplay_contrast_info =
|
||||
static const GimpModuleInfo cdisplay_contrast_info =
|
||||
{
|
||||
N_("High Contrast color display filter"),
|
||||
"Jay Cox <jaycox@earthlink.net>",
|
||||
|
@ -106,15 +106,17 @@ static GType cdisplay_contrast_type = 0;
|
|||
static GimpColorDisplayClass *parent_class = NULL;
|
||||
|
||||
|
||||
G_MODULE_EXPORT const GimpModuleInfo *
|
||||
gimp_module_query (GTypeModule *module)
|
||||
{
|
||||
return &cdisplay_contrast_info;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT gboolean
|
||||
gimp_module_register (GTypeModule *module,
|
||||
GimpModuleInfo **inforet)
|
||||
gimp_module_register (GTypeModule *module)
|
||||
{
|
||||
cdisplay_contrast_get_type (module);
|
||||
|
||||
if (inforet)
|
||||
*inforet = &cdisplay_contrast_info;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ static gboolean colorsel_triangle_event (GtkWidget *widget,
|
|||
ColorselTriangle *triangle);
|
||||
|
||||
|
||||
static GimpModuleInfo colorsel_triangle_info =
|
||||
static const GimpModuleInfo colorsel_triangle_info =
|
||||
{
|
||||
N_("Painter-style color selector as a pluggable color selector"),
|
||||
"Simon Budig <Simon.Budig@unix-ag.org>",
|
||||
|
@ -125,15 +125,17 @@ static GType colorsel_triangle_type = 0;
|
|||
static GimpColorSelectorClass *parent_class = NULL;
|
||||
|
||||
|
||||
G_MODULE_EXPORT const GimpModuleInfo *
|
||||
gimp_module_query (GTypeModule *module)
|
||||
{
|
||||
return &colorsel_triangle_info;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT gboolean
|
||||
gimp_module_register (GTypeModule *module,
|
||||
GimpModuleInfo **info_return)
|
||||
gimp_module_register (GTypeModule *module)
|
||||
{
|
||||
colorsel_triangle_get_type (module);
|
||||
|
||||
if (info_return)
|
||||
*info_return = &colorsel_triangle_info;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ static void pressure_adjust_update (GtkAdjustment *adj,
|
|||
ColorselWater *water);
|
||||
|
||||
|
||||
static GimpModuleInfo colorsel_water_info =
|
||||
static const GimpModuleInfo colorsel_water_info =
|
||||
{
|
||||
N_("Watercolor style color selector as a pluggable module"),
|
||||
"Raph Levien <raph@acm.org>, Sven Neumann <sven@gimp.org>",
|
||||
|
@ -122,15 +122,17 @@ static GType colorsel_water_type = 0;
|
|||
static GimpColorSelectorClass *parent_class = NULL;
|
||||
|
||||
|
||||
G_MODULE_EXPORT const GimpModuleInfo *
|
||||
gimp_module_query (GTypeModule *module)
|
||||
{
|
||||
return &colorsel_water_info;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT gboolean
|
||||
gimp_module_register (GTypeModule *module,
|
||||
GimpModuleInfo **info_return)
|
||||
gimp_module_register (GTypeModule *module)
|
||||
{
|
||||
colorsel_water_get_type (module);
|
||||
|
||||
if (info_return)
|
||||
*info_return = &colorsel_water_info;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue