Commit 1ed8dd4f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/actions/data-commands.c app/actions/documents-commands.c

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

	* app/actions/data-commands.c
	* app/actions/documents-commands.c
	* app/actions/drawable-commands.c
	* app/actions/gradients-commands.c
	* app/actions/image-commands.c
	* app/actions/layers-commands.c
	* app/actions/palettes-commands.c
	* app/actions/select-commands.c
	* app/actions/vectors-commands.c
	* app/core/gimp-contexts.c
	* app/core/gimp-documents.c
	* app/core/gimp-edit.c
	* app/core/gimp-modules.c
	* app/core/gimp-parasites.c
	* app/core/gimp-templates.c
	* app/core/gimp-units.c
	* app/core/gimpchannel.c
	* app/core/gimpdatafactory.[ch]
	* app/core/gimpdrawable-bucket-fill.c
	* app/core/gimpimage-merge.c
	* app/core/gimpimagefile.c
	* app/core/gimplayer-floating-sel.c
	* app/core/gimppdbprogress.c
	* app/core/gimpselection.c
	* app/dialogs/palette-import-dialog.c
	* app/display/gimpdisplayshell-dnd.c
	* app/gui/session.c
	* app/gui/themes.c
	* app/pdb/gimpprocedure.c
	* app/plug-in/gimpplugin-message.c
	* app/plug-in/gimpplugin.c
	* app/plug-in/gimppluginmanager-file.c
	* app/plug-in/gimppluginmanager.c
	* app/text/gimptextlayer-xcf.c
	* app/text/gimptextlayer.c
	* app/widgets/gimpcontrollers.c
	* app/widgets/gimpdataeditor.c
	* app/widgets/gimpdevices.c
	* app/widgets/gimpdnd-xds.c
	* app/widgets/gimplayertreeview.c
	* app/widgets/gimptoolbox-dnd.c
	* app/widgets/gimptoolbox.c
	* app/widgets/gimpuimanager.c
	* app/widgets/gimpvectorstreeview.c
	* tools/pdbgen/pdb/brush.pdb
	* tools/pdbgen/pdb/gradient.pdb
	* tools/pdbgen/pdb/palette.pdb: convert lots of g_message() to
	gimp_message(). Make sure we never pass unknown strings (like
	error->message) to printf-like functions directly; run them
	thorugh "%s" instead. Don't translate some messages which should
	never happen.

	* app/pdb/brush_cmds.c
	* app/pdb/gradient_cmds.c
	* app/pdb/palette_cmds.c: regenerated.
parent 27f5e542
2006-10-09 Michael Natterer <mitch@gimp.org>
* app/actions/data-commands.c
* app/actions/documents-commands.c
* app/actions/drawable-commands.c
* app/actions/gradients-commands.c
* app/actions/image-commands.c
* app/actions/layers-commands.c
* app/actions/palettes-commands.c
* app/actions/select-commands.c
* app/actions/vectors-commands.c
* app/core/gimp-contexts.c
* app/core/gimp-documents.c
* app/core/gimp-edit.c
* app/core/gimp-modules.c
* app/core/gimp-parasites.c
* app/core/gimp-templates.c
* app/core/gimp-units.c
* app/core/gimpchannel.c
* app/core/gimpdatafactory.[ch]
* app/core/gimpdrawable-bucket-fill.c
* app/core/gimpimage-merge.c
* app/core/gimpimagefile.c
* app/core/gimplayer-floating-sel.c
* app/core/gimppdbprogress.c
* app/core/gimpselection.c
* app/dialogs/palette-import-dialog.c
* app/display/gimpdisplayshell-dnd.c
* app/gui/session.c
* app/gui/themes.c
* app/pdb/gimpprocedure.c
* app/plug-in/gimpplugin-message.c
* app/plug-in/gimpplugin.c
* app/plug-in/gimppluginmanager-file.c
* app/plug-in/gimppluginmanager.c
* app/text/gimptextlayer-xcf.c
* app/text/gimptextlayer.c
* app/widgets/gimpcontrollers.c
* app/widgets/gimpdataeditor.c
* app/widgets/gimpdevices.c
* app/widgets/gimpdnd-xds.c
* app/widgets/gimplayertreeview.c
* app/widgets/gimptoolbox-dnd.c
* app/widgets/gimptoolbox.c
* app/widgets/gimpuimanager.c
* app/widgets/gimpvectorstreeview.c
* tools/pdbgen/pdb/brush.pdb
* tools/pdbgen/pdb/gradient.pdb
* tools/pdbgen/pdb/palette.pdb: convert lots of g_message() to
gimp_message(). Make sure we never pass unknown strings (like
error->message) to printf-like functions directly; run them
thorugh "%s" instead. Don't translate some messages which should
never happen.
* app/pdb/brush_cmds.c
* app/pdb/gradient_cmds.c
* app/pdb/palette_cmds.c: regenerated.
2006-10-09 Sven Neumann <sven@gimp.org>
 
* app/dialogs/tips-parser.[ch]: accept printf-style format strings.
......
......@@ -53,8 +53,8 @@ typedef struct _GimpDataDeleteData GimpDataDeleteData;
struct _GimpDataDeleteData
{
GimpDataFactory *factory;
GimpData *data;
GimpDataFactoryView *view;
GimpData *data;
};
......@@ -99,8 +99,10 @@ data_open_as_image_cmd_callback (GtkAction *action,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (context->gimp, G_OBJECT (view),
GIMP_MESSAGE_ERROR,
_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
......@@ -218,8 +220,8 @@ data_delete_cmd_callback (GtkAction *action,
delete_data = g_new0 (GimpDataDeleteData, 1);
delete_data->factory = view->factory;
delete_data->data = data;
delete_data->view = view;
delete_data->data = data;
dialog = gimp_message_dialog_new (_("Delete Object"), GIMP_STOCK_QUESTION,
GTK_WIDGET (view), 0,
......@@ -307,11 +309,13 @@ data_delete_confirm_response (GtkWidget *dialog,
{
GError *error = NULL;
if (! gimp_data_factory_data_delete (delete_data->factory,
if (! gimp_data_factory_data_delete (delete_data->view->factory,
delete_data->data,
TRUE, &error))
{
g_message (error->message);
gimp_message (delete_data->view->factory->gimp,
G_OBJECT (delete_data->view), GIMP_MESSAGE_ERROR,
"%s", error->message);
g_clear_error (&error);
}
}
......
......@@ -316,7 +316,9 @@ documents_open_image (GimpContext *context,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"), filename, error->message);
gimp_message (context->gimp, NULL, GIMP_MESSAGE_ERROR,
_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
......
......@@ -71,7 +71,8 @@ drawable_desaturate_cmd_callback (GtkAction *action,
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Desaturate operates only on RGB color layers."));
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("Desaturate operates only on RGB color layers."));
return;
}
......@@ -92,11 +93,14 @@ drawable_equalize_cmd_callback (GtkAction *action,
{
GimpImage *image;
GimpDrawable *drawable;
GtkWidget *widget;
return_if_no_drawable (image, drawable, data);
return_if_no_widget (widget, data);
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Equalize does not operate on indexed layers."));
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("Equalize does not operate on indexed layers."));
return;
}
......@@ -110,11 +114,14 @@ drawable_invert_cmd_callback (GtkAction *action,
{
GimpImage *image;
GimpDrawable *drawable;
GtkWidget *widget;
return_if_no_drawable (image, drawable, data);
return_if_no_widget (widget, data);
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Invert does not operate on indexed layers."));
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("Invert does not operate on indexed layers."));
return;
}
......@@ -129,12 +136,15 @@ drawable_levels_stretch_cmd_callback (GtkAction *action,
GimpImage *image;
GimpDrawable *drawable;
GimpContext *context;
GtkWidget *widget;
return_if_no_drawable (image, drawable, data);
return_if_no_context (context, data);
return_if_no_widget (widget, data);
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("White Balance operates only on RGB color layers."));
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("White Balance operates only on RGB color layers."));
return;
}
......
......@@ -24,6 +24,7 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpgradient-save.h"
#include "core/gimpcontext.h"
......@@ -79,6 +80,8 @@ gradients_save_as_pov_ray_cmd_callback (GtkAction *action,
GTK_RESPONSE_CANCEL,
-1);
g_object_set_data (G_OBJECT (chooser), "gimp", context->gimp);
g_free (title);
gtk_window_set_screen (GTK_WINDOW (chooser),
......@@ -124,8 +127,12 @@ gradients_save_as_pov_ray_response (GtkWidget *dialog,
if (! gimp_gradient_save_pov (gradient, filename, &error))
{
g_message (error->message);
gimp_message (g_object_get_data (G_OBJECT (dialog), "gimp"),
G_OBJECT (dialog),
GIMP_MESSAGE_ERROR,
"%s", error->message);
g_clear_error (&error);
return;
}
}
......
......@@ -366,13 +366,16 @@ image_crop_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
GtkWidget *widget;
gint x1, y1, x2, y2;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
if (! gimp_channel_bounds (gimp_image_get_mask (image),
&x1, &y1, &x2, &y2))
{
g_message (_("Cannot crop because the current selection is empty."));
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("Cannot crop because the current selection is empty."));
return;
}
......
......@@ -591,14 +591,17 @@ layers_crop_cmd_callback (GtkAction *action,
{
GimpImage *image;
GimpLayer *layer;
GtkWidget *widget;
gint x1, y1, x2, y2;
gint off_x, off_y;
return_if_no_layer (image, layer, data);
return_if_no_widget (widget, data);
if (! gimp_channel_bounds (gimp_image_get_mask (image),
&x1, &y1, &x2, &y2))
{
g_message (_("Cannot crop because the current selection is empty."));
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("Cannot crop because the current selection is empty."));
return;
}
......@@ -981,7 +984,8 @@ layers_add_mask_response (GtkWidget *widget,
if (dialog->add_mask_type == GIMP_ADD_CHANNEL_MASK &&
! dialog->channel)
{
g_message (_("Please select a channel first"));
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("Please select a channel first"));
return;
}
......@@ -1065,7 +1069,8 @@ layers_scale_layer_callback (GtkWidget *dialog,
}
else
{
g_message (_("Invalid width or height. Both must be positive."));
gimp_message (display->image->gimp, NULL, GIMP_MESSAGE_ERROR,
"Invalid width or height. Both must be positive.");
}
}
......@@ -1103,7 +1108,8 @@ layers_resize_layer_callback (GtkWidget *dialog,
}
else
{
g_message (_("Invalid width or height. Both must be positive."));
gimp_message (context->gimp, NULL, GIMP_MESSAGE_ERROR,
"Invalid width or height. Both must be positive.");
}
}
......
......@@ -107,7 +107,9 @@ palettes_merge_callback (GtkWidget *widget,
if (! sel_list)
{
g_message ("Can't merge palettes because there are no palettes selected.");
gimp_message (gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
"Can't merge palettes because "
"there are no palettes selected.");
return;
}
......
......@@ -286,7 +286,7 @@ select_stroke_cmd_callback (GtkAction *action,
if (! drawable)
{
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("There is no active layer or channel to stroke to."));
return;
}
......@@ -307,15 +307,17 @@ select_stroke_last_vals_cmd_callback (GtkAction *action,
GimpImage *image;
GimpDrawable *drawable;
GimpContext *context;
GtkWidget *widget;
GimpStrokeDesc *desc;
return_if_no_image (image, data);
return_if_no_context (context, data);
return_if_no_widget (widget, data);
drawable = gimp_image_active_drawable (image);
if (! drawable)
{
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("There is no active layer or channel to stroke to."));
return;
}
......
......@@ -306,10 +306,12 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
GtkWidget *widget;
GimpProcedure *procedure;
GValueArray *args;
GimpDisplay *display;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
if (value)
procedure = gimp_pdb_lookup_procedure (image->gimp->pdb,
......@@ -320,7 +322,8 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action,
if (! procedure)
{
g_message ("Selection to path procedure lookup failed.");
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR,
"Selection to path procedure lookup failed.");
return;
}
......@@ -356,7 +359,7 @@ vectors_stroke_cmd_callback (GtkAction *action,
if (! drawable)
{
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("There is no active layer or channel to stroke to."));
return;
}
......@@ -378,15 +381,17 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action,
GimpVectors *vectors;
GimpDrawable *drawable;
GimpContext *context;
GtkWidget *widget;
GimpStrokeDesc *desc;
return_if_no_vectors (image, vectors, data);
return_if_no_context (context, data);
return_if_no_widget (widget, data);
drawable = gimp_image_active_drawable (image);
if (! drawable)
{
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
_("There is no active layer or channel to stroke to."));
return;
}
......@@ -429,9 +434,11 @@ vectors_paste_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
GtkWidget *widget;
gchar *svg;
gsize svg_size;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
svg = gimp_clipboard_get_svg (image->gimp, &svg_size);
......@@ -442,8 +449,8 @@ vectors_paste_cmd_callback (GtkAction *action,
if (! gimp_vectors_import_buffer (image, svg, svg_size,
TRUE, TRUE, -1, &error))
{
gimp_message (image->gimp, NULL, GIMP_MESSAGE_ERROR,
error->message);
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR,
"%s", error->message);
g_clear_error (&error);
}
else
......@@ -624,9 +631,11 @@ vectors_import_response (GtkWidget *widget,
}
else
{
gimp_message (dialog->image->gimp, NULL, GIMP_MESSAGE_ERROR,
error->message);
gimp_message (dialog->image->gimp, G_OBJECT (widget),
GIMP_MESSAGE_ERROR,
"%s", error->message);
g_error_free (error);
return;
}
g_free (filename);
......@@ -655,9 +664,11 @@ vectors_export_response (GtkWidget *widget,
if (! gimp_vectors_export_file (dialog->image, vectors, filename, &error))
{
gimp_message (dialog->image->gimp, NULL, GIMP_MESSAGE_ERROR,
error->message);
gimp_message (dialog->image->gimp, G_OBJECT (widget),
GIMP_MESSAGE_ERROR,
"%s", error->message);
g_error_free (error);
return;
}
g_free (filename);
......
......@@ -92,7 +92,7 @@ gimp_contexts_load (Gimp *gimp)
NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_error_free (error);
}
......@@ -118,7 +118,7 @@ gimp_contexts_save (Gimp *gimp)
"end of user context",
NULL, &error))
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_error_free (error);
}
......
......@@ -54,7 +54,7 @@ gimp_documents_load (Gimp *gimp)
&error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_error_free (error);
}
......@@ -87,7 +87,7 @@ gimp_documents_save (Gimp *gimp)
header, footer, NULL,
&error))
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_error_free (error);
}
......
......@@ -511,8 +511,9 @@ gimp_edit_extract_visible (GimpImage *image,
if ((x1 == x2) || (y1 == y2))
{
g_message (_("Unable to cut or copy because the "
"selected region is empty."));
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
_("Unable to cut or copy because the "
"selected region is empty."));
return NULL;
}
......
......@@ -138,7 +138,7 @@ gimp_modules_load (Gimp *gimp)
if (error)
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_clear_error (&error);
}
......@@ -214,7 +214,7 @@ gimp_modules_unload (Gimp *gimp)
if (error)
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_clear_error (&error);
}
}
......
......@@ -117,7 +117,8 @@ gimp_parasiterc_load (Gimp *gimp)
filename, NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_error_free (error);
}
......@@ -150,7 +151,7 @@ gimp_parasiterc_save (Gimp *gimp)
header, footer, NULL,
&error))
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_error_free (error);
}
......
......@@ -49,8 +49,8 @@ gimp_templates_load (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
if (!gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
filename, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
filename, NULL, &error))
{
if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
......@@ -60,15 +60,16 @@ gimp_templates_load (Gimp *gimp)
filename = g_build_filename (gimp_sysconf_directory (),
"templaterc", NULL);
if (!gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
filename, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
filename, NULL, &error))
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR,
"%s", error->message);
}
}
else
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
}
g_clear_error (&error);
......@@ -105,7 +106,7 @@ gimp_templates_save (Gimp *gimp)
header, footer, NULL,
&error))
{
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_error_free (error);
}
......
......@@ -163,7 +163,7 @@ gimp_unitrc_load (Gimp *gimp)
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
g_message (error->message);
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_clear_error (&error);
gimp_config_file_backup_on_error (filename, "unitrc", NULL);
......@@ -179,6 +179,7 @@ gimp_unitrc_save (Gimp *gimp)
GimpConfigWriter *writer;
gchar *filename;
gint i;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
......@@ -253,7 +254,11 @@ gimp_unitrc_save (Gimp *gimp)
}
}
gimp_config_writer_finish (writer, "end of units", NULL);
if (! gimp_config_writer_finish (writer, "end of units", &error))
{
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
g_clear_error (&error);
}
}
......
......@@ -684,7 +684,9 @@ gimp_channel_stroke (GimpItem *item,
&n_segs_in, &n_segs_out,
0, 0, 0, 0))
{
g_message (_("Cannot stroke empty channel."));
gimp_message (gimp_item_get_image (item)->gimp, NULL,
GIMP_MESSAGE_WARNING,
_("Cannot stroke empty channel."));
return FALSE;
}
......
......@@ -403,7 +403,9 @@ gimp_data_factory_data_save (GimpDataFactory *factory)
*/
if (error)
{
g_message (_("Failed to save data:\n\n%s"), error->message);
gimp_message (factory->gimp, NULL, GIMP_MESSAGE_ERROR,
_("Failed to save data:\n\n%s"),
error->message);
g_clear_error (&error);
}
}
......@@ -542,13 +544,13 @@ gimp_data_factory_data_get_standard (GimpDataFactory *factory)
}
gboolean
gimp_data_factory_data_save_single (GimpDataFactory *factory,
GimpData *data)
gimp_data_factory_data_save_single (GimpDataFactory *factory,
GimpData *data,
GError **error)
{
GError *error = NULL;
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), FALSE);
g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! data->dirty)
return TRUE;
......@@ -558,7 +560,12 @@ gimp_data_factory_data_save_single (GimpDataFactory *factory,
gchar *writable_dir = gimp_data_factory_get_save_dir (factory);
if (! writable_dir)
return FALSE;