diff --git a/ChangeLog b/ChangeLog index de5eccecad..a68472a396 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2006-04-09 Michael Natterer + + * app/plug-in/Makefile.am + * app/plug-in/plug-ins-help.[ch] + * app/plug-in/plug-ins-locale.[ch]: new files managing plug-in + help domains and locale domains. + + * app/plug-in/plug-ins.[ch]: removed the functions here. Minor + unrelated cleanups. + + * app/plug-in/plug-in.c + * app/actions/plug-in-actions.c + * app/menus/plug-in-menus.c + * app/widgets/gimpfiledialog.c + * app/widgets/gimpfileprocview.c + * app/widgets/gimphelp.c + * tools/pdbgen/pdb/help.pdb + * tools/pdbgen/pdb/plug_in.pdb: changed includes accordingly. + + * app/pdb/help_cmds.c + * app/pdb/plug_in_cmds.c: regenerated. + 2006-04-09 Michael Natterer * app/plug-in/plug-in-rc.[ch] (plug_in_rc_parse): return a GSList* diff --git a/app/actions/plug-in-actions.c b/app/actions/plug-in-actions.c index f7ca2b76f3..42f22c1d38 100644 --- a/app/actions/plug-in-actions.c +++ b/app/actions/plug-in-actions.c @@ -36,6 +36,8 @@ #include "pdb/gimppluginprocedure.h" #include "plug-in/plug-ins.h" +#include "plug-in/plug-ins-help.h" +#include "plug-in/plug-ins-locale.h" #include "widgets/gimpactiongroup.h" #include "widgets/gimphelp-ids.h" diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index f4c12efb19..017381996d 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -32,8 +32,8 @@ #include "pdb/gimppluginprocedure.h" -#include "plug-in/plug-ins.h" #include "plug-in/plug-in-def.h" +#include "plug-in/plug-ins-locale.h" #include "widgets/gimpuimanager.h" diff --git a/app/pdb/help_cmds.c b/app/pdb/help_cmds.c index d3f0ead4bc..57ba32e9ef 100644 --- a/app/pdb/help_cmds.c +++ b/app/pdb/help_cmds.c @@ -30,7 +30,7 @@ #include "core/gimp.h" #include "plug-in/plug-in.h" -#include "plug-in/plug-ins.h" +#include "plug-in/plug-ins-help.h" static GValueArray * diff --git a/app/pdb/plug_in_cmds.c b/app/pdb/plug_in_cmds.c index 20492bf6c3..f34041defb 100644 --- a/app/pdb/plug_in_cmds.c +++ b/app/pdb/plug_in_cmds.c @@ -26,7 +26,6 @@ #include #include "libgimpbase/gimpbase.h" -#include "libgimpbase/gimpprotocol.h" #include "pdb-types.h" #include "gimp-pdb.h" @@ -36,8 +35,8 @@ #include "core/gimp.h" #include "gimppluginprocedure.h" #include "plug-in/plug-in-def.h" -#include "plug-in/plug-in-params.h" #include "plug-in/plug-in.h" +#include "plug-in/plug-ins-help.h" #include "plug-in/plug-ins-query.h" #include "plug-in/plug-ins.h" diff --git a/app/plug-in/Makefile.am b/app/plug-in/Makefile.am index 182ae4a8ed..55649b5858 100644 --- a/app/plug-in/Makefile.am +++ b/app/plug-in/Makefile.am @@ -44,6 +44,10 @@ libappplug_in_a_SOURCES = \ plug-in-shm.h \ plug-ins.c \ plug-ins.h \ + plug-ins-help.c \ + plug-ins-help.h \ + plug-ins-locale.c \ + plug-ins-locale.h \ plug-ins-query.c \ plug-ins-query.h diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 275f16b505..93665d8076 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -79,13 +79,14 @@ #include "pdb/gimptemporaryprocedure.h" #include "plug-in.h" -#include "plug-ins.h" #include "plug-in-debug.h" #include "plug-in-def.h" #include "plug-in-message.h" #include "plug-in-params.h" #include "plug-in-progress.h" #include "plug-in-shm.h" +#include "plug-ins.h" +#include "plug-ins-locale.h" #include "gimp-intl.h" @@ -107,6 +108,7 @@ static gboolean plug_in_recv_message (GIOChannel *channel, static void plug_in_prep_for_exec (gpointer data); #endif + void plug_in_init (Gimp *gimp) { diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index a4518df13a..23de6a0e44 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -42,37 +42,18 @@ #include "pdb/gimptemporaryprocedure.h" #include "plug-in.h" -#include "plug-ins.h" #include "plug-in-data.h" #include "plug-in-def.h" #include "plug-in-params.h" #include "plug-in-progress.h" #include "plug-in-rc.h" +#include "plug-ins.h" +#include "plug-ins-help.h" +#include "plug-ins-locale.h" #include "gimp-intl.h" -#define STD_PLUGINS_DOMAIN GETTEXT_PACKAGE "-std-plug-ins" - - -typedef struct _PlugInLocaleDomain PlugInLocaleDomain; -typedef struct _PlugInHelpDomain PlugInHelpDomain; - -struct _PlugInLocaleDomain -{ - gchar *prog_name; - gchar *domain_name; - gchar *domain_path; -}; - -struct _PlugInHelpDomain -{ - gchar *prog_name; - gchar *domain_name; - gchar *domain_uri; -}; - - static void plug_ins_add_from_file (const GimpDatafileData *file_data, gpointer data); static void plug_ins_add_from_rc (Gimp *gimp, @@ -295,7 +276,8 @@ plug_ins_init (Gimp *gimp, plug_ins_file_proc_compare, gimp); - gimp_menus_init (gimp, gimp->plug_in_defs, STD_PLUGINS_DOMAIN); + gimp_menus_init (gimp, gimp->plug_in_defs, + plug_ins_standard_locale_domain ()); } /* build list of automatically started extensions */ @@ -372,32 +354,8 @@ plug_ins_exit (Gimp *gimp) g_slist_free (gimp->plug_in_menu_branches); gimp->plug_in_menu_branches = NULL; - for (list = gimp->plug_in_locale_domains; list; list = list->next) - { - PlugInLocaleDomain *domain = list->data; - - g_free (domain->prog_name); - g_free (domain->domain_name); - g_free (domain->domain_path); - g_free (domain); - } - - g_slist_free (gimp->plug_in_locale_domains); - gimp->plug_in_locale_domains = NULL; - - for (list = gimp->plug_in_help_domains; list; list = list->next) - { - PlugInHelpDomain *domain = list->data; - - g_free (domain->prog_name); - g_free (domain->domain_name); - g_free (domain->domain_uri); - g_free (domain); - } - - g_slist_free (gimp->plug_in_help_domains); - gimp->plug_in_help_domains = NULL; - + plug_ins_locale_exit (gimp); + plug_ins_help_exit (gimp); plug_in_data_free (gimp); g_slist_foreach (gimp->plug_in_procedures, (GFunc) g_object_unref, NULL); @@ -570,158 +528,6 @@ plug_ins_menu_branch_add (Gimp *gimp, #endif } -void -plug_ins_locale_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_path) -{ - PlugInLocaleDomain *domain; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - g_return_if_fail (prog_name != NULL); - g_return_if_fail (domain_name != NULL); - - domain = g_new (PlugInLocaleDomain, 1); - - domain->prog_name = g_strdup (prog_name); - domain->domain_name = g_strdup (domain_name); - domain->domain_path = g_strdup (domain_path); - - gimp->plug_in_locale_domains = g_slist_prepend (gimp->plug_in_locale_domains, - domain); - -#ifdef VERBOSE - g_print ("added locale domain \"%s\" for path \"%s\"\n", - domain->domain_name ? domain->domain_name : "(null)", - domain->domain_path ? - gimp_filename_to_utf8 (domain->domain_path) : "(null)"); -#endif -} - -const gchar * -plug_ins_locale_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **domain_path) -{ - GSList *list; - - g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); - - if (domain_path) - *domain_path = gimp_locale_directory (); - - /* A NULL prog_name is GIMP itself, return the default domain */ - if (! prog_name) - return NULL; - - for (list = gimp->plug_in_locale_domains; list; list = list->next) - { - PlugInLocaleDomain *domain = list->data; - - if (domain && domain->prog_name && - ! strcmp (domain->prog_name, prog_name)) - { - if (domain_path && domain->domain_path) - *domain_path = domain->domain_path; - - return domain->domain_name; - } - } - - return STD_PLUGINS_DOMAIN; -} - -void -plug_ins_help_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_uri) -{ - PlugInHelpDomain *domain; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - g_return_if_fail (prog_name != NULL); - g_return_if_fail (domain_name != NULL); - - domain = g_new (PlugInHelpDomain, 1); - - domain->prog_name = g_strdup (prog_name); - domain->domain_name = g_strdup (domain_name); - domain->domain_uri = g_strdup (domain_uri); - - gimp->plug_in_help_domains = g_slist_prepend (gimp->plug_in_help_domains, - domain); - -#ifdef VERBOSE - g_print ("added help domain \"%s\" for base uri \"%s\"\n", - domain->domain_name ? domain->domain_name : "(null)", - domain->domain_uri ? domain->domain_uri : "(null)"); -#endif -} - -const gchar * -plug_ins_help_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **domain_uri) -{ - GSList *list; - - g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); - - if (domain_uri) - *domain_uri = NULL; - - /* A NULL prog_name is GIMP itself, return the default domain */ - if (! prog_name) - return NULL; - - for (list = gimp->plug_in_help_domains; list; list = list->next) - { - PlugInHelpDomain *domain = list->data; - - if (domain && domain->prog_name && - ! strcmp (domain->prog_name, prog_name)) - { - if (domain_uri && domain->domain_uri) - *domain_uri = domain->domain_uri; - - return domain->domain_name; - } - } - - return NULL; -} - -gint -plug_ins_help_domains (Gimp *gimp, - gchar ***help_domains, - gchar ***help_uris) -{ - GSList *list; - gint n_domains; - gint i; - - g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); - g_return_val_if_fail (help_domains != NULL, 0); - g_return_val_if_fail (help_uris != NULL, 0); - - n_domains = g_slist_length (gimp->plug_in_help_domains); - - *help_domains = g_new0 (gchar *, n_domains); - *help_uris = g_new0 (gchar *, n_domains); - - for (list = gimp->plug_in_help_domains, i = 0; list; list = list->next, i++) - { - PlugInHelpDomain *domain = list->data; - - (*help_domains)[i] = g_strdup (domain->domain_name); - (*help_uris)[i] = g_strdup (domain->domain_uri); - } - - return n_domains; -} - /* private functions */ @@ -902,7 +708,7 @@ plug_ins_procedure_insert (Gimp *gimp, if (strcmp (GIMP_OBJECT (proc)->name, GIMP_OBJECT (tmp_proc)->name) == 0) { - GSList *list3; + GSList *list2; list->data = g_object_ref (proc); @@ -914,12 +720,12 @@ plug_ins_procedure_insert (Gimp *gimp, /* search the plugin list to see if any plugins had references to * the tmp_proc. */ - for (list3 = gimp->plug_in_defs; list3; list3 = list3->next) + for (list2 = gimp->plug_in_defs; list2; list2 = list2->next) { - PlugInDef *plug_in_def2 = list3->data; + PlugInDef *plug_in_def = list2->data; - if (g_slist_find (plug_in_def2->procedures, tmp_proc)) - plug_in_def_remove_procedure (plug_in_def2, tmp_proc); + if (g_slist_find (plug_in_def->procedures, tmp_proc)) + plug_in_def_remove_procedure (plug_in_def, tmp_proc); } /* also remove it from the lists of load and save procs */ @@ -944,6 +750,8 @@ plug_ins_file_proc_compare (gconstpointer a, Gimp *gimp = data; const GimpPlugInProcedure *proc_a = a; const GimpPlugInProcedure *proc_b = b; + const gchar *domain_a; + const gchar *domain_b; gchar *label_a; gchar *label_b; gint retval = 0; @@ -954,14 +762,11 @@ plug_ins_file_proc_compare (gconstpointer a, if (strncmp (proc_b->prog, "gimp-xcf", 8) == 0) return 1; - label_a = gimp_plug_in_procedure_get_label (proc_a, - plug_ins_locale_domain (gimp, - proc_a->prog, - NULL)); - label_b = gimp_plug_in_procedure_get_label (proc_b, - plug_ins_locale_domain (gimp, - proc_b->prog, - NULL)); + domain_a = plug_ins_locale_domain (gimp, proc_a->prog, NULL); + domain_b = plug_ins_locale_domain (gimp, proc_b->prog, NULL); + + label_a = gimp_plug_in_procedure_get_label (proc_a, domain_a); + label_b = gimp_plug_in_procedure_get_label (proc_b, domain_b); if (label_a && label_b) retval = g_utf8_collate (label_a, label_b); diff --git a/app/plug-in/gimppluginmanager.h b/app/plug-in/gimppluginmanager.h index 1a1c22e68b..072baa7640 100644 --- a/app/plug-in/gimppluginmanager.h +++ b/app/plug-in/gimppluginmanager.h @@ -70,32 +70,5 @@ void plug_ins_menu_branch_add (Gimp *gimp, const gchar *menu_path, const gchar *menu_label); -/* Add a locale domain */ -void plug_ins_locale_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_path); - -/* Retrieve a plug-ins locale domain */ -const gchar * plug_ins_locale_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **locale_path); - -/* Add a help domain */ -void plug_ins_help_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_uri); - -/* Retrieve a plug-ins help domain */ -const gchar * plug_ins_help_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **help_uri); - -/* Retrieve all help domains */ -gint plug_ins_help_domains (Gimp *gimp, - gchar ***help_domains, - gchar ***help_uris); - #endif /* __PLUG_INS_H__ */ diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index 275f16b505..93665d8076 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -79,13 +79,14 @@ #include "pdb/gimptemporaryprocedure.h" #include "plug-in.h" -#include "plug-ins.h" #include "plug-in-debug.h" #include "plug-in-def.h" #include "plug-in-message.h" #include "plug-in-params.h" #include "plug-in-progress.h" #include "plug-in-shm.h" +#include "plug-ins.h" +#include "plug-ins-locale.h" #include "gimp-intl.h" @@ -107,6 +108,7 @@ static gboolean plug_in_recv_message (GIOChannel *channel, static void plug_in_prep_for_exec (gpointer data); #endif + void plug_in_init (Gimp *gimp) { diff --git a/app/plug-in/plug-ins-help.c b/app/plug-in/plug-ins-help.c new file mode 100644 index 0000000000..ac6193270c --- /dev/null +++ b/app/plug-in/plug-ins-help.c @@ -0,0 +1,153 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * plug-ins.c + * + * 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. + */ + +#include "config.h" + +#include + +#include + +#include "plug-in-types.h" + +#include "core/gimp.h" + +#include "plug-ins-help.h" + + +typedef struct _PlugInHelpDomain PlugInHelpDomain; + +struct _PlugInHelpDomain +{ + gchar *prog_name; + gchar *domain_name; + gchar *domain_uri; +}; + + +void +plug_ins_help_exit (Gimp *gimp) +{ + GSList *list; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + for (list = gimp->plug_in_help_domains; list; list = list->next) + { + PlugInHelpDomain *domain = list->data; + + g_free (domain->prog_name); + g_free (domain->domain_name); + g_free (domain->domain_uri); + g_free (domain); + } + + g_slist_free (gimp->plug_in_help_domains); + gimp->plug_in_help_domains = NULL; +} + +void +plug_ins_help_domain_add (Gimp *gimp, + const gchar *prog_name, + const gchar *domain_name, + const gchar *domain_uri) +{ + PlugInHelpDomain *domain; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (prog_name != NULL); + g_return_if_fail (domain_name != NULL); + + domain = g_new (PlugInHelpDomain, 1); + + domain->prog_name = g_strdup (prog_name); + domain->domain_name = g_strdup (domain_name); + domain->domain_uri = g_strdup (domain_uri); + + gimp->plug_in_help_domains = g_slist_prepend (gimp->plug_in_help_domains, + domain); + +#ifdef VERBOSE + g_print ("added help domain \"%s\" for base uri \"%s\"\n", + domain->domain_name ? domain->domain_name : "(null)", + domain->domain_uri ? domain->domain_uri : "(null)"); +#endif +} + +const gchar * +plug_ins_help_domain (Gimp *gimp, + const gchar *prog_name, + const gchar **domain_uri) +{ + GSList *list; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + if (domain_uri) + *domain_uri = NULL; + + /* A NULL prog_name is GIMP itself, return the default domain */ + if (! prog_name) + return NULL; + + for (list = gimp->plug_in_help_domains; list; list = list->next) + { + PlugInHelpDomain *domain = list->data; + + if (domain && domain->prog_name && + ! strcmp (domain->prog_name, prog_name)) + { + if (domain_uri && domain->domain_uri) + *domain_uri = domain->domain_uri; + + return domain->domain_name; + } + } + + return NULL; +} + +gint +plug_ins_help_domains (Gimp *gimp, + gchar ***help_domains, + gchar ***help_uris) +{ + GSList *list; + gint n_domains; + gint i; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); + g_return_val_if_fail (help_domains != NULL, 0); + g_return_val_if_fail (help_uris != NULL, 0); + + n_domains = g_slist_length (gimp->plug_in_help_domains); + + *help_domains = g_new0 (gchar *, n_domains); + *help_uris = g_new0 (gchar *, n_domains); + + for (list = gimp->plug_in_help_domains, i = 0; list; list = list->next, i++) + { + PlugInHelpDomain *domain = list->data; + + (*help_domains)[i] = g_strdup (domain->domain_name); + (*help_uris)[i] = g_strdup (domain->domain_uri); + } + + return n_domains; +} diff --git a/app/plug-in/plug-ins-help.h b/app/plug-in/plug-ins-help.h new file mode 100644 index 0000000000..cca79bf830 --- /dev/null +++ b/app/plug-in/plug-ins-help.h @@ -0,0 +1,44 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * plug-ins-help.h + * + * 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. + */ + +#ifndef __PLUG_INS_HELP_H__ +#define __PLUG_INS_HELP_H__ + + +void plug_ins_help_exit (Gimp *gimp); + +/* Add a help domain */ +void plug_ins_help_domain_add (Gimp *gimp, + const gchar *prog_name, + const gchar *domain_name, + const gchar *domain_uri); + +/* Retrieve a plug-ins help domain */ +const gchar * plug_ins_help_domain (Gimp *gimp, + const gchar *prog_name, + const gchar **help_uri); + +/* Retrieve all help domains */ +gint plug_ins_help_domains (Gimp *gimp, + gchar ***help_domains, + gchar ***help_uris); + + +#endif /* __PLUG_INS_HELP_H__ */ diff --git a/app/plug-in/plug-ins-locale.c b/app/plug-in/plug-ins-locale.c new file mode 100644 index 0000000000..b4fbde857e --- /dev/null +++ b/app/plug-in/plug-ins-locale.c @@ -0,0 +1,133 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * plug-ins-locale.c + * + * 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. + */ + +#include "config.h" + +#include + +#include + +#include "libgimpbase/gimpbase.h" + +#include "plug-in-types.h" + +#include "core/gimp.h" + +#include "plug-ins-locale.h" + + +typedef struct _PlugInLocaleDomain PlugInLocaleDomain; + +struct _PlugInLocaleDomain +{ + gchar *prog_name; + gchar *domain_name; + gchar *domain_path; +}; + + +void +plug_ins_locale_exit (Gimp *gimp) +{ + GSList *list; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + for (list = gimp->plug_in_locale_domains; list; list = list->next) + { + PlugInLocaleDomain *domain = list->data; + + g_free (domain->prog_name); + g_free (domain->domain_name); + g_free (domain->domain_path); + g_free (domain); + } + + g_slist_free (gimp->plug_in_locale_domains); + gimp->plug_in_locale_domains = NULL; +} + +void +plug_ins_locale_domain_add (Gimp *gimp, + const gchar *prog_name, + const gchar *domain_name, + const gchar *domain_path) +{ + PlugInLocaleDomain *domain; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (prog_name != NULL); + g_return_if_fail (domain_name != NULL); + + domain = g_new (PlugInLocaleDomain, 1); + + domain->prog_name = g_strdup (prog_name); + domain->domain_name = g_strdup (domain_name); + domain->domain_path = g_strdup (domain_path); + + gimp->plug_in_locale_domains = g_slist_prepend (gimp->plug_in_locale_domains, + domain); + +#ifdef VERBOSE + g_print ("added locale domain \"%s\" for path \"%s\"\n", + domain->domain_name ? domain->domain_name : "(null)", + domain->domain_path ? + gimp_filename_to_utf8 (domain->domain_path) : "(null)"); +#endif +} + +const gchar * +plug_ins_locale_domain (Gimp *gimp, + const gchar *prog_name, + const gchar **domain_path) +{ + GSList *list; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + if (domain_path) + *domain_path = gimp_locale_directory (); + + /* A NULL prog_name is GIMP itself, return the default domain */ + if (! prog_name) + return NULL; + + for (list = gimp->plug_in_locale_domains; list; list = list->next) + { + PlugInLocaleDomain *domain = list->data; + + if (domain && domain->prog_name && + ! strcmp (domain->prog_name, prog_name)) + { + if (domain_path && domain->domain_path) + *domain_path = domain->domain_path; + + return domain->domain_name; + } + } + + return plug_ins_standard_locale_domain (); +} + +const gchar * +plug_ins_standard_locale_domain (void) +{ + return GETTEXT_PACKAGE "-std-plug-ins"; +} diff --git a/app/plug-in/plug-ins-locale.h b/app/plug-in/plug-ins-locale.h new file mode 100644 index 0000000000..3d72ad50f3 --- /dev/null +++ b/app/plug-in/plug-ins-locale.h @@ -0,0 +1,42 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * plug-ins-locale.h + * + * 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. + */ + +#ifndef __PLUG_INS_LOCALE_H__ +#define __PLUG_INS_LOCALE_H__ + + +void plug_ins_locale_exit (Gimp *gimp); + +/* Add a locale domain */ +void plug_ins_locale_domain_add (Gimp *gimp, + const gchar *prog_name, + const gchar *domain_name, + const gchar *domain_path); + +/* Retrieve a plug-ins locale domain */ +const gchar * plug_ins_locale_domain (Gimp *gimp, + const gchar *prog_name, + const gchar **locale_path); + +/* Retrieve the locale domain of the standard plug-ins */ +const gchar * plug_ins_standard_locale_domain (void) G_GNUC_CONST; + + +#endif /* __PLUG_INS_LOCALE_H__ */ diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index a4518df13a..23de6a0e44 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -42,37 +42,18 @@ #include "pdb/gimptemporaryprocedure.h" #include "plug-in.h" -#include "plug-ins.h" #include "plug-in-data.h" #include "plug-in-def.h" #include "plug-in-params.h" #include "plug-in-progress.h" #include "plug-in-rc.h" +#include "plug-ins.h" +#include "plug-ins-help.h" +#include "plug-ins-locale.h" #include "gimp-intl.h" -#define STD_PLUGINS_DOMAIN GETTEXT_PACKAGE "-std-plug-ins" - - -typedef struct _PlugInLocaleDomain PlugInLocaleDomain; -typedef struct _PlugInHelpDomain PlugInHelpDomain; - -struct _PlugInLocaleDomain -{ - gchar *prog_name; - gchar *domain_name; - gchar *domain_path; -}; - -struct _PlugInHelpDomain -{ - gchar *prog_name; - gchar *domain_name; - gchar *domain_uri; -}; - - static void plug_ins_add_from_file (const GimpDatafileData *file_data, gpointer data); static void plug_ins_add_from_rc (Gimp *gimp, @@ -295,7 +276,8 @@ plug_ins_init (Gimp *gimp, plug_ins_file_proc_compare, gimp); - gimp_menus_init (gimp, gimp->plug_in_defs, STD_PLUGINS_DOMAIN); + gimp_menus_init (gimp, gimp->plug_in_defs, + plug_ins_standard_locale_domain ()); } /* build list of automatically started extensions */ @@ -372,32 +354,8 @@ plug_ins_exit (Gimp *gimp) g_slist_free (gimp->plug_in_menu_branches); gimp->plug_in_menu_branches = NULL; - for (list = gimp->plug_in_locale_domains; list; list = list->next) - { - PlugInLocaleDomain *domain = list->data; - - g_free (domain->prog_name); - g_free (domain->domain_name); - g_free (domain->domain_path); - g_free (domain); - } - - g_slist_free (gimp->plug_in_locale_domains); - gimp->plug_in_locale_domains = NULL; - - for (list = gimp->plug_in_help_domains; list; list = list->next) - { - PlugInHelpDomain *domain = list->data; - - g_free (domain->prog_name); - g_free (domain->domain_name); - g_free (domain->domain_uri); - g_free (domain); - } - - g_slist_free (gimp->plug_in_help_domains); - gimp->plug_in_help_domains = NULL; - + plug_ins_locale_exit (gimp); + plug_ins_help_exit (gimp); plug_in_data_free (gimp); g_slist_foreach (gimp->plug_in_procedures, (GFunc) g_object_unref, NULL); @@ -570,158 +528,6 @@ plug_ins_menu_branch_add (Gimp *gimp, #endif } -void -plug_ins_locale_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_path) -{ - PlugInLocaleDomain *domain; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - g_return_if_fail (prog_name != NULL); - g_return_if_fail (domain_name != NULL); - - domain = g_new (PlugInLocaleDomain, 1); - - domain->prog_name = g_strdup (prog_name); - domain->domain_name = g_strdup (domain_name); - domain->domain_path = g_strdup (domain_path); - - gimp->plug_in_locale_domains = g_slist_prepend (gimp->plug_in_locale_domains, - domain); - -#ifdef VERBOSE - g_print ("added locale domain \"%s\" for path \"%s\"\n", - domain->domain_name ? domain->domain_name : "(null)", - domain->domain_path ? - gimp_filename_to_utf8 (domain->domain_path) : "(null)"); -#endif -} - -const gchar * -plug_ins_locale_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **domain_path) -{ - GSList *list; - - g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); - - if (domain_path) - *domain_path = gimp_locale_directory (); - - /* A NULL prog_name is GIMP itself, return the default domain */ - if (! prog_name) - return NULL; - - for (list = gimp->plug_in_locale_domains; list; list = list->next) - { - PlugInLocaleDomain *domain = list->data; - - if (domain && domain->prog_name && - ! strcmp (domain->prog_name, prog_name)) - { - if (domain_path && domain->domain_path) - *domain_path = domain->domain_path; - - return domain->domain_name; - } - } - - return STD_PLUGINS_DOMAIN; -} - -void -plug_ins_help_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_uri) -{ - PlugInHelpDomain *domain; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - g_return_if_fail (prog_name != NULL); - g_return_if_fail (domain_name != NULL); - - domain = g_new (PlugInHelpDomain, 1); - - domain->prog_name = g_strdup (prog_name); - domain->domain_name = g_strdup (domain_name); - domain->domain_uri = g_strdup (domain_uri); - - gimp->plug_in_help_domains = g_slist_prepend (gimp->plug_in_help_domains, - domain); - -#ifdef VERBOSE - g_print ("added help domain \"%s\" for base uri \"%s\"\n", - domain->domain_name ? domain->domain_name : "(null)", - domain->domain_uri ? domain->domain_uri : "(null)"); -#endif -} - -const gchar * -plug_ins_help_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **domain_uri) -{ - GSList *list; - - g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); - - if (domain_uri) - *domain_uri = NULL; - - /* A NULL prog_name is GIMP itself, return the default domain */ - if (! prog_name) - return NULL; - - for (list = gimp->plug_in_help_domains; list; list = list->next) - { - PlugInHelpDomain *domain = list->data; - - if (domain && domain->prog_name && - ! strcmp (domain->prog_name, prog_name)) - { - if (domain_uri && domain->domain_uri) - *domain_uri = domain->domain_uri; - - return domain->domain_name; - } - } - - return NULL; -} - -gint -plug_ins_help_domains (Gimp *gimp, - gchar ***help_domains, - gchar ***help_uris) -{ - GSList *list; - gint n_domains; - gint i; - - g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); - g_return_val_if_fail (help_domains != NULL, 0); - g_return_val_if_fail (help_uris != NULL, 0); - - n_domains = g_slist_length (gimp->plug_in_help_domains); - - *help_domains = g_new0 (gchar *, n_domains); - *help_uris = g_new0 (gchar *, n_domains); - - for (list = gimp->plug_in_help_domains, i = 0; list; list = list->next, i++) - { - PlugInHelpDomain *domain = list->data; - - (*help_domains)[i] = g_strdup (domain->domain_name); - (*help_uris)[i] = g_strdup (domain->domain_uri); - } - - return n_domains; -} - /* private functions */ @@ -902,7 +708,7 @@ plug_ins_procedure_insert (Gimp *gimp, if (strcmp (GIMP_OBJECT (proc)->name, GIMP_OBJECT (tmp_proc)->name) == 0) { - GSList *list3; + GSList *list2; list->data = g_object_ref (proc); @@ -914,12 +720,12 @@ plug_ins_procedure_insert (Gimp *gimp, /* search the plugin list to see if any plugins had references to * the tmp_proc. */ - for (list3 = gimp->plug_in_defs; list3; list3 = list3->next) + for (list2 = gimp->plug_in_defs; list2; list2 = list2->next) { - PlugInDef *plug_in_def2 = list3->data; + PlugInDef *plug_in_def = list2->data; - if (g_slist_find (plug_in_def2->procedures, tmp_proc)) - plug_in_def_remove_procedure (plug_in_def2, tmp_proc); + if (g_slist_find (plug_in_def->procedures, tmp_proc)) + plug_in_def_remove_procedure (plug_in_def, tmp_proc); } /* also remove it from the lists of load and save procs */ @@ -944,6 +750,8 @@ plug_ins_file_proc_compare (gconstpointer a, Gimp *gimp = data; const GimpPlugInProcedure *proc_a = a; const GimpPlugInProcedure *proc_b = b; + const gchar *domain_a; + const gchar *domain_b; gchar *label_a; gchar *label_b; gint retval = 0; @@ -954,14 +762,11 @@ plug_ins_file_proc_compare (gconstpointer a, if (strncmp (proc_b->prog, "gimp-xcf", 8) == 0) return 1; - label_a = gimp_plug_in_procedure_get_label (proc_a, - plug_ins_locale_domain (gimp, - proc_a->prog, - NULL)); - label_b = gimp_plug_in_procedure_get_label (proc_b, - plug_ins_locale_domain (gimp, - proc_b->prog, - NULL)); + domain_a = plug_ins_locale_domain (gimp, proc_a->prog, NULL); + domain_b = plug_ins_locale_domain (gimp, proc_b->prog, NULL); + + label_a = gimp_plug_in_procedure_get_label (proc_a, domain_a); + label_b = gimp_plug_in_procedure_get_label (proc_b, domain_b); if (label_a && label_b) retval = g_utf8_collate (label_a, label_b); diff --git a/app/plug-in/plug-ins.h b/app/plug-in/plug-ins.h index 1a1c22e68b..072baa7640 100644 --- a/app/plug-in/plug-ins.h +++ b/app/plug-in/plug-ins.h @@ -70,32 +70,5 @@ void plug_ins_menu_branch_add (Gimp *gimp, const gchar *menu_path, const gchar *menu_label); -/* Add a locale domain */ -void plug_ins_locale_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_path); - -/* Retrieve a plug-ins locale domain */ -const gchar * plug_ins_locale_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **locale_path); - -/* Add a help domain */ -void plug_ins_help_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_uri); - -/* Retrieve a plug-ins help domain */ -const gchar * plug_ins_help_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **help_uri); - -/* Retrieve all help domains */ -gint plug_ins_help_domains (Gimp *gimp, - gchar ***help_domains, - gchar ***help_uris); - #endif /* __PLUG_INS_H__ */ diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c index 78f0b2e42a..3a9e10c6f4 100644 --- a/app/widgets/gimpfiledialog.c +++ b/app/widgets/gimpfiledialog.c @@ -37,7 +37,7 @@ #include "file/file-utils.h" -#include "plug-in/plug-ins.h" +#include "plug-in/plug-ins-locale.h" #include "pdb/gimp-pdb.h" #include "pdb/gimppluginprocedure.h" diff --git a/app/widgets/gimpfileprocview.c b/app/widgets/gimpfileprocview.c index c775cbd5d9..4037a46902 100644 --- a/app/widgets/gimpfileprocview.c +++ b/app/widgets/gimpfileprocview.c @@ -31,6 +31,7 @@ #include "core/gimpmarshal.h" #include "plug-in/plug-ins-help.h" +#include "plug-in/plug-ins-locale.h" #include "pdb/gimppluginprocedure.h" diff --git a/app/widgets/gimphelp.c b/app/widgets/gimphelp.c index 6fa47aabe5..5cfccd2e0d 100644 --- a/app/widgets/gimphelp.c +++ b/app/widgets/gimphelp.c @@ -39,7 +39,7 @@ #include "pdb/gimp-pdb.h" #include "pdb/gimpprocedure.h" -#include "plug-in/plug-ins.h" +#include "plug-in/plug-ins-help.h" #include "gimphelp.h" #include "gimphelp-ids.h" diff --git a/tools/pdbgen/pdb/help.pdb b/tools/pdbgen/pdb/help.pdb index 32f5d1b79a..c55d086875 100644 --- a/tools/pdbgen/pdb/help.pdb +++ b/tools/pdbgen/pdb/help.pdb @@ -52,7 +52,7 @@ CODE } -@headers = qw("core/gimp.h" "plug-in/plug-in.h" "plug-in/plug-ins.h"); +@headers = qw("core/gimp.h" "plug-in/plug-in.h" "plug-in/plug-ins-help.h"); @procs = qw(help); diff --git a/tools/pdbgen/pdb/plug_in.pdb b/tools/pdbgen/pdb/plug_in.pdb index f9e1544244..59aa61635f 100644 --- a/tools/pdbgen/pdb/plug_in.pdb +++ b/tools/pdbgen/pdb/plug_in.pdb @@ -265,11 +265,11 @@ CODE @headers = qw( - "libgimpbase/gimpbase.h" "libgimpbase/gimpprotocol.h" - "core/gimp.h" + "libgimpbase/gimpbase.h" "core/gimp.h" "plug-in/plug-in.h" "plug-in/plug-ins.h" + "plug-in/plug-ins-help.h" "plug-in/plug-ins-query.h" - "plug-in/plug-in-def.h" "plug-in/plug-in-params.h" + "plug-in/plug-in-def.h" "gimppluginprocedure.h"); @procs = qw(plugins_query