Commit 1d95a05a authored by Manish Singh's avatar Manish Singh
Browse files

gimp_message. libgimp also overrides g_message for all plugins. Converted

* redid the error message handling. g_message now calls message_box or prints
to console depending on whether the no_interface is set or not. gimp-message
is also exported to the PDB as a wrapper to g_message, and libgimp has a new
API: gimp_message. libgimp also overrides g_message for all plugins. Converted
lots of messages in app/* to g_message. Made script-fu a little friendlier.

* updated the regex code from grep 2.2

* said goodbye to the old script-fu logo in script-fu.h

-Yosh
parent 36e02fc7
Thu May 28 01:16:26 PDT 1998 Manish Singh <yosh@gimp.org>
* redid the error message handling. g_message now calls
message_box or prints to console depending on whether the
no_interface is set or not. gimp-message is also exported
to the PDB as a wrapper to g_message, and libgimp has a new
API: gimp_message. libgimp also overrides g_message for all
plugins. Converted lots of messages in app/* to g_message.
Made script-fu a little friendlier.
* updated the regex code from grep 2.2
Wed May 27 11:22:46 MEST 1998 Sven Neumann <sven@gimp.org>
* plug-ins/ifscompose/ifscompose.h: removed definition of TRUE
......
......@@ -564,29 +564,25 @@ file_prefs_ok_callback (GtkWidget *widget,
if (levels_of_undo < 0)
{
message_box("Error: Levels of undo must be zero or greater.",
NULL, NULL);
g_message ("Error: Levels of undo must be zero or greater.");
levels_of_undo = old_levels_of_undo;
return;
}
if (marching_speed < 50)
{
message_box("Error: Marching speed must be 50 or greater.",
NULL, NULL);
g_message ("Error: Marching speed must be 50 or greater.");
marching_speed = old_marching_speed;
return;
}
if (default_width < 1)
{
message_box("Error: Default width must be one or greater.",
NULL, NULL);
g_message ("Error: Default width must be one or greater.");
default_width = old_default_width;
return;
}
if (default_height < 1)
{
message_box("Error: Default height must be one or greater.",
NULL, NULL);
g_message ("Error: Default height must be one or greater.");
default_height = old_default_height;
return;
}
......@@ -752,7 +748,7 @@ file_prefs_save_callback (GtkWidget *widget,
gradient_path = save_gradient_path;
if (restart_notification)
message_box("You will need to restart GIMP for these changes to take effect.", NULL, NULL);
g_message ("You will need to restart GIMP for these changes to take effect.");
g_list_free (update);
g_list_free (remove);
......@@ -2486,7 +2482,7 @@ image_resize_callback (GtkWidget *w,
}
else
{
message_box("Resize Error: Both width and height must be greater than zero.", NULL, NULL);
g_message ("Resize Error: Both width and height must be greater than zero.");
return;
}
}
......@@ -2516,7 +2512,7 @@ image_scale_callback (GtkWidget *w,
}
else
{
message_box("Scale Error: Both width and height must be greater than zero.", NULL, NULL);
g_message ("Scale Error: Both width and height must be greater than zero.");
return;
}
}
......
......@@ -114,6 +114,8 @@ static void plug_in_args_destroy (Argument *args,
static Argument* progress_init_invoker (Argument *args);
static Argument* progress_update_invoker (Argument *args);
static Argument* message_invoker (Argument *args);
static GSList *plug_in_defs = NULL;
static GSList *gimprc_proc_defs = NULL;
......@@ -184,6 +186,30 @@ static ProcRecord progress_update_proc =
};
static ProcArg message_args[] =
{
{ PDB_STRING,
"message",
"Message to display in the dialog." }
};
static ProcRecord message_proc =
{
"gimp_message",
"Displays a dialog box with a message",
"Displays a dialog box with a message. Useful for status or error reporting.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
1,
message_args,
0,
NULL,
{ { message_invoker } },
};
void
plug_in_init ()
{
......@@ -198,6 +224,9 @@ plug_in_init ()
procedural_db_register (&progress_init_proc);
procedural_db_register (&progress_update_proc);
/* initialize the message box procedural db calls */
procedural_db_register (&message_proc);
/* initialize the gimp protocol library and set the read and
* write handlers.
*/
......@@ -652,7 +681,7 @@ plug_in_new (char *name)
path = search_in_path (plug_in_path, name);
if (!path)
{
warning ("unable to locate plug-in: \"%s\"", name);
g_message ("unable to locate plug-in: \"%s\"", name);
return NULL;
}
}
......@@ -732,7 +761,7 @@ plug_in_open (PlugIn *plug_in)
*/
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
{
warning ("unable to open pipe");
g_message ("unable to open pipe");
return 0;
}
......@@ -780,7 +809,7 @@ plug_in_open (PlugIn *plug_in)
}
else if (plug_in->pid == -1)
{
warning ("unable to run plug-in: %s\n", plug_in->args[0]);
g_message ("unable to run plug-in: %s\n", plug_in->args[0]);
plug_in_destroy (plug_in);
return 0;
}
......@@ -2973,3 +3002,10 @@ progress_update_invoker (Argument *args)
return procedural_db_return_args (&progress_update_proc, success);
}
static Argument*
message_invoker (Argument *args)
{
g_message (args[0].value.pdb_pointer, NULL, NULL);
return procedural_db_return_args (&message_proc, TRUE);
}
......@@ -22,6 +22,8 @@
#include <sys/param.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include "appenv.h"
#include "app_procs.h"
#include "batch.h"
......@@ -53,7 +55,7 @@
#include "tools.h"
#include "undo.h"
#include "xcf.h"
#include <gtk/gtk.h>
#include "errors.h"
#include "config.h"
......@@ -514,6 +516,7 @@ app_init (void)
render_setup (transparency_type, transparency_size);
tools_options_dialog_new ();
tools_select (RECT_SELECT);
g_set_message_handler (&message_box_func);
}
color_transfer_init ();
......
......@@ -320,7 +320,7 @@ color_balance_initialize (void *gdisp_ptr)
if (! drawable_color (gimage_active_drawable (gdisp->gimage)))
{
message_box ("Color balance operates only on RGB color drawables.", NULL, NULL);
g_message ("Color balance operates only on RGB color drawables.");
return;
}
......
......@@ -346,7 +346,7 @@ curves_initialize (void *gdisp_ptr)
if (drawable_indexed (gimage_active_drawable (gdisp->gimage)))
{
message_box ("Curves for indexed drawables cannot be adjusted.", NULL, NULL);
g_message ("Curves for indexed drawables cannot be adjusted.");
return;
}
......
......@@ -364,7 +364,7 @@ hue_saturation_initialize (void *gdisp_ptr)
if (! drawable_color (gimage_active_drawable (gdisp->gimage)))
{
message_box ("Hue-Saturation operates only on RGB color drawables.", NULL, NULL);
g_message ("Hue-Saturation operates only on RGB color drawables.");
return;
}
......
......@@ -185,7 +185,7 @@ temp_buf_copy (src, dest)
if (!src)
{
warning ("trying to copy a temp buf which is NULL.");
g_message ("trying to copy a temp buf which is NULL.");
return dest;
}
......@@ -195,7 +195,7 @@ temp_buf_copy (src, dest)
{
new = dest;
if (dest->width != src->width || dest->height != src->height)
warning ("In temp_buf_copy, the widths or heights don't match.");
g_message ("In temp_buf_copy, the widths or heights don't match.");
/* The temp buf is smart, and can translate between color and gray */
/* (only necessary if not we allocated it */
if (src->bytes != new->bytes)
......@@ -205,7 +205,7 @@ temp_buf_copy (src, dest)
else if (src->bytes == 2) /* grayscale */
temp_buf_to_color (src, new);
else
warning ("Cannot convert from indexed color.");
g_message ("Cannot convert from indexed color.");
return new;
}
}
......@@ -271,7 +271,7 @@ temp_buf_copy_area (src, dest, x, y, w, h, border)
if (!src)
{
warning ("trying to copy a temp buf which is NULL.");
g_message ("trying to copy a temp buf which is NULL.");
return dest;
}
......@@ -295,7 +295,7 @@ temp_buf_copy_area (src, dest, x, y, w, h, border)
{
new = dest;
if (dest->bytes != src->bytes)
warning ("In temp_buf_copy_area, the widths or heights or bytes don't match.");
g_message ("In temp_buf_copy_area, the widths or heights or bytes don't match.");
}
/* Set the offsets for the dest */
......@@ -464,7 +464,7 @@ temp_buf_swap (buf)
{
if (stat_buf.st_mode & S_IFDIR)
{
warning ("Error in temp buf caching: \"%s\" is a directory (cannot overwrite)",
g_message ("Error in temp buf caching: \"%s\" is a directory (cannot overwrite)",
filename);
g_free (filename);
return;
......@@ -480,7 +480,7 @@ temp_buf_swap (buf)
else
{
perror ("Error in temp buf caching");
warning ("Cannot write \"%s\"", filename);
g_message ("Cannot write \"%s\"", filename);
g_free (filename);
return;
}
......@@ -537,7 +537,7 @@ temp_buf_unswap (buf)
unlink (buf->filename);
}
if (!succ)
warning ("Error in temp buf caching: information swapped to disk was lost!");
g_message ("Error in temp buf caching: information swapped to disk was lost!");
g_free (buf->filename); /* free filename */
buf->filename = NULL;
......@@ -570,7 +570,7 @@ temp_buf_swap_free (buf)
unlink (buf->filename);
}
else
warning ("Error in temp buf disk swapping: information swapped to disk was lost!");
g_message ("Error in temp buf disk swapping: information swapped to disk was lost!");
if (buf->filename)
g_free (buf->filename); /* free filename */
......
......@@ -343,7 +343,7 @@ threshold_initialize (void *gdisp_ptr)
if (drawable_indexed (gimage_active_drawable (gdisp->gimage)))
{
message_box ("Threshold does not operate on indexed drawables.", NULL, NULL);
g_message ("Threshold does not operate on indexed drawables.");
return;
}
......
......@@ -1133,7 +1133,7 @@ bezier_convert (BezierSelect *bezier_sel,
x = (long) list->data;
list = list->next;
if (!list)
warning ("cannot properly scanline convert bezier curve: %d", i);
g_message ("cannot properly scanline convert bezier curve: %d", i);
else
{
/* bounds checking */
......
......@@ -550,7 +550,7 @@ blend_button_press (Tool *tool,
switch (drawable_type (gimage_active_drawable (gdisp->gimage)))
{
case INDEXED_GIMAGE: case INDEXEDA_GIMAGE:
message_box ("Blend: Invalid for indexed images.", NULL, NULL);
g_message ("Blend: Invalid for indexed images.");
return;
break;
......@@ -622,7 +622,7 @@ blend_button_release (Tool *tool,
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
message_box ("Blend operation failed.", NULL, NULL);
g_message ("Blend operation failed.");
procedural_db_destroy_args (return_vals, nreturn_vals);
}
......
......@@ -286,7 +286,7 @@ brightness_contrast_initialize (void *gdisp_ptr)
if (drawable_indexed (gimage_active_drawable (gdisp->gimage)))
{
message_box ("Brightness-Contrast does not operate on indexed drawables.", NULL, NULL);
g_message ("Brightness-Contrast does not operate on indexed drawables.");
return;
}
......
......@@ -269,8 +269,8 @@ load_brush(char *filename)
}
else
{
warning ("Unknown GIMP version #%d in \"%s\"\n", header.version,
filename);
g_message ("Unknown GIMP version #%d in \"%s\"\n", header.version,
filename);
fclose (fp);
free_brush (brush);
return;
......@@ -287,7 +287,7 @@ load_brush(char *filename)
brush->name = (char *) g_malloc (sizeof (char) * bn_size);
if ((fread (brush->name, 1, bn_size, fp)) < bn_size)
{
warning ("Error in GIMP brush file...aborting.");
g_message ("Error in GIMP brush file...aborting.");
fclose (fp);
free_brush (brush);
return;
......@@ -300,7 +300,7 @@ load_brush(char *filename)
/* Read the image data */
if ((fread (temp_buf_data (brush->mask), 1, header.width * header.height, fp)) <
header.width * header.height)
warning ("GIMP brush file appears to be truncated.");
g_message ("GIMP brush file appears to be truncated.");
/* Clean up */
fclose (fp);
......
......@@ -327,7 +327,7 @@ bucket_fill_button_release (tool, bevent, gdisp_ptr)
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
message_box ("Bucket Fill operation failed.", NULL, NULL);
g_message ("Bucket Fill operation failed.");
procedural_db_destroy_args (return_vals, nreturn_vals);
}
......@@ -424,7 +424,7 @@ bucket_fill (gimage, drawable, fill_mode, paint_mode,
if (!pattern)
{
message_box ("No available patterns for this operation.", NULL, NULL);
g_message ("No available patterns for this operation.");
return;
}
......
......@@ -798,10 +798,10 @@ channel_list_events (GtkWidget *widget,
switch (kevent->keyval)
{
case GDK_Up:
printf ("up arrow\n");
/* printf ("up arrow\n"); */
break;
case GDK_Down:
printf ("down arrow\n");
/* printf ("down arrow\n"); */
break;
default:
return FALSE;
......
......@@ -228,7 +228,7 @@ clone_paint_func (PaintCore *paint_core,
if (clone_options->type == PatternClone)
if (!get_active_pattern ())
message_box ("No patterns available for this operation.", NULL, NULL);
g_message ("No patterns available for this operation.");
break;
case FINISH_PAINT :
......
......@@ -320,7 +320,7 @@ color_balance_initialize (void *gdisp_ptr)
if (! drawable_color (gimage_active_drawable (gdisp->gimage)))
{
message_box ("Color balance operates only on RGB color drawables.", NULL, NULL);
g_message ("Color balance operates only on RGB color drawables.");
return;
}
......
......@@ -564,29 +564,25 @@ file_prefs_ok_callback (GtkWidget *widget,
if (levels_of_undo < 0)
{
message_box("Error: Levels of undo must be zero or greater.",
NULL, NULL);
g_message ("Error: Levels of undo must be zero or greater.");
levels_of_undo = old_levels_of_undo;
return;
}
if (marching_speed < 50)
{
message_box("Error: Marching speed must be 50 or greater.",
NULL, NULL);
g_message ("Error: Marching speed must be 50 or greater.");
marching_speed = old_marching_speed;
return;
}
if (default_width < 1)
{
message_box("Error: Default width must be one or greater.",
NULL, NULL);
g_message ("Error: Default width must be one or greater.");
default_width = old_default_width;
return;
}
if (default_height < 1)
{
message_box("Error: Default height must be one or greater.",
NULL, NULL);
g_message ("Error: Default height must be one or greater.");
default_height = old_default_height;
return;
}
......@@ -752,7 +748,7 @@ file_prefs_save_callback (GtkWidget *widget,
gradient_path = save_gradient_path;
if (restart_notification)
message_box("You will need to restart GIMP for these changes to take effect.", NULL, NULL);
g_message ("You will need to restart GIMP for these changes to take effect.");
g_list_free (update);
g_list_free (remove);
......@@ -2486,7 +2482,7 @@ image_resize_callback (GtkWidget *w,
}
else
{
message_box("Resize Error: Both width and height must be greater than zero.", NULL, NULL);
g_message ("Resize Error: Both width and height must be greater than zero.");
return;
}
}
......@@ -2516,7 +2512,7 @@ image_scale_callback (GtkWidget *w,
}
else
{
message_box("Scale Error: Both width and height must be greater than zero.", NULL, NULL);
g_message ("Scale Error: Both width and height must be greater than zero.");
return;
}
}
......
......@@ -303,8 +303,7 @@ convert_to_indexed (void *gimage_ptr)
dialog->num_cols = 255;
if (!shown_message_already)
{
message_box ("Note: You are attempting to convert an image\nwith alpha/layers. It is recommended that you quantize\nto no more than 255 colors if you wish to make\na transparent or animated GIF from it.\n\nYou won't get this message again\nuntil the next time you run GIMP.\nHave a nice day!",
NULL, NULL);
g_message ("Note: You are attempting to convert an image\nwith alpha/layers. It is recommended that you quantize\nto no more than 255 colors if you wish to make\na transparent or animated GIF from it.\n\nYou won't get this message again\nuntil the next time you run GIMP.\nHave a nice day!");
shown_message_already = True;
}
}
......@@ -1015,7 +1014,7 @@ generate_histogram_rgb (Histogram histogram,
has_alpha = (gboolean) layer_has_alpha(layer);
g_print ("col_limit = %d, nfc = %d\n", col_limit, num_found_cols);
/* g_print ("col_limit = %d, nfc = %d\n", col_limit, num_found_cols);*/
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles, 0, 0,
GIMP_DRAWABLE(layer)->width,
......@@ -1083,7 +1082,7 @@ generate_histogram_rgb (Histogram histogram,
* quantizing at a later stage.
*/
needs_quantize = TRUE;
g_print ("\nmax colours exceeded - needs quantize.\n");
/* g_print ("\nmax colours exceeded - needs quantize.\n");*/
goto already_found;
}
else
......@@ -1102,7 +1101,7 @@ generate_histogram_rgb (Histogram histogram,
}
}
g_print ("O: col_limit = %d, nfc = %d\n", col_limit, num_found_cols);
/* g_print ("O: col_limit = %d, nfc = %d\n", col_limit, num_found_cols);*/
}
......
......@@ -97,7 +97,7 @@ datafiles_read_directories (char *path_str,
dir = opendir(path);
if (!dir)
warning("error reading datafiles directory \"%s\"", path);
g_message ("error reading datafiles directory \"%s\"", path);
else
{
while ((dir_ent = readdir(dir)))
......
Supports Markdown
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