diff --git a/ChangeLog b/ChangeLog index 4bbd6917c2..a244590cd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +Mon May 3 12:04:47 PDT 1999 Manish Singh + + * tools/pdbgen/plug_in.pdb + * tools/pdbgen/interface.pdb: new files + + * tools/pdbgen/app.pl: add no_id_lookup option + + * tools/pdbgen/Makefile.am: added new pdb files, plug_in.h + + * tools/pdbgen/enums.pl: plug_in.h enums + + * app/plug_in.[ch]: removed PDB stuff, exported current_plug_in, + proc_defs, and plug_in_progress_{init,update} + + * app/interface_cmds.c + * app/plug_in_cmds.c + * app/internal_procs.c: pdbgenned files + + * app/Makefile.am: new files: interface_cmds.c, plug_in_cmds.c + Sun May 2 14:56:52 PDT 1999 Manish Singh * app/gimpimage.h: guide types used to start at 1, so make them diff --git a/app/Makefile.am b/app/Makefile.am index f9b9f681c6..127df46bed 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -232,6 +232,7 @@ gimp_SOURCES = \ install.h \ interface.c \ interface.h \ + interface_cmds.c \ internal_procs.c \ internal_procs.h \ invert.c \ @@ -306,6 +307,7 @@ gimp_SOURCES = \ pixmaps2.h \ plug_in.c \ plug_in.h \ + plug_in_cmds.c \ posterize.c \ posterize.h \ preferences_dialog.c \ diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index 872adb61cc..62e304d09f 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/gui/plug-in-commands.c b/app/gui/plug-in-commands.c index 872adb61cc..62e304d09f 100644 --- a/app/gui/plug-in-commands.c +++ b/app/gui/plug-in-commands.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/gui/plug-in-menus.c b/app/gui/plug-in-menus.c index 872adb61cc..62e304d09f 100644 --- a/app/gui/plug-in-menus.c +++ b/app/gui/plug-in-menus.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/interface_cmds.c b/app/interface_cmds.c new file mode 100644 index 0000000000..a036c3538b --- /dev/null +++ b/app/interface_cmds.c @@ -0,0 +1,153 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* NOTE: This file is autogenerated by pdbgen.pl. */ + +#include "procedural_db.h" + +#include "appenv.h" + +static ProcRecord message_proc; +static ProcRecord message_get_handler_proc; +static ProcRecord message_set_handler_proc; + +void +register_interface_procs (void) +{ + procedural_db_register (&message_proc); + procedural_db_register (&message_get_handler_proc); + procedural_db_register (&message_set_handler_proc); +} + +static Argument * +message_invoker (Argument *args) +{ + gboolean success = TRUE; + gchar *message; + + message = (gchar *) args[0].value.pdb_pointer; + if (message == NULL) + success = FALSE; + + if (success) + g_message (message, NULL, NULL); + + return procedural_db_return_args (&message_proc, success); +} + +static ProcArg message_inargs[] = +{ + { + PDB_STRING, + "message", + "Message to display in the dialog" + } +}; + +static ProcRecord message_proc = +{ + "gimp_message", + "Displays a dialog box with a message.", + "Displays a dialog box with a message. Useful for status or error reporting.", + "Manish Singh", + "Manish Singh", + "1998", + PDB_INTERNAL, + 1, + message_inargs, + 0, + NULL, + { { message_invoker } } +}; + +static Argument * +message_get_handler_invoker (Argument *args) +{ + Argument *return_args; + + return_args = procedural_db_return_args (&message_get_handler_proc, TRUE); + return_args[1].value.pdb_int = message_handler; + + return return_args; +} + +static ProcArg message_get_handler_outargs[] = +{ + { + PDB_INT32, + "handler", + "The current handler type: { MESSAGE_BOX (0), CONSOLE (1), ERROR_CONSOLE (2) }" + } +}; + +static ProcRecord message_get_handler_proc = +{ + "gimp_message_get_handler", + "Returns the current state of where warning messages are displayed.", + "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", + "Manish Singh", + "Manish Singh", + "1998", + PDB_INTERNAL, + 0, + NULL, + 1, + message_get_handler_outargs, + { { message_get_handler_invoker } } +}; + +static Argument * +message_set_handler_invoker (Argument *args) +{ + gboolean success = TRUE; + gint32 handler; + + handler = args[0].value.pdb_int; + if (handler < MESSAGE_BOX || handler > ERROR_CONSOLE) + success = FALSE; + + if (success) + message_handler = handler; + + return procedural_db_return_args (&message_set_handler_proc, success); +} + +static ProcArg message_set_handler_inargs[] = +{ + { + PDB_INT32, + "handler", + "The new handler type: { MESSAGE_BOX (0), CONSOLE (1), ERROR_CONSOLE (2) }" + } +}; + +static ProcRecord message_set_handler_proc = +{ + "gimp_message_set_handler", + "Controls where warning messages are displayed.", + "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", + "Manish Singh", + "Manish Singh", + "1998", + PDB_INTERNAL, + 1, + message_set_handler_inargs, + 0, + NULL, + { { message_set_handler_invoker } } +}; diff --git a/app/internal_procs.c b/app/internal_procs.c index 6f2640f0fc..de40e0909b 100644 --- a/app/internal_procs.c +++ b/app/internal_procs.c @@ -44,6 +44,7 @@ void register_gimprc_procs (void); void register_gradient_procs (void); void register_gradient_select_procs (void); void register_guides_procs (void); +void register_interface_procs (void); void register_layer_procs (void); void register_misc_procs (void); void register_palette_procs (void); @@ -51,13 +52,14 @@ void register_parasite_procs (void); void register_paths_procs (void); void register_pattern_select_procs (void); void register_patterns_procs (void); +void register_plug_in_procs (void); void register_procedural_db_procs (void); void register_text_tool_procs (void); void register_tools_procs (void); void register_undo_procs (void); void register_unit_procs (void); -/* 288 procedures registered total */ +/* 295 procedures registered total */ void internal_procs_init (void) @@ -68,84 +70,90 @@ internal_procs_init (void) app_init_update_status (NULL, _("Brushes"), 0.01); register_brushes_procs (); - app_init_update_status (NULL, _("Channel"), 0.049); + app_init_update_status (NULL, _("Channel"), 0.047); register_channel_procs (); - app_init_update_status (NULL, _("Channel Ops"), 0.097); + app_init_update_status (NULL, _("Channel Ops"), 0.095); register_channel_ops_procs (); - app_init_update_status (NULL, _("Color"), 0.104); + app_init_update_status (NULL, _("Color"), 0.102); register_color_procs (); - app_init_update_status (NULL, _("Convert"), 0.146); + app_init_update_status (NULL, _("Convert"), 0.142); register_convert_procs (); - app_init_update_status (NULL, _("Drawable procedures"), 0.16); + app_init_update_status (NULL, _("Drawable procedures"), 0.156); register_drawable_procs (); - app_init_update_status (NULL, _("Edit procedures"), 0.233); + app_init_update_status (NULL, _("Edit procedures"), 0.227); register_edit_procs (); - app_init_update_status (NULL, _("File Operations"), 0.253); + app_init_update_status (NULL, _("File Operations"), 0.247); register_fileops_procs (); - app_init_update_status (NULL, _("Floating selections"), 0.274); + app_init_update_status (NULL, _("Floating selections"), 0.268); register_floating_sel_procs (); - app_init_update_status (NULL, _("GDisplay procedures"), 0.295); + app_init_update_status (NULL, _("GDisplay procedures"), 0.288); register_gdisplay_procs (); - app_init_update_status (NULL, _("Image"), 0.306); + app_init_update_status (NULL, _("Image"), 0.298); register_gimage_procs (); - app_init_update_status (NULL, _("Image mask"), 0.49); + app_init_update_status (NULL, _("Image mask"), 0.478); register_gimage_mask_procs (); - app_init_update_status (NULL, _("Gimprc procedures"), 0.549); + app_init_update_status (NULL, _("Gimprc procedures"), 0.536); register_gimprc_procs (); - app_init_update_status (NULL, _("Gradients"), 0.556); + app_init_update_status (NULL, _("Gradients"), 0.542); register_gradient_procs (); - app_init_update_status (NULL, _("Gradient UI"), 0.573); + app_init_update_status (NULL, _("Gradient UI"), 0.559); register_gradient_select_procs (); - app_init_update_status (NULL, _("Guide procedures"), 0.587); + app_init_update_status (NULL, _("Guide procedures"), 0.573); register_guides_procs (); - app_init_update_status (NULL, _("Layer"), 0.608); + app_init_update_status (NULL, _("Interface"), 0.593); + register_interface_procs (); + + app_init_update_status (NULL, _("Layer"), 0.603); register_layer_procs (); - app_init_update_status (NULL, _("Miscellaneous"), 0.712); + app_init_update_status (NULL, _("Miscellaneous"), 0.705); register_misc_procs (); - app_init_update_status (NULL, _("Palette"), 0.719); + app_init_update_status (NULL, _("Palette"), 0.712); register_palette_procs (); - app_init_update_status (NULL, _("Parasite procedures"), 0.743); + app_init_update_status (NULL, _("Parasite procedures"), 0.736); register_parasite_procs (); - app_init_update_status (NULL, _("Paths"), 0.788); + app_init_update_status (NULL, _("Paths"), 0.78); register_paths_procs (); - app_init_update_status (NULL, _("Pattern UI"), 0.819); + app_init_update_status (NULL, _("Pattern UI"), 0.81); register_pattern_select_procs (); - app_init_update_status (NULL, _("Patterns"), 0.83); + app_init_update_status (NULL, _("Patterns"), 0.82); register_patterns_procs (); - app_init_update_status (NULL, _("Procedural database"), 0.844); + app_init_update_status (NULL, _("Plug-in"), 0.834); + register_plug_in_procs (); + + app_init_update_status (NULL, _("Procedural database"), 0.847); register_procedural_db_procs (); - app_init_update_status (NULL, _("Text procedures"), 0.872); + app_init_update_status (NULL, _("Text procedures"), 0.875); register_text_tool_procs (); - app_init_update_status (NULL, _("Tool procedures"), 0.885); + app_init_update_status (NULL, _("Tool procedures"), 0.888); register_tools_procs (); - app_init_update_status (NULL, _("Undo"), 0.955); + app_init_update_status (NULL, _("Undo"), 0.956); register_undo_procs (); - app_init_update_status (NULL, _("Units"), 0.962); + app_init_update_status (NULL, _("Units"), 0.963); register_unit_procs (); } diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index 872adb61cc..62e304d09f 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/gimpplugin-progress.h b/app/plug-in/gimpplugin-progress.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/gimpplugin-progress.h +++ b/app/plug-in/gimpplugin-progress.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/gimpplugin.h b/app/plug-in/gimpplugin.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/gimpplugin.h +++ b/app/plug-in/gimpplugin.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/gimppluginmanager.h b/app/plug-in/gimppluginmanager.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/gimppluginmanager.h +++ b/app/plug-in/gimppluginmanager.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in-def.c b/app/plug-in/plug-in-def.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-in-def.c +++ b/app/plug-in/plug-in-def.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in-def.h b/app/plug-in/plug-in-def.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/plug-in-def.h +++ b/app/plug-in/plug-in-def.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in-params.c b/app/plug-in/plug-in-params.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-in-params.c +++ b/app/plug-in/plug-in-params.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in-params.h b/app/plug-in/plug-in-params.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/plug-in-params.h +++ b/app/plug-in/plug-in-params.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug-in/plug-in-progress.c b/app/plug-in/plug-in-progress.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-in-progress.c +++ b/app/plug-in/plug-in-progress.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in-progress.h b/app/plug-in/plug-in-progress.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/plug-in-progress.h +++ b/app/plug-in/plug-in-progress.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-in.h b/app/plug-in/plug-in.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/plug-in.h +++ b/app/plug-in/plug-in.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index 872adb61cc..62e304d09f 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug-in/plug-ins.h b/app/plug-in/plug-ins.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug-in/plug-ins.h +++ b/app/plug-in/plug-ins.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug_in.c b/app/plug_in.c index 872adb61cc..62e304d09f 100644 --- a/app/plug_in.c +++ b/app/plug_in.c @@ -102,8 +102,6 @@ #include "libgimp/gimpintl.h" - - typedef struct _PlugInBlocked PlugInBlocked; struct _PlugInBlocked @@ -160,28 +158,16 @@ static void plug_in_args_destroy (Argument *args, int nargs, int full_destroy); -static Argument* progress_init_invoker (Argument *args); -static Argument* progress_update_invoker (Argument *args); - -static Argument* message_invoker (Argument *args); - -static Argument* message_handler_get_invoker (Argument *args); -static Argument* message_handler_set_invoker (Argument *args); - -static Argument* plugin_temp_PDB_name_invoker (Argument *args); - -static Argument* plugins_query_invoker (Argument *args); - +PlugIn *current_plug_in = NULL; +GSList *proc_defs = NULL; static GSList *plug_in_defs = NULL; static GSList *gimprc_proc_defs = NULL; -static GSList *proc_defs = NULL; static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static PlugIn *current_plug_in = NULL; static GIOChannel *current_readchannel = NULL; static GIOChannel *current_writechannel = NULL; static int current_write_buffer_index = 0; @@ -200,240 +186,9 @@ static HANDLE shm_handle; static int write_pluginrc = FALSE; -static ProcArg progress_init_args[] = -{ - { PDB_STRING, - "message", - "Message to use in the progress dialog." }, - { PDB_INT32, - "gdisplay", - "GDisplay to update progressbar in, or -1 for a seperate window" } -}; - -static ProcRecord progress_init_proc = -{ - "gimp_progress_init", - "Initializes the progress bar for the current plug-in", - "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 2, - progress_init_args, - 0, - NULL, - { { progress_init_invoker } }, -}; - -static ProcArg progress_update_args[] = -{ - { PDB_FLOAT, - "percentage", - "Percentage of progress completed" } -}; - -static ProcRecord progress_update_proc = -{ - "gimp_progress_update", - "Updates the progress bar for the current plug-in", - "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - progress_update_args, - 0, - NULL, - { { progress_update_invoker } }, -}; - - -static ProcArg message_args[] = -{ - { PDB_STRING, - "message", - "Message to display in the dialog." } -}; - -static ProcRecord message_proc = -{ - "gimp_message", - "Displays a dialog box with a message", - "Displays a dialog box with a message. Useful for status or error reporting.", - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1995-1996", - PDB_INTERNAL, - 1, - message_args, - 0, - NULL, - { { message_invoker } }, -}; - - -static ProcArg message_handler_get_out_args[] = -{ - { PDB_INT32, - "handler", - "the current handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_get_proc = -{ - "gimp_message_handler_get", - "Returns the current state of where warning messages are displayed.", - "This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - message_handler_get_out_args, - { { message_handler_get_invoker } }, -}; - -static ProcArg message_handler_set_args[] = -{ - { PDB_INT32, - "handler", - "the new handler type: { MESSAGE_BOX (0), CONSOLE (1) }" } -}; - -static ProcRecord message_handler_set_proc = -{ - "gimp_message_handler_set", - "Controls where warning messages are displayed.", - "This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where gimp was started.", - "Manish Singh", - "Manish Singh", - "1998", - PDB_INTERNAL, - 1, - message_handler_set_args, - 0, - NULL, - { { message_handler_set_invoker } }, -}; - -static ProcArg plugin_temp_PDB_name_out_args[] = -{ - { PDB_STRING, - "Temp name", - "A unique temporary name for a temporary PDB entry name", - }, -}; - -static ProcRecord plugin_temp_PDB_name_proc = -{ - "gimp_temp_PDB_name", - "Generates a unique temporary PDB name", - "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", - "Andy Thomas", - "Andy Thomas", - "1998", - PDB_INTERNAL, - 0, - NULL, - 1, - plugin_temp_PDB_name_out_args, - { { plugin_temp_PDB_name_invoker } }, -}; - -/* The number keeps getting repeated here because in is required - * by the PDB interface for *ARRAY types. - */ -static ProcArg plugins_query_out_args[] = -{ - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "menu_path", - "the menu path of the plugin" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_accelerator", - "String representing keyboard accelerator (could be empty string)" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_location", - "Location of the plugin program" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_image_type", - "Type of image that this plugin will work on" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_INT32ARRAY, - "plugin_install_time", - "Time that the plugin was installed" - }, - { PDB_INT32, - "num_plugins", - "the number of plugins" - }, - { PDB_STRINGARRAY, - "plugin_real_name", - "The internal name of the plugin" - } -}; - -static ProcArg plugins_query_in_args[] = -{ - { PDB_STRING, - "search_string", - "If not an empty string then use this as a search pattern" - } -}; - - -ProcRecord plugin_query_proc = -{ - "gimp_plugins_query", - "Queries the plugin database for its contents", - "This procedure queries the contents of the plugin database", - "Andy Thomas", - "Andy Thomas", - "1999", - PDB_INTERNAL, - - /* Input arguments */ - sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]), - plugins_query_in_args, - - /* Output arguments */ - sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]), - plugins_query_out_args, - - /* Exec method */ - { { plugins_query_invoker } }, -}; - - void -plug_in_init () +plug_in_init (void) { extern int use_shm; char *filename; @@ -442,22 +197,6 @@ plug_in_init () PlugInProcDef *proc_def; gfloat nplugins, nth; - /* initialize the progress init and update procedure db calls. */ - procedural_db_register (&progress_init_proc); - procedural_db_register (&progress_update_proc); - - /* initialize the message box procedural db calls */ - procedural_db_register (&message_proc); - procedural_db_register (&message_handler_get_proc); - procedural_db_register (&message_handler_set_proc); - - /* initialize the temp name PDB interafce */ - procedural_db_register (&plugin_temp_PDB_name_proc); - - /* initialize the plugin browser */ - procedural_db_register (&plugin_query_proc); - - /* initialize the gimp protocol library and set the read and * write handlers. */ @@ -659,9 +398,8 @@ plug_in_init () } - void -plug_in_kill () +plug_in_kill (void) { GSList *tmp; PlugIn *plug_in; @@ -1618,7 +1356,7 @@ plug_in_handle_message (WireMessage *msg) } static void -plug_in_handle_quit () +plug_in_handle_quit (void) { plug_in_close (current_plug_in, FALSE); } @@ -2190,7 +1928,7 @@ plug_in_push (PlugIn *plug_in) } static void -plug_in_pop () +plug_in_pop (void) { GSList *tmp; @@ -2438,7 +2176,7 @@ plug_in_query (char *filename, } static void -plug_in_add_to_db () +plug_in_add_to_db (void) { PlugInProcDef *proc_def; Argument args[4]; @@ -2492,7 +2230,7 @@ plug_in_add_to_db () } static void -plug_in_make_menu () +plug_in_make_menu (void) { GtkMenuEntry entry; PlugInProcDef *proc_def; @@ -3412,7 +3150,7 @@ plug_in_progress_cancel (GtkWidget *widget, plug_in_destroy (plug_in); } -static void +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID) @@ -3433,7 +3171,7 @@ plug_in_progress_init (PlugIn *plug_in, plug_in_progress_cancel, plug_in); } -static void +void plug_in_progress_update (PlugIn *plug_in, double percentage) { @@ -3442,210 +3180,3 @@ plug_in_progress_update (PlugIn *plug_in, progress_update (plug_in->progress, percentage); } - -static Argument* -progress_init_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_init (current_plug_in, args[0].value.pdb_pointer, - args[1].value.pdb_int); - } - - return procedural_db_return_args (&progress_init_proc, success); -} - -static Argument* -progress_update_invoker (Argument *args) -{ - int success = FALSE; - - if (current_plug_in && current_plug_in->open) - { - success = TRUE; - if (no_interface == FALSE) - plug_in_progress_update (current_plug_in, args[0].value.pdb_float); - } - - return procedural_db_return_args (&progress_update_proc, success); -} - -static Argument* -message_invoker (Argument *args) -{ - g_message (args[0].value.pdb_pointer, NULL, NULL); - return procedural_db_return_args (&message_proc, TRUE); -} - -static Argument* -message_handler_get_invoker (Argument *args) -{ - Argument *return_args; - - return_args = procedural_db_return_args (&message_handler_get_proc, TRUE); - return_args[1].value.pdb_int = message_handler; - return return_args; -} - -static Argument* -message_handler_set_invoker (Argument *args) -{ - int success = TRUE; - - if ((args[0].value.pdb_int >= MESSAGE_BOX) && - (args[0].value.pdb_int <= CONSOLE)) - message_handler = args[0].value.pdb_int; - else - success = FALSE; - - return procedural_db_return_args (&message_handler_set_proc, success); -} - -static Argument* -plugin_temp_PDB_name_invoker (Argument *args) -{ - Argument *return_args; - static gint proc_number = 0; - static gchar *proc_name = "temp_plugin_number_%d"; - static gchar temp_area[20+10]; /* 10 should allow enough plugins! */ - - return_args = procedural_db_return_args (&plugin_temp_PDB_name_proc, TRUE); - sprintf(temp_area,proc_name,proc_number++); - return_args[1].value.pdb_pointer = g_strdup(temp_area); - return return_args; -} - -static int -match_strings (regex_t * preg, - char * a) -{ - int ret = regexec (preg, a, 0, NULL, 0); - return ret; -} - -static Argument* -plugins_query_invoker (Argument *args) -{ - Argument *return_args; - PlugInProcDef *proc_def; - gchar * search_str; - GSList *tmp; - gint i = 0; - guint num_plugins = 0; - gchar * *menu_strs; - gchar * *accel_strs; - gchar * *prog_strs; - gchar * *types_strs; - gchar * *realname_strs; - gint *time_ints; - regex_t sregex; - - /* Get the search string */ - search_str = args[0].value.pdb_pointer; - - if(search_str && strlen(search_str) > 0) - { - regcomp(&sregex,search_str,REG_ICASE); - } - else - search_str = NULL; - - /* count number of plugin entries */ - /* then allocate 4 arrays of correct size where we can store the - * strings. - */ - - tmp = proc_defs; - while (tmp) - { - proc_def = tmp->data; - tmp = tmp->next; - if (proc_def->prog && proc_def->menu_path) - { - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - num_plugins++; - } - } - - return_args = procedural_db_return_args (&plugin_query_proc, TRUE); - - menu_strs = g_new(gchar *,num_plugins); - accel_strs = g_new(gchar *,num_plugins); - prog_strs = g_new(gchar *,num_plugins); - types_strs = g_new(gchar *,num_plugins); - realname_strs = g_new(gchar *,num_plugins); - time_ints = g_new(gint ,num_plugins); - - return_args[1].value.pdb_int = num_plugins; - return_args[2].value.pdb_pointer = menu_strs; - - return_args[3].value.pdb_int = num_plugins; - return_args[4].value.pdb_pointer = accel_strs; - - return_args[5].value.pdb_int = num_plugins; - return_args[6].value.pdb_pointer = prog_strs; - - return_args[7].value.pdb_int = num_plugins; - return_args[8].value.pdb_pointer = types_strs; - - return_args[9].value.pdb_int = num_plugins; - return_args[10].value.pdb_pointer = time_ints; - - return_args[11].value.pdb_int = num_plugins; - return_args[12].value.pdb_pointer = realname_strs; - - tmp = proc_defs; - while (tmp) - { - - if(i > num_plugins) - g_error (_("Internal error counting plugins")); - - proc_def = tmp->data; - tmp = tmp->next; - - if (proc_def->prog && proc_def->menu_path) - { - ProcRecord *pr = &proc_def->db_info; - - gchar * name = strrchr (proc_def->menu_path, '/'); - - if (name) - name = name + 1; - else - name = proc_def->menu_path; - - if(search_str && match_strings(&sregex,name)) - continue; - - menu_strs[i] = g_strdup(proc_def->menu_path); - accel_strs[i] = g_strdup(proc_def->accelerator); - prog_strs[i] = g_strdup(proc_def->prog); - types_strs[i] = g_strdup(proc_def->image_types); - time_ints[i] = proc_def->mtime; - realname_strs[i] = g_strdup(pr->name); - - i++; - } - } - - /* This I hope frees up internal stuff */ - if(search_str) - free (sregex.buffer); - - return return_args; -} - diff --git a/app/plug_in.h b/app/plug_in.h index 3c7032bbc1..446e667d71 100644 --- a/app/plug_in.h +++ b/app/plug_in.h @@ -183,4 +183,10 @@ void plug_in_add_internal (PlugInProcDef* proc_def); GSList* plug_in_extensions_parse (char *extensions); int plug_in_image_types_parse (char *image_types); +void plug_in_progress_init (PlugIn *plug_in, char *message, gint gdisp_ID); +void plug_in_progress_update (PlugIn *plug_in, double percentage); + +extern PlugIn *current_plug_in; +extern GSList *proc_defs; + #endif /* __PLUG_IN_H__ */ diff --git a/app/plug_in_cmds.c b/app/plug_in_cmds.c new file mode 100644 index 0000000000..d1f4e85fca --- /dev/null +++ b/app/plug_in_cmds.c @@ -0,0 +1,378 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* NOTE: This file is autogenerated by pdbgen.pl. */ + +#include "procedural_db.h" + +#include +#include + +#include "appenv.h" +#include "gdisplay.h" +#include "plug_in.h" +#include "regex.h" + +#include "libgimp/gimpintl.h" + +static ProcRecord progress_init_proc; +static ProcRecord progress_update_proc; +static ProcRecord temp_PDB_name_proc; +static ProcRecord plugins_query_proc; + +void +register_plug_in_procs (void) +{ + procedural_db_register (&progress_init_proc); + procedural_db_register (&progress_update_proc); + procedural_db_register (&temp_PDB_name_proc); + procedural_db_register (&plugins_query_proc); +} + +static int +match_strings (regex_t *preg, + gchar *a) +{ + return regexec (preg, a, 0, NULL, 0); +} + +static Argument * +progress_init_invoker (Argument *args) +{ + gchar *message; + gint32 gdisplay; + + message = (gchar *) args[0].value.pdb_pointer; + + gdisplay = args[1].value.pdb_int; + + if (current_plug_in && current_plug_in->open && !no_interface) + plug_in_progress_init (current_plug_in, message, gdisplay); + + return procedural_db_return_args (&progress_init_proc, TRUE); +} + +static ProcArg progress_init_inargs[] = +{ + { + PDB_STRING, + "message", + "Message to use in the progress dialog" + }, + { + PDB_DISPLAY, + "gdisplay", + "GDisplay to update progressbar in, or -1 for a seperate window" + } +}; + +static ProcRecord progress_init_proc = +{ + "gimp_progress_init", + "Initializes the progress bar for the current plug-in.", + "Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + 2, + progress_init_inargs, + 0, + NULL, + { { progress_init_invoker } } +}; + +static Argument * +progress_update_invoker (Argument *args) +{ + gdouble percentage; + + percentage = args[0].value.pdb_float; + + if (current_plug_in && current_plug_in->open && !no_interface) + plug_in_progress_update (current_plug_in, percentage); + + return procedural_db_return_args (&progress_update_proc, TRUE); +} + +static ProcArg progress_update_inargs[] = +{ + { + PDB_FLOAT, + "percentage", + "Percentage of progress completed" + } +}; + +static ProcRecord progress_update_proc = +{ + "gimp_progress_update", + "Updates the progress bar for the current plug-in.", + "Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + 1, + progress_update_inargs, + 0, + NULL, + { { progress_update_invoker } } +}; + +static Argument * +temp_PDB_name_invoker (Argument *args) +{ + Argument *return_args; + gchar *temp_name; + static gint proc_number = 0; + + temp_name = g_strdup_printf ("temp_plugin_number_%d", proc_number++); + + return_args = procedural_db_return_args (&temp_PDB_name_proc, TRUE); + return_args[1].value.pdb_pointer = temp_name; + + return return_args; +} + +static ProcArg temp_PDB_name_outargs[] = +{ + { + PDB_STRING, + "temp_name", + "A unique temporary name for a temporary PDB entry" + } +}; + +static ProcRecord temp_PDB_name_proc = +{ + "gimp_temp_PDB_name", + "Generates a unique temporary PDB name.", + "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.", + "Andy Thomas", + "Andy Thomas", + "1998", + PDB_INTERNAL, + 0, + NULL, + 1, + temp_PDB_name_outargs, + { { temp_PDB_name_invoker } } +}; + +static Argument * +plugins_query_invoker (Argument *args) +{ + Argument *return_args; + gchar *search_str; + gint32 num_plugins = 0; + gchar **menu_strs; + gchar **accel_strs; + gchar **prog_strs; + gchar **types_strs; + gint32 *time_ints; + gchar **realname_strs; + PlugInProcDef *proc_def; + GSList *tmp = NULL; + gint i = 0; + regex_t sregex; + + search_str = (gchar *) args[0].value.pdb_pointer; + + if (search_str && strlen (search_str)) + regcomp (&sregex, search_str, REG_ICASE); + else + search_str = NULL; + + /* count number of plugin entries, then allocate 4 arrays of correct size + * where we can store the strings. + */ + + tmp = proc_defs; + while (tmp) + { + proc_def = tmp->data; + tmp = tmp->next; + + if (proc_def->prog && proc_def->menu_path) + { + gchar *name = strrchr (proc_def->menu_path, '/'); + + if (name) + name = name + 1; + else + name = proc_def->menu_path; + + if (search_str && match_strings (&sregex, name)) + continue; + + num_plugins++; + } + } + + menu_strs = g_new (gchar *, num_plugins); + accel_strs = g_new (gchar *, num_plugins); + prog_strs = g_new (gchar *, num_plugins); + types_strs = g_new (gchar *, num_plugins); + realname_strs = g_new (gchar *, num_plugins); + time_ints = g_new (gint , num_plugins); + + tmp = proc_defs; + while (tmp) + { + if (i > num_plugins) + g_error (_("Internal error counting plugins")); + + proc_def = tmp->data; + tmp = tmp->next; + + if (proc_def->prog && proc_def->menu_path) + { + ProcRecord *pr = &proc_def->db_info; + + gchar *name = strrchr (proc_def->menu_path, '/'); + + if (name) + name = name + 1; + else + name = proc_def->menu_path; + + if (search_str && match_strings(&sregex,name)) + continue; + + menu_strs[i] = g_strdup (proc_def->menu_path); + accel_strs[i] = g_strdup (proc_def->accelerator); + prog_strs[i] = g_strdup (proc_def->prog); + types_strs[i] = g_strdup (proc_def->image_types); + realname_strs[i] = g_strdup (pr->name); + time_ints[i] = proc_def->mtime; + + i++; + } + } + + /* This I hope frees up internal stuff */ + if (search_str) + free (sregex.buffer); + + return_args = procedural_db_return_args (&plugins_query_proc, TRUE); + + return_args[1].value.pdb_int = num_plugins; + return_args[2].value.pdb_pointer = menu_strs; + return_args[3].value.pdb_int = num_plugins; + return_args[4].value.pdb_pointer = accel_strs; + return_args[5].value.pdb_int = num_plugins; + return_args[6].value.pdb_pointer = prog_strs; + return_args[7].value.pdb_int = num_plugins; + return_args[8].value.pdb_pointer = types_strs; + return_args[9].value.pdb_int = num_plugins; + return_args[10].value.pdb_pointer = time_ints; + return_args[11].value.pdb_int = num_plugins; + return_args[12].value.pdb_pointer = realname_strs; + + return return_args; +} + +static ProcArg plugins_query_inargs[] = +{ + { + PDB_STRING, + "search_string", + "If not an empty string then use this as a search pattern" + } +}; + +static ProcArg plugins_query_outargs[] = +{ + { + PDB_INT32, + "num_plugins", + "The number of plugins" + }, + { + PDB_STRINGARRAY, + "menu_path", + "The menu path of the plugin" + }, + { + PDB_INT32, + "num_plugins", + "The number of plugins" + }, + { + PDB_STRINGARRAY, + "plugin_accelerator", + "String representing keyboard accelerator (could be empty string)" + }, + { + PDB_INT32, + "num_plugins", + "The number of plugins" + }, + { + PDB_STRINGARRAY, + "plugin_location", + "Location of the plugin program" + }, + { + PDB_INT32, + "num_plugins", + "The number of plugins" + }, + { + PDB_STRINGARRAY, + "plugin_image_type", + "Type of image that this plugin will work on" + }, + { + PDB_INT32, + "num_plugins", + "The number of plugins" + }, + { + PDB_INT32ARRAY, + "plugin_install_time", + "Time that the plugin was installed" + }, + { + PDB_INT32, + "num_plugins", + "The number of plugins" + }, + { + PDB_STRINGARRAY, + "plugin_real_name", + "The internal name of the plugin" + } +}; + +static ProcRecord plugins_query_proc = +{ + "gimp_plugins_query", + "Queries the plugin database for its contents.", + "This procedure queries the contents of the plugin database.", + "Andy Thomas", + "Andy Thomas", + "1998", + PDB_INTERNAL, + 1, + plugins_query_inargs, + 12, + plugins_query_outargs, + { { plugins_query_invoker } } +}; diff --git a/tools/pdbgen/Makefile.am b/tools/pdbgen/Makefile.am index 4252e7268a..cfcab25ff3 100644 --- a/tools/pdbgen/Makefile.am +++ b/tools/pdbgen/Makefile.am @@ -19,6 +19,7 @@ pdb_sources = \ pdb/gradient.pdb \ pdb/gradient_select.pdb \ pdb/guides.pdb \ + pdb/interface.pdb \ pdb/layer.pdb \ pdb/misc.pdb \ pdb/palette.pdb \ @@ -26,6 +27,7 @@ pdb_sources = \ pdb/paths.pdb \ pdb/pattern_select.pdb \ pdb/patterns.pdb \ + pdb/plug_in.pdb \ pdb/procedural_db.pdb \ pdb/text_tool.pdb \ pdb/tools.pdb \ @@ -45,27 +47,28 @@ EXTRA_DIST = \ $(pdb_sources) enum_headers = \ - $(top_srcdir)/app/convert.h \ - $(top_srcdir)/app/channel_ops.h \ - $(top_srcdir)/app/text_tool.h \ - $(top_srcdir)/app/gimpdrawable.h \ - $(top_srcdir)/app/gimpimage.h \ - $(top_srcdir)/app/procedural_db.h \ - $(top_srcdir)/app/paint_funcs.h \ + $(top_srcdir)/app/appenv.h \ $(top_srcdir)/app/blend.h \ $(top_srcdir)/app/bucket_fill.h \ - $(top_srcdir)/app/clone.h \ - $(top_srcdir)/app/convolve.h \ $(top_srcdir)/app/channel.h \ - $(top_srcdir)/app/eraser.h \ - $(top_srcdir)/app/paint_core.h \ - $(top_srcdir)/app/lut_funcs.h \ - $(top_srcdir)/app/shear_tool.h \ + $(top_srcdir)/app/channel_ops.h \ + $(top_srcdir)/app/clone.h \ $(top_srcdir)/app/color_balance.h \ + $(top_srcdir)/app/convert.h \ + $(top_srcdir)/app/convolve.h \ + $(top_srcdir)/app/eraser.h \ + $(top_srcdir)/app/gimpdrawable.h \ + $(top_srcdir)/app/gimpimage.h \ $(top_srcdir)/app/hue_saturation.h \ + $(top_srcdir)/app/layer.h \ $(top_srcdir)/app/layerF.h \ - $(top_srcdir)/app/layer.h \ - $(top_srcdir)/app/plug_in.h + $(top_srcdir)/app/lut_funcs.h \ + $(top_srcdir)/app/paint_core.h \ + $(top_srcdir)/app/paint_funcs.h \ + $(top_srcdir)/app/plug_in.h \ + $(top_srcdir)/app/procedural_db.h \ + $(top_srcdir)/app/shear_tool.h \ + $(top_srcdir)/app/text_tool.h pdb_scripts = \ $(srcdir)/pdbgen.pl \ @@ -77,7 +80,7 @@ pdb_scripts = \ $(srcdir)/enums.pl: stamp-enums @: -stamp-enums: $(srcdir)/enumgen.pl $(enum_headers) +stamp-enums: $(srcdir)/enumgen.pl $(enum_headers) Makefile.am (srcdir=$(srcdir) && $(PERL) enumgen.pl $(enum_headers)) \ && echo timestamp > stamp-enums diff --git a/tools/pdbgen/app.pl b/tools/pdbgen/app.pl index e16d2f3d38..2eeddb9e2e 100644 --- a/tools/pdbgen/app.pl +++ b/tools/pdbgen/app.pl @@ -136,7 +136,9 @@ sub declare_args { } unless (exists $_->{no_declare}) { - $result .= ' ' x 2 . $arg->{type} . &arg_vname($_); + my $type = exists $_->{no_id_lookup} ? 'gint32 ' : $arg->{type}; + + $result .= ' ' x 2 . $type . &arg_vname($_); if (!exists $_->{no_init} && exists $_->{init}) { $result .= $arg->{type} =~ /\*$/ ? ' = NULL' : ' = 0' } @@ -237,7 +239,7 @@ sub marshal_inargs { my $var = &arg_vname($_); my $value = &arg_value($arg, $argc++); - if (exists $arg->{id_func}) { + if (exists $arg->{id_func} && !exists $_->{no_id_lookup}) { my $id_func = $arg->{id_func}; $id_func = $_->{id_func} if exists $_->{id_func}; diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl index 6fb3aaba33..49812d7e45 100644 --- a/tools/pdbgen/enums.pl +++ b/tools/pdbgen/enums.pl @@ -20,6 +20,94 @@ package Gimp::CodeGen::enums; %enums = ( + MessageHandlerType => + { contig => 1, + header => 'appenv.h', + symbols => [ qw(MESSAGE_BOX CONSOLE ERROR_CONSOLE) ], + mapping => { MESSAGE_BOX => '0', + CONSOLE => '1', + ERROR_CONSOLE => '2' } + }, + GradientType => + { contig => 1, + header => 'blend.h', + symbols => [ qw(LINEAR BILINEAR RADIAL SQUARE CONICAL_SYMMETRIC + CONICAL_ASYMMETRIC SHAPEBURST_ANGULAR + SHAPEBURST_SPHERICAL SHAPEBURST_DIMPLED + SPIRAL_CLOCKWISE SPIRAL_ANTICLOCKWISE) ], + mapping => { LINEAR => '0', + BILINEAR => '1', + RADIAL => '2', + SQUARE => '3', + CONICAL_SYMMETRIC => '4', + CONICAL_ASYMMETRIC => '5', + SHAPEBURST_ANGULAR => '6', + SHAPEBURST_SPHERICAL => '7', + SHAPEBURST_DIMPLED => '8', + SPIRAL_CLOCKWISE => '9', + SPIRAL_ANTICLOCKWISE => '10' } + }, + BlendMode => + { contig => 1, + header => 'blend.h', + symbols => [ qw(FG_BG_RGB_MODE FG_BG_HSV_MODE FG_TRANS_MODE + CUSTOM_MODE) ], + mapping => { FG_BG_RGB_MODE => '0', + FG_BG_HSV_MODE => '1', + FG_TRANS_MODE => '2', + CUSTOM_MODE => '3' }, + nicks => { FG_BG_RGB_MODE => 'FG_BG_RGB', + FG_BG_HSV_MODE => 'FG_BG_HSV', + FG_TRANS_MODE => 'FG_TRANS', + CUSTOM_MODE => 'CUSTOM' } + }, + RepeatMode => + { contig => 1, + header => 'blend.h', + symbols => [ qw(REPEAT_NONE REPEAT_SAWTOOTH REPEAT_TRIANGULAR) ], + mapping => { REPEAT_NONE => '0', + REPEAT_SAWTOOTH => '1', + REPEAT_TRIANGULAR => '2' } + }, + BucketFillMode => + { contig => 1, + header => 'bucket_fill.h', + symbols => [ qw(FG_BUCKET_FILL BG_BUCKET_FILL PATTERN_BUCKET_FILL) ], + mapping => { FG_BUCKET_FILL => '0', + BG_BUCKET_FILL => '1', + PATTERN_BUCKET_FILL => '2' } + }, + ChannelOps => + { contig => 1, + header => 'channel.h', + symbols => [ qw(ADD SUB REPLACE INTERSECT) ], + mapping => { ADD => '0', + SUB => '1', + REPLACE => '2', + INTERSECT => '3' } + }, + ChannelOffsetType => + { contig => 1, + header => 'channel_ops.h', + symbols => [ qw(OFFSET_BACKGROUND OFFSET_TRANSPARENT) ], + mapping => { OFFSET_BACKGROUND => '0', + OFFSET_TRANSPARENT => '1' } + }, + CloneType => + { contig => 1, + header => 'clone.h', + symbols => [ qw(IMAGE_CLONE PATTERN_CLONE) ], + mapping => { IMAGE_CLONE => '0', + PATTERN_CLONE => '1' } + }, + TransferMode => + { contig => 1, + header => 'color_balance.h', + symbols => [ qw(SHADOWS MIDTONES HIGHLIGHTS) ], + mapping => { SHADOWS => '0', + MIDTONES => '1', + HIGHLIGHTS => '2' } + }, ConvertPaletteType => { contig => 1, header => 'convert.h', @@ -31,19 +119,16 @@ package Gimp::CodeGen::enums; MONO_PALETTE => '3', CUSTOM_PALETTE => '4' } }, - ChannelOffsetType => + ConvolveType => { contig => 1, - header => 'channel_ops.h', - symbols => [ qw(OFFSET_BACKGROUND OFFSET_TRANSPARENT) ], - mapping => { OFFSET_BACKGROUND => '0', - OFFSET_TRANSPARENT => '1' } - }, - SizeType => - { contig => 1, - header => 'text_tool.h', - symbols => [ qw(PIXELS POINTS) ], - mapping => { PIXELS => '0', - POINTS => '1' } + header => 'convolve.h', + symbols => [ qw(BLUR_CONVOLVE SHARPEN_CONVOLVE CUSTOM_CONVOLVE) ], + mapping => { BLUR_CONVOLVE => '0', + SHARPEN_CONVOLVE => '1', + CUSTOM_CONVOLVE => '2' }, + nicks => { BLUR_CONVOLVE => 'BLUR', + SHARPEN_CONVOLVE => 'SHARPEN', + CUSTOM_CONVOLVE => 'CUSTOM' } }, GimpFillType => { contig => 1, @@ -113,6 +198,137 @@ package Gimp::CodeGen::enums; CLIP_TO_BOTTOM_LAYER => '2', FLATTEN_IMAGE => '3' } }, + HueRange => + { contig => 1, + header => 'hue_saturation.h', + symbols => [ qw(ALL_HUES RED_HUES YELLOW_HUES GREEN_HUES CYAN_HUES + BLUE_HUES MAGENTA_HUES) ], + mapping => { ALL_HUES => '0', + RED_HUES => '1', + YELLOW_HUES => '2', + GREEN_HUES => '3', + CYAN_HUES => '4', + BLUE_HUES => '5', + MAGENTA_HUES => '6' } + }, + MaskApplyMode => + { contig => 1, + header => 'layer.h', + symbols => [ qw(APPLY DISCARD) ], + mapping => { APPLY => '0', + DISCARD => '1' } + }, + AddMaskType => + { contig => 1, + header => 'layerF.h', + symbols => [ qw(ADD_WHITE_MASK ADD_BLACK_MASK ADD_ALPHA_MASK) ], + mapping => { ADD_WHITE_MASK => '0', + ADD_BLACK_MASK => '1', + ADD_ALPHA_MASK => '2' }, + nicks => { ADD_WHITE_MASK => 'WHITE_MASK', + ADD_BLACK_MASK => 'BLACK_MASK', + ADD_ALPHA_MASK => 'ALPHA_MASK' } + }, + ChannelLutType => + { contig => 1, + header => 'lut_funcs.h', + symbols => [ qw(VALUE_LUT RED_LUT GREEN_LUT BLUE_LUT ALPHA_LUT) ], + mapping => { VALUE_LUT => '0', + RED_LUT => '1', + GREEN_LUT => '2', + BLUE_LUT => '3', + ALPHA_LUT => '4' }, + nicks => { VALUE_LUT => 'VALUE/GRAY', + RED_LUT => 'RED', + GREEN_LUT => 'GREEN', + BLUE_LUT => 'BLUE', + ALPHA_LUT => 'ALPHA' } + }, + BrushApplicationMode => + { contig => 1, + header => 'paint_core.h', + symbols => [ qw(HARD SOFT PRESSURE) ], + mapping => { HARD => '0', + SOFT => '1', + PRESSURE => '2' } + }, + PaintApplicationMode => + { contig => 1, + header => 'paint_core.h', + symbols => [ qw(CONSTANT INCREMENTAL) ], + mapping => { CONSTANT => '0', + INCREMENTAL => '1' }, + nicks => { CONSTANT => 'CONTINUOUS' } + }, + GradientPaintMode => + { contig => 1, + header => 'paint_core.h', + symbols => [ qw(ONCE_FORWARD ONCE_BACKWARDS LOOP_SAWTOOTH + LOOP_TRIANGLE ONCE_END_COLOR) ], + mapping => { ONCE_FORWARD => '0', + ONCE_BACKWARDS => '1', + LOOP_SAWTOOTH => '2', + LOOP_TRIANGLE => '3', + ONCE_END_COLOR => '4' } + }, + LayerModeEffects => + { contig => 1, + header => 'paint_funcs.h', + symbols => [ qw(NORMAL_MODE DISSOLVE_MODE BEHIND_MODE + MULTIPLY_MODE SCREEN_MODE OVERLAY_MODE + DIFFERENCE_MODE ADDITION_MODE SUBTRACT_MODE + DARKEN_ONLY_MODE LIGHTEN_ONLY_MODE HUE_MODE + SATURATION_MODE COLOR_MODE VALUE_MODE DIVIDE_MODE + ERASE_MODE REPLACE_MODE) ], + mapping => { NORMAL_MODE => '0', + DISSOLVE_MODE => '1', + BEHIND_MODE => '2', + MULTIPLY_MODE => '3', + SCREEN_MODE => '4', + OVERLAY_MODE => '5', + DIFFERENCE_MODE => '6', + ADDITION_MODE => '7', + SUBTRACT_MODE => '8', + DARKEN_ONLY_MODE => '9', + LIGHTEN_ONLY_MODE => '10', + HUE_MODE => '11', + SATURATION_MODE => '12', + COLOR_MODE => '13', + VALUE_MODE => '14', + DIVIDE_MODE => '15', + ERASE_MODE => '16', + REPLACE_MODE => '17' }, + nicks => { NORMAL_MODE => 'NORMAL', + DISSOLVE_MODE => 'DISSOLVE', + BEHIND_MODE => 'BEHIND', + MULTIPLY_MODE => 'MULTIPLY/BURN', + SCREEN_MODE => 'SCREEN', + OVERLAY_MODE => 'OVERLAY', + DIFFERENCE_MODE => 'DIFFERENCE', + ADDITION_MODE => 'ADDITION', + SUBTRACT_MODE => 'SUBTRACT', + DARKEN_ONLY_MODE => 'DARKEN_ONLY', + LIGHTEN_ONLY_MODE => 'LIGHTEN_ONLY', + HUE_MODE => 'HUE', + SATURATION_MODE => 'SATURATION', + COLOR_MODE => 'COLOR', + VALUE_MODE => 'VALUE', + DIVIDE_MODE => 'DIVIDE/DODGE', + ERASE_MODE => 'ERASE', + REPLACE_MODE => 'REPLACE' } + }, + RunModeType => + { contig => 1, + header => 'plug_in.h', + symbols => [ qw(RUN_INTERACTIVE RUN_NONINTERACTIVE + RUN_WITH_LAST_VALS) ], + mapping => { RUN_INTERACTIVE => '0', + RUN_NONINTERACTIVE => '1', + RUN_WITH_LAST_VALS => '2' }, + nicks => { RUN_INTERACTIVE => 'INTERACTIVE', + RUN_NONINTERACTIVE => 'NONINTERACTIVE', + RUN_WITH_LAST_VALS => 'WITH_LAST_VALS' } + }, PDBArgType => { contig => 1, header => 'procedural_db.h', @@ -166,170 +382,6 @@ package Gimp::CodeGen::enums; PDB_PLUGIN => 'PLUGIN', PDB_EXTENSION => 'EXTENSION' } }, - LayerModeEffects => - { contig => 1, - header => 'paint_funcs.h', - symbols => [ qw(NORMAL_MODE DISSOLVE_MODE BEHIND_MODE - MULTIPLY_MODE SCREEN_MODE OVERLAY_MODE - DIFFERENCE_MODE ADDITION_MODE SUBTRACT_MODE - DARKEN_ONLY_MODE LIGHTEN_ONLY_MODE HUE_MODE - SATURATION_MODE COLOR_MODE VALUE_MODE DIVIDE_MODE - ERASE_MODE REPLACE_MODE) ], - mapping => { NORMAL_MODE => '0', - DISSOLVE_MODE => '1', - BEHIND_MODE => '2', - MULTIPLY_MODE => '3', - SCREEN_MODE => '4', - OVERLAY_MODE => '5', - DIFFERENCE_MODE => '6', - ADDITION_MODE => '7', - SUBTRACT_MODE => '8', - DARKEN_ONLY_MODE => '9', - LIGHTEN_ONLY_MODE => '10', - HUE_MODE => '11', - SATURATION_MODE => '12', - COLOR_MODE => '13', - VALUE_MODE => '14', - DIVIDE_MODE => '15', - ERASE_MODE => '16', - REPLACE_MODE => '17' }, - nicks => { NORMAL_MODE => 'NORMAL', - DISSOLVE_MODE => 'DISSOLVE', - BEHIND_MODE => 'BEHIND', - MULTIPLY_MODE => 'MULTIPLY/BURN', - SCREEN_MODE => 'SCREEN', - OVERLAY_MODE => 'OVERLAY', - DIFFERENCE_MODE => 'DIFFERENCE', - ADDITION_MODE => 'ADDITION', - SUBTRACT_MODE => 'SUBTRACT', - DARKEN_ONLY_MODE => 'DARKEN_ONLY', - LIGHTEN_ONLY_MODE => 'LIGHTEN_ONLY', - HUE_MODE => 'HUE', - SATURATION_MODE => 'SATURATION', - COLOR_MODE => 'COLOR', - VALUE_MODE => 'VALUE', - DIVIDE_MODE => 'DIVIDE/DODGE', - ERASE_MODE => 'ERASE', - REPLACE_MODE => 'REPLACE' } - }, - GradientType => - { contig => 1, - header => 'blend.h', - symbols => [ qw(LINEAR BILINEAR RADIAL SQUARE CONICAL_SYMMETRIC - CONICAL_ASYMMETRIC SHAPEBURST_ANGULAR - SHAPEBURST_SPHERICAL SHAPEBURST_DIMPLED - SPIRAL_CLOCKWISE SPIRAL_ANTICLOCKWISE) ], - mapping => { LINEAR => '0', - BILINEAR => '1', - RADIAL => '2', - SQUARE => '3', - CONICAL_SYMMETRIC => '4', - CONICAL_ASYMMETRIC => '5', - SHAPEBURST_ANGULAR => '6', - SHAPEBURST_SPHERICAL => '7', - SHAPEBURST_DIMPLED => '8', - SPIRAL_CLOCKWISE => '9', - SPIRAL_ANTICLOCKWISE => '10' } - }, - BlendMode => - { contig => 1, - header => 'blend.h', - symbols => [ qw(FG_BG_RGB_MODE FG_BG_HSV_MODE FG_TRANS_MODE - CUSTOM_MODE) ], - mapping => { FG_BG_RGB_MODE => '0', - FG_BG_HSV_MODE => '1', - FG_TRANS_MODE => '2', - CUSTOM_MODE => '3' }, - nicks => { FG_BG_RGB_MODE => 'FG_BG_RGB', - FG_BG_HSV_MODE => 'FG_BG_HSV', - FG_TRANS_MODE => 'FG_TRANS', - CUSTOM_MODE => 'CUSTOM' } - }, - RepeatMode => - { contig => 1, - header => 'blend.h', - symbols => [ qw(REPEAT_NONE REPEAT_SAWTOOTH REPEAT_TRIANGULAR) ], - mapping => { REPEAT_NONE => '0', - REPEAT_SAWTOOTH => '1', - REPEAT_TRIANGULAR => '2' } - }, - BucketFillMode => - { contig => 1, - header => 'bucket_fill.h', - symbols => [ qw(FG_BUCKET_FILL BG_BUCKET_FILL PATTERN_BUCKET_FILL) ], - mapping => { FG_BUCKET_FILL => '0', - BG_BUCKET_FILL => '1', - PATTERN_BUCKET_FILL => '2' } - }, - CloneType => - { contig => 1, - header => 'clone.h', - symbols => [ qw(IMAGE_CLONE PATTERN_CLONE) ], - mapping => { IMAGE_CLONE => '0', - PATTERN_CLONE => '1' } - }, - ConvolveType => - { contig => 1, - header => 'convolve.h', - symbols => [ qw(BLUR_CONVOLVE SHARPEN_CONVOLVE CUSTOM_CONVOLVE) ], - mapping => { BLUR_CONVOLVE => '0', - SHARPEN_CONVOLVE => '1', - CUSTOM_CONVOLVE => '2' }, - nicks => { BLUR_CONVOLVE => 'BLUR', - SHARPEN_CONVOLVE => 'SHARPEN', - CUSTOM_CONVOLVE => 'CUSTOM' } - }, - ChannelOps => - { contig => 1, - header => 'channel.h', - symbols => [ qw(ADD SUB REPLACE INTERSECT) ], - mapping => { ADD => '0', - SUB => '1', - REPLACE => '2', - INTERSECT => '3' } - }, - BrushApplicationMode => - { contig => 1, - header => 'paint_core.h', - symbols => [ qw(HARD SOFT PRESSURE) ], - mapping => { HARD => '0', - SOFT => '1', - PRESSURE => '2' } - }, - PaintApplicationMode => - { contig => 1, - header => 'paint_core.h', - symbols => [ qw(CONSTANT INCREMENTAL) ], - mapping => { CONSTANT => '0', - INCREMENTAL => '1' }, - nicks => { CONSTANT => 'CONTINUOUS' } - }, - GradientPaintMode => - { contig => 1, - header => 'paint_core.h', - symbols => [ qw(ONCE_FORWARD ONCE_BACKWARDS LOOP_SAWTOOTH - LOOP_TRIANGLE ONCE_END_COLOR) ], - mapping => { ONCE_FORWARD => '0', - ONCE_BACKWARDS => '1', - LOOP_SAWTOOTH => '2', - LOOP_TRIANGLE => '3', - ONCE_END_COLOR => '4' } - }, - ChannelLutType => - { contig => 1, - header => 'lut_funcs.h', - symbols => [ qw(VALUE_LUT RED_LUT GREEN_LUT BLUE_LUT ALPHA_LUT) ], - mapping => { VALUE_LUT => '0', - RED_LUT => '1', - GREEN_LUT => '2', - BLUE_LUT => '3', - ALPHA_LUT => '4' }, - nicks => { VALUE_LUT => 'VALUE/GRAY', - RED_LUT => 'RED', - GREEN_LUT => 'GREEN', - BLUE_LUT => 'BLUE', - ALPHA_LUT => 'ALPHA' } - }, ShearType => { contig => 1, header => 'shear_tool.h', @@ -339,56 +391,12 @@ package Gimp::CodeGen::enums; nicks => { HORZ_SHEAR => 'HORIZONTAL', VERT_SHEAR => 'VERTICAL' } }, - TransferMode => + SizeType => { contig => 1, - header => 'color_balance.h', - symbols => [ qw(SHADOWS MIDTONES HIGHLIGHTS) ], - mapping => { SHADOWS => '0', - MIDTONES => '1', - HIGHLIGHTS => '2' } - }, - HueRange => - { contig => 1, - header => 'hue_saturation.h', - symbols => [ qw(ALL_HUES RED_HUES YELLOW_HUES GREEN_HUES CYAN_HUES - BLUE_HUES MAGENTA_HUES) ], - mapping => { ALL_HUES => '0', - RED_HUES => '1', - YELLOW_HUES => '2', - GREEN_HUES => '3', - CYAN_HUES => '4', - BLUE_HUES => '5', - MAGENTA_HUES => '6' } - }, - AddMaskType => - { contig => 1, - header => 'layerF.h', - symbols => [ qw(ADD_WHITE_MASK ADD_BLACK_MASK ADD_ALPHA_MASK) ], - mapping => { ADD_WHITE_MASK => '0', - ADD_BLACK_MASK => '1', - ADD_ALPHA_MASK => '2' }, - nicks => { ADD_WHITE_MASK => 'WHITE_MASK', - ADD_BLACK_MASK => 'BLACK_MASK', - ADD_ALPHA_MASK => 'ALPHA_MASK' } - }, - MaskApplyMode => - { contig => 1, - header => 'layer.h', - symbols => [ qw(APPLY DISCARD) ], - mapping => { APPLY => '0', - DISCARD => '1' } - }, - RunModeType => - { contig => 1, - header => 'plug_in.h', - symbols => [ qw(RUN_INTERACTIVE RUN_NONINTERACTIVE - RUN_WITH_LAST_VALS) ], - mapping => { RUN_INTERACTIVE => '0', - RUN_NONINTERACTIVE => '1', - RUN_WITH_LAST_VALS => '2' }, - nicks => { RUN_INTERACTIVE => 'INTERACTIVE', - RUN_NONINTERACTIVE => 'NONINTERACTIVE', - RUN_WITH_LAST_VALS => 'WITH_LAST_VALS' } + header => 'text_tool.h', + symbols => [ qw(PIXELS POINTS) ], + mapping => { PIXELS => '0', + POINTS => '1' } } ); diff --git a/tools/pdbgen/pdb/interface.pdb b/tools/pdbgen/pdb/interface.pdb new file mode 100644 index 0000000000..eb4c79bb23 --- /dev/null +++ b/tools/pdbgen/pdb/interface.pdb @@ -0,0 +1,84 @@ +# The GIMP -- an image manipulation program +# Copyright (C) 1998-1999 Manish Singh + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# "Perlized" from C source by Manish Singh + +sub pdb_misc { + $author = $copyright = 'Manish Singh'; + $date = '1998'; +} + +sub message { + $blurb = 'Displays a dialog box with a message.'; + + $help = <<'HELP'; +Displays a dialog box with a message. Useful for status or error reporting. +HELP + + &pdb_misc; + + @inargs = ( + { name => 'message', type => 'string', + desc => 'Message to display in the dialog' } + ); + + %invoke = ( code => 'g_message (message, NULL, NULL);' ); +} + +sub message_get_handler { + $blurb = <<'BLURB'; +Returns the current state of where warning messages are displayed. +BLURB + + $help = <<'HELP'; +This procedure returns the way g_message warnings are displayed. They can be +shown in a dialog box or printed on the console where gimp was started. +HELP + + &pdb_misc; + + @outargs = ( + { name => 'handler', type => 'enum MessageHandlerType', + desc => 'The current handler type: { %%desc%% }', + alias => 'message_handler', no_declare => 1 } + ); +} + +sub message_set_handler { + $blurb = 'Controls where warning messages are displayed.'; + + $help = <<'HELP'; +This procedure controls how g_message warnings are displayed. They can be shown +in a dialog box or printed on the console where gimp was started. +HELP + + &pdb_misc; + + @inargs = ( + { name => 'handler', type => 'enum MessageHandlerType', + desc => 'The new handler type: { %%desc%% }' } + ); + + %invoke = ( code => 'message_handler = handler;' ); +} + +@procs = qw(message message_get_handler message_set_handler); +%exports = (app => [@procs]); + +$desc = 'Interface'; + +1; diff --git a/tools/pdbgen/pdb/plug_in.pdb b/tools/pdbgen/pdb/plug_in.pdb new file mode 100644 index 0000000000..cd47c84beb --- /dev/null +++ b/tools/pdbgen/pdb/plug_in.pdb @@ -0,0 +1,246 @@ +# The GIMP -- an image manipulation program +# Copyright (C) 1995 Spencer Kimball and Peter Mattis + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# "Perlized" from C source by Manish Singh + +sub andy_pdb_misc { + $author = $copyright = 'Andy Thomas'; + $date = '1998'; +} + +# The defs + +sub progress_init { + $blurb = 'Initializes the progress bar for the current plug-in.'; + + $help = <<'HELP'; +Initializes the progress bar for the current plug-in. It is only valid to call +this procedure from a plug-in. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'message', type => 'string', no_success => 1, + desc => 'Message to use in the progress dialog' }, + { name => 'gdisplay', type => 'display', no_success => 1, + desc => 'GDisplay to update progressbar in, or -1 for a seperate + window', + no_id_lookup => 1 } + ); + + %invoke = ( + code => <<'CODE' +if (current_plug_in && current_plug_in->open && !no_interface) + plug_in_progress_init (current_plug_in, message, gdisplay); +CODE + ); +} + +sub progress_update { + $blurb = 'Updates the progress bar for the current plug-in.'; + + $help = <<'HELP'; +Updates the progress bar for the current plug-in. It is only valid to call this +procedure from a plug-in. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'percentage', type => 'float', + desc => 'Percentage of progress completed' } + ); + + %invoke = ( + code => <<'CODE' +if (current_plug_in && current_plug_in->open && !no_interface) + plug_in_progress_update (current_plug_in, percentage); +CODE + ); +} + +sub temp_PDB_name { + $blurb = 'Generates a unique temporary PDB name.'; + + $help = <<'HELP'; +This procedure generates a temporary PDB entry name that is guaranteed to be +unique. It is many used by the interactive popup dialogs to generate a PDB +entry name. +HELP + + &andy_pdb_misc; + + @outargs = ( + { name => 'temp_name', type => 'string', + desc => 'A unique temporary name for a temporary PDB entry' } + ); + + %invoke = ( + vars => [ 'static gint proc_number = 0' ], + code => <<'CODE' +temp_name = g_strdup_printf ("temp_plugin_number_%d", proc_number++); +CODE + ); +} + +sub plugins_query { + $blurb = 'Queries the plugin database for its contents.'; + + $help = 'This procedure queries the contents of the plugin database.'; + + &andy_pdb_misc; + + @inargs = ( + { name => 'search_string', type => 'string', + desc => 'If not an empty string then use this as a search pattern', + alias => 'search_str', no_success => 1 } + ); + + @outargs = ( + { name => 'menu_path', type => 'stringarray', + desc => 'The menu path of the plugin', + alias => 'menu_strs' }, + { name => 'plugin_accelerator', type => 'stringarray', + desc => 'String representing keyboard accelerator (could be empty + string)', + alias => 'accel_strs' }, + { name => 'plugin_location', type => 'stringarray', + desc => 'Location of the plugin program', + alias => 'prog_strs' }, + { name => 'plugin_image_type', type => 'stringarray', + desc => 'Type of image that this plugin will work on', + alias => 'types_strs' }, + { name => 'plugin_install_time', type => 'int32array', + desc => 'Time that the plugin was installed', + alias => 'time_ints' }, + { name => 'plugin_real_name', type => 'stringarray', + desc => 'The internal name of the plugin', + alias => 'realname_strs' } + ); + + foreach (@outargs) { + $_->{array} = { name => 'num_plugins', no_declare => 1, + desc => 'The number of plugins' } + } + + $outargs[0]->{array}->{init} = 1; + delete $outargs[0]->{array}->{no_declare}; + + %invoke = ( + headers => [ qw("libgimp/gimpintl.h") ], + vars => [ 'PlugInProcDef *proc_def', 'GSList *tmp = NULL', + 'gint i = 0', 'regex_t sregex' ], + code => <<'CODE' +{ + if (search_str && strlen (search_str)) + regcomp (&sregex, search_str, REG_ICASE); + else + search_str = NULL; + + /* count number of plugin entries, then allocate 4 arrays of correct size + * where we can store the strings. + */ + + tmp = proc_defs; + while (tmp) + { + proc_def = tmp->data; + tmp = tmp->next; + + if (proc_def->prog && proc_def->menu_path) + { + gchar *name = strrchr (proc_def->menu_path, '/'); + + if (name) + name = name + 1; + else + name = proc_def->menu_path; + + if (search_str && match_strings (&sregex, name)) + continue; + + num_plugins++; + } + } + + menu_strs = g_new (gchar *, num_plugins); + accel_strs = g_new (gchar *, num_plugins); + prog_strs = g_new (gchar *, num_plugins); + types_strs = g_new (gchar *, num_plugins); + realname_strs = g_new (gchar *, num_plugins); + time_ints = g_new (gint , num_plugins); + + tmp = proc_defs; + while (tmp) + { + if (i > num_plugins) + g_error (_("Internal error counting plugins")); + + proc_def = tmp->data; + tmp = tmp->next; + + if (proc_def->prog && proc_def->menu_path) + { + ProcRecord *pr = &proc_def->db_info; + + gchar *name = strrchr (proc_def->menu_path, '/'); + + if (name) + name = name + 1; + else + name = proc_def->menu_path; + + if (search_str && match_strings(&sregex,name)) + continue; + + menu_strs[i] = g_strdup (proc_def->menu_path); + accel_strs[i] = g_strdup (proc_def->accelerator); + prog_strs[i] = g_strdup (proc_def->prog); + types_strs[i] = g_strdup (proc_def->image_types); + realname_strs[i] = g_strdup (pr->name); + time_ints[i] = proc_def->mtime; + + i++; + } + } + + /* This I hope frees up internal stuff */ + if (search_str) + free (sregex.buffer); +} +CODE + ); +} + +@headers = qw("plug_in.h" "regex.h" "appenv.h" ); + +$extra{app}->{code} = <<'CODE'; +static int +match_strings (regex_t *preg, + gchar *a) +{ + return regexec (preg, a, 0, NULL, 0); +} +CODE + +@procs = qw(progress_init progress_update temp_PDB_name plugins_query); +%exports = (app => [@procs]); + +$desc = 'Plug-in'; + +1;