Commit a27cedc0 authored by Tor Lillqvist's avatar Tor Lillqvist

First batch of changes to merge the Win32 version. This will be

done in pieces, don't expect to be able to compile on Win32 from
these sources yet.  Ans of course, the official version of GTk+
doesn't include the Win32 stuff yet.
parent f67bef8c
......@@ -15,15 +15,26 @@
* 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 <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <sys/types.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _MSC_VER
#include <process.h> /* For _getpid() */
#endif
#include <gtk/gtk.h>
#include "libgimp/gimpfeatures.h"
......@@ -73,8 +84,6 @@
#include "color_notebook.h"
#include "color_select.h"
#include "config.h"
#include "libgimp/gimpintl.h"
#define LOGO_WIDTH_MIN 300
......@@ -169,21 +178,22 @@ splash_logo_load_size (GtkWidget *window)
if (logo_pixmap)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s/gimp1_1_splash.ppm", DATADIR);
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm",
DATADIR);
fp = fopen (buf, "rb");
if (!fp)
return 0;
fgets (buf, 1024, fp);
fgets (buf, sizeof (buf), fp);
if (strcmp (buf, "P6\n") != 0)
{
fclose (fp);
return 0;
}
fgets (buf, 1024, fp);
fgets (buf, 1024, fp);
fgets (buf, sizeof (buf), fp);
fgets (buf, sizeof (buf), fp);
sscanf (buf, "%d %d", &logo_width, &logo_height);
fclose (fp);
......@@ -204,24 +214,25 @@ splash_logo_load (GtkWidget *window)
if (logo_pixmap)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s/gimp1_1_splash.ppm", DATADIR);
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm",
DATADIR);
fp = fopen (buf, "rb");
if (!fp)
return 0;
fgets (buf, 1024, fp);
fgets (buf, sizeof (buf), fp);
if (strcmp (buf, "P6\n") != 0)
{
fclose (fp);
return 0;
}
fgets (buf, 1024, fp);
fgets (buf, 1024, fp);
fgets (buf, sizeof (buf), fp);
fgets (buf, sizeof (buf), fp);
sscanf (buf, "%d %d", &logo_width, &logo_height);
fgets (buf, 1024, fp);
fgets (buf, sizeof (buf), fp);
if (strcmp (buf, "255\n") != 0)
{
fclose (fp);
......@@ -273,6 +284,7 @@ splash_text_draw (GtkWidget *widget)
((logo_area_width - gdk_string_width (font, NAME)) / 2),
(0.25 * logo_area_height),
NAME);
gdk_font_unref (font);
font = gdk_font_load ("-Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-*");
gdk_draw_string (widget->window,
......@@ -293,6 +305,7 @@ splash_text_draw (GtkWidget *widget)
((logo_area_width - gdk_string_width (font, AUTHORS)) / 2),
(0.80 * logo_area_height),
AUTHORS);
gdk_font_unref (font);
}
static void
......@@ -424,7 +437,7 @@ app_init_update_status(char *label1val,
{
while ( strlen (label2val) > max_label_length )
{
temp = strchr (label2val, '/');
temp = strchr (label2val, G_DIR_SEPARATOR);
if (temp == NULL) /* for sanity */
break;
temp++;
......@@ -462,7 +475,7 @@ app_init (void)
gimp_dir = gimp_directory ();
if (gimp_dir[0] != '\000')
{
g_snprintf (filename, MAXPATHLEN, "%s/gtkrc", gimp_dir);
g_snprintf (filename, MAXPATHLEN, "%s" G_DIR_SEPARATOR_S "gtkrc", gimp_dir);
if ((be_verbose == TRUE) || (no_splash == TRUE))
g_print (_("parsing \"%s\"\n"), filename);
......@@ -539,7 +552,8 @@ app_init (void)
if (swap_path == NULL)
swap_path = "/tmp";
toast_old_temp_files ();
path = g_strdup_printf ("%s/gimpswap.%ld", swap_path, (long)getpid ());
path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimpswap.%ld",
swap_path, (long)getpid ());
tile_swap_add (path, NULL, NULL);
g_free (path);
......@@ -759,9 +773,17 @@ toast_old_temp_files (void)
*/
int pid = atoi (entry->d_name + 9);
#ifndef NATIVE_WIN32
if (kill (pid, 0))
#else
/* On Windows, you can't remove open files anyhow,
* so no harm trying.
*/
#endif
{
g_string_sprintf (filename, "%s/%s", swap_path, entry->d_name);
g_string_sprintf (filename, "%s" G_DIR_SEPARATOR_S "%s",
swap_path, entry->d_name);
unlink (filename->str);
}
}
......
......@@ -19,11 +19,23 @@
#define __APPENV_H__
#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)
......
......@@ -30,6 +30,7 @@
#include <math.h>
#include <stdlib.h>
#include "appenv.h"
#include "asupsample.h"
......
......@@ -15,12 +15,22 @@
* 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 <errno.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <sys/stat.h>
#ifdef _MSC_VER
#include <process.h> /* For _getpid() */
#endif
#include "appenv.h"
#include "drawable.h"
#include "errors.h"
......@@ -416,7 +426,8 @@ generate_unique_filename (void)
{
pid_t pid;
pid = getpid ();
return g_strdup_printf ("%s/gimp%d.%d", temp_path, (int) pid, swap_index++);
return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp%d.%d",
temp_path, (int) pid, swap_index++);
}
......
......@@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "tile_cache.h"
#include "tile_manager.h"
#include "tile_swap.h"
......
#include "config.h"
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef USE_PTHREADS
#include <pthread.h>
#endif
#ifdef _MSC_VER
#include <io.h>
#endif
#include "libgimp/gimpintl.h"
#define MAX_OPEN_SWAP_FILES 16
......@@ -352,7 +360,11 @@ tile_swap_open (SwapFile *swap_file)
nopen_swap_files -= 1;
}
#ifndef NATIVE_WIN32
swap_file->fd = open (swap_file->filename, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
#else
swap_file->fd = open (swap_file->filename, O_CREAT|O_RDWR|_O_BINARY, _S_IREAD|_S_IWRITE);
#endif
if (swap_file->fd == -1)
{
g_message (_("unable to open swap file...BAD THINGS WILL HAPPEN SOON"));
......
#include "config.h"
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "appenv.h"
#include "app_procs.h"
......@@ -43,10 +47,14 @@ batch_init ()
{
if (!read_from_stdin)
{
#ifndef NATIVE_WIN32 /* for now */
g_print (_("reading batch commands from stdin\n"));
gdk_input_add (STDIN_FILENO, GDK_INPUT_READ, batch_read, NULL);
read_from_stdin = TRUE;
}
#else
g_error ("Batch mode from standard input not implemented on Win32");
#endif
}
else
{
......
......@@ -31,6 +31,10 @@
#define ROUND(A) floor((A)+0.5)
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif /* M_PI */
static Blob *
blob_new (int y, int height)
{
......
......@@ -235,7 +235,7 @@ clone_paint_func (PaintCore *paint_core,
y2 = paint_core->lasty;
/* If the control key is down, move the src target and return */
if (paint_core->state & ControlMask)
if (paint_core->state & GDK_CONTROL_MASK)
{
src_x = x1;
src_y = y1;
......@@ -269,7 +269,7 @@ clone_paint_func (PaintCore *paint_core,
break;
case INIT_PAINT :
if (paint_core->state & ControlMask)
if (paint_core->state & GDK_CONTROL_MASK)
{
the_src_gdisp = gdisp;
clone_set_src_drawable(drawable);
......
......@@ -17,6 +17,7 @@
*/
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "color_area.h"
#include "color_notebook.h"
......
......@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "actionarea.h"
#include "color_select.h"
......
......@@ -429,9 +429,11 @@ ipal_clear (GimpColormapDialog* ipal)
palette = GTK_WIDGET(ipal->palette);
width = palette->allocation.width;
height = palette->allocation.height;
row = g_new(guchar, width * 3);
/* Watch out for negative values (at least on Win32) */
width = (int) (gint16) palette->allocation.width;
height = (int) (gint16) palette->allocation.height;
if (width > 0)
row = g_new(guchar, width * 3);
gtk_preview_size(ipal->palette, width, height);
......@@ -448,7 +450,8 @@ ipal_clear (GimpColormapDialog* ipal)
for (j = 0; j < 4 && i+j < height; j++)
gtk_preview_draw_row (ipal->palette, row, 0, i + j, width);
}
g_free (row);
if (width > 0)
g_free (row);
gtk_widget_draw (palette, NULL);
}
......
......@@ -18,12 +18,24 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#ifndef HAVE_RINT
#define rint(x) floor (x + 0.5)
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "appenv.h"
#include "gimpbrushgenerated.h"
#include "paint_core.h"
#include "gimprc.h"
#include <math.h>
#include <stdio.h>
#define OVERSAMPLING 5
......@@ -228,7 +240,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
register double exponent;
register guchar a;
register int length;
register char *lookup;
register guchar *lookup;
double buffer[OVERSAMPLING];
register double sum, c, s, tx, ty;
int width, height;
......
......@@ -18,12 +18,24 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#ifndef HAVE_RINT
#define rint(x) floor (x + 0.5)
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "appenv.h"
#include "gimpbrushgenerated.h"
#include "paint_core.h"
#include "gimprc.h"
#include <math.h>
#include <stdio.h>
#define OVERSAMPLING 5
......@@ -228,7 +240,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
register double exponent;
register guchar a;
register int length;
register char *lookup;
register guchar *lookup;
double buffer[OVERSAMPLING];
register double sum, c, s, tx, ty;
int width, height;
......
......@@ -18,12 +18,24 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#ifndef HAVE_RINT
#define rint(x) floor (x + 0.5)
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "appenv.h"
#include "gimpbrushgenerated.h"
#include "paint_core.h"
#include "gimprc.h"
#include <math.h>
#include <stdio.h>
#define OVERSAMPLING 5
......@@ -228,7 +240,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
register double exponent;
register guchar a;
register int length;
register char *lookup;
register guchar *lookup;
double buffer[OVERSAMPLING];
register double sum, c, s, tx, ty;
int width, height;
......
......@@ -18,15 +18,29 @@
* 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 <stdio.h>
#include <string.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef _MSC_VER
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#endif
#ifndef S_IXUSR
#define S_IXUSR _S_IEXEC
#endif
#endif
#include <glib.h>
#include "datafiles.h"
......@@ -70,7 +84,7 @@ datafiles_read_directories (char *path_str,
next_token = local_path;
token = xstrsep(&next_token, ":");
token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S);
while (token)
{
......@@ -90,8 +104,8 @@ datafiles_read_directories (char *path_str,
if (!err && S_ISDIR(filestat.st_mode))
{
if (path[strlen(path) - 1] != '/')
strcat(path, "/");
if (path[strlen(path) - 1] != G_DIR_SEPARATOR)
strcat(path, G_DIR_SEPARATOR_S);
/* Open directory */
dir = opendir(path);
......@@ -124,7 +138,7 @@ datafiles_read_directories (char *path_str,
g_free(path);
token = xstrsep(&next_token, ":");
token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S);
} /* while */
g_free(local_path);
......
......@@ -19,7 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <strings.h>
#include <string.h>
#include "gimpdrawableP.h"
#include "gimpsignal.h"
#include "gimage.h"
......
......@@ -15,6 +15,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpobjectP.h"
#include "gimpobject.h"
#include "gimpsignal.h"
......
......@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "buildmenu.h"
#include "channels_dialog.h"
......
......@@ -18,15 +18,29 @@
* 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 <stdio.h>
#include <string.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef _MSC_VER
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#endif
#ifndef S_IXUSR
#define S_IXUSR _S_IEXEC
#endif
#endif
#include <glib.h>
#include "datafiles.h"
......@@ -70,7 +84,7 @@ datafiles_read_directories (char *path_str,
next_token = local_path;
token = xstrsep(&next_token, ":");
token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S);
while (token)
{
......@@ -90,8 +104,8 @@ datafiles_read_directories (char *path_str,
if (!err && S_ISDIR(filestat.st_mode))
{
if (path[strlen(path) - 1] != '/')
strcat(path, "/");
if (path[strlen(path) - 1] != G_DIR_SEPARATOR)
strcat(path, G_DIR_SEPARATOR_S);
/* Open directory */
dir = opendir(path);
......@@ -124,7 +138,7 @@ datafiles_read_directories (char *path_str,
g_free(path);
token = xstrsep(&next_token, ":");
token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S);
} /* while */
g_free(local_path);
......
......@@ -18,10 +18,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <time.h>
#include "appenv.h"
#include "module_db.h"
......@@ -335,16 +340,14 @@ module_info_free (module_info *mod)
/* helper functions */
/* name must be of the form lib*.so */
/* TODO: need support for WIN32-style dll names. Maybe this function
* should live in libgmodule? */
/* name must be of the form lib*.so (Unix) or *.dll (Win32) */
static gboolean
valid_module_name (const char *filename)
{
const char *basename;
int len;
basename = strrchr (filename, '/');
basename = strrchr (filename, G_DIR_SEPARATOR);
if (basename)
basename++;
else
......@@ -352,6 +355,7 @@ valid_module_name (const char *filename)
len = strlen (basename);
#ifndef WIN32
if (len < 3 + 1 + 3)
return FALSE;
......@@ -360,6 +364,10 @@ valid_module_name (const char *filename)
if (strcmp (basename + len - 3, ".so"))
return FALSE;
#else
if (g_strcasecmp (basename + len - 4, ".dll"))
return FALSE;
#endif
return TRUE;
}
......
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "appenv.h"
#include "about_dialog.h"
#include "actionarea.h"
......
......@@ -45,9 +45,11 @@ tips_dialog_create ()
if (tips_count == 0)
{
if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL)
temp = (char *) g_strdup_printf ("%s/%s", gimp_data_dir, TIPS_FILE_NAME);
temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_data_dir, TIPS_FILE_NAME);
else
temp = (char *) g_strdup_printf ("%s/%s", DATADIR, TIPS_FILE_NAME);
temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
DATADIR, TIPS_FILE_NAME);
read_tips_file ((char *)temp);
g_free (temp);
}
......@@ -219,7 +221,7 @@ read_tips_file (char *filename)
char *tip = NULL;
char *str = NULL;
fp = fopen (filename, "rb");
fp = fopen (filename, "r");
if (!fp)
{
store_tip (_("Your GIMP tips file appears to be missing!\n"
......
......@@ -329,7 +329,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* if the first mouse button is down, check for automatic
* scrolling...
*/
if ((mevent->state & Button1Mask) && !active_tool->scroll_lock)
if ((mevent->state & GDK_BUTTON1_MASK) && !active_tool->scroll_lock)
{
if (mevent->x < 0 || mevent->y < 0 ||
mevent->x > gdisp->disp_width ||
......
......@@ -329,7 +329,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* if the first mouse button is down, check for automatic
* scrolling...
*/
if ((mevent->state & Button1Mask) && !active_tool->scroll_lock)
if ((mevent->state & GDK_BUTTON1_MASK) && !active_tool->scroll_lock)
{
if (mevent->x < 0 || mevent->y < 0 ||
mevent->x > gdisp->disp_width ||
......
......@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "buildmenu.h"
#include "channels_dialog.h"
......
......@@ -329,7 +329,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* if the first mouse button is down, check for automatic