libgimp/gimp.h libgimp/gimpcolordisplay.h libgimp/gimpcolorselector.h

2000-05-28  Michael Natterer  <mitch@gimp.org>

	* libgimp/gimp.h
	* libgimp/gimpcolordisplay.h
	* libgimp/gimpcolorselector.h
	* libgimp/gimpmatrix.h
	* libgimp/gimpmodule.h
	* libgimp/gimpunit_pdb.c: purely cosmetic stuff and added some
	typedefs to make the html documentation nicer. Moved the module
	documentation from the headers to the sgml files.

	* app/module_db.[ch]: The type of the "init" and "unload" functions
	has changed. Code cleanup.

2000-05-28  Michael Natterer  <mitch@gimp.org>

	* libgimp/libgimp-decl.txt
	* libgimp/libgimp-docs.sgml
	* libgimp/libgimp-sections.txt
	* libgimp/tmpl/gimp.sgml
	* libgimp/tmpl/gimpcolorbutton.sgml
	* libgimp/tmpl/gimpcolordisplay.sgml
	* libgimp/tmpl/gimpcolorselector.sgml
	* libgimp/tmpl/gimpcolorspace.sgml
	* libgimp/tmpl/gimpcompat.sgml
	* libgimp/tmpl/gimpenums.sgml
	* libgimp/tmpl/gimpfeatures.sgml
	* libgimp/tmpl/gimplimits.sgml
	* libgimp/tmpl/gimpmath.sgml
	* libgimp/tmpl/gimpmodule.sgml
	* libgimp/tmpl/gimpparasite.sgml
	* libgimp/tmpl/gimpparasiteio.sgml
	* libgimp/tmpl/gimppixmap.sgml
	* libgimp/tmpl/gimpprotocol.sgml
	* libgimp/tmpl/gimpsignal.sgml
	* libgimp/tmpl/gimpui.sgml
	* libgimp/tmpl/gimpunit.sgml
	* libgimp/tmpl/gimputils.sgml
	* libgimp/tmpl/gimpvector.sgml
	* libgimp/tmpl/gimpwire.sgml
	* libgimp/tmpl/libgimp-unused.sgml: Moved the module documentation
	from the libgimp headers here, updates, cleanups.
This commit is contained in:
Michael Natterer 2000-05-28 00:00:28 +00:00 committed by Michael Natterer
parent f2e4a9a490
commit 2b775b6b8c
39 changed files with 1865 additions and 1579 deletions

View File

@ -1,3 +1,17 @@
2000-05-28 Michael Natterer <mitch@gimp.org>
* libgimp/gimp.h
* libgimp/gimpcolordisplay.h
* libgimp/gimpcolorselector.h
* libgimp/gimpmatrix.h
* libgimp/gimpmodule.h
* libgimp/gimpunit_pdb.c: purely cosmetic stuff and added some
typedefs to make the html documentation nicer. Moved the module
documentation from the headers to the sgml files.
* app/module_db.[ch]: The type of the "init" and "unload" functions
has changed. Code cleanup.
2000-05-27 Sven Neumann <sven@gimp.org>
* app/color_select.c: use spinbuttons in the GIMP

View File

@ -41,12 +41,15 @@
#include "libgimp/gimpenv.h"
#include "libgimp/gimpmodule.h"
#include "libgimp/gimpintl.h"
/* export this to gimprc.c */
char *module_db_load_inhibit = NULL;
typedef enum {
/* export this to gimprc.c */
gchar *module_db_load_inhibit = NULL;
typedef enum
{
ST_MODULE_ERROR, /* missing module_load function or other error */
ST_LOADED_OK, /* happy and running (normal state of affairs) */
ST_LOAD_FAILED, /* module_load returned GIMP_MODULE_UNLOAD */
@ -54,7 +57,8 @@ typedef enum {
ST_UNLOADED_OK /* callback arrived, module not in memory anymore */
} module_state;
static const char * const statename[] = {
static const gchar * const statename[] =
{
N_("Module error"),
N_("Loaded OK"),
N_("Load failed"),
@ -63,68 +67,76 @@ static const char * const statename[] = {
};
#ifdef __EMX__
extern void gimp_color_selector_register();
extern void gimp_color_selector_unregister();
extern void gimp_color_display_register();
extern void gimp_color_display_unregister();
extern void dialog_register();
extern void dialog_unregister();
extern void gimp_color_selector_register ();
extern void gimp_color_selector_unregister ();
extern void gimp_color_display_register ();
extern void gimp_color_display_unregister ();
extern void dialog_register ();
extern void dialog_unregister ();
static struct main_funcs_struc {
static struct main_funcs_struc
{
gchar *name;
void (*func)();
void (*func) ();
}
gimp_main_funcs[] = {
{ "gimp_color_selector_register", gimp_color_selector_register },
gimp_main_funcs[] =
{
{ "gimp_color_selector_register", gimp_color_selector_register },
{ "gimp_color_selector_unregister", gimp_color_selector_unregister },
{ "gimp_color_display_register", gimp_color_display_register },
{ "gimp_color_display_unregister", gimp_color_display_unregister },
{ "dialog_register", dialog_register },
{ "dialog_unregister", dialog_unregister },
{ "gimp_color_display_register", gimp_color_display_register },
{ "gimp_color_display_unregister", gimp_color_display_unregister },
{ "dialog_register", dialog_register },
{ "dialog_unregister", dialog_unregister },
{ NULL, NULL }
};
#endif
/* one of these objects is kept per-module */
typedef struct {
typedef struct
{
GtkObject object;
gchar *fullpath; /* path to the module */
module_state state; /* what's happened to the module */
gboolean ondisk; /* TRUE if file still exists */
gboolean load_inhibit; /* user requests not to load at boot time */
gint refs; /* how many time we're running in the module */
/* stuff from now on may be NULL depending on the state the module is in */
GimpModuleInfo *info; /* returned values from module_init */
GModule *module; /* handle on the module */
gchar *last_module_error;
GimpModuleInitFunc *init;
GimpModuleUnloadFunc *unload;
} module_info;
GimpModuleInitFunc init;
GimpModuleUnloadFunc unload;
} ModuleInfo;
static guint module_info_get_type (void);
#define MODULE_INFO_TYPE module_info_get_type()
#define MODULE_INFO(obj) GTK_CHECK_CAST (obj, MODULE_INFO_TYPE, module_info)
#define MODULE_INFO(obj) GTK_CHECK_CAST (obj, MODULE_INFO_TYPE, ModuleInfo)
#define IS_MODULE_INFO(obj) GTK_CHECK_TYPE (obj, MODULE_INFO_TYPE)
#define NUM_INFO_LINES 7
typedef struct {
GtkWidget *table;
GtkWidget *label[NUM_INFO_LINES];
GtkWidget *button_label;
module_info *last_update;
GtkWidget *button;
GtkWidget *list;
GtkWidget *load_inhibit_check;
} browser_st;
typedef struct
{
GtkWidget *table;
GtkWidget *label[NUM_INFO_LINES];
GtkWidget *button_label;
ModuleInfo *last_update;
GtkWidget *button;
GtkWidget *list;
GtkWidget *load_inhibit_check;
} BrowserState;
/* global set of module_info pointers */
static GimpSet *modules;
static GimpSetHandlerId modules_handler;
static GimpSet *modules;
static GimpSetHandlerId modules_handler;
/* If the inhibit state of any modules changes, we might need to
* re-write the modulerc. */
@ -146,26 +158,43 @@ static gboolean need_to_rewrite_modulerc = FALSE;
/* prototypes */
static void module_initialize (char *filename);
static void mod_load (module_info *mod, gboolean verbose);
static void mod_unload (module_info *mod, gboolean verbose);
static module_info *module_find_by_path (const char *fullpath);
#ifdef DUMP_DB
static void print_module_info (gpointer data, gpointer user_data);
#endif
static void browser_popdown_callback (GtkWidget *w, gpointer client_data);
static void browser_destroy_callback (GtkWidget *w, gpointer client_data);
static void browser_info_update (module_info *, browser_st *);
static void browser_info_add (GimpSet *, module_info *, browser_st *);
static void browser_info_remove (GimpSet *, module_info *, browser_st *);
static void browser_info_init (browser_st *st, GtkWidget *table);
static void browser_select_callback (GtkWidget *widget, GtkWidget *child);
static void browser_load_unload_callback (GtkWidget *widget, gpointer data);
static void browser_refresh_callback (GtkWidget *widget, gpointer data);
static void make_list_item (gpointer data, gpointer user_data);
static void module_initialize (gchar *filename);
static void mod_load (ModuleInfo *mod,
gboolean verbose);
static void mod_unload (ModuleInfo *mod,
gboolean verbose);
static ModuleInfo * module_find_by_path (const gchar *fullpath);
static void gimp_module_ref (module_info *mod);
static void gimp_module_unref (module_info *mod);
#ifdef DUMP_DB
static void print_module_info (gpointer data,
gpointer user_data);
#endif
static void browser_popdown_callback (GtkWidget *widget,
gpointer data);
static void browser_destroy_callback (GtkWidget *widget,
gpointer data);
static void browser_info_update (ModuleInfo *mod,
BrowserState *st);
static void browser_info_add (GimpSet *set,
ModuleInfo *mod,
BrowserState *st);
static void browser_info_remove (GimpSet *set,
ModuleInfo *mod,
BrowserState *st);
static void browser_info_init (BrowserState *st,
GtkWidget *table);
static void browser_select_callback (GtkWidget *widget,
GtkWidget *child);
static void browser_load_unload_callback (GtkWidget *widget,
gpointer data);
static void browser_refresh_callback (GtkWidget *widget,
gpointer data);
static void make_list_item (gpointer data,
gpointer user_data);
static void gimp_module_ref (ModuleInfo *mod);
static void gimp_module_unref (ModuleInfo *mod);
@ -175,7 +204,7 @@ static void gimp_module_unref (module_info *mod);
void
module_db_init (void)
{
char *filename;
gchar *filename;
/* load the modulerc file */
filename = gimp_personal_rc_file ("modulerc");
@ -198,7 +227,7 @@ static void
free_a_single_module (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
if (mod->module && mod->unload && mod->state == ST_LOADED_OK)
{
@ -210,8 +239,8 @@ static void
add_to_inhibit_string (gpointer data,
gpointer user_data)
{
module_info *mod = data;
GString *str = user_data;
ModuleInfo *mod = data;
GString *str = user_data;
if (mod->load_inhibit)
{
@ -224,11 +253,11 @@ add_to_inhibit_string (gpointer data,
static gboolean
module_db_write_modulerc (void)
{
GString *str;
gchar *p;
char *filename;
FILE *fp;
gboolean saved = FALSE;
GString *str;
gchar *p;
gchar *filename;
FILE *fp;
gboolean saved = FALSE;
str = g_string_new (NULL);
gimp_set_foreach (modules, add_to_inhibit_string, str);
@ -256,12 +285,12 @@ void
module_db_free (void)
{
if (need_to_rewrite_modulerc)
{
{
if (module_db_write_modulerc ())
{
{
need_to_rewrite_modulerc = FALSE;
}
}
}
}
gimp_set_foreach (modules, free_a_single_module, NULL);
}
@ -274,7 +303,7 @@ module_db_browser_new (void)
GtkWidget *vbox;
GtkWidget *listbox;
GtkWidget *button;
browser_st *st;
BrowserState *st;
shell = gimp_dialog_new (_("Module DB"), "module_db_dialog",
gimp_standard_help_func,
@ -300,7 +329,7 @@ module_db_browser_new (void)
gtk_widget_set_usize (listbox, 125, 100);
gtk_widget_show (listbox);
st = g_new0 (browser_st, 1);
st = g_new0 (BrowserState, 1);
st->list = gtk_list_new ();
gtk_list_set_selection_mode (GTK_LIST (st->list), GTK_SELECTION_BROWSE);
@ -361,14 +390,16 @@ module_db_browser_new (void)
/**************************************************************/
/* module_info object glue */
/* ModuleInfo object glue */
typedef struct {
typedef struct
{
GtkObjectClass parent_class;
} module_infoClass;
} ModuleInfoClass;
enum {
enum
{
MODIFIED,
LAST_SIGNAL
};
@ -378,7 +409,7 @@ static guint module_info_signals[LAST_SIGNAL];
static void
module_info_destroy (GtkObject *object)
{
module_info *mod = MODULE_INFO (object);
ModuleInfo *mod = MODULE_INFO (object);
/* if this trips, then we're onto some serious lossage in a moment */
g_return_if_fail (mod->refs == 0);
@ -389,25 +420,25 @@ module_info_destroy (GtkObject *object)
}
static void
module_info_class_init (module_infoClass *klass)
module_info_class_init (ModuleInfoClass *klass)
{
GtkObjectClass *object_class;
GtkType type;
object_class = GTK_OBJECT_CLASS(klass);
object_class = GTK_OBJECT_CLASS (klass);
type = object_class->type;
object_class->destroy = module_info_destroy;
module_info_signals[MODIFIED] =
gimp_signal_new ("modified", 0, type, 0, gimp_sigtype_void);
gimp_signal_new ("modified", 0, type, 0, gimp_sigtype_void);
gtk_object_class_add_signals(object_class, module_info_signals, LAST_SIGNAL);
gtk_object_class_add_signals (object_class, module_info_signals, LAST_SIGNAL);
}
static void
module_info_init (module_info *mod)
module_info_init (ModuleInfo *mod)
{
/* don't need to do anything */
}
@ -421,9 +452,9 @@ module_info_get_type (void)
{
static const GtkTypeInfo module_info_info =
{
"module_info",
sizeof (module_info),
sizeof (module_infoClass),
"ModuleInfo",
sizeof (ModuleInfo),
sizeof (ModuleInfoClass),
(GtkClassInitFunc) module_info_class_init,
(GtkObjectInitFunc) module_info_init,
/* reserved_1 */ NULL,
@ -431,8 +462,8 @@ module_info_get_type (void)
(GtkClassInitFunc) NULL,
};
module_info_type = gtk_type_unique (gtk_object_get_type(),
&module_info_info);
module_info_type =
gtk_type_unique (gtk_object_get_type (), &module_info_info);
}
return module_info_type;
@ -441,19 +472,19 @@ module_info_get_type (void)
/* exported API: */
static void
module_info_modified (module_info *mod)
module_info_modified (ModuleInfo *mod)
{
gtk_signal_emit (GTK_OBJECT (mod), module_info_signals[MODIFIED]);
}
static module_info *
static ModuleInfo *
module_info_new (void)
{
return MODULE_INFO (gtk_type_new (module_info_get_type ()));
}
static void
module_info_free (module_info *mod)
module_info_free (ModuleInfo *mod)
{
gtk_object_unref (GTK_OBJECT (mod));
}
@ -465,10 +496,10 @@ module_info_free (module_info *mod)
/* name must be of the form lib*.so (Unix) or *.dll (Win32) */
static gboolean
valid_module_name (const char *filename)
valid_module_name (const gchar *filename)
{
const char *basename;
int len;
const gchar *basename;
gint len;
basename = g_basename (filename);
@ -496,12 +527,13 @@ valid_module_name (const char *filename)
static gboolean
module_inhibited (const char *fullpath,
const char *inhibit_list)
module_inhibited (const gchar *fullpath,
const gchar *inhibit_list)
{
char *p;
int pathlen;
const char *start, *end;
gchar *p;
gint pathlen;
const gchar *start;
const gchar *end;
/* common case optimisation: the list is empty */
if (!inhibit_list || *inhibit_list == '\000')
@ -531,9 +563,9 @@ module_inhibited (const char *fullpath,
static void
module_initialize (char *filename)
module_initialize (gchar *filename)
{
module_info *mod;
ModuleInfo *mod;
if (!valid_module_name (filename))
return;
@ -581,8 +613,8 @@ module_initialize (char *filename)
}
static void
mod_load (module_info *mod,
gboolean verbose)
mod_load (ModuleInfo *mod,
gboolean verbose)
{
gpointer symbol;
@ -632,12 +664,12 @@ mod_load (module_info *mod,
mod->info = NULL;
gimp_module_ref (mod); /* loaded modules are assumed to have a ref of 1 */
if (mod->init (&mod->info) == GIMP_MODULE_UNLOAD)
{
mod->state = ST_LOAD_FAILED;
gimp_module_unref (mod);
mod->info = NULL;
return;
}
{
mod->state = ST_LOAD_FAILED;
gimp_module_unref (mod);
mod->info = NULL;
return;
}
/* module is now happy */
mod->state = ST_LOADED_OK;
@ -648,14 +680,13 @@ mod_load (module_info *mod,
mod->unload = symbol;
else
mod->unload = NULL;
}
static void
mod_unload_completed_callback (void *data)
{
module_info *mod = data;
ModuleInfo *mod = data;
g_return_if_fail (mod->state == ST_UNLOAD_REQUESTED);
@ -672,8 +703,8 @@ mod_unload_completed_callback (void *data)
}
static void
mod_unload (module_info *mod,
gboolean verbose)
mod_unload (ModuleInfo *mod,
gboolean verbose)
{
g_return_if_fail (mod->module != NULL);
g_return_if_fail (mod->unload != NULL);
@ -694,31 +725,30 @@ mod_unload (module_info *mod,
}
#ifdef DUMP_DB
static void
print_module_info (gpointer data,
gpointer user_data)
{
module_info *i = data;
ModuleInfo *i = data;
printf ("\n%s: %s\n",
i->fullpath, statename[i->state]);
printf (" module:%p lasterr:%s init:%p unload:%p\n",
i->module, i->last_module_error? i->last_module_error : "NONE",
i->init, i->unload);
g_print ("\n%s: %s\n",
i->fullpath, statename[i->state]);
g_print (" module:%p lasterr:%s init:%p unload:%p\n",
i->module, i->last_module_error? i->last_module_error : "NONE",
i->init, i->unload);
if (i->info)
{
printf (" shutdown_data: %p\n"
" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->shutdown_data,
i->info->purpose, i->info->author, i->info->version,
i->info->copyright, i->info->date);
}
{
g_print (" shutdown_data: %p\n"
" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->shutdown_data,
i->info->purpose, i->info->author, i->info->version,
i->info->copyright, i->info->date);
}
}
#endif
@ -728,31 +758,31 @@ print_module_info (gpointer data,
/* UI functions */
static void
browser_popdown_callback (GtkWidget *w,
gpointer client_data)
browser_popdown_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_destroy (GTK_WIDGET (client_data));
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
browser_destroy_callback (GtkWidget *w,
gpointer client_data)
browser_destroy_callback (GtkWidget *widget,
gpointer data)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (modules), client_data);
gtk_signal_disconnect_by_data (GTK_OBJECT (modules), data);
gimp_set_remove_handler (modules, modules_handler);
g_free (client_data);
g_free (data);
}
static void
browser_load_inhibit_callback (GtkWidget *w,
browser_load_inhibit_callback (GtkWidget *widget,
gpointer data)
{
browser_st *st = data;
BrowserState *st = data;
gboolean new_value;
g_return_if_fail (st->last_update != NULL);
new_value = ! GTK_TOGGLE_BUTTON (w)->active;
new_value = ! GTK_TOGGLE_BUTTON (widget)->active;
if (new_value == st->last_update->load_inhibit)
return;
@ -764,59 +794,58 @@ browser_load_inhibit_callback (GtkWidget *w,
}
static void
browser_info_update (module_info *mod,
browser_st *st)
browser_info_update (ModuleInfo *mod,
BrowserState *st)
{
int i;
const char *text[NUM_INFO_LINES - 1];
char *status;
gint i;
const gchar *text[NUM_INFO_LINES - 1];
gchar *status;
/* only update the info if we're actually showing it */
if (mod != st->last_update)
return;
if (!mod)
{
for (i=0; i < NUM_INFO_LINES; i++)
gtk_label_set_text (GTK_LABEL (st->label[i]), "");
gtk_label_set_text (GTK_LABEL(st->button_label), _("<No modules>"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), FALSE);
return;
}
{
for (i=0; i < NUM_INFO_LINES; i++)
gtk_label_set_text (GTK_LABEL (st->label[i]), "");
gtk_label_set_text (GTK_LABEL(st->button_label), _("<No modules>"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), FALSE);
return;
}
if (mod->info)
{
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->ondisk? _("on disk") : _("only in memory");
}
{
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->ondisk? _("on disk") : _("only in memory");
}
else
{
text[0] = "--";
text[1] = "--";
text[2] = "--";
text[3] = "--";
text[4] = "--";
text[5] = mod->ondisk? _("on disk") : _("nowhere (click 'refresh')");
}
{
text[0] = "--";
text[1] = "--";
text[2] = "--";
text[3] = "--";
text[4] = "--";
text[5] = mod->ondisk? _("on disk") : _("nowhere (click 'refresh')");
}
if (mod->state == ST_MODULE_ERROR && mod->last_module_error)
status = g_strdup_printf ("%s (%s)", gettext (statename[mod->state]),
mod->last_module_error);
else
{
status = g_strdup (gettext (statename[mod->state]));
}
{
status = g_strdup (gettext (statename[mod->state]));
}
for (i=0; i < NUM_INFO_LINES - 1; i++)
{
gtk_label_set_text (GTK_LABEL (st->label[i]), gettext (text[i]));
}
{
gtk_label_set_text (GTK_LABEL (st->label[i]), gettext (text[i]));
}
gtk_label_set_text (GTK_LABEL (st->label[NUM_INFO_LINES-1]), status);
@ -827,33 +856,36 @@ browser_info_update (module_info *mod,
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), TRUE);
/* work out what the button should do (if anything) */
switch (mod->state) {
case ST_MODULE_ERROR:
case ST_LOAD_FAILED:
case ST_UNLOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Load"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), mod->ondisk);
break;
switch (mod->state)
{
case ST_MODULE_ERROR:
case ST_LOAD_FAILED:
case ST_UNLOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Load"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), mod->ondisk);
break;
case ST_UNLOAD_REQUESTED:
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
break;
case ST_UNLOAD_REQUESTED:
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
break;
case ST_LOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Unload"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button),
mod->unload? TRUE : FALSE);
break;
}
case ST_LOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Unload"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button),
mod->unload? TRUE : FALSE);
break;
}
}
static void
browser_info_init (browser_st *st,
GtkWidget *table)
browser_info_init (BrowserState *st,
GtkWidget *table)
{
GtkWidget *label;
int i;
char *text[] = {
gint i;
gchar *text[] =
{
N_("Purpose:"),
N_("Author:"),
N_("Version:"),
@ -864,22 +896,22 @@ browser_info_init (browser_st *st,
};
for (i=0; i < sizeof(text) / sizeof(char *); i++)
{
label = gtk_label_new (gettext (text[i]));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (label);
{
label = gtk_label_new (gettext (text[i]));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (label);
st->label[i] = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (st->label[i]), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (st->table), st->label[i], 1, 2, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (st->label[i]);
}
st->label[i] = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (st->label[i]), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (st->table), st->label[i], 1, 2, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (st->label[i]);
}
st->load_inhibit_check =
gtk_check_button_new_with_label (_("Autoload during startup"));
gtk_check_button_new_with_label (_("Autoload during startup"));
gtk_widget_show (st->load_inhibit_check);
gtk_table_attach (GTK_TABLE (table), st->load_inhibit_check,
0, 2, i, i+1,
@ -892,8 +924,8 @@ static void
browser_select_callback (GtkWidget *widget,
GtkWidget *child)
{
module_info *i;
browser_st *st;
ModuleInfo *i;
BrowserState *st;
i = gtk_object_get_user_data (GTK_OBJECT (child));
st = gtk_object_get_user_data (GTK_OBJECT (widget));
@ -911,7 +943,7 @@ static void
browser_load_unload_callback (GtkWidget *widget,
gpointer data)
{
browser_st *st = data;
BrowserState *st = data;
if (st->last_update->state == ST_LOADED_OK)
mod_unload (st->last_update, FALSE);
@ -926,9 +958,9 @@ static void
make_list_item (gpointer data,
gpointer user_data)
{
module_info *info = data;
browser_st *st = user_data;
GtkWidget *list_item;
ModuleInfo *info = data;
BrowserState *st = user_data;
GtkWidget *list_item;
if (!st->last_update)
st->last_update = info;
@ -943,22 +975,22 @@ make_list_item (gpointer data,
static void
browser_info_add (GimpSet *set,
module_info *mod,
browser_st *st)
browser_info_add (GimpSet *set,
ModuleInfo *mod,
BrowserState *st)
{
make_list_item (mod, st);
}
static void
browser_info_remove (GimpSet *set,
module_info *mod,
browser_st *st)
browser_info_remove (GimpSet *set,
ModuleInfo *mod,
BrowserState *st)
{
GList *dlist, *free_list;
GtkWidget *list_item;
module_info *i;
ModuleInfo *i;
dlist = gtk_container_children (GTK_CONTAINER (st->list));
free_list = dlist;
@ -990,10 +1022,10 @@ static void
module_db_module_ondisk (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
struct stat statbuf;
int ret;
int old_ondisk = mod->ondisk;
gint ret;
gint old_ondisk = mod->ondisk;
GSList **kill_list = user_data;
ret = stat (mod->fullpath, &statbuf);
@ -1005,10 +1037,10 @@ module_db_module_ondisk (gpointer data,
/* if it's not on the disk, and it isn't in memory, mark it to be
* removed later. */
if (!mod->ondisk && !mod->module)
{
*kill_list = g_slist_append (*kill_list, mod);
mod = NULL;
}
{
*kill_list = g_slist_append (*kill_list, mod);
mod = NULL;
}
if (mod && mod->ondisk != old_ondisk)
module_info_modified (mod);
@ -1019,7 +1051,7 @@ static void
module_db_module_remove (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
gimp_set_remove (modules, mod);
@ -1028,23 +1060,24 @@ module_db_module_remove (gpointer data,
typedef struct {
const char *search_key;
module_info *found;
typedef struct
{
const gchar *search_key;
ModuleInfo *found;
} find_by_path_closure;
static void
module_db_path_cmp (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
find_by_path_closure *cl = user_data;
if (!strcmp (mod->fullpath, cl->search_key))
cl->found = mod;
}
static module_info *
static ModuleInfo *
module_find_by_path (const char *fullpath)
{
find_by_path_closure cl;
@ -1078,7 +1111,7 @@ browser_refresh_callback (GtkWidget *widget,
static void
gimp_module_ref (module_info *mod)
gimp_module_ref (ModuleInfo *mod)
{
g_return_if_fail (mod->refs >= 0);
g_return_if_fail (mod->module != NULL);
@ -1086,7 +1119,7 @@ gimp_module_ref (module_info *mod)
}
static void
gimp_module_unref (module_info *mod)
gimp_module_unref (ModuleInfo *mod)
{
g_return_if_fail (mod->refs > 0);
g_return_if_fail (mod->module != NULL);
@ -1094,11 +1127,11 @@ gimp_module_unref (module_info *mod)
mod->refs--;
if (mod->refs == 0)
{
TRC (("module %p refs hit 0, g_module_closing it\n", mod));
g_module_close (mod->module);
mod->module = NULL;
}
{
TRC (("module %p refs hit 0, g_module_closing it\n", mod));
g_module_close (mod->module);
mod->module = NULL;
}
}
/* End of module_db.c */

View File

@ -17,14 +17,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __MODULE_DB_H__
/* Load any modules we find on the module-path set in the gimprc */
void module_db_init (void);
void module_db_init (void);
/* Unload all modules, in case a module needs some cleanups */
void module_db_free (void);
void module_db_free (void);
GtkWidget *module_db_browser_new (void);

View File

@ -41,12 +41,15 @@
#include "libgimp/gimpenv.h"
#include "libgimp/gimpmodule.h"
#include "libgimp/gimpintl.h"
/* export this to gimprc.c */
char *module_db_load_inhibit = NULL;
typedef enum {
/* export this to gimprc.c */
gchar *module_db_load_inhibit = NULL;
typedef enum
{
ST_MODULE_ERROR, /* missing module_load function or other error */
ST_LOADED_OK, /* happy and running (normal state of affairs) */
ST_LOAD_FAILED, /* module_load returned GIMP_MODULE_UNLOAD */
@ -54,7 +57,8 @@ typedef enum {
ST_UNLOADED_OK /* callback arrived, module not in memory anymore */
} module_state;
static const char * const statename[] = {
static const gchar * const statename[] =
{
N_("Module error"),
N_("Loaded OK"),
N_("Load failed"),
@ -63,68 +67,76 @@ static const char * const statename[] = {
};
#ifdef __EMX__
extern void gimp_color_selector_register();
extern void gimp_color_selector_unregister();
extern void gimp_color_display_register();
extern void gimp_color_display_unregister();
extern void dialog_register();
extern void dialog_unregister();
extern void gimp_color_selector_register ();
extern void gimp_color_selector_unregister ();
extern void gimp_color_display_register ();
extern void gimp_color_display_unregister ();
extern void dialog_register ();
extern void dialog_unregister ();
static struct main_funcs_struc {
static struct main_funcs_struc
{
gchar *name;
void (*func)();
void (*func) ();
}
gimp_main_funcs[] = {
{ "gimp_color_selector_register", gimp_color_selector_register },
gimp_main_funcs[] =
{
{ "gimp_color_selector_register", gimp_color_selector_register },
{ "gimp_color_selector_unregister", gimp_color_selector_unregister },
{ "gimp_color_display_register", gimp_color_display_register },
{ "gimp_color_display_unregister", gimp_color_display_unregister },
{ "dialog_register", dialog_register },
{ "dialog_unregister", dialog_unregister },
{ "gimp_color_display_register", gimp_color_display_register },
{ "gimp_color_display_unregister", gimp_color_display_unregister },
{ "dialog_register", dialog_register },
{ "dialog_unregister", dialog_unregister },
{ NULL, NULL }
};
#endif
/* one of these objects is kept per-module */
typedef struct {
typedef struct
{
GtkObject object;
gchar *fullpath; /* path to the module */
module_state state; /* what's happened to the module */
gboolean ondisk; /* TRUE if file still exists */
gboolean load_inhibit; /* user requests not to load at boot time */
gint refs; /* how many time we're running in the module */
/* stuff from now on may be NULL depending on the state the module is in */
GimpModuleInfo *info; /* returned values from module_init */
GModule *module; /* handle on the module */
gchar *last_module_error;
GimpModuleInitFunc *init;
GimpModuleUnloadFunc *unload;
} module_info;
GimpModuleInitFunc init;
GimpModuleUnloadFunc unload;
} ModuleInfo;
static guint module_info_get_type (void);
#define MODULE_INFO_TYPE module_info_get_type()
#define MODULE_INFO(obj) GTK_CHECK_CAST (obj, MODULE_INFO_TYPE, module_info)
#define MODULE_INFO(obj) GTK_CHECK_CAST (obj, MODULE_INFO_TYPE, ModuleInfo)
#define IS_MODULE_INFO(obj) GTK_CHECK_TYPE (obj, MODULE_INFO_TYPE)
#define NUM_INFO_LINES 7
typedef struct {
GtkWidget *table;
GtkWidget *label[NUM_INFO_LINES];
GtkWidget *button_label;
module_info *last_update;
GtkWidget *button;
GtkWidget *list;
GtkWidget *load_inhibit_check;
} browser_st;
typedef struct
{
GtkWidget *table;
GtkWidget *label[NUM_INFO_LINES];
GtkWidget *button_label;
ModuleInfo *last_update;
GtkWidget *button;
GtkWidget *list;
GtkWidget *load_inhibit_check;
} BrowserState;
/* global set of module_info pointers */
static GimpSet *modules;
static GimpSetHandlerId modules_handler;
static GimpSet *modules;
static GimpSetHandlerId modules_handler;
/* If the inhibit state of any modules changes, we might need to
* re-write the modulerc. */
@ -146,26 +158,43 @@ static gboolean need_to_rewrite_modulerc = FALSE;
/* prototypes */
static void module_initialize (char *filename);
static void mod_load (module_info *mod, gboolean verbose);
static void mod_unload (module_info *mod, gboolean verbose);
static module_info *module_find_by_path (const char *fullpath);
#ifdef DUMP_DB
static void print_module_info (gpointer data, gpointer user_data);
#endif
static void browser_popdown_callback (GtkWidget *w, gpointer client_data);
static void browser_destroy_callback (GtkWidget *w, gpointer client_data);
static void browser_info_update (module_info *, browser_st *);
static void browser_info_add (GimpSet *, module_info *, browser_st *);
static void browser_info_remove (GimpSet *, module_info *, browser_st *);
static void browser_info_init (browser_st *st, GtkWidget *table);
static void browser_select_callback (GtkWidget *widget, GtkWidget *child);
static void browser_load_unload_callback (GtkWidget *widget, gpointer data);
static void browser_refresh_callback (GtkWidget *widget, gpointer data);
static void make_list_item (gpointer data, gpointer user_data);
static void module_initialize (gchar *filename);
static void mod_load (ModuleInfo *mod,
gboolean verbose);
static void mod_unload (ModuleInfo *mod,
gboolean verbose);
static ModuleInfo * module_find_by_path (const gchar *fullpath);
static void gimp_module_ref (module_info *mod);
static void gimp_module_unref (module_info *mod);
#ifdef DUMP_DB
static void print_module_info (gpointer data,
gpointer user_data);
#endif
static void browser_popdown_callback (GtkWidget *widget,
gpointer data);
static void browser_destroy_callback (GtkWidget *widget,
gpointer data);
static void browser_info_update (ModuleInfo *mod,
BrowserState *st);
static void browser_info_add (GimpSet *set,
ModuleInfo *mod,
BrowserState *st);
static void browser_info_remove (GimpSet *set,
ModuleInfo *mod,
BrowserState *st);
static void browser_info_init (BrowserState *st,
GtkWidget *table);
static void browser_select_callback (GtkWidget *widget,
GtkWidget *child);
static void browser_load_unload_callback (GtkWidget *widget,
gpointer data);
static void browser_refresh_callback (GtkWidget *widget,
gpointer data);
static void make_list_item (gpointer data,
gpointer user_data);
static void gimp_module_ref (ModuleInfo *mod);
static void gimp_module_unref (ModuleInfo *mod);
@ -175,7 +204,7 @@ static void gimp_module_unref (module_info *mod);
void
module_db_init (void)
{
char *filename;
gchar *filename;
/* load the modulerc file */
filename = gimp_personal_rc_file ("modulerc");
@ -198,7 +227,7 @@ static void
free_a_single_module (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
if (mod->module && mod->unload && mod->state == ST_LOADED_OK)
{
@ -210,8 +239,8 @@ static void
add_to_inhibit_string (gpointer data,
gpointer user_data)
{
module_info *mod = data;
GString *str = user_data;
ModuleInfo *mod = data;
GString *str = user_data;
if (mod->load_inhibit)
{
@ -224,11 +253,11 @@ add_to_inhibit_string (gpointer data,
static gboolean
module_db_write_modulerc (void)
{
GString *str;
gchar *p;
char *filename;
FILE *fp;
gboolean saved = FALSE;
GString *str;
gchar *p;
gchar *filename;
FILE *fp;
gboolean saved = FALSE;
str = g_string_new (NULL);
gimp_set_foreach (modules, add_to_inhibit_string, str);
@ -256,12 +285,12 @@ void
module_db_free (void)
{
if (need_to_rewrite_modulerc)
{
{
if (module_db_write_modulerc ())
{
{
need_to_rewrite_modulerc = FALSE;
}
}
}
}
gimp_set_foreach (modules, free_a_single_module, NULL);
}
@ -274,7 +303,7 @@ module_db_browser_new (void)
GtkWidget *vbox;
GtkWidget *listbox;
GtkWidget *button;
browser_st *st;
BrowserState *st;
shell = gimp_dialog_new (_("Module DB"), "module_db_dialog",
gimp_standard_help_func,
@ -300,7 +329,7 @@ module_db_browser_new (void)
gtk_widget_set_usize (listbox, 125, 100);
gtk_widget_show (listbox);
st = g_new0 (browser_st, 1);
st = g_new0 (BrowserState, 1);
st->list = gtk_list_new ();
gtk_list_set_selection_mode (GTK_LIST (st->list), GTK_SELECTION_BROWSE);
@ -361,14 +390,16 @@ module_db_browser_new (void)
/**************************************************************/
/* module_info object glue */
/* ModuleInfo object glue */
typedef struct {
typedef struct
{
GtkObjectClass parent_class;
} module_infoClass;
} ModuleInfoClass;
enum {
enum
{
MODIFIED,
LAST_SIGNAL
};
@ -378,7 +409,7 @@ static guint module_info_signals[LAST_SIGNAL];
static void
module_info_destroy (GtkObject *object)
{
module_info *mod = MODULE_INFO (object);
ModuleInfo *mod = MODULE_INFO (object);
/* if this trips, then we're onto some serious lossage in a moment */
g_return_if_fail (mod->refs == 0);
@ -389,25 +420,25 @@ module_info_destroy (GtkObject *object)
}
static void
module_info_class_init (module_infoClass *klass)
module_info_class_init (ModuleInfoClass *klass)
{
GtkObjectClass *object_class;
GtkType type;
object_class = GTK_OBJECT_CLASS(klass);
object_class = GTK_OBJECT_CLASS (klass);
type = object_class->type;
object_class->destroy = module_info_destroy;
module_info_signals[MODIFIED] =
gimp_signal_new ("modified", 0, type, 0, gimp_sigtype_void);
gimp_signal_new ("modified", 0, type, 0, gimp_sigtype_void);
gtk_object_class_add_signals(object_class, module_info_signals, LAST_SIGNAL);
gtk_object_class_add_signals (object_class, module_info_signals, LAST_SIGNAL);
}
static void
module_info_init (module_info *mod)
module_info_init (ModuleInfo *mod)
{
/* don't need to do anything */
}
@ -421,9 +452,9 @@ module_info_get_type (void)
{
static const GtkTypeInfo module_info_info =
{
"module_info",
sizeof (module_info),
sizeof (module_infoClass),
"ModuleInfo",
sizeof (ModuleInfo),
sizeof (ModuleInfoClass),
(GtkClassInitFunc) module_info_class_init,
(GtkObjectInitFunc) module_info_init,
/* reserved_1 */ NULL,
@ -431,8 +462,8 @@ module_info_get_type (void)
(GtkClassInitFunc) NULL,
};
module_info_type = gtk_type_unique (gtk_object_get_type(),
&module_info_info);
module_info_type =
gtk_type_unique (gtk_object_get_type (), &module_info_info);
}
return module_info_type;
@ -441,19 +472,19 @@ module_info_get_type (void)
/* exported API: */
static void
module_info_modified (module_info *mod)
module_info_modified (ModuleInfo *mod)
{
gtk_signal_emit (GTK_OBJECT (mod), module_info_signals[MODIFIED]);
}
static module_info *
static ModuleInfo *
module_info_new (void)
{
return MODULE_INFO (gtk_type_new (module_info_get_type ()));
}
static void
module_info_free (module_info *mod)
module_info_free (ModuleInfo *mod)
{
gtk_object_unref (GTK_OBJECT (mod));
}
@ -465,10 +496,10 @@ module_info_free (module_info *mod)
/* name must be of the form lib*.so (Unix) or *.dll (Win32) */
static gboolean
valid_module_name (const char *filename)
valid_module_name (const gchar *filename)
{
const char *basename;
int len;
const gchar *basename;
gint len;
basename = g_basename (filename);
@ -496,12 +527,13 @@ valid_module_name (const char *filename)
static gboolean
module_inhibited (const char *fullpath,
const char *inhibit_list)
module_inhibited (const gchar *fullpath,
const gchar *inhibit_list)
{
char *p;
int pathlen;
const char *start, *end;
gchar *p;
gint pathlen;
const gchar *start;
const gchar *end;
/* common case optimisation: the list is empty */
if (!inhibit_list || *inhibit_list == '\000')
@ -531,9 +563,9 @@ module_inhibited (const char *fullpath,
static void
module_initialize (char *filename)
module_initialize (gchar *filename)
{
module_info *mod;
ModuleInfo *mod;
if (!valid_module_name (filename))
return;
@ -581,8 +613,8 @@ module_initialize (char *filename)
}
static void
mod_load (module_info *mod,
gboolean verbose)
mod_load (ModuleInfo *mod,
gboolean verbose)
{
gpointer symbol;
@ -632,12 +664,12 @@ mod_load (module_info *mod,
mod->info = NULL;
gimp_module_ref (mod); /* loaded modules are assumed to have a ref of 1 */
if (mod->init (&mod->info) == GIMP_MODULE_UNLOAD)
{
mod->state = ST_LOAD_FAILED;
gimp_module_unref (mod);
mod->info = NULL;
return;
}
{
mod->state = ST_LOAD_FAILED;
gimp_module_unref (mod);
mod->info = NULL;
return;
}
/* module is now happy */
mod->state = ST_LOADED_OK;
@ -648,14 +680,13 @@ mod_load (module_info *mod,
mod->unload = symbol;
else
mod->unload = NULL;
}
static void
mod_unload_completed_callback (void *data)
{
module_info *mod = data;
ModuleInfo *mod = data;
g_return_if_fail (mod->state == ST_UNLOAD_REQUESTED);
@ -672,8 +703,8 @@ mod_unload_completed_callback (void *data)
}
static void
mod_unload (module_info *mod,
gboolean verbose)
mod_unload (ModuleInfo *mod,
gboolean verbose)
{
g_return_if_fail (mod->module != NULL);
g_return_if_fail (mod->unload != NULL);
@ -694,31 +725,30 @@ mod_unload (module_info *mod,
}
#ifdef DUMP_DB
static void
print_module_info (gpointer data,
gpointer user_data)
{
module_info *i = data;
ModuleInfo *i = data;
printf ("\n%s: %s\n",
i->fullpath, statename[i->state]);
printf (" module:%p lasterr:%s init:%p unload:%p\n",
i->module, i->last_module_error? i->last_module_error : "NONE",
i->init, i->unload);
g_print ("\n%s: %s\n",
i->fullpath, statename[i->state]);
g_print (" module:%p lasterr:%s init:%p unload:%p\n",
i->module, i->last_module_error? i->last_module_error : "NONE",
i->init, i->unload);
if (i->info)
{
printf (" shutdown_data: %p\n"
" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->shutdown_data,
i->info->purpose, i->info->author, i->info->version,
i->info->copyright, i->info->date);
}
{
g_print (" shutdown_data: %p\n"
" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->shutdown_data,
i->info->purpose, i->info->author, i->info->version,
i->info->copyright, i->info->date);
}
}
#endif
@ -728,31 +758,31 @@ print_module_info (gpointer data,
/* UI functions */
static void
browser_popdown_callback (GtkWidget *w,
gpointer client_data)
browser_popdown_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_destroy (GTK_WIDGET (client_data));
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
browser_destroy_callback (GtkWidget *w,
gpointer client_data)
browser_destroy_callback (GtkWidget *widget,
gpointer data)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (modules), client_data);
gtk_signal_disconnect_by_data (GTK_OBJECT (modules), data);
gimp_set_remove_handler (modules, modules_handler);
g_free (client_data);
g_free (data);
}
static void
browser_load_inhibit_callback (GtkWidget *w,
browser_load_inhibit_callback (GtkWidget *widget,
gpointer data)
{
browser_st *st = data;
BrowserState *st = data;
gboolean new_value;
g_return_if_fail (st->last_update != NULL);
new_value = ! GTK_TOGGLE_BUTTON (w)->active;
new_value = ! GTK_TOGGLE_BUTTON (widget)->active;
if (new_value == st->last_update->load_inhibit)
return;
@ -764,59 +794,58 @@ browser_load_inhibit_callback (GtkWidget *w,
}
static void
browser_info_update (module_info *mod,
browser_st *st)
browser_info_update (ModuleInfo *mod,
BrowserState *st)
{
int i;
const char *text[NUM_INFO_LINES - 1];
char *status;
gint i;
const gchar *text[NUM_INFO_LINES - 1];
gchar *status;
/* only update the info if we're actually showing it */
if (mod != st->last_update)
return;
if (!mod)
{
for (i=0; i < NUM_INFO_LINES; i++)
gtk_label_set_text (GTK_LABEL (st->label[i]), "");
gtk_label_set_text (GTK_LABEL(st->button_label), _("<No modules>"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), FALSE);
return;
}
{
for (i=0; i < NUM_INFO_LINES; i++)
gtk_label_set_text (GTK_LABEL (st->label[i]), "");
gtk_label_set_text (GTK_LABEL(st->button_label), _("<No modules>"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), FALSE);
return;
}
if (mod->info)
{
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->ondisk? _("on disk") : _("only in memory");
}
{
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->ondisk? _("on disk") : _("only in memory");
}
else
{
text[0] = "--";
text[1] = "--";
text[2] = "--";
text[3] = "--";
text[4] = "--";
text[5] = mod->ondisk? _("on disk") : _("nowhere (click 'refresh')");
}
{
text[0] = "--";
text[1] = "--";
text[2] = "--";
text[3] = "--";
text[4] = "--";
text[5] = mod->ondisk? _("on disk") : _("nowhere (click 'refresh')");
}
if (mod->state == ST_MODULE_ERROR && mod->last_module_error)
status = g_strdup_printf ("%s (%s)", gettext (statename[mod->state]),
mod->last_module_error);
else
{
status = g_strdup (gettext (statename[mod->state]));
}
{
status = g_strdup (gettext (statename[mod->state]));
}
for (i=0; i < NUM_INFO_LINES - 1; i++)
{
gtk_label_set_text (GTK_LABEL (st->label[i]), gettext (text[i]));
}
{
gtk_label_set_text (GTK_LABEL (st->label[i]), gettext (text[i]));
}
gtk_label_set_text (GTK_LABEL (st->label[NUM_INFO_LINES-1]), status);
@ -827,33 +856,36 @@ browser_info_update (module_info *mod,
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), TRUE);
/* work out what the button should do (if anything) */
switch (mod->state) {
case ST_MODULE_ERROR:
case ST_LOAD_FAILED:
case ST_UNLOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Load"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), mod->ondisk);
break;
switch (mod->state)
{
case ST_MODULE_ERROR:
case ST_LOAD_FAILED:
case ST_UNLOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Load"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), mod->ondisk);
break;
case ST_UNLOAD_REQUESTED:
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
break;
case ST_UNLOAD_REQUESTED:
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
break;
case ST_LOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Unload"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button),
mod->unload? TRUE : FALSE);
break;
}
case ST_LOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Unload"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button),
mod->unload? TRUE : FALSE);
break;
}
}
static void
browser_info_init (browser_st *st,
GtkWidget *table)
browser_info_init (BrowserState *st,
GtkWidget *table)
{
GtkWidget *label;
int i;
char *text[] = {
gint i;
gchar *text[] =
{
N_("Purpose:"),
N_("Author:"),
N_("Version:"),
@ -864,22 +896,22 @@ browser_info_init (browser_st *st,
};
for (i=0; i < sizeof(text) / sizeof(char *); i++)
{
label = gtk_label_new (gettext (text[i]));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (label);
{
label = gtk_label_new (gettext (text[i]));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (label);
st->label[i] = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (st->label[i]), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (st->table), st->label[i], 1, 2, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (st->label[i]);
}
st->label[i] = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (st->label[i]), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (st->table), st->label[i], 1, 2, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (st->label[i]);
}
st->load_inhibit_check =
gtk_check_button_new_with_label (_("Autoload during startup"));
gtk_check_button_new_with_label (_("Autoload during startup"));
gtk_widget_show (st->load_inhibit_check);
gtk_table_attach (GTK_TABLE (table), st->load_inhibit_check,
0, 2, i, i+1,
@ -892,8 +924,8 @@ static void
browser_select_callback (GtkWidget *widget,
GtkWidget *child)
{
module_info *i;
browser_st *st;
ModuleInfo *i;
BrowserState *st;
i = gtk_object_get_user_data (GTK_OBJECT (child));
st = gtk_object_get_user_data (GTK_OBJECT (widget));
@ -911,7 +943,7 @@ static void
browser_load_unload_callback (GtkWidget *widget,
gpointer data)
{
browser_st *st = data;
BrowserState *st = data;
if (st->last_update->state == ST_LOADED_OK)
mod_unload (st->last_update, FALSE);
@ -926,9 +958,9 @@ static void
make_list_item (gpointer data,
gpointer user_data)
{
module_info *info = data;
browser_st *st = user_data;
GtkWidget *list_item;
ModuleInfo *info = data;
BrowserState *st = user_data;
GtkWidget *list_item;
if (!st->last_update)
st->last_update = info;
@ -943,22 +975,22 @@ make_list_item (gpointer data,
static void
browser_info_add (GimpSet *set,
module_info *mod,
browser_st *st)
browser_info_add (GimpSet *set,
ModuleInfo *mod,
BrowserState *st)
{
make_list_item (mod, st);
}
static void
browser_info_remove (GimpSet *set,
module_info *mod,
browser_st *st)
browser_info_remove (GimpSet *set,
ModuleInfo *mod,
BrowserState *st)
{
GList *dlist, *free_list;
GtkWidget *list_item;
module_info *i;
ModuleInfo *i;
dlist = gtk_container_children (GTK_CONTAINER (st->list));
free_list = dlist;
@ -990,10 +1022,10 @@ static void
module_db_module_ondisk (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
struct stat statbuf;
int ret;
int old_ondisk = mod->ondisk;
gint ret;
gint old_ondisk = mod->ondisk;
GSList **kill_list = user_data;
ret = stat (mod->fullpath, &statbuf);
@ -1005,10 +1037,10 @@ module_db_module_ondisk (gpointer data,
/* if it's not on the disk, and it isn't in memory, mark it to be
* removed later. */
if (!mod->ondisk && !mod->module)
{
*kill_list = g_slist_append (*kill_list, mod);
mod = NULL;
}
{
*kill_list = g_slist_append (*kill_list, mod);
mod = NULL;
}
if (mod && mod->ondisk != old_ondisk)
module_info_modified (mod);
@ -1019,7 +1051,7 @@ static void
module_db_module_remove (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
gimp_set_remove (modules, mod);
@ -1028,23 +1060,24 @@ module_db_module_remove (gpointer data,
typedef struct {
const char *search_key;
module_info *found;
typedef struct
{
const gchar *search_key;
ModuleInfo *found;
} find_by_path_closure;
static void
module_db_path_cmp (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
find_by_path_closure *cl = user_data;
if (!strcmp (mod->fullpath, cl->search_key))
cl->found = mod;
}
static module_info *
static ModuleInfo *
module_find_by_path (const char *fullpath)
{
find_by_path_closure cl;
@ -1078,7 +1111,7 @@ browser_refresh_callback (GtkWidget *widget,
static void
gimp_module_ref (module_info *mod)
gimp_module_ref (ModuleInfo *mod)
{
g_return_if_fail (mod->refs >= 0);
g_return_if_fail (mod->module != NULL);
@ -1086,7 +1119,7 @@ gimp_module_ref (module_info *mod)
}
static void
gimp_module_unref (module_info *mod)
gimp_module_unref (ModuleInfo *mod)
{
g_return_if_fail (mod->refs > 0);
g_return_if_fail (mod->module != NULL);
@ -1094,11 +1127,11 @@ gimp_module_unref (module_info *mod)
mod->refs--;
if (mod->refs == 0)
{
TRC (("module %p refs hit 0, g_module_closing it\n", mod));
g_module_close (mod->module);
mod->module = NULL;
}
{
TRC (("module %p refs hit 0, g_module_closing it\n", mod));
g_module_close (mod->module);
mod->module = NULL;
}
}
/* End of module_db.c */

View File

@ -17,14 +17,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __MODULE_DB_H__
/* Load any modules we find on the module-path set in the gimprc */
void module_db_init (void);
void module_db_init (void);
/* Unload all modules, in case a module needs some cleanups */
void module_db_free (void);
void module_db_free (void);
GtkWidget *module_db_browser_new (void);

View File

@ -41,12 +41,15 @@
#include "libgimp/gimpenv.h"
#include "libgimp/gimpmodule.h"
#include "libgimp/gimpintl.h"
/* export this to gimprc.c */
char *module_db_load_inhibit = NULL;
typedef enum {
/* export this to gimprc.c */
gchar *module_db_load_inhibit = NULL;
typedef enum
{
ST_MODULE_ERROR, /* missing module_load function or other error */
ST_LOADED_OK, /* happy and running (normal state of affairs) */
ST_LOAD_FAILED, /* module_load returned GIMP_MODULE_UNLOAD */
@ -54,7 +57,8 @@ typedef enum {
ST_UNLOADED_OK /* callback arrived, module not in memory anymore */
} module_state;
static const char * const statename[] = {
static const gchar * const statename[] =
{
N_("Module error"),
N_("Loaded OK"),
N_("Load failed"),
@ -63,68 +67,76 @@ static const char * const statename[] = {
};
#ifdef __EMX__
extern void gimp_color_selector_register();
extern void gimp_color_selector_unregister();
extern void gimp_color_display_register();
extern void gimp_color_display_unregister();
extern void dialog_register();
extern void dialog_unregister();
extern void gimp_color_selector_register ();
extern void gimp_color_selector_unregister ();
extern void gimp_color_display_register ();
extern void gimp_color_display_unregister ();
extern void dialog_register ();
extern void dialog_unregister ();
static struct main_funcs_struc {
static struct main_funcs_struc
{
gchar *name;
void (*func)();
void (*func) ();
}
gimp_main_funcs[] = {
{ "gimp_color_selector_register", gimp_color_selector_register },
gimp_main_funcs[] =
{
{ "gimp_color_selector_register", gimp_color_selector_register },
{ "gimp_color_selector_unregister", gimp_color_selector_unregister },
{ "gimp_color_display_register", gimp_color_display_register },
{ "gimp_color_display_unregister", gimp_color_display_unregister },
{ "dialog_register", dialog_register },
{ "dialog_unregister", dialog_unregister },
{ "gimp_color_display_register", gimp_color_display_register },
{ "gimp_color_display_unregister", gimp_color_display_unregister },
{ "dialog_register", dialog_register },
{ "dialog_unregister", dialog_unregister },
{ NULL, NULL }
};
#endif
/* one of these objects is kept per-module */
typedef struct {
typedef struct
{
GtkObject object;
gchar *fullpath; /* path to the module */
module_state state; /* what's happened to the module */
gboolean ondisk; /* TRUE if file still exists */
gboolean load_inhibit; /* user requests not to load at boot time */
gint refs; /* how many time we're running in the module */
/* stuff from now on may be NULL depending on the state the module is in */
GimpModuleInfo *info; /* returned values from module_init */
GModule *module; /* handle on the module */
gchar *last_module_error;
GimpModuleInitFunc *init;
GimpModuleUnloadFunc *unload;
} module_info;
GimpModuleInitFunc init;
GimpModuleUnloadFunc unload;
} ModuleInfo;
static guint module_info_get_type (void);
#define MODULE_INFO_TYPE module_info_get_type()
#define MODULE_INFO(obj) GTK_CHECK_CAST (obj, MODULE_INFO_TYPE, module_info)
#define MODULE_INFO(obj) GTK_CHECK_CAST (obj, MODULE_INFO_TYPE, ModuleInfo)
#define IS_MODULE_INFO(obj) GTK_CHECK_TYPE (obj, MODULE_INFO_TYPE)
#define NUM_INFO_LINES 7
typedef struct {
GtkWidget *table;
GtkWidget *label[NUM_INFO_LINES];
GtkWidget *button_label;
module_info *last_update;
GtkWidget *button;
GtkWidget *list;
GtkWidget *load_inhibit_check;
} browser_st;
typedef struct
{
GtkWidget *table;
GtkWidget *label[NUM_INFO_LINES];
GtkWidget *button_label;
ModuleInfo *last_update;
GtkWidget *button;
GtkWidget *list;
GtkWidget *load_inhibit_check;
} BrowserState;
/* global set of module_info pointers */
static GimpSet *modules;
static GimpSetHandlerId modules_handler;
static GimpSet *modules;
static GimpSetHandlerId modules_handler;
/* If the inhibit state of any modules changes, we might need to
* re-write the modulerc. */
@ -146,26 +158,43 @@ static gboolean need_to_rewrite_modulerc = FALSE;
/* prototypes */
static void module_initialize (char *filename);
static void mod_load (module_info *mod, gboolean verbose);
static void mod_unload (module_info *mod, gboolean verbose);
static module_info *module_find_by_path (const char *fullpath);
#ifdef DUMP_DB
static void print_module_info (gpointer data, gpointer user_data);
#endif
static void browser_popdown_callback (GtkWidget *w, gpointer client_data);
static void browser_destroy_callback (GtkWidget *w, gpointer client_data);
static void browser_info_update (module_info *, browser_st *);
static void browser_info_add (GimpSet *, module_info *, browser_st *);
static void browser_info_remove (GimpSet *, module_info *, browser_st *);
static void browser_info_init (browser_st *st, GtkWidget *table);
static void browser_select_callback (GtkWidget *widget, GtkWidget *child);
static void browser_load_unload_callback (GtkWidget *widget, gpointer data);
static void browser_refresh_callback (GtkWidget *widget, gpointer data);
static void make_list_item (gpointer data, gpointer user_data);
static void module_initialize (gchar *filename);
static void mod_load (ModuleInfo *mod,
gboolean verbose);
static void mod_unload (ModuleInfo *mod,
gboolean verbose);
static ModuleInfo * module_find_by_path (const gchar *fullpath);
static void gimp_module_ref (module_info *mod);
static void gimp_module_unref (module_info *mod);
#ifdef DUMP_DB
static void print_module_info (gpointer data,
gpointer user_data);
#endif
static void browser_popdown_callback (GtkWidget *widget,
gpointer data);
static void browser_destroy_callback (GtkWidget *widget,
gpointer data);
static void browser_info_update (ModuleInfo *mod,
BrowserState *st);
static void browser_info_add (GimpSet *set,
ModuleInfo *mod,
BrowserState *st);
static void browser_info_remove (GimpSet *set,
ModuleInfo *mod,
BrowserState *st);
static void browser_info_init (BrowserState *st,
GtkWidget *table);
static void browser_select_callback (GtkWidget *widget,
GtkWidget *child);
static void browser_load_unload_callback (GtkWidget *widget,
gpointer data);
static void browser_refresh_callback (GtkWidget *widget,
gpointer data);
static void make_list_item (gpointer data,
gpointer user_data);
static void gimp_module_ref (ModuleInfo *mod);
static void gimp_module_unref (ModuleInfo *mod);
@ -175,7 +204,7 @@ static void gimp_module_unref (module_info *mod);
void
module_db_init (void)
{
char *filename;
gchar *filename;
/* load the modulerc file */
filename = gimp_personal_rc_file ("modulerc");
@ -198,7 +227,7 @@ static void
free_a_single_module (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
if (mod->module && mod->unload && mod->state == ST_LOADED_OK)
{
@ -210,8 +239,8 @@ static void
add_to_inhibit_string (gpointer data,
gpointer user_data)
{
module_info *mod = data;
GString *str = user_data;
ModuleInfo *mod = data;
GString *str = user_data;
if (mod->load_inhibit)
{
@ -224,11 +253,11 @@ add_to_inhibit_string (gpointer data,
static gboolean
module_db_write_modulerc (void)
{
GString *str;
gchar *p;
char *filename;
FILE *fp;
gboolean saved = FALSE;
GString *str;
gchar *p;
gchar *filename;
FILE *fp;
gboolean saved = FALSE;
str = g_string_new (NULL);
gimp_set_foreach (modules, add_to_inhibit_string, str);
@ -256,12 +285,12 @@ void
module_db_free (void)
{
if (need_to_rewrite_modulerc)
{
{
if (module_db_write_modulerc ())
{
{
need_to_rewrite_modulerc = FALSE;
}
}
}
}
gimp_set_foreach (modules, free_a_single_module, NULL);
}
@ -274,7 +303,7 @@ module_db_browser_new (void)
GtkWidget *vbox;
GtkWidget *listbox;
GtkWidget *button;
browser_st *st;
BrowserState *st;
shell = gimp_dialog_new (_("Module DB"), "module_db_dialog",
gimp_standard_help_func,
@ -300,7 +329,7 @@ module_db_browser_new (void)
gtk_widget_set_usize (listbox, 125, 100);
gtk_widget_show (listbox);
st = g_new0 (browser_st, 1);
st = g_new0 (BrowserState, 1);
st->list = gtk_list_new ();
gtk_list_set_selection_mode (GTK_LIST (st->list), GTK_SELECTION_BROWSE);
@ -361,14 +390,16 @@ module_db_browser_new (void)
/**************************************************************/
/* module_info object glue */
/* ModuleInfo object glue */
typedef struct {
typedef struct
{
GtkObjectClass parent_class;
} module_infoClass;
} ModuleInfoClass;
enum {
enum
{
MODIFIED,
LAST_SIGNAL
};
@ -378,7 +409,7 @@ static guint module_info_signals[LAST_SIGNAL];
static void
module_info_destroy (GtkObject *object)
{
module_info *mod = MODULE_INFO (object);
ModuleInfo *mod = MODULE_INFO (object);
/* if this trips, then we're onto some serious lossage in a moment */
g_return_if_fail (mod->refs == 0);
@ -389,25 +420,25 @@ module_info_destroy (GtkObject *object)
}
static void
module_info_class_init (module_infoClass *klass)
module_info_class_init (ModuleInfoClass *klass)
{
GtkObjectClass *object_class;
GtkType type;
object_class = GTK_OBJECT_CLASS(klass);
object_class = GTK_OBJECT_CLASS (klass);
type = object_class->type;
object_class->destroy = module_info_destroy;
module_info_signals[MODIFIED] =
gimp_signal_new ("modified", 0, type, 0, gimp_sigtype_void);
gimp_signal_new ("modified", 0, type, 0, gimp_sigtype_void);
gtk_object_class_add_signals(object_class, module_info_signals, LAST_SIGNAL);
gtk_object_class_add_signals (object_class, module_info_signals, LAST_SIGNAL);
}
static void
module_info_init (module_info *mod)
module_info_init (ModuleInfo *mod)
{
/* don't need to do anything */
}
@ -421,9 +452,9 @@ module_info_get_type (void)
{
static const GtkTypeInfo module_info_info =
{
"module_info",
sizeof (module_info),
sizeof (module_infoClass),
"ModuleInfo",
sizeof (ModuleInfo),
sizeof (ModuleInfoClass),
(GtkClassInitFunc) module_info_class_init,
(GtkObjectInitFunc) module_info_init,
/* reserved_1 */ NULL,
@ -431,8 +462,8 @@ module_info_get_type (void)
(GtkClassInitFunc) NULL,
};
module_info_type = gtk_type_unique (gtk_object_get_type(),
&module_info_info);
module_info_type =
gtk_type_unique (gtk_object_get_type (), &module_info_info);
}
return module_info_type;
@ -441,19 +472,19 @@ module_info_get_type (void)
/* exported API: */
static void
module_info_modified (module_info *mod)
module_info_modified (ModuleInfo *mod)
{
gtk_signal_emit (GTK_OBJECT (mod), module_info_signals[MODIFIED]);
}
static module_info *
static ModuleInfo *
module_info_new (void)
{
return MODULE_INFO (gtk_type_new (module_info_get_type ()));
}
static void
module_info_free (module_info *mod)
module_info_free (ModuleInfo *mod)
{
gtk_object_unref (GTK_OBJECT (mod));
}
@ -465,10 +496,10 @@ module_info_free (module_info *mod)
/* name must be of the form lib*.so (Unix) or *.dll (Win32) */
static gboolean
valid_module_name (const char *filename)
valid_module_name (const gchar *filename)
{
const char *basename;
int len;
const gchar *basename;
gint len;
basename = g_basename (filename);
@ -496,12 +527,13 @@ valid_module_name (const char *filename)
static gboolean
module_inhibited (const char *fullpath,
const char *inhibit_list)
module_inhibited (const gchar *fullpath,
const gchar *inhibit_list)
{
char *p;
int pathlen;
const char *start, *end;
gchar *p;
gint pathlen;
const gchar *start;
const gchar *end;
/* common case optimisation: the list is empty */
if (!inhibit_list || *inhibit_list == '\000')
@ -531,9 +563,9 @@ module_inhibited (const char *fullpath,
static void
module_initialize (char *filename)
module_initialize (gchar *filename)
{
module_info *mod;
ModuleInfo *mod;
if (!valid_module_name (filename))
return;
@ -581,8 +613,8 @@ module_initialize (char *filename)
}
static void
mod_load (module_info *mod,
gboolean verbose)
mod_load (ModuleInfo *mod,
gboolean verbose)
{
gpointer symbol;
@ -632,12 +664,12 @@ mod_load (module_info *mod,
mod->info = NULL;
gimp_module_ref (mod); /* loaded modules are assumed to have a ref of 1 */
if (mod->init (&mod->info) == GIMP_MODULE_UNLOAD)
{
mod->state = ST_LOAD_FAILED;
gimp_module_unref (mod);
mod->info = NULL;
return;
}
{
mod->state = ST_LOAD_FAILED;
gimp_module_unref (mod);
mod->info = NULL;
return;
}
/* module is now happy */
mod->state = ST_LOADED_OK;
@ -648,14 +680,13 @@ mod_load (module_info *mod,
mod->unload = symbol;
else
mod->unload = NULL;
}
static void
mod_unload_completed_callback (void *data)
{
module_info *mod = data;
ModuleInfo *mod = data;
g_return_if_fail (mod->state == ST_UNLOAD_REQUESTED);
@ -672,8 +703,8 @@ mod_unload_completed_callback (void *data)
}
static void
mod_unload (module_info *mod,
gboolean verbose)
mod_unload (ModuleInfo *mod,
gboolean verbose)
{
g_return_if_fail (mod->module != NULL);
g_return_if_fail (mod->unload != NULL);
@ -694,31 +725,30 @@ mod_unload (module_info *mod,
}
#ifdef DUMP_DB
static void
print_module_info (gpointer data,
gpointer user_data)
{
module_info *i = data;
ModuleInfo *i = data;
printf ("\n%s: %s\n",
i->fullpath, statename[i->state]);
printf (" module:%p lasterr:%s init:%p unload:%p\n",
i->module, i->last_module_error? i->last_module_error : "NONE",
i->init, i->unload);
g_print ("\n%s: %s\n",
i->fullpath, statename[i->state]);
g_print (" module:%p lasterr:%s init:%p unload:%p\n",
i->module, i->last_module_error? i->last_module_error : "NONE",
i->init, i->unload);
if (i->info)
{
printf (" shutdown_data: %p\n"
" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->shutdown_data,
i->info->purpose, i->info->author, i->info->version,
i->info->copyright, i->info->date);
}
{
g_print (" shutdown_data: %p\n"
" purpose: %s\n"
" author: %s\n"
" version: %s\n"
" copyright: %s\n"
" date: %s\n",
i->info->shutdown_data,
i->info->purpose, i->info->author, i->info->version,
i->info->copyright, i->info->date);
}
}
#endif
@ -728,31 +758,31 @@ print_module_info (gpointer data,
/* UI functions */
static void
browser_popdown_callback (GtkWidget *w,
gpointer client_data)
browser_popdown_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_destroy (GTK_WIDGET (client_data));
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
browser_destroy_callback (GtkWidget *w,
gpointer client_data)
browser_destroy_callback (GtkWidget *widget,
gpointer data)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (modules), client_data);
gtk_signal_disconnect_by_data (GTK_OBJECT (modules), data);
gimp_set_remove_handler (modules, modules_handler);
g_free (client_data);
g_free (data);
}
static void
browser_load_inhibit_callback (GtkWidget *w,
browser_load_inhibit_callback (GtkWidget *widget,
gpointer data)
{
browser_st *st = data;
BrowserState *st = data;
gboolean new_value;
g_return_if_fail (st->last_update != NULL);
new_value = ! GTK_TOGGLE_BUTTON (w)->active;
new_value = ! GTK_TOGGLE_BUTTON (widget)->active;
if (new_value == st->last_update->load_inhibit)
return;
@ -764,59 +794,58 @@ browser_load_inhibit_callback (GtkWidget *w,
}
static void
browser_info_update (module_info *mod,
browser_st *st)
browser_info_update (ModuleInfo *mod,
BrowserState *st)
{
int i;
const char *text[NUM_INFO_LINES - 1];
char *status;
gint i;
const gchar *text[NUM_INFO_LINES - 1];
gchar *status;
/* only update the info if we're actually showing it */
if (mod != st->last_update)
return;
if (!mod)
{
for (i=0; i < NUM_INFO_LINES; i++)
gtk_label_set_text (GTK_LABEL (st->label[i]), "");
gtk_label_set_text (GTK_LABEL(st->button_label), _("<No modules>"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), FALSE);
return;
}
{
for (i=0; i < NUM_INFO_LINES; i++)
gtk_label_set_text (GTK_LABEL (st->label[i]), "");
gtk_label_set_text (GTK_LABEL(st->button_label), _("<No modules>"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), FALSE);
return;
}
if (mod->info)
{
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->ondisk? _("on disk") : _("only in memory");
}
{
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->ondisk? _("on disk") : _("only in memory");
}
else
{
text[0] = "--";
text[1] = "--";
text[2] = "--";
text[3] = "--";
text[4] = "--";
text[5] = mod->ondisk? _("on disk") : _("nowhere (click 'refresh')");
}
{
text[0] = "--";
text[1] = "--";
text[2] = "--";
text[3] = "--";
text[4] = "--";
text[5] = mod->ondisk? _("on disk") : _("nowhere (click 'refresh')");
}
if (mod->state == ST_MODULE_ERROR && mod->last_module_error)
status = g_strdup_printf ("%s (%s)", gettext (statename[mod->state]),
mod->last_module_error);
else
{
status = g_strdup (gettext (statename[mod->state]));
}
{
status = g_strdup (gettext (statename[mod->state]));
}
for (i=0; i < NUM_INFO_LINES - 1; i++)
{
gtk_label_set_text (GTK_LABEL (st->label[i]), gettext (text[i]));
}
{
gtk_label_set_text (GTK_LABEL (st->label[i]), gettext (text[i]));
}
gtk_label_set_text (GTK_LABEL (st->label[NUM_INFO_LINES-1]), status);
@ -827,33 +856,36 @@ browser_info_update (module_info *mod,
gtk_widget_set_sensitive (GTK_WIDGET (st->load_inhibit_check), TRUE);
/* work out what the button should do (if anything) */
switch (mod->state) {
case ST_MODULE_ERROR:
case ST_LOAD_FAILED:
case ST_UNLOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Load"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), mod->ondisk);
break;
switch (mod->state)
{
case ST_MODULE_ERROR:
case ST_LOAD_FAILED:
case ST_UNLOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Load"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button), mod->ondisk);
break;
case ST_UNLOAD_REQUESTED:
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
break;
case ST_UNLOAD_REQUESTED:
gtk_widget_set_sensitive (GTK_WIDGET (st->button), FALSE);
break;
case ST_LOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Unload"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button),
mod->unload? TRUE : FALSE);
break;
}
case ST_LOADED_OK:
gtk_label_set_text (GTK_LABEL(st->button_label), _("Unload"));
gtk_widget_set_sensitive (GTK_WIDGET (st->button),
mod->unload? TRUE : FALSE);
break;
}
}
static void
browser_info_init (browser_st *st,
GtkWidget *table)
browser_info_init (BrowserState *st,
GtkWidget *table)
{
GtkWidget *label;
int i;
char *text[] = {
gint i;
gchar *text[] =
{
N_("Purpose:"),
N_("Author:"),
N_("Version:"),
@ -864,22 +896,22 @@ browser_info_init (browser_st *st,
};
for (i=0; i < sizeof(text) / sizeof(char *); i++)
{
label = gtk_label_new (gettext (text[i]));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (label);
{
label = gtk_label_new (gettext (text[i]));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (label);
st->label[i] = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (st->label[i]), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (st->table), st->label[i], 1, 2, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (st->label[i]);
}
st->label[i] = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (st->label[i]), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (st->table), st->label[i], 1, 2, i, i+1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (st->label[i]);
}
st->load_inhibit_check =
gtk_check_button_new_with_label (_("Autoload during startup"));
gtk_check_button_new_with_label (_("Autoload during startup"));
gtk_widget_show (st->load_inhibit_check);
gtk_table_attach (GTK_TABLE (table), st->load_inhibit_check,
0, 2, i, i+1,
@ -892,8 +924,8 @@ static void
browser_select_callback (GtkWidget *widget,
GtkWidget *child)
{
module_info *i;
browser_st *st;
ModuleInfo *i;
BrowserState *st;
i = gtk_object_get_user_data (GTK_OBJECT (child));
st = gtk_object_get_user_data (GTK_OBJECT (widget));
@ -911,7 +943,7 @@ static void
browser_load_unload_callback (GtkWidget *widget,
gpointer data)
{
browser_st *st = data;
BrowserState *st = data;
if (st->last_update->state == ST_LOADED_OK)
mod_unload (st->last_update, FALSE);
@ -926,9 +958,9 @@ static void
make_list_item (gpointer data,
gpointer user_data)
{
module_info *info = data;
browser_st *st = user_data;
GtkWidget *list_item;
ModuleInfo *info = data;
BrowserState *st = user_data;
GtkWidget *list_item;
if (!st->last_update)
st->last_update = info;
@ -943,22 +975,22 @@ make_list_item (gpointer data,
static void
browser_info_add (GimpSet *set,
module_info *mod,
browser_st *st)
browser_info_add (GimpSet *set,
ModuleInfo *mod,
BrowserState *st)
{
make_list_item (mod, st);
}
static void
browser_info_remove (GimpSet *set,
module_info *mod,
browser_st *st)
browser_info_remove (GimpSet *set,
ModuleInfo *mod,
BrowserState *st)
{
GList *dlist, *free_list;
GtkWidget *list_item;
module_info *i;
ModuleInfo *i;
dlist = gtk_container_children (GTK_CONTAINER (st->list));
free_list = dlist;
@ -990,10 +1022,10 @@ static void
module_db_module_ondisk (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
struct stat statbuf;
int ret;
int old_ondisk = mod->ondisk;
gint ret;
gint old_ondisk = mod->ondisk;
GSList **kill_list = user_data;
ret = stat (mod->fullpath, &statbuf);
@ -1005,10 +1037,10 @@ module_db_module_ondisk (gpointer data,
/* if it's not on the disk, and it isn't in memory, mark it to be
* removed later. */
if (!mod->ondisk && !mod->module)
{
*kill_list = g_slist_append (*kill_list, mod);
mod = NULL;
}
{
*kill_list = g_slist_append (*kill_list, mod);
mod = NULL;
}
if (mod && mod->ondisk != old_ondisk)
module_info_modified (mod);
@ -1019,7 +1051,7 @@ static void
module_db_module_remove (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
gimp_set_remove (modules, mod);
@ -1028,23 +1060,24 @@ module_db_module_remove (gpointer data,
typedef struct {
const char *search_key;
module_info *found;
typedef struct
{
const gchar *search_key;
ModuleInfo *found;
} find_by_path_closure;
static void
module_db_path_cmp (gpointer data,
gpointer user_data)
{
module_info *mod = data;
ModuleInfo *mod = data;
find_by_path_closure *cl = user_data;
if (!strcmp (mod->fullpath, cl->search_key))
cl->found = mod;
}
static module_info *
static ModuleInfo *
module_find_by_path (const char *fullpath)
{
find_by_path_closure cl;
@ -1078,7 +1111,7 @@ browser_refresh_callback (GtkWidget *widget,
static void
gimp_module_ref (module_info *mod)
gimp_module_ref (ModuleInfo *mod)
{
g_return_if_fail (mod->refs >= 0);
g_return_if_fail (mod->module != NULL);
@ -1086,7 +1119,7 @@ gimp_module_ref (module_info *mod)
}
static void
gimp_module_unref (module_info *mod)
gimp_module_unref (ModuleInfo *mod)
{
g_return_if_fail (mod->refs > 0);
g_return_if_fail (mod->module != NULL);
@ -1094,11 +1127,11 @@ gimp_module_unref (module_info *mod)
mod->refs--;
if (mod->refs == 0)
{
TRC (("module %p refs hit 0, g_module_closing it\n", mod));
g_module_close (mod->module);
mod->module = NULL;
}
{
TRC (("module %p refs hit 0, g_module_closing it\n", mod));
g_module_close (mod->module);
mod->module = NULL;
}
}
/* End of module_db.c */

View File

@ -17,14 +17,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __MODULE_DB_H__
/* Load any modules we find on the module-path set in the gimprc */
void module_db_init (void);
void module_db_init (void);
/* Unload all modules, in case a module needs some cleanups */
void module_db_free (void);
void module_db_free (void);
GtkWidget *module_db_browser_new (void);

View File

@ -1,3 +1,32 @@
2000-05-28 Michael Natterer <mitch@gimp.org>
* libgimp/libgimp-decl.txt
* libgimp/libgimp-docs.sgml
* libgimp/libgimp-sections.txt
* libgimp/tmpl/gimp.sgml
* libgimp/tmpl/gimpcolorbutton.sgml
* libgimp/tmpl/gimpcolordisplay.sgml
* libgimp/tmpl/gimpcolorselector.sgml
* libgimp/tmpl/gimpcolorspace.sgml
* libgimp/tmpl/gimpcompat.sgml
* libgimp/tmpl/gimpenums.sgml
* libgimp/tmpl/gimpfeatures.sgml
* libgimp/tmpl/gimplimits.sgml
* libgimp/tmpl/gimpmath.sgml
* libgimp/tmpl/gimpmodule.sgml
* libgimp/tmpl/gimpparasite.sgml
* libgimp/tmpl/gimpparasiteio.sgml
* libgimp/tmpl/gimppixmap.sgml
* libgimp/tmpl/gimpprotocol.sgml
* libgimp/tmpl/gimpsignal.sgml
* libgimp/tmpl/gimpui.sgml
* libgimp/tmpl/gimpunit.sgml
* libgimp/tmpl/gimputils.sgml
* libgimp/tmpl/gimpvector.sgml
* libgimp/tmpl/gimpwire.sgml
* libgimp/tmpl/libgimp-unused.sgml: Moved the module documentation
from the libgimp headers here, updates, cleanups.
2000-05-27 Michael Natterer <mitch@gimp.org>
* libgimp/*: lotsa files removed/added/changed to reflect the

File diff suppressed because it is too large Load Diff

View File

@ -66,6 +66,7 @@
<chapter id="libgimpui">
<title>GIMP User Interface Library</title>
&libgimp-gimpui;
&GimpChainButton;
&GimpColorButton;
&GimpFileSelection;
@ -78,7 +79,6 @@
&libgimp-gimphelpui;
&libgimp-gimpmenu;
&libgimp-gimpquerybox;
&libgimp-gimpui;
&libgimp-gimpwidgets;
</chapter>

View File

@ -227,7 +227,6 @@ gimp_parasite_find
gimp_parasite_attach
gimp_attach_new_parasite
gimp_parasite_detach
gimp_plugin_help_func
gimp_help
gimp_plugin_help_register
gimp_plugin_domain_add_with_path
@ -528,6 +527,7 @@ GimpColorSelector_SetColorFunc
GimpColorSelectorMethods
GimpColorSelectorID
gimp_color_selector_register
GimpColorSelectorFinishedCB
gimp_color_selector_unregister
</SECTION>
@ -535,6 +535,9 @@ gimp_color_selector_unregister
<FILE>gimpmodule</FILE>
GimpModuleStatus
GimpModuleInfo
GimpModuleInitFunc
GimpModuleCompletedCB
GimpModuleUnloadFunc
</SECTION>
<SECTION>
@ -631,6 +634,7 @@ gimp_image_disable_undo
gimp_image_enable_undo
gimp_image_freeze_undo
gimp_image_thaw_undo
gimp_plugin_help_func
Parasite
PARASITE_PERSISTENT
PARASITE_UNDOABLE

View File

@ -2,10 +2,13 @@
gimp
<!-- ##### SECTION Short_Description ##### -->
Main functions needed for building a GIMP plug-in. This header includes
all other GIMP Library headers.
<!-- ##### SECTION Long_Description ##### -->
<para>
Main functions needed for building a GIMP plug-in. This header includes
all other GIMP Library headers.
</para>
@ -2177,15 +2180,6 @@ gimp
@name:
<!-- ##### MACRO gimp_plugin_help_func ##### -->
<para>
</para>
<!-- # Unused Parameters # -->
@help_data:
<!-- ##### FUNCTION gimp_help ##### -->
<para>

View File

@ -21,7 +21,7 @@ Note that the color is changed in place.
<!-- ##### SECTION See_Also ##### -->
<para>
#libgimp-gimpcolorspace
</para>
<!-- ##### STRUCT GimpColorButton ##### -->

View File

@ -2,16 +2,22 @@
gimpcolordisplay
<!-- ##### SECTION Short_Description ##### -->
Functions and definitiions for creating a pluggable GIMP
display color correction module.
<!-- ##### SECTION Long_Description ##### -->
<para>
Functions and definitiions for creating a pluggable GIMP
display color correction module.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GModule
</para>
<para>
#libgimp-gimpmodule
</para>
<!-- ##### USER_FUNCTION GimpColorDisplayInit ##### -->

View File

@ -2,61 +2,91 @@
gimpcolorselector
<!-- ##### SECTION Short_Description ##### -->
Functions and definitiions for creating a pluggable GIMP
color selector module.
<!-- ##### SECTION Long_Description ##### -->
<para>
Functions and definitiions for creating a pluggable GIMP
color selector module.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GModule
</para>
<para>
#libgimp-gimpmodule
</para>
<!-- ##### USER_FUNCTION GimpColorSelector_Callback ##### -->
<para>
A function of this type should be called by the color selector each
time the user modifies the selected color.
</para>
@data:
@r:
@g:
@b:
@data: The @data passed to the #GimpColorSelector_NewFunc function.
@r: The new color's red component.
@g: The new color's green component.
@b: The new color's blue component.
<!-- ##### USER_FUNCTION GimpColorSelector_NewFunc ##### -->
<para>
A function of this type is called to create a new instance of the
color selector. The new selector should set its current color to
the RGB triple given (each component is in the range 0 - 255
inclusive, with white at 255,255,255 and black at 0,0,0).
</para>
<para>
The selector should call @cb with argument @data each time the
user modifies the selected color.
</para>
<para>
The selector must return a #GtkWidget which implements the color
selection UI. The selector can optionally return @selector_data,
an opaque pointer which will be passed in to subsequent invokations
on the selector.
</para>
@r:
@g:
@b:
@cb:
@data:
@selector_data:
@Returns:
@r: The red component of intitial color.
@g: The green component of intitial color.
@b: The blue component of intitial color.
@cb: The function to call each time the user modifies the selected color.
@data: The @data to pass to @cb.
@selector_data: An optional data pointer which will be passed in to subsequent invokations on the selector.
@Returns: A #GtkWidget which implements the color selection UI.
<!-- ##### USER_FUNCTION GimpColorSelector_FreeFunc ##### -->
<para>
A function of this type is called when the color selector is no
longer required. This function should *not* free widgets that are
containted within the UI widget returned by new(), since they are
destroyed on behalf of the selector by the caller of this
function.
</para>
@selector_data:
@selector_data: The @selector_data pointer returned by the #GimpColorSelector_NewFunc function.
<!-- ##### USER_FUNCTION GimpColorSelector_SetColorFunc ##### -->
<para>
A function of this type is called to change the selector's current
color. The required color is specified as in the new() function.
If the @set_current parameter is #FALSE, then only the old color
should be set - if @set_current is #TRUE, both the old color and
the current color should be set to the RGB triple given. This
function merely gives a hint to the color selector; the selector
can choose to ignore this information.
</para>
@selector_data:
@r:
@g:
@b:
@set_current:
@selector_data: The @selector_data pointer returned by the #GimpColorSelector_NewFunc function.
@r: The new color's red component.
@g: The new color's green component.
@b: The new color's blue component.
@set_current: Set the current color.
<!-- ##### STRUCT GimpColorSelectorMethods ##### -->
@ -73,23 +103,40 @@ gimpcolorselector
<!-- ##### FUNCTION gimp_color_selector_register ##### -->
<para>
Register a color selector. Returns an identifier for the color
selector on success, or #NULL if the name is already in use. Both
the @name and @methods table are internalised, so may be g_free()'d after
this call.
</para>
@name:
@help_page:
@methods:
@Returns:
@name: The color selector's name.
@help_page: The help page.
@methods: The color selector's methods.
@Returns: The #GimpColorSelectorID of the new color selector.
<!-- ##### USER_FUNCTION GimpColorSelectorFinishedCB ##### -->
<para>
A function of this type will be called once all instances of a color
selector have finished after the selector module called
gimp_color_selector_unregister().
</para>
@finished_data: The @finished_data as specified in gimp_color_selector_register().
<!-- ##### FUNCTION gimp_color_selector_unregister ##### -->
<para>
Remove the selector @id from active service. New instances of the
selector will not be created, but existing ones are allowed to
continue. If @finished_cb is non-#NULL, it will be called once all
instances have finished. The callback could be used to unload
dynamiclly loaded code, for example.
</para>
@id:
@callback:
@data:
@Returns:
@id: The @id as returned by gimp_color_selector_register().
@finished_cb: Optional callback which will be called once all instances have finished.
@finished_data: The @finished_data which will be passed to @finished_cb.
@Returns: #TRUE on success, #FALSE if @id was not found.

View File

@ -2,10 +2,14 @@
gimpcolorspace
<!-- ##### SECTION Short_Description ##### -->
Utility functions which convert colors between different color models.
<!-- ##### SECTION Long_Description ##### -->
<para>
When programming pixel data manipulation functions you will often use
algorithms operating on a color model different from the one GIMP
uses. This file provides utility functions to concert colors between
different color spaces.
</para>

View File

@ -6,6 +6,7 @@ Compatibility definitions for older plug-ins.
<!-- ##### SECTION Long_Description ##### -->
<para>
Compatibility definitions for older plug-ins.
</para>
@ -147,6 +148,15 @@ Compatibility definitions for older plug-ins.
<!-- ##### MACRO gimp_plugin_help_func ##### -->
<para>
</para>
<!-- # Unused Parameters # -->
@help_data:
<!-- ##### MACRO Parasite ##### -->
<para>

View File

@ -2,10 +2,11 @@
gimpenums
<!-- ##### SECTION Short_Description ##### -->
Enums and definitions.
<!-- ##### SECTION Long_Description ##### -->
<para>
Enums and definitions.
</para>

View File

@ -2,10 +2,13 @@
gimpfeatures
<!-- ##### SECTION Short_Description ##### -->
Macros and constants useful for determining GIMP's version number and
capabilities.
<!-- ##### SECTION Long_Description ##### -->
<para>
Macros and constants useful for determining GIMP's version number and
capabilities.
</para>

View File

@ -2,10 +2,11 @@
gimplimits
<!-- ##### SECTION Short_Description ##### -->
Boundaries of some GIMP data types and some global constants.
<!-- ##### SECTION Long_Description ##### -->
<para>
Boundaries of some GIMP data types and some global constants.
</para>

View File

@ -6,6 +6,7 @@ Mathematical definitions and macros.
<!-- ##### SECTION Long_Description ##### -->
<para>
Mathematical definitions and macros.
</para>

View File

@ -2,16 +2,17 @@
gimpmodule
<!-- ##### SECTION Short_Description ##### -->
Common definitions for creating a pluggable GIMP module.
<!-- ##### SECTION Long_Description ##### -->
<para>
Common definitions for creating a pluggable GIMP module.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GModule
</para>
<!-- ##### ENUM GimpModuleStatus ##### -->
@ -26,3 +27,59 @@ gimpmodule
</para>
<!-- ##### USER_FUNCTION GimpModuleInitFunc ##### -->
<para>
GIMP modules should #G_MODULE_EXPORT a function named "module_init"
of this type.
</para>
<para>
The "module_init" function is called by the GIMP at startup,
and should return either #GIMP_MODULE_OK if it sucessfully initialised or
#GIMP_MODULE_UNLOAD if the module failed to hook whatever functions
it wanted. #GIMP_MODULE_UNLOAD causes the module to be closed, so
the module must not have registered any internal functions or given
out pointers to its data to anyone.
</para>
<para>
If the module returns #GIMP_MODULE_OK, it should also return a
#GimpModuleInfo structure describing itself.
</para>
@module_info: Returns the #GimpModuleInfo desribing the module.
@Returns: A #GimpModuleStatus value indicating success.
<!-- ##### USER_FUNCTION GimpModuleCompletedCB ##### -->
<para>
The type of the @completed_cb passed to the "module_unload" function
(see below).
</para>
@completed_data: <para>
Must be the @completed_data pointer provided by the "module_unload"
function.
</para>
<!-- ##### USER_FUNCTION GimpModuleUnloadFunc ##### -->
<para>
If GIMP modules want to allow themselves to be unloaded, they
should #G_MODULE_EXPORT a function named "module_unload" of
this type.
</para>
<para>
GIMP calls the "module_unload" unload request function to ask
a module to prepare itself to be unloaded. It is called with the
value of @shutdown_data supplied in the #GimpModuleInfo struct.
The module should ensure that none of its code or data are being
used, and then call the supplied @completed_cb callback function with
the @completed_data provided. Typically the shutdown request function
will queue de-registration activities then return. Only when the
de-registration has finished should the @completed_cb be invoked.
</para>
@shutdown_data: The @shutdown_data supplied in the #GimpModuleInfo struct.
@completed_cb: The function to call after successful unload.
@completed_data: Has to be passed to the @completed_cb.

View File

@ -2,16 +2,18 @@
gimpparasite
<!-- ##### SECTION Short_Description ##### -->
Arbitrary pieces of data which can be attached to various GIMP objects.
<!-- ##### SECTION Long_Description ##### -->
<para>
Arbitrary pieces of data which can be attached to various GIMP objects.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
gimp_image_parasite_attach(), gimp_drawable_parasite_attach(),
gimp_parasite_attach() and their related functions.
</para>
<!-- ##### STRUCT GimpParasite ##### -->

View File

@ -2,16 +2,17 @@
gimpparasiteio
<!-- ##### SECTION Short_Description ##### -->
Utility functions to (de)serialize certain C structures to/from #GimpParasite's.
<!-- ##### SECTION Long_Description ##### -->
<para>
Utility functions to (de)serialize certain C structures to/from #GimpParasite's.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GimpParasite
</para>
<!-- ##### MACRO GIMP_PIXPIPE_MAXDIM ##### -->

View File

@ -6,13 +6,25 @@ Widget which creates a #GtkPixmap from XPM data.
<!-- ##### SECTION Long_Description ##### -->
<para>
Widget which creates a #GtkPixmap from XPM data.
</para>
<para>
Use this widget instead of #GtkPixmap if you don't want to worry about
the parent container's "realized" state.
</para>
<para>
Note that the drawback of the easy interface is that the actual #GdkPixmap
and it's mask have to be constructed every time you call gimp_pixmap_new()
and cannot be cached in memory without doing bad hacks.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
gimp_pixmap_button_new()
</para>
<para>
#GtkPixmap
</para>
<!-- ##### STRUCT GimpPixmap ##### -->
<para>

View File

@ -2,16 +2,17 @@
gimpprotocol
<!-- ##### SECTION Short_Description ##### -->
The communication protocol between GIMP and it's plug-ins.
<!-- ##### SECTION Long_Description ##### -->
<para>
The communication protocol between GIMP and it's plug-ins.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#libgimp-gimpwire
</para>
<!-- ##### MACRO GP_VERSION ##### -->

View File

@ -6,6 +6,7 @@ Portable signal handling.
<!-- ##### SECTION Long_Description ##### -->
<para>
Portable signal handling.
</para>

View File

@ -2,10 +2,13 @@
gimpui
<!-- ##### SECTION Short_Description ##### -->
Common user interface functions.
Common user interface functions. This header includes all other GIMP User
Interface Library headers.
<!-- ##### SECTION Long_Description ##### -->
<para>
Common user interface functions. This header includes all other GIMP User
Interface Library headers.
</para>

View File

@ -7,6 +7,8 @@ user-defined units.
<!-- ##### SECTION Long_Description ##### -->
<para>
Provides a collection of predefined units and functions for creating
user-defined units.
</para>

View File

@ -13,7 +13,7 @@ provide it here.
<!-- ##### SECTION See_Also ##### -->
<para>
g_strescape()
</para>
<!-- ##### FUNCTION gimp_strescape ##### -->

View File

@ -6,6 +6,7 @@ Utilities to set up and manipulate vectors.
<!-- ##### SECTION Long_Description ##### -->
<para>
Utilities to set up and manipulate vectors.
</para>

View File

@ -2,16 +2,19 @@
gimpwire
<!-- ##### SECTION Short_Description ##### -->
The lowlevel I/O protocol used for communication between GIMP and
it's plug-ins.
<!-- ##### SECTION Long_Description ##### -->
<para>
The lowlevel I/O protocol used for communication between GIMP and
it's plug-ins.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#libgimp-gimpprotocol
</para>
<!-- ##### STRUCT WireMessage ##### -->

View File

@ -96,16 +96,16 @@ parasiteF
<!-- ##### SECTION ./tmpl/color_selector.sgml:Short_Description ##### -->
<!-- ##### SECTION ./tmpl/parasiteF.sgml:Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/color_selector.sgml:Short_Description ##### -->
<!-- ##### SECTION ./tmpl/parasiteio.sgml:See_Also ##### -->
<para>

File diff suppressed because it is too large Load Diff

View File

@ -62,14 +62,15 @@ struct _GimpColorDisplayMethods
GimpColorDisplayConfigureCancel cancel;
};
/*
* The following two functions are implemted and exported by gimp/app
* but need to be marked for it here too ...
/* The following two functions are implemted and exported by gimp/app
* but need to be marked for it here too ...
*/
G_MODULE_EXPORT
gboolean gimp_color_display_register (const char *name,
GimpColorDisplayMethods *methods);
gboolean gimp_color_display_register (const gchar *name,
GimpColorDisplayMethods *methods);
G_MODULE_EXPORT
gboolean gimp_color_display_unregister (const char *name);
gboolean gimp_color_display_unregister (const gchar *name);
#endif /* __GIMP_COLOR_DISPLAY_H__ */

View File

@ -21,89 +21,55 @@
#ifndef __COLOR_SELECTOR_H__
#define __COLOR_SELECTOR_H__
/********************************/
/* color selector registration */
/* For information look at the html documentation */
/* A function of this type should be called by the color selector each
* time the user modifies the selected color. */
typedef void (*GimpColorSelector_Callback)(void *data, int r, int g, int b);
typedef void (* GimpColorSelector_Callback) (gpointer data,
gint r,
gint g,
gint b);
typedef GtkWidget * (* GimpColorSelector_NewFunc) (gint r,
gint g,
gint b,
GimpColorSelector_Callback cb,
gpointer data,
gpointer *selector_data);
typedef void (* GimpColorSelector_FreeFunc) (gpointer selector_data);
/* A function of this type is called to create a new instance of the
* color selector. The new selector should set its current color to
* the RGB triple given (each component is in the range 0 - 255
* inclusive, with white at 255,255,255 and black at 0,0,0).
*
* The selector should call "cb" with argument "data" each time the
* user modifies the selected color.
*
* The selector must return a GtkWidget which implements the color
* selection UI. The selector can optionally return "selector_data",
* an opaque pointer which will be passed in to subsequent invokations
* on the selector. */
typedef GtkWidget * (*GimpColorSelector_NewFunc)(int r, int g, int b,
GimpColorSelector_Callback cb,
void *data,
void **selector_data);
/* A function of this type is called when the color selector is no
* longer required. This function should not free widgets that are
* containted within the UI widget returned by new(), since they are
* destroyed on behalf of the selector by the caller of this
* function. */
typedef void (*GimpColorSelector_FreeFunc)(void *selector_data);
/* A function of this type is called to change the selector's current
* color. The required color is specified as in the new() function.
* If the "set_current" parameter is FALSE, then only the old color
* should be set - if "set_current" is TRUE, both the old color and
* the current color should be set to the RGB triple given. This
* function merely gives a hint to the color selector; the selector
* can choose to ignore this information. */
typedef void (*GimpColorSelector_SetColorFunc)(void *selector_data,
int r, int g, int b,
int set_current);
typedef void (* GimpColorSelector_SetColorFunc) (gpointer selector_data,
gint r,
gint g,
gint b,
gboolean set_current);
typedef struct _GimpColorSelectorMethods GimpColorSelectorMethods;
struct _GimpColorSelectorMethods {
struct _GimpColorSelectorMethods
{
GimpColorSelector_NewFunc new;
GimpColorSelector_FreeFunc free;
GimpColorSelector_SetColorFunc setcolor;
};
typedef void *GimpColorSelectorID;
typedef gpointer GimpColorSelectorID;
#ifndef __COLOR_NOTEBOOK_C__ /* Bypass when compiling the source for
* these functions. */
#ifndef __COLOR_NOTEBOOK_C__
/* Register a color selector. Returns an identifier for the color
* selector on success, or NULL if the name is already in use. Both
* the name and method table are internalised, so may be freed after
* this call. */
GimpColorSelectorID gimp_color_selector_register (const char *name,
const char *help_page,
GimpColorSelectorMethods *methods);
/* Bypass when compiling the source for these functions.
*/
GimpColorSelectorID gimp_color_selector_register (const gchar *name,
const gchar *help_page,
GimpColorSelectorMethods *methods);
typedef void (* GimpColorSelectorFinishedCB) (gpointer finished_data);
gboolean gimp_color_selector_unregister (GimpColorSelectorID id,
GimpColorSelectorFinishedCB finished_cb,
gpointer finished_data);
/* Remove the selector "id" from active service. New instances of the
* selector will not be created, but existing ones are allowed to
* continue. If "callback" is non-NULL, it will be called once all
* instances have finished. The callback could be used to unload
* dynamiclly loaded code, for example.
*
* Returns TRUE on success, FALSE if "id" was not found. */
gboolean gimp_color_selector_unregister (GimpColorSelectorID id,
void (*callback)(void *data),
void *data);
#endif /* !__COLOR_NOTEBOOK_C__ */
#endif /* __COLOR_SELECTOR_H__ */

View File

@ -1,4 +1,4 @@
/* LIBGIMP - The GIMP Library
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpmatrix.h

View File

@ -19,74 +19,62 @@
*/
#ifndef __GIMPMODULE_H__
#define __GIMPMODULE_H__
#define __GIMPMODULE_H__
#include <gmodule.h>
/* For information look at the html documentation */
typedef enum {
typedef enum
{
GIMP_MODULE_OK,
GIMP_MODULE_UNLOAD
} GimpModuleStatus;
typedef struct _GimpModuleInfo GimpModuleInfo;
typedef struct {
void *shutdown_data;
const char *purpose;
const char *author;
const char *version;
const char *copyright;
const char *date;
} GimpModuleInfo;
struct _GimpModuleInfo
{
gpointer shutdown_data;
const gchar *purpose;
const gchar *author;
const gchar *version;
const gchar *copyright;
const gchar *date;
};
/* Module initialization */
/* GIMP modules should G_MODULE_EXPORT a function named "module_init"
* of the following type: */
typedef GimpModuleStatus (GimpModuleInitFunc) (GimpModuleInfo **);
typedef GimpModuleStatus (* GimpModuleInitFunc) (GimpModuleInfo **module_info);
#ifndef MODULE_COMPILATION /* On Win32 this declaration clashes with
* the definition (which uses G_MODULE_EXPORT)
* and thus should be bypassed when compiling
* the module itself.
*/
GimpModuleInitFunc module_init;
#endif
#ifndef MODULE_COMPILATION
/* This function is called by the GIMP at startup, and should return
* either GIMP_MODULE_OK if it sucessfully initialised or
* GIMP_MODULE_UNLOAD if the module failed to hook whatever functions
* it wanted. GIMP_MODULE_UNLOAD causes the module to be closed, so
* the module must not have registered any internal functions or given
* out pointers to its data to anyone.
*
* If the module returns GIMP_MODULE_OK, it should also return a
* GimpModuleInfo structure describing itself.
/* On Win32 this declaration clashes with the definition
* (which uses G_MODULE_EXPORT) and thus should be bypassed
* when compiling the module itself.
*/
GimpModuleInitFunc module_init;
#endif /* ! MODULE_COMPILATION */
/* If GIMP modules want to allow themselves to be unloaded, they
* should G_MODULE_EXPORT a function named "module_unload" with the
* following type: */
typedef void (GimpModuleUnloadFunc) (void *shutdown_data,
void (*completed_cb)(void *),
void *completed_data);
/* Module unload */
#ifndef MODULE_COMPILATION /* The same as for module_init */
typedef void (* GimpModuleCompletedCB) (gpointer completed_data);
typedef void (* GimpModuleUnloadFunc) (gpointer shutdown_data,
GimpModuleCompletedCB completed_cb,
gpointer completed_data);
#ifndef MODULE_COMPILATION
/* The same as for module_init.
*/
GimpModuleUnloadFunc module_unload;
#endif
/* GIMP calls this unload request function to ask a module to
* prepare itself to be unloaded. It is called with the value of
* shutdown_data supplied in the GimpModuleInfo struct. The module
* should ensure that none of its code or data are being used, and
* then call the supplied "completed_cb" callback function with the
* data provided. Typically the shutdown request function will queue
* de-registration activities then return. Only when the
* de-registration has finished should the completed_cb be invoked. */
#endif /* ! MODULE_COMPILATION */
#endif /* __GIMPMODULE_H__ */

View File

@ -96,8 +96,8 @@ gimp_unit_get_number_of_units (void)
* gimp_unit_get_number_of_built_in_units:
*
* Returns the number of #GimpUnit's which are hardcoded in the unit system
* (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo units"
* UNIT_PIXEL and UNIT_PERCENT).
* (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo unit"
* UNIT_PIXEL).
*
* Returns: The number of built-in units.
*