Commit 7c3c4c30 authored by Sven Neumann's avatar Sven Neumann

new functions gimp_plugin_domain_add() and gimp_plugin_domain_add_with_path()

that allow a plugin to specify its textdomain in the query() function. The
info is saved and read in from the pluginrc, but not yet used.


--Sven
parent 27d4717c
Wed Feb 23 19:04:08 CET 2000 Sven Neumann <sven@gimp.org>
* app/gimprc.c
* app/internal_procs.c
* app/plug_in.[ch]
* app/plug_in_cmds.c
* libgimp/gimp.[ch]
* tools/pdbgen/pdb/plug_in.pdb: new functions
gimp_plugin_domain_add() and gimp_plugin_domain_add_with_path()
that allow a plugin to specify its textdomain in the query()
function. The info is saved and read in from the pluginrc, but
not yet used.
2000-02-23 Michael Natterer <mitch@gimp.org>
* app/file_new_dialog.c: use a gimp_query_boolean_box().
......
......@@ -282,9 +282,9 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe.
*/
if (use_shm)
{
plug_in_init_shm();
}
{
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
......@@ -301,15 +301,15 @@ plug_in_init (void)
else
filename = gimp_personal_rc_file ("pluginrc");
app_init_update_status(_("Resource configuration"), filename, -1);
app_init_update_status (_("Resource configuration"), filename, -1);
parse_gimprc_file (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
*/
tmp = plug_in_defs;
app_init_update_status(_("Plug-ins"), "", 0);
nplugins = g_slist_length(tmp);
app_init_update_status (_("Plug-ins"), "", 0);
nplugins = g_slist_length (tmp);
nth = 0;
while (tmp)
{
......@@ -623,6 +623,49 @@ plug_in_file_handler (char *name,
return NULL;
}
PlugInDef *
plug_in_def_new (gchar *prog)
{
PlugInDef *plug_in_def;
g_return_val_if_fail (prog != NULL, NULL);
plug_in_def = g_new (PlugInDef, 1);
plug_in_def->prog = g_strdup (prog);
plug_in_def->proc_defs = NULL;
plug_in_def->locale_domain = NULL;
plug_in_def->locale_path = NULL;
plug_in_def->mtime = 0;
plug_in_def->query = FALSE;
return plug_in_def;
}
void
plug_in_def_free (PlugInDef *plug_in_def,
gboolean free_proc_defs)
{
GSList *list;
g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain);
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path);
if (free_proc_defs && plug_in_def->proc_defs)
{
for (list = plug_in_def->proc_defs; list; list = list->next)
g_free (list->data);
g_slist_free (plug_in_def->proc_defs);
}
g_free (plug_in_def);
}
void
plug_in_def_add (PlugInDef *plug_in_def)
{
......@@ -673,24 +716,23 @@ plug_in_def_add (PlugInDef *plug_in_def)
{
/* Use cached plug-in entry */
tmp->data = plug_in_def;
g_free (tplug_in_def->prog);
g_free (tplug_in_def);
plug_in_def_free (tplug_in_def, FALSE);
}
else
{
g_free (plug_in_def->prog);
g_free (plug_in_def);
plug_in_def_free (plug_in_def, FALSE);
}
return;
}
}
write_pluginrc = TRUE;
g_print ("\"%s\" executable not found\n", plug_in_def->prog);
g_free (plug_in_def->prog);
g_free (plug_in_def);
plug_in_def_free (plug_in_def, FALSE);
}
gchar *
plug_in_menu_path (gchar *name)
{
......@@ -2177,12 +2219,22 @@ plug_in_write_rc (char *filename)
if (tmp2)
fprintf (fp, "\n");
}
if (plug_in_def->locale_domain)
{
fprintf (fp, "\n\t(locale-def \"%s\"", plug_in_def->locale_domain);
if (plug_in_def->locale_path)
fprintf (fp, " \"%s\")", plug_in_def->locale_path);
else
fprintf (fp, ")");
}
fprintf (fp, ")\n");
if (tmp)
fprintf (fp, "\n");
}
}
fclose (fp);
......@@ -2225,9 +2277,7 @@ plug_in_init_file (char *filename)
plug_in_def = NULL;
}
plug_in_def = g_new (PlugInDef, 1);
plug_in_def->prog = g_strdup (filename);
plug_in_def->proc_defs = NULL;
plug_in_def = plug_in_def_new (filename);
plug_in_def->mtime = datafile_mtime ();
plug_in_def->query = TRUE;
......
......@@ -54,6 +54,7 @@
#define ERROR 0
#define DONE 1
#define OK 2
#define LOCALE_DEF 3
typedef enum {
TT_STRING,
......@@ -187,6 +188,7 @@ static int parse_preview_size (gpointer val1p, gpointer val2p);
static int parse_nav_preview_size (gpointer val1p, gpointer val2p);
static int parse_units (gpointer val1p, gpointer val2p);
static int parse_plug_in (gpointer val1p, gpointer val2p);
static int parse_locale_def (PlugInDef *plug_in_def);
static int parse_plug_in_def (gpointer val1p, gpointer val2p);
static int parse_device (gpointer val1p, gpointer val2p);
static int parse_menu_path (gpointer val1p, gpointer val2p);
......@@ -1409,19 +1411,15 @@ parse_plug_in_def (gpointer val1p,
{
PlugInDef *plug_in_def;
PlugInProcDef *proc_def;
GSList *tmp_list;
int token;
gint token;
gint success;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
plug_in_def = g_new (PlugInDef, 1);
plug_in_def->prog = g_strdup (token_str);
plug_in_def->proc_defs = NULL;
plug_in_def->mtime = 0;
plug_in_def->query = FALSE;
plug_in_def = plug_in_def_new (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
......@@ -1430,11 +1428,18 @@ parse_plug_in_def (gpointer val1p,
plug_in_def->mtime = token_int;
while (parse_proc_def (&proc_def))
success = OK;
while (success == OK)
{
proc_def->mtime = plug_in_def->mtime;
proc_def->prog = g_strdup (plug_in_def->prog);
plug_in_def->proc_defs = g_slist_append (plug_in_def->proc_defs, proc_def);
success = parse_proc_def (&proc_def);
if (success == OK)
{
proc_def->mtime = plug_in_def->mtime;
proc_def->prog = g_strdup (plug_in_def->prog);
plug_in_def->proc_defs = g_slist_append (plug_in_def->proc_defs, proc_def);
}
else if (success == LOCALE_DEF)
success = parse_locale_def (plug_in_def);
}
token = peek_next_token ();
......@@ -1448,19 +1453,52 @@ parse_plug_in_def (gpointer val1p,
error:
g_message (_("error parsing pluginrc"));
tmp_list = plug_in_def->proc_defs;
while (tmp_list)
plug_in_def_free (plug_in_def, TRUE);
return ERROR;
}
static int
parse_locale_def (PlugInDef *plug_in_def)
{
int token;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (token_str);
token = peek_next_token ();
if (token && token == TOKEN_STRING)
{
g_free (tmp_list->data);
tmp_list = tmp_list->next;
token = get_next_token ();
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = g_strdup (token_str);
token = peek_next_token ();
}
g_slist_free (plug_in_def->proc_defs);
g_free (plug_in_def->prog);
g_free (plug_in_def);
if (!token || token != TOKEN_RIGHT_PAREN)
goto error;
token = get_next_token ();
return OK;
error:
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = NULL;
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = NULL;
return ERROR;
}
static int
parse_proc_def (PlugInProcDef **proc_def)
{
......@@ -1474,9 +1512,17 @@ parse_proc_def (PlugInProcDef **proc_def)
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL) ||
(strcmp ("proc-def", token_sym) != 0))
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
if ((strcmp ("locale-def", token_sym) == 0))
{
token = get_next_token ();
return LOCALE_DEF; /* it's a locale_def, let parse_locale_def do the rest */
}
else if (strcmp ("proc-def", token_sym) != 0)
return ERROR;
token = get_next_token ();
pd = g_new0 (PlugInProcDef, 1);
......
......@@ -282,9 +282,9 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe.
*/
if (use_shm)
{
plug_in_init_shm();
}
{
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
......@@ -301,15 +301,15 @@ plug_in_init (void)
else
filename = gimp_personal_rc_file ("pluginrc");
app_init_update_status(_("Resource configuration"), filename, -1);
app_init_update_status (_("Resource configuration"), filename, -1);
parse_gimprc_file (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
*/
tmp = plug_in_defs;
app_init_update_status(_("Plug-ins"), "", 0);
nplugins = g_slist_length(tmp);
app_init_update_status (_("Plug-ins"), "", 0);
nplugins = g_slist_length (tmp);
nth = 0;
while (tmp)
{
......@@ -623,6 +623,49 @@ plug_in_file_handler (char *name,
return NULL;
}
PlugInDef *
plug_in_def_new (gchar *prog)
{
PlugInDef *plug_in_def;
g_return_val_if_fail (prog != NULL, NULL);
plug_in_def = g_new (PlugInDef, 1);
plug_in_def->prog = g_strdup (prog);
plug_in_def->proc_defs = NULL;
plug_in_def->locale_domain = NULL;
plug_in_def->locale_path = NULL;
plug_in_def->mtime = 0;
plug_in_def->query = FALSE;
return plug_in_def;
}
void
plug_in_def_free (PlugInDef *plug_in_def,
gboolean free_proc_defs)
{
GSList *list;
g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain);
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path);
if (free_proc_defs && plug_in_def->proc_defs)
{
for (list = plug_in_def->proc_defs; list; list = list->next)
g_free (list->data);
g_slist_free (plug_in_def->proc_defs);
}
g_free (plug_in_def);
}
void
plug_in_def_add (PlugInDef *plug_in_def)
{
......@@ -673,24 +716,23 @@ plug_in_def_add (PlugInDef *plug_in_def)
{
/* Use cached plug-in entry */
tmp->data = plug_in_def;
g_free (tplug_in_def->prog);
g_free (tplug_in_def);
plug_in_def_free (tplug_in_def, FALSE);
}
else
{
g_free (plug_in_def->prog);
g_free (plug_in_def);
plug_in_def_free (plug_in_def, FALSE);
}
return;
}
}
write_pluginrc = TRUE;
g_print ("\"%s\" executable not found\n", plug_in_def->prog);
g_free (plug_in_def->prog);
g_free (plug_in_def);
plug_in_def_free (plug_in_def, FALSE);
}
gchar *
plug_in_menu_path (gchar *name)
{
......@@ -2177,12 +2219,22 @@ plug_in_write_rc (char *filename)
if (tmp2)
fprintf (fp, "\n");
}
if (plug_in_def->locale_domain)
{
fprintf (fp, "\n\t(locale-def \"%s\"", plug_in_def->locale_domain);
if (plug_in_def->locale_path)
fprintf (fp, " \"%s\")", plug_in_def->locale_path);
else
fprintf (fp, ")");
}
fprintf (fp, ")\n");
if (tmp)
fprintf (fp, "\n");
}
}
fclose (fp);
......@@ -2225,9 +2277,7 @@ plug_in_init_file (char *filename)
plug_in_def = NULL;
}
plug_in_def = g_new (PlugInDef, 1);
plug_in_def->prog = g_strdup (filename);
plug_in_def->proc_defs = NULL;
plug_in_def = plug_in_def_new (filename);
plug_in_def->mtime = datafile_mtime ();
plug_in_def->query = TRUE;
......
......@@ -282,9 +282,9 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe.
*/
if (use_shm)
{
plug_in_init_shm();
}
{
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
......@@ -301,15 +301,15 @@ plug_in_init (void)
else
filename = gimp_personal_rc_file ("pluginrc");
app_init_update_status(_("Resource configuration"), filename, -1);
app_init_update_status (_("Resource configuration"), filename, -1);
parse_gimprc_file (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
*/
tmp = plug_in_defs;
app_init_update_status(_("Plug-ins"), "", 0);
nplugins = g_slist_length(tmp);
app_init_update_status (_("Plug-ins"), "", 0);
nplugins = g_slist_length (tmp);
nth = 0;
while (tmp)
{
......@@ -623,6 +623,49 @@ plug_in_file_handler (char *name,
return NULL;
}
PlugInDef *
plug_in_def_new (gchar *prog)
{
PlugInDef *plug_in_def;
g_return_val_if_fail (prog != NULL, NULL);
plug_in_def = g_new (PlugInDef, 1);
plug_in_def->prog = g_strdup (prog);
plug_in_def->proc_defs = NULL;
plug_in_def->locale_domain = NULL;
plug_in_def->locale_path = NULL;
plug_in_def->mtime = 0;
plug_in_def->query = FALSE;
return plug_in_def;
}
void
plug_in_def_free (PlugInDef *plug_in_def,
gboolean free_proc_defs)
{
GSList *list;
g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain);
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path);
if (free_proc_defs && plug_in_def->proc_defs)
{
for (list = plug_in_def->proc_defs; list; list = list->next)
g_free (list->data);
g_slist_free (plug_in_def->proc_defs);
}
g_free (plug_in_def);
}
void
plug_in_def_add (PlugInDef *plug_in_def)
{
......@@ -673,24 +716,23 @@ plug_in_def_add (PlugInDef *plug_in_def)
{
/* Use cached plug-in entry */
tmp->data = plug_in_def;
g_free (tplug_in_def->prog);
g_free (tplug_in_def);
plug_in_def_free (tplug_in_def, FALSE);
}
else
{
g_free (plug_in_def->prog);
g_free (plug_in_def);
plug_in_def_free (plug_in_def, FALSE);
}
return;
}
}
write_pluginrc = TRUE;
g_print ("\"%s\" executable not found\n", plug_in_def->prog);
g_free (plug_in_def->prog);
g_free (plug_in_def);
plug_in_def_free (plug_in_def, FALSE);
}
gchar *
plug_in_menu_path (gchar *name)
{
......@@ -2177,12 +2219,22 @@ plug_in_write_rc (char *filename)
if (tmp2)
fprintf (fp, "\n");
}
if (plug_in_def->locale_domain)
{
fprintf (fp, "\n\t(locale-def \"%s\"", plug_in_def->locale_domain);
if (plug_in_def->locale_path)
fprintf (fp, " \"%s\")", plug_in_def->locale_path);
else
fprintf (fp, ")");
}
fprintf (fp, ")\n");
if (tmp)
fprintf (fp, "\n");
}
}
fclose (fp);
......@@ -2225,9 +2277,7 @@ plug_in_init_file (char *filename)
plug_in_def = NULL;
}
plug_in_def = g_new (PlugInDef, 1);
plug_in_def->prog = g_strdup (filename);
plug_in_def->proc_defs = NULL;
plug_in_def = plug_in_def_new (filename);
plug_in_def->mtime = datafile_mtime ();
plug_in_def->query = TRUE;
......
......@@ -60,7 +60,7 @@ void register_tools_procs (void);
void register_undo_procs (void);
void register_unit_procs (void);
/* 320 procedures registered total */
/* 321 procedures registered total */
void
internal_procs_init (void)
......@@ -74,7 +74,7 @@ internal_procs_init (void)
app_init_update_status (NULL, _("Channel"), 0.044);
register_channel_procs ();
app_init_update_status (NULL, _("Channel Ops"), 0.091);
app_init_update_status (NULL, _("Channel Ops"), 0.09);
register_channel_ops_procs ();
app_init_update_status (NULL, _("Color"), 0.097);
......@@ -83,7 +83,7 @@ internal_procs_init (void)
app_init_update_status (NULL, _("Convert"), 0.134);
register_convert_procs ();
app_init_update_status (NULL, _("Drawable procedures"), 0.144);
app_init_update_status (NULL, _("Drawable procedures"), 0.143);
register_drawable_procs ();
app_init_update_status (NULL, _("Edit procedures"), 0.212);
......@@ -92,70 +92,70 @@ internal_procs_init (void)
app_init_update_status (NULL, _("File Operations"), 0.231);
register_fileops_procs ();
app_init_update_status (NULL, _("Floating selections"), 0.256);
app_init_update_status (NULL, _("Floating selections"), 0.255);
register_floating_sel_procs ();
app_init_update_status (NULL, _("GDisplay procedures"), 0.275);
app_init_update_status (NULL, _("GDisplay procedures"), 0.274);
register_gdisplay_procs ();
app_init_update_status (NULL, _("Image"), 0.284);
app_init_update_status (NULL, _("Image"), 0.283);
register_gimage_procs ();
app_init_update_status (NULL, _("Image mask"), 0.469);
app_init_update_status (NULL, _("Image mask"), 0.467);
register_gimage_mask_procs ();
app_init_update_status (NULL, _("Gimprc procedures"), 0.522);
app_init_update_status (NULL, _("Gimprc procedures"), 0.52);
register_gimprc_procs ();
app_init_update_status (NULL, _("Help procedures"), 0.531);
app_init_update_status (NULL, _("Help procedures"), 0.53);
register_gimphelp_procs ();
app_init_update_status (NULL, _("Gradients"), 0.534);
app_init_update_status (NULL, _("Gradients"), 0.533);
register_gradient_procs ();
app_init_update_status (NULL, _("Gradient UI"), 0.55);
app_init_update_status (NULL, _("Gradient UI"), 0.548);
register_gradient_select_procs ();
app_init_update_status (NULL, _("Guide procedures"), 0.562);
app_init_update_status (NULL, _("Guide procedures"), 0.561);
register_guides_procs ();
app_init_update_status (NULL, _("Interface"), 0.581);
app_init_update_status (NULL, _("Interface"), 0.579);
register_interface_procs ();
app_init_update_status (NULL, _("Layer"), 0.591);
app_init_update_status (NULL, _("Layer"), 0.589);
register_layer_procs ();
app_init_update_status (NULL, _("Miscellaneous"), 0.688);
app_init_update_status (NULL, _("Miscellaneous"), 0.685);
register_misc_procs ();
app_init_update_status (NULL, _("Palette"), 0.694);
app_init_update_status (NULL, _("Palette"), 0.692);
register_palette_procs ();
app_init_update_status (NULL, _("Parasite procedures"), 0.716);
app_init_update_status (NULL, _("Parasite procedures"), 0.713);
register_parasite_procs ();
app_init_update_status (NULL, _("Paths"), 0.756);
app_init_update_status (NULL, _("Paths"), 0.754);
register_paths_procs ();
app_init_update_status (NULL, _("Pattern UI"), 0.797);
app_init_update_status (NULL, _("Pattern UI"), 0.794);
register_pattern_select_procs ();
app_init_update_status (NULL, _("Patterns"), 0.806);
app_init_update_status (NULL, _("Patterns"), 0.804);
register_patterns_procs ();
app_init_update_status (NULL, _("Plug-in"), 0.819);
app_init_update_status (NULL, _("Plug-in"), 0.816);
register_plug_in_procs ();
app_init_update_status (NULL, _("Procedural database"), 0.831);
app_init_update_status (NULL, _("Procedural database"), 0.832);
register_procedural_db_procs ();
app_init_update_status (NULL, _("Text procedures"), 0.856);
app_init_update_status (NULL, _("Text procedures"), 0.857);
register_text_tool_procs ();
app_init_update_status (NULL, _("Tool procedures"), 0.869);
register_tools_procs ();
app_init_update_status (NULL, _("Undo"), 0.959);
app_init_update_status (NULL, _("Undo"), 0.96);
register_undo_procs ();
app_init_update_status (NULL, _("Units"), 0.966);
......
......@@ -282,9 +282,9 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe.
*/
if (use_shm)
{
plug_in_init_shm();
}
{
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
......@@ -301,15 +301,15 @@ plug_in_init (void)
else
filename = gimp_personal_rc_file ("pluginrc");
app_init_update_status(_("Resource configuration"), filename, -1);
app_init_update_status (_("Resource configuration"), filename, -1);
parse_gimprc_file (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
*/
tmp = plug_in_defs;