new function which returns string arrays of all registered locale domains

2006-04-27  Michael Natterer  <mitch@gimp.org>

	* 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.
This commit is contained in:
Michael Natterer 2006-04-27 21:53:33 +00:00 committed by Michael Natterer
parent ee66f2f31d
commit 305ada6354
12 changed files with 196 additions and 129 deletions

View File

@ -1,3 +1,23 @@
2006-04-27 Michael Natterer <mitch@gimp.org>
* 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 <mitch@gimp.org>
Added some signals inspired by Rockwalrus' libpdb:

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -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);

View File

@ -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;
}

View File

@ -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__ */

View File

@ -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

View File

@ -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;
}

View File

@ -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__ */

View File

@ -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