cache the result of gimp_plug_in_procedure_get_label() and made the return

2007-03-10  Sven Neumann  <sven@gimp.org>

	* app/plug-in/gimppluginprocedure.[ch]: cache the result of
	gimp_plug_in_procedure_get_label() and made the return value 
const.


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

	* app/file/file-open.c
	* app/file/file-save.c: include the plug-in name (or actually 
the
	label) in the error messages.


svn path=/trunk/; revision=22095
This commit is contained in:
Sven Neumann 2007-03-10 21:22:22 +00:00 committed by Sven Neumann
parent 4ddfeb7ddc
commit 8fd67e0e95
11 changed files with 55 additions and 48 deletions

View file

@ -1,3 +1,20 @@
2007-03-10 Sven Neumann <sven@gimp.org>
* app/plug-in/gimppluginprocedure.[ch]: cache the result of
gimp_plug_in_procedure_get_label() and made the return value const.
* app/actions/plug-in-actions.c
* app/plug-in/gimpplugin-cleanup.c
* app/plug-in/gimppluginmanager.c
* app/widgets/gimpfiledialog.c
* app/widgets/gimpfileprocview.c
* app/widgets/gimpimagepropview.c: changed accordingly.
* app/file/file-open.c
* app/file/file-save.c: include the plug-in name (or actually the
label) in the error messages.
2007-03-10 Michael Natterer <mitch@gimp.org>
* app/core/core-types.h: don't include libgimpmath/gimpmathtypes.h

View file

@ -495,17 +495,15 @@ plug_in_actions_history_changed (GimpPlugInManager *manager,
if (proc)
{
gchar *label;
gchar *repeat;
gchar *reshow;
const gchar *label;
gchar *repeat;
gchar *reshow;
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);
g_free (label);
gimp_action_group_set_action_label (group, "plug-in-repeat", repeat);
gimp_action_group_set_action_label (group, "plug-in-reshow", reshow);
@ -523,25 +521,20 @@ plug_in_actions_history_changed (GimpPlugInManager *manager,
for (i = 0; i < gimp_plug_in_manager_history_length (manager); i++)
{
GtkAction *action;
gchar *name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
gchar *label;
gchar *name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name);
g_free (name);
proc = gimp_plug_in_manager_history_nth (manager, i);
label = gimp_plug_in_procedure_get_label (proc);
g_object_set (action,
"visible", TRUE,
"procedure", proc,
"label", label,
"label", gimp_plug_in_procedure_get_label (proc),
"stock-id", gimp_plug_in_procedure_get_stock_id (proc),
"tooltip", gimp_plug_in_procedure_get_blurb (proc),
NULL);
g_free (label);
}
for (; i < gimp_plug_in_manager_history_size (manager); i++)

View file

@ -166,15 +166,17 @@ file_open_image (Gimp *gimp,
else
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Plug-In returned SUCCESS but did not "
"return an image"));
_("%s plug-in returned SUCCESS but did not "
"return an image"),
gimp_plug_in_procedure_get_label (file_proc));
*status = GIMP_PDB_EXECUTION_ERROR;
}
}
else if (*status != GIMP_PDB_CANCEL)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Plug-In could not open image"));
_("%s plug-In could not open image"),
gimp_plug_in_procedure_get_label (file_proc));
}
g_value_array_free (return_vals);

View file

@ -190,7 +190,8 @@ file_save (GimpImage *image,
else if (status != GIMP_PDB_CANCEL)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Plug-In could not save image"));
_("%s plug-in could not save image"),
gimp_plug_in_procedure_get_label (file_proc));
}
g_object_unref (image);

View file

@ -159,14 +159,11 @@ gimp_plug_in_cleanup (GimpPlugIn *plug_in,
if (cleanup->undo_group_count != image->group_count)
{
gchar *label;
label = gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure));
GimpProcedure *proc = proc_frame->procedure;
g_message ("Plug-In '%s' left image undo in inconsistent state, "
"closing open undo groups.", label);
g_free (label);
"closing open undo groups.",
gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc)));
while (image->pushing_undo_group != GIMP_UNDO_GROUP_NONE &&
cleanup->undo_group_count < image->group_count)

View file

@ -955,11 +955,11 @@ gimp_plug_in_manager_file_proc_compare (gconstpointer a,
gconstpointer b,
gpointer data)
{
const GimpPlugInProcedure *proc_a = a;
const GimpPlugInProcedure *proc_b = b;
gchar *label_a;
gchar *label_b;
gint retval = 0;
GimpPlugInProcedure *proc_a = GIMP_PLUG_IN_PROCEDURE (a);
GimpPlugInProcedure *proc_b = GIMP_PLUG_IN_PROCEDURE (b);
const gchar *label_a;
const gchar *label_b;
gint retval = 0;
if (g_str_has_prefix (proc_a->prog, "gimp-xcf"))
return -1;
@ -973,8 +973,5 @@ gimp_plug_in_manager_file_proc_compare (gconstpointer a,
if (label_a && label_b)
retval = g_utf8_collate (label_a, label_b);
g_free (label_a);
g_free (label_b);
return retval;
}

View file

@ -124,6 +124,8 @@ gimp_plug_in_procedure_finalize (GObject *object)
g_list_foreach (proc->menu_paths, (GFunc) g_free, NULL);
g_list_free (proc->menu_paths);
g_free (proc->label);
g_free (proc->icon_data);
g_free (proc->image_types);
@ -518,8 +520,8 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
return FALSE;
}
gchar *
gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc)
const gchar *
gimp_plug_in_procedure_get_label (GimpPlugInProcedure *proc)
{
const gchar *path;
gchar *stripped;
@ -528,6 +530,9 @@ gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc)
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
if (proc->label)
return proc->label;
if (proc->menu_label)
path = dgettext (proc->locale_domain, proc->menu_label);
else if (proc->menu_paths)
@ -552,7 +557,9 @@ gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc)
if (ellipsis && ellipsis == (label + strlen (label) - 3))
*ellipsis = '\0';
return label;
proc->label = label;
return proc->label;
}
const gchar *

View file

@ -48,6 +48,7 @@ struct _GimpPlugInProcedure
gchar *help_domain;
gchar *menu_label;
GList *menu_paths;
gchar *label;
GimpIconType icon_type;
gint icon_data_length;
guint8 *icon_data;
@ -103,7 +104,7 @@ gboolean gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure
const gchar *menu_path,
GError **error);
gchar * gimp_plug_in_procedure_get_label (const GimpPlugInProcedure *proc);
const gchar * gimp_plug_in_procedure_get_label (GimpPlugInProcedure *proc);
const gchar * gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc);
void gimp_plug_in_procedure_set_icon (GimpPlugInProcedure *proc,

View file

@ -535,14 +535,11 @@ gimp_file_dialog_add_filters (GimpFileDialog *dialog,
if (file_proc->extensions_list)
{
GtkFileFilter *filter = gtk_file_filter_new ();
gchar *label;
GString *str;
GSList *ext;
gint i;
label = gimp_plug_in_procedure_get_label (file_proc);
str = g_string_new (label);
g_free (label);
str = g_string_new (gimp_plug_in_procedure_get_label (file_proc));
/* an arbitrary limit to keep the file dialog from becoming too wide */
#define MAX_EXTENSIONS 4

View file

@ -139,9 +139,9 @@ gimp_file_proc_view_new (Gimp *gimp,
if (! proc->prefixes_list) /* skip URL loaders */
{
gchar *label = gimp_plug_in_procedure_get_label (proc);
gchar *help_id = gimp_plug_in_procedure_get_help_id (proc);
GSList *list2;
const gchar *label = gimp_plug_in_procedure_get_label (proc);
gchar *help_id = gimp_plug_in_procedure_get_help_id (proc);
GSList *list2;
if (label)
{
@ -152,8 +152,6 @@ gimp_file_proc_view_new (Gimp *gimp,
COLUMN_EXTENSIONS, proc->extensions,
COLUMN_HELP_ID, help_id,
-1);
g_free (label);
}
g_free (help_id);

View file

@ -363,7 +363,6 @@ gimp_image_prop_view_label_set_filetype (GtkWidget *label,
{
GimpPlugInManager *manager = image->gimp->plug_in_manager;
GimpPlugInProcedure *proc;
gchar *text;
proc = gimp_image_get_save_proc (image);
if (! proc)
@ -377,10 +376,8 @@ gimp_image_prop_view_label_set_filetype (GtkWidget *label,
}
}
text = proc ? gimp_plug_in_procedure_get_label (proc) : NULL;
gtk_label_set_text (GTK_LABEL (label), text);
g_free (text);
gtk_label_set_text (GTK_LABEL (label),
proc ? gimp_plug_in_procedure_get_label (proc) : NULL);
}
static void