app/plug-in/Makefile.am app/plug-in/plug-ins-help.[ch] new files managing

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

	* 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.
This commit is contained in:
Michael Natterer 2006-04-09 16:25:47 +00:00 committed by Michael Natterer
parent 618202c37e
commit 5cf5b8ca1c
21 changed files with 454 additions and 494 deletions

View File

@ -1,3 +1,25 @@
2006-04-09 Michael Natterer <mitch@gimp.org>
* 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 <mitch@gimp.org>
* app/plug-in/plug-in-rc.[ch] (plug_in_rc_parse): return a GSList*

View File

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

View File

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

View File

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

View File

@ -26,7 +26,6 @@
#include <glib-object.h>
#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"

View File

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

View File

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

View File

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

View File

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

View File

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

153
app/plug-in/plug-ins-help.c Normal file
View File

@ -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 <string.h>
#include <glib-object.h>
#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;
}

View File

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

View File

@ -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 <string.h>
#include <glib-object.h>
#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";
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -265,11 +265,11 @@ CODE
@headers = qw(<string.h> <stdlib.h>
"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