diff --git a/ChangeLog b/ChangeLog index 2b9f09f67f..a3fbb74000 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2006-04-27 Michael Natterer + + * app/plug-in/plug-in-locale-domain.[ch] (plug_in_locale_domains): + new function which returns string arrays of all registered locale + domains and paths. + + (plug_in_standard_locale_domain): removed this function. The + standard plug-in domain is included in the domains returned by + plug_in_locale_domains(). + + * app/plug-in/plug-ins.c (plug_ins_init): simply bind the text + domains here instead of calling gimp_menus_init(). Destroy + gimp->plug_in_defs much earlier. + + * app/core/gimp-gui.[ch] + * app/gui/gui-vtable.c: removed gimp_menus_init(). + + * app/menus/plug-in-menus.[ch]: removed plug_in_menus_init(), + binding text domains is completely done in the core now. + 2006-04-27 Michael Natterer Added some signals inspired by Rockwalrus' libpdb: diff --git a/app/core/gimp-gui.c b/app/core/gimp-gui.c index 1d358a4001..283672e748 100644 --- a/app/core/gimp-gui.c +++ b/app/core/gimp-gui.c @@ -56,7 +56,6 @@ gimp_gui_init (Gimp *gimp) gimp->gui.display_create = NULL; gimp->gui.display_delete = NULL; gimp->gui.displays_reconnect = NULL; - gimp->gui.menus_init = NULL; gimp->gui.menus_create_branch = NULL; gimp->gui.progress_new = NULL; gimp->gui.progress_free = NULL; @@ -294,18 +293,6 @@ gimp_reconnect_displays (Gimp *gimp, gimp->gui.displays_reconnect (gimp, old_image, new_image); } -void -gimp_menus_init (Gimp *gimp, - GSList *plug_in_defs, - const gchar *std_plugins_domain) -{ - g_return_if_fail (GIMP_IS_GIMP (gimp)); - g_return_if_fail (std_plugins_domain != NULL); - - if (gimp->gui.menus_init) - gimp->gui.menus_init (gimp, plug_in_defs, std_plugins_domain); -} - void gimp_menus_create_branch (Gimp *gimp, const gchar *progname, diff --git a/app/core/gimp-gui.h b/app/core/gimp-gui.h index bc5cd59476..4ad8aaca37 100644 --- a/app/core/gimp-gui.h +++ b/app/core/gimp-gui.h @@ -55,9 +55,6 @@ struct _GimpGui GimpImage *old_image, GimpImage *new_image); - void (* menus_init) (Gimp *gimp, - GSList *plug_in_defs, - const gchar *std_domain); void (* menus_create_branch) (Gimp *gimp, const gchar *progname, const gchar *menu_path, @@ -119,9 +116,6 @@ void gimp_help (Gimp *gimp, const gchar *help_domain, const gchar *help_id); -void gimp_menus_init (Gimp *gimp, - GSList *plug_in_defs, - const gchar *std_plugins_domain); void gimp_menus_create_branch (Gimp *gimp, const gchar *progname, const gchar *menu_path, diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c index cefa29d108..2a8ac110d7 100644 --- a/app/gui/gui-vtable.c +++ b/app/gui/gui-vtable.c @@ -68,7 +68,6 @@ #include "actions/plug-in-actions.h" #include "menus/menus.h" -#include "menus/plug-in-menus.h" #include "dialogs/dialogs.h" @@ -103,9 +102,6 @@ static void gui_display_delete (GimpObject *display); static void gui_displays_reconnect (Gimp *gimp, GimpImage *old_image, GimpImage *new_image); -static void gui_menus_init (Gimp *gimp, - GSList *plug_in_defs, - const gchar *plugins_domain); static void gui_menus_create_branch (Gimp *gimp, const gchar *progname, const gchar *menu_path, @@ -154,7 +150,6 @@ gui_vtable_init (Gimp *gimp) gimp->gui.display_create = gui_display_create; gimp->gui.display_delete = gui_display_delete; gimp->gui.displays_reconnect = gui_displays_reconnect; - gimp->gui.menus_init = gui_menus_init; gimp->gui.menus_create_branch = gui_menus_create_branch; gimp->gui.progress_new = gui_new_progress; gimp->gui.progress_free = gui_free_progress; @@ -372,14 +367,6 @@ gui_displays_reconnect (Gimp *gimp, gimp_displays_reconnect (gimp, old_image, new_image); } -static void -gui_menus_init (Gimp *gimp, - GSList *plug_in_defs, - const gchar *std_plugins_domain) -{ - plug_in_menus_init (gimp, plug_in_defs, std_plugins_domain); -} - static void gui_menus_create_branch (Gimp *gimp, const gchar *progname, diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index 65b2706bcc..7cd5b7dd9d 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -32,7 +32,6 @@ #include "pdb/gimppluginprocedure.h" -#include "plug-in/plug-in-def.h" #include "plug-in/plug-in-locale-domain.h" #include "widgets/gimpuimanager.h" @@ -78,56 +77,6 @@ static gchar * plug_in_menus_build_path (GimpUIManager *manager, /* public functions */ -void -plug_in_menus_init (Gimp *gimp, - GSList *plug_in_defs, - const gchar *std_plugins_domain) -{ - GSList *domains = NULL; - GSList *tmp; - - g_return_if_fail (std_plugins_domain != NULL); - - domains = g_slist_append (domains, (gpointer) std_plugins_domain); - - bindtextdomain (std_plugins_domain, gimp_locale_directory ()); -#ifdef HAVE_BIND_TEXTDOMAIN_CODESET - bind_textdomain_codeset (std_plugins_domain, "UTF-8"); -#endif - - for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp)) - { - PlugInDef *plug_in_def = tmp->data; - - if (plug_in_def->procedures) - { - const gchar *locale_domain; - const gchar *locale_path; - GSList *list; - - locale_domain = plug_in_locale_domain (gimp, - plug_in_def->prog, - &locale_path); - - for (list = domains; list; list = list->next) - if (! strcmp (locale_domain, (const gchar *) list->data)) - break; - - if (! list) - { - domains = g_slist_append (domains, (gpointer) locale_domain); - - bindtextdomain (locale_domain, locale_path); -#ifdef HAVE_BIND_TEXTDOMAIN_CODESET - bind_textdomain_codeset (locale_domain, "UTF-8"); -#endif - } - } - } - - g_slist_free (domains); -} - void plug_in_menus_setup (GimpUIManager *manager, const gchar *ui_path) diff --git a/app/menus/plug-in-menus.h b/app/menus/plug-in-menus.h index ba2c9bd117..ccaf9f04bf 100644 --- a/app/menus/plug-in-menus.h +++ b/app/menus/plug-in-menus.h @@ -20,10 +20,6 @@ #define __PLUG_IN_MENUS_H__ -void plug_in_menus_init (Gimp *gimp, - GSList *plug_in_defs, - const gchar *std_plugins_domain); - void plug_in_menus_setup (GimpUIManager *manager, const gchar *ui_path); diff --git a/app/plug-in/gimppluginmanager-locale-domain.c b/app/plug-in/gimppluginmanager-locale-domain.c index 52e09be70a..76238e2f8f 100644 --- a/app/plug-in/gimppluginmanager-locale-domain.c +++ b/app/plug-in/gimppluginmanager-locale-domain.c @@ -33,6 +33,9 @@ #include "plug-in-locale-domain.h" +#define STD_PLUG_INS_LOCALE_DOMAIN GETTEXT_PACKAGE "-std-plug-ins" + + typedef struct _PlugInLocaleDomain PlugInLocaleDomain; struct _PlugInLocaleDomain @@ -123,11 +126,57 @@ plug_in_locale_domain (Gimp *gimp, } } - return plug_in_standard_locale_domain (); + return STD_PLUG_INS_LOCALE_DOMAIN; } -const gchar * -plug_in_standard_locale_domain (void) +gint +plug_in_locale_domains (Gimp *gimp, + gchar ***locale_domains, + gchar ***locale_paths) { - return GETTEXT_PACKAGE "-std-plug-ins"; + GSList *list; + GSList *unique = NULL; + gint n_domains; + gint i; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); + g_return_val_if_fail (locale_domains != NULL, 0); + g_return_val_if_fail (locale_paths != NULL, 0); + + for (list = gimp->plug_in_locale_domains; list; list = list->next) + { + PlugInLocaleDomain *domain = list->data; + GSList *tmp; + + for (tmp = unique; tmp; tmp = tmp->next) + if (! strcmp (domain->domain_name, (const gchar *) tmp->data)) + break; + + if (! tmp) + unique = g_slist_prepend (unique, domain); + } + + unique = g_slist_reverse (unique); + + n_domains = g_slist_length (unique) + 1; + + *locale_domains = g_new0 (gchar *, n_domains); + *locale_paths = g_new0 (gchar *, n_domains); + + (*locale_domains)[0] = g_strdup (STD_PLUG_INS_LOCALE_DOMAIN); + (*locale_paths)[0] = g_strdup (gimp_locale_directory ()); + + for (list = unique, i = 1; list; list = list->next, i++) + { + PlugInLocaleDomain *domain = list->data; + + (*locale_domains)[i] = g_strdup (domain->domain_name); + (*locale_paths)[i] = (domain->domain_path ? + g_strdup (domain->domain_path) : + g_strdup (gimp_locale_directory ())); + } + + g_slist_free (unique); + + return n_domains; } diff --git a/app/plug-in/gimppluginmanager-locale-domain.h b/app/plug-in/gimppluginmanager-locale-domain.h index ccc5820efb..908c9eef0f 100644 --- a/app/plug-in/gimppluginmanager-locale-domain.h +++ b/app/plug-in/gimppluginmanager-locale-domain.h @@ -22,21 +22,23 @@ #define __PLUG_IN_LOCALE_DOMAIN_H__ -void plug_in_locale_domain_exit (Gimp *gimp); +void plug_in_locale_domain_exit (Gimp *gimp); /* Add a locale domain */ -void plug_in_locale_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_path); +void plug_in_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_in_locale_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **locale_path); +const gchar * plug_in_locale_domain (Gimp *gimp, + const gchar *prog_name, + const gchar **locale_path); -/* Retrieve the locale domain of the standard plug-ins */ -const gchar * plug_in_standard_locale_domain (void) G_GNUC_CONST; +/* Retrieve all help domains */ +gint plug_in_locale_domains (Gimp *gimp, + gchar ***locale_domains, + gchar ***locale_paths); #endif /* __PLUG_IN_LOCALE_DOMAIN_H__ */ diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 0afb1e1552..e22367fb2d 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -264,8 +264,18 @@ plug_ins_init (Gimp *gimp, plug_in_def->help_domain_uri); } + /* we're done with the plug-in-defs */ + g_slist_foreach (gimp->plug_in_defs, (GFunc) plug_in_def_free, NULL); + g_slist_free (gimp->plug_in_defs); + gimp->plug_in_defs = NULL; + if (! gimp->no_interface) { + gchar **locale_domains; + gchar **locale_paths; + gint n_domains; + gint i; + gimp->load_procs = g_slist_sort_with_data (gimp->load_procs, plug_ins_file_proc_compare, gimp); @@ -273,8 +283,19 @@ plug_ins_init (Gimp *gimp, plug_ins_file_proc_compare, gimp); - gimp_menus_init (gimp, gimp->plug_in_defs, - plug_in_standard_locale_domain ()); + n_domains = plug_in_locale_domains (gimp, &locale_domains, + &locale_paths); + + for (i = 0; i < n_domains; i++) + { + bindtextdomain (locale_domains[i], locale_paths[i]); +#ifdef HAVE_BIND_TEXTDOMAIN_CODESET + bind_textdomain_codeset (locale_domains[i], "UTF-8"); +#endif + } + + g_strfreev (locale_domains); + g_strfreev (locale_paths); } /* add the plug-in procs to the procedure database */ @@ -330,11 +351,6 @@ plug_ins_init (Gimp *gimp, } status_callback ("", "", 1.0); - - /* free up stuff */ - g_slist_foreach (gimp->plug_in_defs, (GFunc) plug_in_def_free, NULL); - g_slist_free (gimp->plug_in_defs); - gimp->plug_in_defs = NULL; } void diff --git a/app/plug-in/plug-in-locale-domain.c b/app/plug-in/plug-in-locale-domain.c index 52e09be70a..76238e2f8f 100644 --- a/app/plug-in/plug-in-locale-domain.c +++ b/app/plug-in/plug-in-locale-domain.c @@ -33,6 +33,9 @@ #include "plug-in-locale-domain.h" +#define STD_PLUG_INS_LOCALE_DOMAIN GETTEXT_PACKAGE "-std-plug-ins" + + typedef struct _PlugInLocaleDomain PlugInLocaleDomain; struct _PlugInLocaleDomain @@ -123,11 +126,57 @@ plug_in_locale_domain (Gimp *gimp, } } - return plug_in_standard_locale_domain (); + return STD_PLUG_INS_LOCALE_DOMAIN; } -const gchar * -plug_in_standard_locale_domain (void) +gint +plug_in_locale_domains (Gimp *gimp, + gchar ***locale_domains, + gchar ***locale_paths) { - return GETTEXT_PACKAGE "-std-plug-ins"; + GSList *list; + GSList *unique = NULL; + gint n_domains; + gint i; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); + g_return_val_if_fail (locale_domains != NULL, 0); + g_return_val_if_fail (locale_paths != NULL, 0); + + for (list = gimp->plug_in_locale_domains; list; list = list->next) + { + PlugInLocaleDomain *domain = list->data; + GSList *tmp; + + for (tmp = unique; tmp; tmp = tmp->next) + if (! strcmp (domain->domain_name, (const gchar *) tmp->data)) + break; + + if (! tmp) + unique = g_slist_prepend (unique, domain); + } + + unique = g_slist_reverse (unique); + + n_domains = g_slist_length (unique) + 1; + + *locale_domains = g_new0 (gchar *, n_domains); + *locale_paths = g_new0 (gchar *, n_domains); + + (*locale_domains)[0] = g_strdup (STD_PLUG_INS_LOCALE_DOMAIN); + (*locale_paths)[0] = g_strdup (gimp_locale_directory ()); + + for (list = unique, i = 1; list; list = list->next, i++) + { + PlugInLocaleDomain *domain = list->data; + + (*locale_domains)[i] = g_strdup (domain->domain_name); + (*locale_paths)[i] = (domain->domain_path ? + g_strdup (domain->domain_path) : + g_strdup (gimp_locale_directory ())); + } + + g_slist_free (unique); + + return n_domains; } diff --git a/app/plug-in/plug-in-locale-domain.h b/app/plug-in/plug-in-locale-domain.h index ccc5820efb..908c9eef0f 100644 --- a/app/plug-in/plug-in-locale-domain.h +++ b/app/plug-in/plug-in-locale-domain.h @@ -22,21 +22,23 @@ #define __PLUG_IN_LOCALE_DOMAIN_H__ -void plug_in_locale_domain_exit (Gimp *gimp); +void plug_in_locale_domain_exit (Gimp *gimp); /* Add a locale domain */ -void plug_in_locale_domain_add (Gimp *gimp, - const gchar *prog_name, - const gchar *domain_name, - const gchar *domain_path); +void plug_in_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_in_locale_domain (Gimp *gimp, - const gchar *prog_name, - const gchar **locale_path); +const gchar * plug_in_locale_domain (Gimp *gimp, + const gchar *prog_name, + const gchar **locale_path); -/* Retrieve the locale domain of the standard plug-ins */ -const gchar * plug_in_standard_locale_domain (void) G_GNUC_CONST; +/* Retrieve all help domains */ +gint plug_in_locale_domains (Gimp *gimp, + gchar ***locale_domains, + gchar ***locale_paths); #endif /* __PLUG_IN_LOCALE_DOMAIN_H__ */ diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index 0afb1e1552..e22367fb2d 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -264,8 +264,18 @@ plug_ins_init (Gimp *gimp, plug_in_def->help_domain_uri); } + /* we're done with the plug-in-defs */ + g_slist_foreach (gimp->plug_in_defs, (GFunc) plug_in_def_free, NULL); + g_slist_free (gimp->plug_in_defs); + gimp->plug_in_defs = NULL; + if (! gimp->no_interface) { + gchar **locale_domains; + gchar **locale_paths; + gint n_domains; + gint i; + gimp->load_procs = g_slist_sort_with_data (gimp->load_procs, plug_ins_file_proc_compare, gimp); @@ -273,8 +283,19 @@ plug_ins_init (Gimp *gimp, plug_ins_file_proc_compare, gimp); - gimp_menus_init (gimp, gimp->plug_in_defs, - plug_in_standard_locale_domain ()); + n_domains = plug_in_locale_domains (gimp, &locale_domains, + &locale_paths); + + for (i = 0; i < n_domains; i++) + { + bindtextdomain (locale_domains[i], locale_paths[i]); +#ifdef HAVE_BIND_TEXTDOMAIN_CODESET + bind_textdomain_codeset (locale_domains[i], "UTF-8"); +#endif + } + + g_strfreev (locale_domains); + g_strfreev (locale_paths); } /* add the plug-in procs to the procedure database */ @@ -330,11 +351,6 @@ plug_ins_init (Gimp *gimp, } status_callback ("", "", 1.0); - - /* free up stuff */ - g_slist_foreach (gimp->plug_in_defs, (GFunc) plug_in_def_free, NULL); - g_slist_free (gimp->plug_in_defs); - gimp->plug_in_defs = NULL; } void