Commit 6ef23d98 authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc

1999-09-01  Tor Lillqvist  <tml@iki.fi>

* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.

* libgimp/gimp.h: Include gimpmath.h.

* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.

* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.

* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().

* app/app_procs.[ch]: app_exit() takes a gboolean.

* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.

* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.

* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it.  g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
parent 28449546
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
Wed Sep 1 22:16:41 MEST 1999 Sven Neumann <sven@gimp.org>
* app/paint_core.c: Only set the defaults for non_gui operations
......@@ -18,6 +56,7 @@ Wed Sep 1 20:45:56 MEST 1999 Sven Neumann <sven@gimp.org>
when drawing a line using <Shift>. Do we need the angle here too??
Wed Sep 1 14:12:17 CEST 1999 Pablo Saratxaga <pablo@mandrakesoft.com>
* po/da.po, configure.in: added danish file from
Henrik Hansen <hh@mailserver.dk>
......
......@@ -130,7 +130,7 @@ void
file_quit_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
app_exit (0);
app_exit (FALSE);
}
void
......
......@@ -677,10 +677,10 @@ app_exit_finish (void)
}
void
app_exit (int kill_it)
app_exit (gboolean kill_it)
{
/* If it's the user's perogative, and there are dirty images */
if (kill_it == FALSE && gdisplays_dirty () && no_interface == FALSE)
if (!kill_it && gdisplays_dirty () && no_interface == FALSE)
really_quit_dialog ();
else
app_exit_finish ();
......
......@@ -21,7 +21,7 @@
/* Function declarations */
void gimp_init (int, char **);
void app_init (void);
void app_exit (int);
void app_exit (gboolean);
void app_exit_finish (void);
int app_exit_finish_done (void);
void app_init_update_status(char *label1val, char *label2val, float pct_progress);
......
......@@ -20,60 +20,15 @@
#include "glib.h"
/* The GIMP shouldn't need to know much about X11 (or Windows), so
* I'll remove this inclusion of gdkx.h. This will speed up compilations
* a bit, too. If some source file needs gdkx.h, it can include it.
*/
#if 0
#include "gdk/gdkx.h"
#endif
#include "gtk/gtk.h"
#include "gimpsetF.h"
#include "colormap_dialog.t.h"
/* Without gdkx.h no GDK_DISPLAY() */
#if 0
#define DISPLAY ((Display *) GDK_DISPLAY())
#endif
/* important macros - we reuse the ones from glib */
#define BOUNDS(a,x,y) CLAMP(a,x,y)
#define MINIMUM(x,y) MIN(x,y)
#define MAXIMUM(x,y) MAX(x,y)
#ifndef G_PI /* G_PI will be in GLib eventually */
#define G_PI 3.14159265358979323846
#endif
#ifndef G_PI_2 /* As will G_PI_2 */
#define G_PI_2 1.57079632679489661923
#endif
#ifndef G_PI_4 /* As will G_PI_4 */
#define G_PI_4 0.78539816339744830962
#endif
#ifndef G_SQRT2 /* As will G_SQRT2 */
#define G_SQRT2 1.4142135623730951
#endif
#ifdef HAVE_RINT
#define RINT(x) rint(x)
#else
#define RINT(x) floor ((x) + 0.5)
#endif
#define ROUND(x) ((int) ((x) + 0.5))
/* Square */
#define SQR(x) ((x) * (x))
/* limit a (0->511) int to 255 */
#define MAX255(a) ((a) | (((a) & 256) - (((a) & 256) >> 8)))
/* clamp a >>int32<<-range int between 0 and 255 inclusive */
/* broken! -> #define CLAMP0255(a) ((a & 0xFFFFFF00)? (~(a>>31)) : a) */
#define CLAMP0255(a) CLAMP(a,0,255)
typedef enum {
MESSAGE_BOX,
CONSOLE,
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "actionarea.h"
#include "color_balance.h"
......@@ -30,6 +32,7 @@
#include "interface.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#define TEXT_WIDTH 55
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "actionarea.h"
#include "buildmenu.h"
......@@ -32,6 +34,7 @@
#include "gimplut.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#define GRAPH 0x1
#define XRANGE_TOP 0x2
......
......@@ -96,7 +96,7 @@ batch_run_cmd (char *cmd)
if (g_strcasecmp (cmd, "(gimp-quit 0)") == 0)
{
app_exit (0);
app_exit (FALSE);
exit (0);
}
......
......@@ -18,7 +18,7 @@
#include "config.h"
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "cursorutil.h"
#include "draw_core.h"
......@@ -34,6 +34,7 @@
#include "selection_options.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
/* Bezier extensions made by Raphael FRANCOIS (fraph@ibm.net)
......
......@@ -15,7 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <math.h>
#include "config.h"
#include "appenv.h"
#include "asupsample.h"
#include "blend.h"
......@@ -39,6 +40,7 @@
#include "tile.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
/* target size */
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "channel.h"
#include "drawable.h"
......@@ -32,6 +34,7 @@
#include "gimppreviewcache.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "channel_pvt.h"
#include "tile.h"
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "actionarea.h"
#include "color_balance.h"
......@@ -30,6 +32,7 @@
#include "interface.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#define TEXT_WIDTH 55
......
......@@ -130,7 +130,7 @@ void
file_quit_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
app_exit (0);
app_exit (FALSE);
}
void
......
......@@ -78,10 +78,10 @@
* [Adam D. Moss - adam@gimp.org]
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "actionarea.h"
......@@ -97,6 +97,7 @@
#include "preferences_dialog.h" /* ick. */
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "layer_pvt.h" /* ick. */
#include "drawable_pvt.h" /* ick ick. */
......
......@@ -17,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
......@@ -30,6 +28,8 @@
#include "gimprc.h"
#include "gimpbrush.h"
#include "libgimp/gimpmath.h"
#define OVERSAMPLING 5
static void
......
......@@ -17,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
......@@ -30,6 +28,8 @@
#include "gimprc.h"
#include "gimpbrush.h"
#include "libgimp/gimpmath.h"
#define OVERSAMPLING 5
static void
......
......@@ -17,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
......@@ -30,6 +28,8 @@
#include "gimprc.h"
#include "gimpbrush.h"
#include "libgimp/gimpmath.h"
#define OVERSAMPLING 5
static void
......
......@@ -19,7 +19,6 @@
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -35,7 +34,9 @@
#include "gimpbrushpipeP.h"
#include "paint_core.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
/* Code duplicated from plug-ins/common/gpb.c...
* The struct, and code to parse/build it probably should be in libgimp.
......
......@@ -19,7 +19,6 @@
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -35,7 +34,9 @@
#include "gimpbrushpipeP.h"
#include "paint_core.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
/* Code duplicated from plug-ins/common/gpb.c...
* The struct, and code to parse/build it probably should be in libgimp.
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "channel.h"
#include "drawable.h"
......@@ -32,6 +34,7 @@
#include "gimppreviewcache.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "channel_pvt.h"
#include "tile.h"
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "channel.h"
#include "drawable.h"
......@@ -32,6 +34,7 @@
#include "gimppreviewcache.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "channel_pvt.h"
#include "tile.h"
......
......@@ -15,7 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <math.h>
#include "config.h"
#include "appenv.h"
#include "asupsample.h"
#include "blend.h"
......@@ -39,6 +40,7 @@
#include "tile.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
/* target size */
......
......@@ -78,10 +78,10 @@
* [Adam D. Moss - adam@gimp.org]
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "actionarea.h"
......@@ -97,6 +97,7 @@
#include "preferences_dialog.h" /* ick. */
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "layer_pvt.h" /* ick. */
#include "drawable_pvt.h" /* ick ick. */
......
......@@ -15,8 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "colormaps.h"
#include "cursorutil.h"
......@@ -48,6 +51,7 @@
#include "layer_pvt.h" /* ick. (not alone either) */
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#define OVERHEAD 25 /* in units of pixel area */
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "actionarea.h"
#include "buildmenu.h"
......@@ -32,6 +34,7 @@
#include "gimplut.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#define GRAPH 0x1
#define XRANGE_TOP 0x2
......
......@@ -15,8 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "colormaps.h"
#include "cursorutil.h"
......@@ -48,6 +51,7 @@
#include "layer_pvt.h" /* ick. (not alone either) */
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#define OVERHEAD 25 /* in units of pixel area */
......
......@@ -170,7 +170,7 @@ toolbox_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
app_exit (0);
app_exit (FALSE);
return TRUE;
}
......
......@@ -170,7 +170,7 @@ toolbox_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
app_exit (0);
app_exit (FALSE);
return TRUE;
}
......
......@@ -16,10 +16,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "gdk/gdkkeysyms.h"
#include "appenv.h"
#include "drawable.h"
#include "errors.h"
......@@ -35,6 +37,7 @@
#include "gimage.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
/* the dodgeburn structures */
......
......@@ -41,6 +41,10 @@
#include "errors.h"
#include "libgimp/gimpintl.h"
#ifdef NATIVE_WIN32
#include <windows.h>
#endif
extern gchar *prog_name;
void
......@@ -68,28 +72,33 @@ gimp_message_func (gchar *str)
void
gimp_fatal_error (gchar *fmt, ...)
{
#ifndef NATIVE_WIN32
va_list args;
va_start (args, fmt);
#ifndef NATIVE_WIN32
printf (_("%s: fatal error: %s\n"), prog_name, g_strdup_vprintf (fmt, args));
#else
g_error (_("%s: fatal error: %s\n"), prog_name, g_strdup_vprintf (fmt, args));
#endif
va_end (args);
#ifndef NATIVE_WIN32
g_on_error_query (prog_name);
#else
/* g_on_error_query unreliable on Win32 */
abort ();
/* g_on_error_query doesn't do anything reasonable on Win32. */
va_list args;
gchar *msg;
va_start (args, fmt);
msg = g_strdup_vprintf (fmt, args);
va_end (args);
MessageBox (NULL, msg, prog_name, MB_OK|MB_ICONERROR);
/* I don't dare do anything more. */
ExitProcess (1);
#endif
app_exit (1);
app_exit (TRUE);
}
void
gimp_terminate (gchar *fmt, ...)
{
#ifndef NATIVE_WIN32
va_list args;
va_start (args, fmt);
......@@ -98,9 +107,18 @@ gimp_terminate (gchar *fmt, ...)
printf ("\n");
va_end (args);
#ifndef NATIVE_WIN32
if (use_debug_handler)
g_on_error_query (prog_name);
#else
/* g_on_error_query doesn't do anything reasonable on Win32. */
va_list args;
gchar *msg;
va_start (args, fmt);
msg = g_strdup_vprintf (fmt, args);
va_end (args);
MessageBox (NULL, msg, prog_name, MB_OK|MB_ICONERROR);
#endif
gdk_exit (1);
}
......@@ -58,6 +58,7 @@
#include "undo.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
typedef struct _OverwriteBox OverwriteBox;
......
......@@ -15,8 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "colormaps.h"
#include "cursorutil.h"
......@@ -48,6 +51,7 @@
#include "layer_pvt.h" /* ick. (not alone either) */
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#define OVERHEAD 25 /* in units of pixel area */
......
......@@ -17,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
......@@ -30,6 +28,8 @@
#include "gimprc.h"
#include "gimpbrush.h"
#include "libgimp/gimpmath.h"
#define OVERSAMPLING 5
static void
......
......@@ -19,7 +19,6 @@
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -35,7 +34,9 @@
#include "gimpbrushpipeP.h"
#include "paint_core.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
/* Code duplicated from plug-ins/common/gpb.c...
* The struct, and code to parse/build it probably should be in libgimp.
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/