Commit 48d054e8 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added new function gimp_message() as a replacement for g_message(). Part

2006-08-08  Sven Neumann  <sven@gimp.org>

	* app/core/gimp.[ch]: added new function gimp_message() as a
	replacement for g_message(). Part of the fix for bug #347214.

	* app/actions/data-commands.c
	* app/actions/documents-commands.c
	* app/actions/file-commands.c
	* app/actions/layers-commands.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimagefile.c
	* app/core/gimpitem.c
	* app/core/gimplayer.c
	* app/dialogs/file-open-dialog.c
	* app/dialogs/file-open-location-dialog.c
	* app/dialogs/file-save-dialog.c
	* app/display/gimpdisplayshell-dnd.c
	* app/pdb/gimppdb.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorizetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c
	* app/widgets/gimpwidgets-utils.c
	* app/xcf/xcf-load.c
	* app/xcf/xcf-private.h
	* app/xcf/xcf-save.c
	* app/xcf/xcf.c
	* tools/pdbgen/pdb/brush.pdb
	* tools/pdbgen/pdb/gradient.pdb
	* tools/pdbgen/pdb/image.pdb
	* tools/pdbgen/pdb/palette.pdb: use gimp_message() instead of
	gimp_message() whenever we have a GimpProgress.

	* app/pdb/brush_cmds.c
	* app/pdb/gradient_cmds.c
	* app/pdb/image_cmds.c
	* app/pdb/palette_cmds.c: regenerated.
parent 504fe2cc
2006-08-08 Sven Neumann <sven@gimp.org>
* app/core/gimp.[ch]: added new function gimp_message() as a
replacement for g_message(). Part of the fix for bug #347214.
* app/actions/data-commands.c
* app/actions/documents-commands.c
* app/actions/file-commands.c
* app/actions/layers-commands.c
* app/core/gimpimage-convert.c
* app/core/gimpimagefile.c
* app/core/gimpitem.c
* app/core/gimplayer.c
* app/dialogs/file-open-dialog.c
* app/dialogs/file-open-location-dialog.c
* app/dialogs/file-save-dialog.c
* app/display/gimpdisplayshell-dnd.c
* app/pdb/gimppdb.c
* app/tools/gimpblendtool.c
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcolorizetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c
* app/widgets/gimpwidgets-utils.c
* app/xcf/xcf-load.c
* app/xcf/xcf-private.h
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/pdb/brush.pdb
* tools/pdbgen/pdb/gradient.pdb
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/palette.pdb: use gimp_message() instead of
gimp_message() whenever we have a GimpProgress.
* app/pdb/brush_cmds.c
* app/pdb/gradient_cmds.c
* app/pdb/image_cmds.c
* app/pdb/palette_cmds.c: regenerated.
2006-08-08 Sven Neumann <sven@gimp.org>
* app/core/gimp-gui.[ch]
......
......@@ -75,7 +75,8 @@ data_open_as_image_cmd_callback (GtkAction *action,
GimpContext *context;
GimpData *data;
context = gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
context =
gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
data = (GimpData *)
gimp_context_get_by_type (context,
......@@ -96,9 +97,8 @@ data_open_as_image_cmd_callback (GtkAction *action,
if (! image && status != GIMP_PDB_CANCEL)
{
gchar *filename;
gchar *filename = file_utils_uri_display_name (uri);
filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
......
......@@ -314,9 +314,8 @@ documents_open_image (GimpContext *context,
if (! image && status != GIMP_PDB_CANCEL)
{
gchar *filename;
gchar *filename = file_utils_uri_display_name (uri);
filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"), filename, error->message);
g_clear_error (&error);
......
......@@ -237,8 +237,9 @@ file_save_cmd_callback (GtkAction *action,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Saving '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (image->gimp, GIMP_PROGRESS (display),
_("Saving '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
......@@ -311,17 +312,22 @@ file_revert_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display;
GimpImage *image;
GtkWidget *dialog;
const gchar *uri;
return_if_no_display (display, data);
uri = gimp_object_get_name (GIMP_OBJECT (display->image));
image = display->image;
dialog = g_object_get_data (G_OBJECT (display->image), REVERT_DATA_KEY);
uri = gimp_object_get_name (GIMP_OBJECT (image));
dialog = g_object_get_data (G_OBJECT (image), REVERT_DATA_KEY);
if (! uri)
{
g_message (_("Revert failed. No file name associated with this image."));
gimp_message (image->gimp, GIMP_PROGRESS (display),
_("Revert failed. "
"No file name associated with this image."));
}
else if (dialog)
{
......@@ -369,7 +375,7 @@ file_revert_cmd_callback (GtkAction *action,
"on disk, you will lose all changes, "
"including all undo information."));
g_object_set_data (G_OBJECT (display->image), REVERT_DATA_KEY, dialog);
g_object_set_data (G_OBJECT (image), REVERT_DATA_KEY, dialog);
gtk_widget_show (dialog);
}
......@@ -560,8 +566,9 @@ file_revert_confirm_response (GtkWidget *dialog,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Reverting to '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (gimp, GIMP_PROGRESS (display),
_("Reverting to '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
......
......@@ -928,8 +928,7 @@ layers_new_layer_response (GtkWidget *widget,
}
else
{
g_message ("new_layer_query_response: "
"could not allocate new layer");
g_warning ("%s: could not allocate new layer", G_STRFUNC);
}
}
......
......@@ -69,6 +69,7 @@
#include "gimppattern.h"
#include "gimppatternclipboard.h"
#include "gimpparasitelist.h"
#include "gimpprogress.h"
#include "gimptemplate.h"
#include "gimptoolinfo.h"
......@@ -975,3 +976,22 @@ gimp_get_user_context (Gimp *gimp)
return gimp->user_context;
}
void
gimp_message (Gimp *gimp,
GimpProgress *progress,
const gchar *format,
...)
{
va_list args;
gchar *message;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
gimp_show_message (gimp, progress, NULL, message);
}
......@@ -171,5 +171,10 @@ void gimp_set_user_context (Gimp *gimp,
GimpContext *context);
GimpContext * gimp_get_user_context (Gimp *gimp);
void gimp_message (Gimp *gimp,
GimpProgress *progress,
const gchar *format,
...) G_GNUC_PRINTF(3,4);
#endif /* __GIMP_H__ */
......@@ -792,7 +792,8 @@ gimp_image_convert (GimpImage *image,
if (custom_palette->n_colors < 1)
{
g_message (_("Cannot convert image: palette is empty."));
gimp_message (image->gimp, progress,
_("Cannot convert image: palette is empty."));
return;
}
}
......
......@@ -289,7 +289,7 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
if (! success)
{
g_message (error->message);
gimp_message (imagefile->gimp, progress, error->message);
g_error_free (error);
}
}
......
......@@ -797,14 +797,13 @@ gimp_item_scale (GimpItem *item,
* Scales item dimensions and offsets by uniform width and
* height factors.
*
* Use gimp_item_scale_by_factors() in circumstances when the
* same width and height scaling factors are to be uniformly
* applied to a set of items. In this context, the item's
* dimensions and offsets from the sides of the containing
* image all change by these predetermined factors. By fiat,
* the fixed point of the transform is the upper left hand
* corner of the image. Returns gboolean #FALSE if a requested
* scale factor is zero or if a scaling zero's out a item
* Use gimp_item_scale_by_factors() in circumstances when the same
* width and height scaling factors are to be uniformly applied to a
* set of items. In this context, the item's dimensions and offsets
* from the sides of the containing image all change by these
* predetermined factors. By fiat, the fixed point of the transform is
* the upper left hand corner of the image. Returns #FALSE if a
* requested scale factor is zero or if a scaling zero's out a item
* dimension; returns #TRUE otherwise.
*
* Use gimp_item_scale() in circumstances where new item width
......@@ -831,7 +830,7 @@ gimp_item_scale_by_factors (GimpItem *item,
if (w_factor == 0.0 || h_factor == 0.0)
{
g_message ("gimp_item_scale_by_factors: Error. Requested width or height scale equals zero.");
g_warning ("%s: requested width or height scale equals zero", G_STRFUNC);
return FALSE;
}
......@@ -895,7 +894,7 @@ gimp_item_scale_by_origin (GimpItem *item,
if (new_width == 0 || new_height == 0)
{
g_message ("gimp_layer_scale: Error. Requested width or height equals zero.");
g_warning ("%s: requested width or height equals zero", G_STRFUNC);
return;
}
......
......@@ -1104,7 +1104,7 @@ gimp_layer_new_from_region (PixelRegion *region,
if (! new_layer)
{
g_message ("gimp_layer_new_from_region: could not allocate new layer");
g_warning ("%s: could not allocate new layer", G_STRFUNC);
return NULL;
}
......
......@@ -200,8 +200,8 @@ file_open_dialog_open_image (GtkWidget *open_dialog,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (gimp, GIMP_PROGRESS (open_dialog),
_("Opening '%s' failed:\n\n%s"), filename, error->message);
g_clear_error (&error);
g_free (filename);
......@@ -251,8 +251,8 @@ file_open_dialog_open_layer (GtkWidget *open_dialog,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (image->gimp, GIMP_PROGRESS (open_dialog),
_("Opening '%s' failed:\n\n%s"), filename, error->message);
g_clear_error (&error);
g_free (filename);
......
......@@ -201,8 +201,9 @@ file_open_location_response (GtkDialog *dialog,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (gimp, GIMP_PROGRESS (box),
_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
......
......@@ -267,10 +267,11 @@ file_save_dialog_check_uri (GtkWidget *save_dialog,
G_STRFUNC);
#endif
g_message (_("The given filename does not have any known "
"file extension. Please enter a known file "
"extension or select a file format from the "
"file format list."));
gimp_message (gimp, GIMP_PROGRESS (save_dialog),
_("The given filename does not have any known "
"file extension. Please enter a known file "
"extension or select a file format from the "
"file format list."));
g_free (uri);
g_free (basename);
return FALSE;
......@@ -485,8 +486,8 @@ file_save_dialog_save_image (GtkWidget *save_dialog,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Saving '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (image->gimp, GIMP_PROGRESS (save_dialog),
_("Saving '%s' failed:\n\n%s"), filename, error->message);
g_clear_error (&error);
g_free (filename);
......
......@@ -277,7 +277,8 @@ gimp_display_shell_drop_svg (GtkWidget *widget,
(const gchar *) svg_data, svg_data_len,
TRUE, TRUE, -1, &error))
{
g_message (error->message);
gimp_message (image->gimp, GIMP_PROGRESS (shell->display),
error->message);
g_clear_error (&error);
}
else
......@@ -420,7 +421,7 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
GError *error = NULL;
new_layer = file_open_layer (image->gimp, context,
GIMP_PROGRESS (shell->statusbar),
GIMP_PROGRESS (shell->display),
image, uri, GIMP_RUN_INTERACTIVE, NULL,
&status, &error);
......@@ -447,8 +448,9 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
{
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
gimp_message (image->gimp, GIMP_PROGRESS (shell->display),
_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
......
......@@ -215,7 +215,7 @@ brush_delete_invoker (GimpProcedure *procedure,
if (! success)
{
g_message (error->message);
gimp_message (gimp, progress, error->message);
g_clear_error (&error);
}
}
......
......@@ -295,7 +295,8 @@ gimp_pdb_execute_procedure_by_name_args (GimpPDB *pdb,
if (list == NULL)
{
g_message (_("PDB calling error:\n"
gimp_message (pdb->gimp, progress,
_("PDB calling error:\n"
"Procedure '%s' not found"), name);
return_vals = gimp_procedure_get_return_values (NULL, FALSE);
......@@ -359,8 +360,9 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
if (procedure == NULL)
{
g_message (_("PDB calling error:\n"
"Procedure '%s' not found"), name);
gimp_message (pdb->gimp, progress,
_("PDB calling error:\n"
"Procedure '%s' not found"), name);
return_vals = gimp_procedure_get_return_values (NULL, FALSE);
g_value_set_enum (return_vals->values, GIMP_PDB_CALLING_ERROR);
......@@ -392,10 +394,11 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
g_value_array_free (args);
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
gimp_object_get_name (GIMP_OBJECT (procedure)),
i + 1, expected, got);
gimp_message (pdb->gimp, progress,
_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
gimp_object_get_name (GIMP_OBJECT (procedure)),
i + 1, expected, got);
return_vals = gimp_procedure_get_return_values (procedure, FALSE);
g_value_set_enum (return_vals->values, GIMP_PDB_CALLING_ERROR);
......
......@@ -264,7 +264,7 @@ gradient_delete_invoker (GimpProcedure *procedure,
if (! success)
{
g_message (error->message);
gimp_message (gimp, progress, error->message);
g_clear_error (&error);
}
}
......
......@@ -1942,8 +1942,9 @@ image_set_resolution_invoker (GimpProcedure *procedure,
! FINITE (yresolution) ||
yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION)
{
g_message (_("Image resolution is out of bounds, "
"using the default resolution instead."));
gimp_message (gimp, progress,
_("Image resolution is out of bounds, "
"using the default resolution instead."));
success = FALSE;
}
else
......
......@@ -182,7 +182,7 @@ palette_delete_invoker (GimpProcedure *procedure,
if (! success)
{
g_message (error->message);
gimp_message (gimp, progress, error->message);
g_clear_error (&error);
}
}
......
......@@ -146,8 +146,10 @@ gimp_blend_tool_button_press (GimpTool *tool,
switch (gimp_drawable_type (drawable))
{
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
g_message (_("Blend: Invalid for indexed images."));
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Blend: Invalid for indexed images."));
return;
break;
......
......@@ -31,6 +31,7 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "widgets/gimphelp-ids.h"
......@@ -161,7 +162,8 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Brightness-Contrast does not operate on indexed layers."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Brightness-Contrast does not operate on indexed layers."));
return FALSE;
}
......
......@@ -31,6 +31,7 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "widgets/gimphelp-ids.h"
......@@ -153,7 +154,8 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Color balance operates only on RGB color layers."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Color balance operates only on RGB color layers."));
return FALSE;
}
......
......@@ -31,6 +31,7 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "widgets/gimphelp-ids.h"
......@@ -150,7 +151,8 @@ gimp_colorize_tool_initialize (GimpTool *tool,
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Colorize operates only on RGB color layers."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Colorize operates only on RGB color layers."));
return FALSE;
}
......
......@@ -41,6 +41,7 @@
#include "core/gimpdrawable-histogram.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpcolorbar.h"
......@@ -250,7 +251,8 @@ gimp_curves_tool_initialize (GimpTool *tool,
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Curves for indexed layers cannot be adjusted."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Curves for indexed layers cannot be adjusted."));
return FALSE;
}
......
......@@ -31,6 +31,7 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "widgets/gimphelp-ids.h"
......@@ -172,7 +173,8 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Hue-Saturation operates only on RGB color layers."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Hue-Saturation operates only on RGB color layers."));
return FALSE;
}
......
......@@ -39,6 +39,7 @@
#include "core/gimpdrawable-histogram.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpcolorbar.h"
......@@ -236,7 +237,8 @@ gimp_levels_tool_initialize (GimpTool *tool,
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Levels for indexed layers cannot be adjusted."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Levels for indexed layers cannot be adjusted."));
return FALSE;
}
......
......@@ -30,6 +30,7 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "widgets/gimphelp-ids.h"
......@@ -134,7 +135,8 @@ gimp_posterize_tool_initialize (GimpTool *tool,
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Posterize does not operate on indexed layers."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Posterize does not operate on indexed layers."));
return FALSE;
}
......
......@@ -32,6 +32,7 @@
#include "core/gimpdrawable-histogram.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "core/gimpprogress.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimphelp-ids.h"
......@@ -150,7 +151,8 @@ gimp_threshold_tool_initialize (GimpTool *tool,
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Threshold does not operate on indexed layers."));
gimp_message (display->image->gimp, GIMP_PROGRESS (display),
_("Threshold does not operate on indexed layers."));
return FALSE;
}
......
......@@ -903,7 +903,7 @@ gimp_text_buffer_save (GtkTextBuffer *buffer,
GtkTextIter start_iter;
GtkTextIter end_iter;
gint fd;
gchar *text_contents;
gchar *text_contents;
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
......
......@@ -275,16 +275,18 @@ xcf_load_image (Gimp *gimp,
if (num_successful_elements == 0)
goto hard_error;
g_message ("XCF: This file is corrupt! I have loaded as much\n"
"of it as I can, but it is incomplete.");
gimp_message (gimp, info->progress,
"XCF: This file is corrupt! I have loaded as much\n"
"of it as I can, but it is incomplete.");
gimp_image_undo_enable (image);
return image;
hard_error:
g_message ("XCF: This file is corrupt! I could not even\n"
"salvage any partial image data from it.");
gimp_message (gimp, info->progress,
"XCF: This file is corrupt! I could not even\n"
"salvage any partial image data from it.");
g_object_unref (image);
......@@ -313,9 +315,10 @@ xcf_load_image_props (XcfInfo *info,
{
gint i;
g_message (_("XCF warning: version 0 of XCF file format\n"
"did not save indexed colormaps correctly.\n"
"Substituting grayscale map."));
gimp_message (info->gimp, info->progress,
_("XCF warning: version 0 of XCF file format\n"
"did not save indexed colormaps correctly.\n"
"Substituting grayscale map."));
info->cp +=
xcf_read_int32 (info->fp, (guint32 *) &image->num_cols, 1);
image->cmap = g_new (guchar, image->num_cols * 3);
......@@ -362,7 +365,9 @@ xcf_load_image_props (XcfInfo *info,
(compression != COMPRESS_ZLIB) &&
(compression != COMPRESS_FRACTAL))
{