Commit 36a955a5 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

add "locale_domain" and "help_domain" members and APIs to get/set them.

2007-02-18  Michael Natterer  <mitch@gimp.org>

	* app/plug-in/gimppluginprocedure.[ch]: add "locale_domain" and
	"help_domain" members and APIs to get/set them. Removed locale and
	help domain parameters from all other functions.

	* app/plug-in/gimpplugin.c (gimp_plug_in_add_temp_proc)
	* app/plug-in/plug-in-def.c (plug_in_def_add_procedure)
	(plug_in_def_set_locale_domain_name)
	(plug_in_def_set_help_domain_name): make sure all plug-in procedures
	have locale and help domains.

	* app/plug-in/gimppluginmanager.[ch]: removed function
	gimp_plug_in_manager_get_label().

	* app/plug-in/gimppluginmanager.c
	* app/plug-in/gimpplugin-cleanup.c
	* app/actions/plug-in-actions.c
	* app/widgets/gimpfiledialog.c
	* app/widgets/gimpfileprocview.c
	* app/widgets/gimpimagepropview.c: changed (simplified) accordingly.


svn path=/trunk/; revision=21937
parent 1504a7f5
2007-02-18 Michael Natterer <mitch@gimp.org>
* app/plug-in/gimppluginprocedure.[ch]: add "locale_domain" and
"help_domain" members and APIs to get/set them. Removed locale and
help domain parameters from all other functions.
* app/plug-in/gimpplugin.c (gimp_plug_in_add_temp_proc)
* app/plug-in/plug-in-def.c (plug_in_def_add_procedure)
(plug_in_def_set_locale_domain_name)
(plug_in_def_set_help_domain_name): make sure all plug-in procedures
have locale and help domains.
* app/plug-in/gimppluginmanager.[ch]: removed function
gimp_plug_in_manager_get_label().
* app/plug-in/gimppluginmanager.c
* app/plug-in/gimpplugin-cleanup.c
* app/actions/plug-in-actions.c
* app/widgets/gimpfiledialog.c
* app/widgets/gimpfileprocview.c
* app/widgets/gimpimagepropview.c: changed (simplified) accordingly.
2007-02-18 Sven Neumann <sven@gimp.org>
* app/widgets/gimppixbuf.c (gimp_pixbuf_targets_add): skip Windows
......@@ -385,7 +385,6 @@ plug_in_actions_menu_path_added (GimpPlugInProcedure *plug_in_proc,
const gchar *menu_path,
GimpActionGroup *group)
{
const gchar *progname;
const gchar *locale_domain;
const gchar *path_translated;
......@@ -394,10 +393,7 @@ plug_in_actions_menu_path_added (GimpPlugInProcedure *plug_in_proc,
gimp_object_get_name (GIMP_OBJECT (plug_in_proc)), menu_path);
#endif
progname = gimp_plug_in_procedure_get_progname (plug_in_proc);
locale_domain = gimp_plug_in_manager_get_locale_domain (group->gimp->plug_in_manager,
progname, NULL);
locale_domain = gimp_plug_in_procedure_get_locale_domain (plug_in_proc);
path_translated = dgettext (locale_domain, menu_path);
......@@ -412,19 +408,12 @@ plug_in_actions_add_proc (GimpActionGroup *group,
GimpPlugInProcedure *proc)
{
GimpPlugInActionEntry entry;
const gchar *progname;
const gchar *locale_domain;
const gchar *help_domain;
const gchar *label;
gchar *path_original = NULL;
gchar *path_translated = NULL;
progname = gimp_plug_in_procedure_get_progname (proc);
locale_domain = gimp_plug_in_manager_get_locale_domain (group->gimp->plug_in_manager,
progname, NULL);
help_domain = gimp_plug_in_manager_get_help_domain (group->gimp->plug_in_manager,
progname, NULL);
locale_domain = gimp_plug_in_procedure_get_locale_domain (proc);
if (proc->menu_label)
{
......@@ -457,9 +446,9 @@ plug_in_actions_add_proc (GimpActionGroup *group,
entry.stock_id = gimp_plug_in_procedure_get_stock_id (proc);
entry.label = label;
entry.accelerator = NULL;
entry.tooltip = gimp_plug_in_procedure_get_blurb (proc, locale_domain);
entry.tooltip = gimp_plug_in_procedure_get_blurb (proc);
entry.procedure = proc;
entry.help_id = gimp_plug_in_procedure_get_help_id (proc, help_domain);
entry.help_id = gimp_plug_in_procedure_get_help_id (proc);
#if 0
g_print ("adding plug-in action '%s' (%s)\n",
......@@ -500,8 +489,6 @@ plug_in_actions_history_changed (GimpPlugInManager *manager,
GimpActionGroup *group)
{
GimpPlugInProcedure *proc;
const gchar *progname;
const gchar *domain;
gint i;
proc = gimp_plug_in_manager_history_nth (manager, 0);
......@@ -512,11 +499,7 @@ plug_in_actions_history_changed (GimpPlugInManager *manager,
gchar *repeat;
gchar *reshow;
progname = gimp_plug_in_procedure_get_progname (proc);
domain = gimp_plug_in_manager_get_locale_domain (manager,
progname, NULL);
label = gimp_plug_in_procedure_get_label (proc, domain);
label = gimp_plug_in_procedure_get_label (proc);
repeat = g_strdup_printf (_("Re_peat \"%s\""), label);
reshow = g_strdup_printf (_("R_e-Show \"%s\""), label);
......@@ -546,19 +529,16 @@ plug_in_actions_history_changed (GimpPlugInManager *manager,
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name);
g_free (name);
proc = gimp_plug_in_manager_history_nth (manager, i);
progname = gimp_plug_in_procedure_get_progname (proc);
domain = gimp_plug_in_manager_get_locale_domain (manager,
progname, NULL);
proc = gimp_plug_in_manager_history_nth (manager, i);
label = gimp_plug_in_procedure_get_label (proc, domain);
label = gimp_plug_in_procedure_get_label (proc);
g_object_set (action,
"visible", TRUE,
"procedure", proc,
"label", label,
"stock-id", gimp_plug_in_procedure_get_stock_id (proc),
"tooltip", gimp_plug_in_procedure_get_blurb (proc, domain),
"tooltip", gimp_plug_in_procedure_get_blurb (proc),
NULL);
g_free (label);
......
......@@ -34,7 +34,6 @@
#include "gimpplugin.h"
#include "gimpplugin-cleanup.h"
#include "gimppluginmanager.h"
#include "gimppluginmanager-locale-domain.h"
#include "gimppluginprocedure.h"
......@@ -160,13 +159,9 @@ gimp_plug_in_cleanup (GimpPlugIn *plug_in,
if (cleanup->undo_group_count != image->group_count)
{
const gchar *domain;
gchar *label;
gchar *label;
domain = gimp_plug_in_manager_get_locale_domain (plug_in->manager,
plug_in->prog, NULL);
label = gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure),
domain);
label = gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure));
g_message ("Plug-In '%s' left image undo in inconsistent state, "
"closing open undo groups.", label);
......
......@@ -83,6 +83,7 @@
#include "gimpplugin-progress.h"
#include "gimpplugindebug.h"
#include "gimppluginmanager.h"
#include "gimppluginmanager-help-domain.h"
#include "gimppluginmanager-locale-domain.h"
#include "gimptemporaryprocedure.h"
#include "plug-in-def.h"
......@@ -836,14 +837,7 @@ gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in)
proc = GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure);
if (proc)
{
const gchar *domain;
domain = gimp_plug_in_manager_get_locale_domain (plug_in->manager,
plug_in->prog, NULL);
undo_desc = gimp_plug_in_procedure_get_label (proc, domain);
}
undo_desc = gimp_plug_in_procedure_get_label (proc);
if (! undo_desc)
undo_desc = g_strdup (gimp_object_get_name (GIMP_OBJECT (plug_in)));
......@@ -934,9 +928,24 @@ void
gimp_plug_in_add_temp_proc (GimpPlugIn *plug_in,
GimpTemporaryProcedure *proc)
{
const gchar *locale_domain;
const gchar *help_domain;
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
locale_domain = gimp_plug_in_manager_get_locale_domain (plug_in->manager,
plug_in->prog,
NULL);
help_domain = gimp_plug_in_manager_get_help_domain (plug_in->manager,
plug_in->prog,
NULL);
gimp_plug_in_procedure_set_locale_domain (GIMP_PLUG_IN_PROCEDURE (proc),
locale_domain);
gimp_plug_in_procedure_set_help_domain (GIMP_PLUG_IN_PROCEDURE (proc),
help_domain);
plug_in->temp_procedures = g_slist_prepend (plug_in->temp_procedures,
g_object_ref (proc));
gimp_plug_in_manager_add_temp_proc (plug_in->manager, proc);
......
......@@ -769,20 +769,6 @@ gimp_plug_in_manager_history_changed (GimpPlugInManager *manager)
g_signal_emit (manager, manager_signals[HISTORY_CHANGED], 0);
}
gchar *
gimp_plug_in_manager_get_label (GimpPlugInManager *manager,
GimpPlugInProcedure *proc)
{
const gchar *domain;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
domain = gimp_plug_in_manager_get_locale_domain (manager, proc->prog, NULL);
return gimp_plug_in_procedure_get_label (proc, domain);
}
/* private functions */
......@@ -950,11 +936,8 @@ gimp_plug_in_manager_file_proc_compare (gconstpointer a,
gconstpointer b,
gpointer data)
{
GimpPlugInManager *manager = 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;
......@@ -965,13 +948,8 @@ gimp_plug_in_manager_file_proc_compare (gconstpointer a,
if (g_str_has_prefix (proc_b->prog, "gimp-xcf"))
return 1;
domain_a = gimp_plug_in_manager_get_locale_domain (manager, proc_a->prog,
NULL);
domain_b = gimp_plug_in_manager_get_locale_domain (manager, 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);
label_a = gimp_plug_in_procedure_get_label (proc_a);
label_b = gimp_plug_in_procedure_get_label (proc_b);
if (label_a && label_b)
retval = g_utf8_collate (label_a, label_b);
......
......@@ -115,8 +115,5 @@ void gimp_plug_in_manager_plug_in_pop (GimpPlugInManager *manager);
void gimp_plug_in_manager_history_changed (GimpPlugInManager *manager);
gchar * gimp_plug_in_manager_get_label (GimpPlugInManager *manager,
GimpPlugInProcedure *proc);
#endif /* __GIMP_PLUG_IN_MANAGER_H__ */
......@@ -117,6 +117,8 @@ gimp_plug_in_procedure_finalize (GObject *object)
GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (object);
g_free (proc->prog);
g_free (proc->locale_domain);
g_free (proc->help_domain);
g_free (proc->menu_label);
g_list_foreach (proc->menu_paths, (GFunc) g_free, NULL);
......@@ -288,6 +290,42 @@ gimp_plug_in_procedure_get_progname (const GimpPlugInProcedure *proc)
return GIMP_PLUG_IN_PROCEDURE_GET_CLASS (proc)->get_progname (proc);
}
void
gimp_plug_in_procedure_set_locale_domain (GimpPlugInProcedure *proc,
const gchar *locale_domain)
{
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc));
g_free (proc->locale_domain);
proc->locale_domain = g_strdup (locale_domain);
}
const gchar *
gimp_plug_in_procedure_get_locale_domain (const GimpPlugInProcedure *proc)
{
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
return proc->locale_domain;
}
void
gimp_plug_in_procedure_set_help_domain (GimpPlugInProcedure *proc,
const gchar *help_domain)
{
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc));
g_free (proc->help_domain);
proc->help_domain = g_strdup (help_domain);
}
const gchar *
gimp_plug_in_procedure_get_help_domain (const GimpPlugInProcedure *proc)
{
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
return proc->help_domain;
}
gboolean
gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
const gchar *menu_path,
......@@ -481,8 +519,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
}
gchar *
gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc,
const gchar *locale_domain)
gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc)
{
const gchar *path;
gchar *stripped;
......@@ -492,9 +529,9 @@ gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc,
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
if (proc->menu_label)
path = dgettext (locale_domain, proc->menu_label);
path = dgettext (proc->locale_domain, proc->menu_label);
else if (proc->menu_paths)
path = dgettext (locale_domain, proc->menu_paths->data);
path = dgettext (proc->locale_domain, proc->menu_paths->data);
else
return NULL;
......@@ -519,8 +556,7 @@ gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc,
}
const gchar *
gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc,
const gchar *locale_domain)
gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc)
{
GimpProcedure *procedure;
......@@ -530,7 +566,7 @@ gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc,
/* do not to pass the empty string to gettext() */
if (procedure->blurb && strlen (procedure->blurb))
return dgettext (locale_domain, procedure->blurb);
return dgettext (proc->locale_domain, procedure->blurb);
return NULL;
}
......@@ -618,13 +654,12 @@ gimp_plug_in_procedure_get_pixbuf (const GimpPlugInProcedure *proc)
}
gchar *
gimp_plug_in_procedure_get_help_id (const GimpPlugInProcedure *proc,
const gchar *help_domain)
gimp_plug_in_procedure_get_help_id (const GimpPlugInProcedure *proc)
{
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
if (help_domain)
return g_strconcat (help_domain, "?", GIMP_OBJECT (proc)->name, NULL);
if (proc->help_domain)
return g_strconcat (proc->help_domain, "?", GIMP_OBJECT (proc)->name, NULL);
return g_strdup (GIMP_OBJECT (proc)->name);
}
......
......@@ -44,6 +44,8 @@ struct _GimpPlugInProcedure
/* common members */
gchar *prog;
gchar *locale_domain;
gchar *help_domain;
gchar *menu_label;
GList *menu_paths;
GimpIconType icon_type;
......@@ -88,14 +90,22 @@ GimpPlugInProcedure * gimp_plug_in_procedure_find (GSList
const gchar *proc_name);
const gchar * gimp_plug_in_procedure_get_progname (const GimpPlugInProcedure *proc);
void gimp_plug_in_procedure_set_locale_domain (GimpPlugInProcedure *proc,
const gchar *locale_domain);
const gchar * gimp_plug_in_procedure_get_locale_domain (const GimpPlugInProcedure *proc);
void gimp_plug_in_procedure_set_help_domain (GimpPlugInProcedure *proc,
const gchar *help_domain);
const gchar * gimp_plug_in_procedure_get_help_domain (const GimpPlugInProcedure *proc);
gboolean gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
const gchar *menu_path,
GError **error);
gchar * gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc,
const gchar *locale_domain);
const gchar * gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc,
const gchar *locale_domain);
gchar * gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc);
const gchar * gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc);
void gimp_plug_in_procedure_set_icon (GimpPlugInProcedure *proc,
GimpIconType type,
const guint8 *data,
......@@ -103,8 +113,8 @@ void gimp_plug_in_procedure_set_icon (GimpPlugInProcedure
const gchar * gimp_plug_in_procedure_get_stock_id (const GimpPlugInProcedure *proc);
GdkPixbuf * gimp_plug_in_procedure_get_pixbuf (const GimpPlugInProcedure *proc);
gchar * gimp_plug_in_procedure_get_help_id (const GimpPlugInProcedure *proc,
const gchar *help_domain);
gchar * gimp_plug_in_procedure_get_help_id (const GimpPlugInProcedure *proc);
gboolean gimp_plug_in_procedure_get_sensitive (const GimpPlugInProcedure *proc,
GimpImageType image_type);
......
......@@ -68,6 +68,11 @@ plug_in_def_add_procedure (PlugInDef *plug_in_def,
proc->mtime = plug_in_def->mtime;
gimp_plug_in_procedure_set_locale_domain (proc,
plug_in_def->locale_domain_name);
gimp_plug_in_procedure_set_help_domain (proc,
plug_in_def->help_domain_name);
plug_in_def->procedures = g_slist_append (plug_in_def->procedures,
g_object_ref (proc));
}
......@@ -87,11 +92,21 @@ void
plug_in_def_set_locale_domain_name (PlugInDef *plug_in_def,
const gchar *domain_name)
{
GSList *list;
g_return_if_fail (plug_in_def != NULL);
if (plug_in_def->locale_domain_name)
g_free (plug_in_def->locale_domain_name);
plug_in_def->locale_domain_name = g_strdup (domain_name);
for (list = plug_in_def->procedures; list; list = g_slist_next (list))
{
GimpPlugInProcedure *procedure = list->data;
gimp_plug_in_procedure_set_locale_domain (procedure,
plug_in_def->locale_domain_name);
}
}
void
......@@ -109,11 +124,21 @@ void
plug_in_def_set_help_domain_name (PlugInDef *plug_in_def,
const gchar *domain_name)
{
GSList *list;
g_return_if_fail (plug_in_def != NULL);
if (plug_in_def->help_domain_name)
g_free (plug_in_def->help_domain_name);
plug_in_def->help_domain_name = g_strdup (domain_name);
for (list = plug_in_def->procedures; list; list = g_slist_next (list))
{
GimpPlugInProcedure *procedure = list->data;
gimp_plug_in_procedure_set_help_domain (procedure,
plug_in_def->help_domain_name);
}
}
void
......
......@@ -540,8 +540,7 @@ gimp_file_dialog_add_filters (GimpFileDialog *dialog,
GSList *ext;
gint i;
label = gimp_plug_in_manager_get_label (gimp->plug_in_manager,
file_proc);
label = gimp_plug_in_procedure_get_label (file_proc);
str = g_string_new (label);
g_free (label);
......
......@@ -30,8 +30,6 @@
#include "core/gimp.h"
#include "core/gimpmarshal.h"
#include "plug-in/gimppluginmanager-help-domain.h"
#include "plug-in/gimppluginmanager-locale-domain.h"
#include "plug-in/gimppluginprocedure.h"
#include "gimpfileprocview.h"
......@@ -141,18 +139,9 @@ gimp_file_proc_view_new (Gimp *gimp,
if (! proc->prefixes_list) /* skip URL loaders */
{
const gchar *locale_domain;
const gchar *help_domain;
gchar *label;
gchar *help_id;
GSList *list2;
locale_domain = gimp_plug_in_manager_get_locale_domain (gimp->plug_in_manager,
proc->prog, NULL);
help_domain = gimp_plug_in_manager_get_help_domain (gimp->plug_in_manager,
proc->prog, NULL);
label = gimp_plug_in_procedure_get_label (proc, locale_domain);
help_id = gimp_plug_in_procedure_get_help_id (proc, help_domain);
gchar *label = gimp_plug_in_procedure_get_label (proc);
gchar *help_id = gimp_plug_in_procedure_get_help_id (proc);
GSList *list2;
if (label)
{
......
......@@ -46,6 +46,7 @@
#include "file/file-utils.h"
#include "plug-in/gimppluginmanager.h"
#include "plug-in/gimppluginprocedure.h"
#include "gimpimagepropview.h"
#include "gimppropwidgets.h"
......@@ -376,7 +377,7 @@ gimp_image_prop_view_label_set_filetype (GtkWidget *label,
}
}
text = proc ? gimp_plug_in_manager_get_label (manager, proc) : NULL;
text = proc ? gimp_plug_in_procedure_get_label (proc) : NULL;
gtk_label_set_text (GTK_LABEL (label), text);
g_free (text);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment