Commit 951c92a6 authored by Tor Lillqvist's avatar Tor Lillqvist

Second batch of Win32 merge.

parent 3152a7db
......@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <gtk/gtk.h>
......@@ -25,6 +26,7 @@
#include "config.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
#include "about_dialog.h"
#include "interface.h"
......@@ -294,7 +296,8 @@ about_dialog_load_logo (GtkWidget *window)
if (logo_pixmap)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s/gimp_logo.ppm", DATADIR);
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_logo.ppm",
gimp_data_directory ());
fp = fopen (buf, "rb");
if (!fp)
......
This diff is collapsed.
......@@ -38,6 +38,7 @@
#include <gtk/gtk.h>
#include "libgimp/gimpfeatures.h"
#include "libgimp/gimpenv.h"
#include "appenv.h"
#include "app_procs.h"
......@@ -179,7 +180,7 @@ splash_logo_load_size (GtkWidget *window)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm",
DATADIR);
gimp_data_directory ());
fp = fopen (buf, "rb");
if (!fp)
......@@ -215,7 +216,7 @@ splash_logo_load (GtkWidget *window)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm",
DATADIR);
gimp_data_directory ());
fp = fopen (buf, "rb");
if (!fp)
......@@ -340,7 +341,7 @@ static GtkWidget *pbar = NULL;
static void
destroy_initialization_status_window(void)
{
if(win_initstatus)
if (win_initstatus)
{
gtk_widget_destroy(win_initstatus);
if (logo_pixmap != NULL)
......@@ -473,20 +474,15 @@ app_init_update_status(char *label1val,
void
app_init (void)
{
char filename[MAXPATHLEN];
char *gimp_dir;
char *path;
gchar *filename;
gchar *path;
gimp_dir = gimp_directory ();
if (gimp_dir[0] != '\000')
{
g_snprintf (filename, MAXPATHLEN, "%s" G_DIR_SEPARATOR_S "gtkrc", gimp_dir);
filename = gimp_gtkrc ();
if ((be_verbose == TRUE) || (no_splash == TRUE))
g_print (_("parsing \"%s\"\n"), filename);
if ((be_verbose == TRUE) || (no_splash == TRUE))
g_print (_("parsing \"%s\"\n"), filename);
gtk_rc_parse (filename);
}
gtk_rc_parse (filename);
if (no_interface == FALSE)
get_standard_colormaps ();
......@@ -555,10 +551,11 @@ app_init (void)
/* Add the swap file */
if (swap_path == NULL)
swap_path = "/tmp";
swap_path = g_get_tmp_dir ();
toast_old_temp_files ();
path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimpswap.%ld",
swap_path, (long)getpid ());
path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimpswap.%lu",
swap_path, (unsigned long) getpid ());
tile_swap_add (path, NULL, NULL);
g_free (path);
......
......@@ -2,6 +2,7 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
......
......@@ -9,6 +9,10 @@
#include <unistd.h>
#endif
#ifdef _MSC_VER
#include <io.h>
#endif
#include "appenv.h"
#include "app_procs.h"
#include "batch.h"
......@@ -51,10 +55,10 @@ batch_init ()
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
{
......
......@@ -20,6 +20,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "actionarea.h"
#include "color_notebook.h"
......
......@@ -35,6 +35,7 @@
#include "gimpsignal.h"
#include "libgimp/gimpintl.h"
#include "libgimp/parasite.h"
#include "layer_pvt.h"
#include "tile_manager_pvt.h"
......
......@@ -15,9 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <sys/param.h>
#include "appenv.h"
#include "actionarea.h"
......@@ -32,6 +34,7 @@
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
#define CELL_SIZE 20 /* The size of the preview cells */
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
......@@ -212,20 +215,14 @@ devices_init (void)
void
devices_restore()
{
char *gimp_dir;
char filename[MAXPATHLEN];
char *filename;
GList *tmp_list;
DeviceInfo *device_info;
/* Augment with information from rc file */
gimp_dir = gimp_directory ();
if (gimp_dir)
{
g_snprintf (filename, MAXPATHLEN, "%s/devicerc", gimp_dir);
parse_gimprc_file (filename);
}
filename = gimp_personal_rc_file ("devicerc");
parse_gimprc_file (filename);
g_free (filename);
tmp_list = devices_info;
device_info = NULL;
......@@ -625,25 +622,19 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
static void
devices_write_rc (void)
{
char *gimp_dir;
char filename[MAXPATHLEN];
char *filename;
FILE *fp;
devices_save_current_info();
filename = gimp_personal_rc_file ("devicerc");
fp = fopen (filename, "wb");
g_free (filename);
gimp_dir = gimp_directory ();
if ('\000' != gimp_dir[0])
{
g_snprintf (filename, MAXPATHLEN, "%s/devicerc", gimp_dir);
if (!fp)
return;
fp = fopen (filename, "wb");
if (!fp)
return;
g_list_foreach (devices_info, (GFunc)devices_write_rc_device, fp);
g_list_foreach (devices_info, (GFunc)devices_write_rc_device, fp);
fclose (fp);
}
fclose (fp);
}
void
......
......@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <gtk/gtk.h>
......@@ -25,6 +26,7 @@
#include "config.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
#include "about_dialog.h"
#include "interface.h"
......@@ -294,7 +296,8 @@ about_dialog_load_logo (GtkWidget *window)
if (logo_pixmap)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s/gimp_logo.ppm", DATADIR);
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_logo.ppm",
gimp_data_directory ());
fp = fopen (buf, "rb");
if (!fp)
......
......@@ -20,6 +20,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "actionarea.h"
#include "color_notebook.h"
......
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
......@@ -8,8 +10,8 @@
#include "interface.h"
#include "wilber.h"
#include "config.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
#define TIPS_FILE_NAME "gimp_tips.txt"
......@@ -39,22 +41,17 @@ tips_dialog_create ()
GtkWidget *button_prev;
GtkWidget *vbox_check;
GtkWidget *button_check;
guchar * temp;
gchar * temp;
guchar * src;
guchar * dest;
gchar * gimp_data_dir;
int x;
int y;
if (tips_count == 0)
{
if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL)
temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_data_dir, TIPS_FILE_NAME);
else
temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
DATADIR, TIPS_FILE_NAME);
read_tips_file ((char *)temp);
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_data_directory (), TIPS_FILE_NAME);
read_tips_file (temp);
g_free (temp);
}
......
......@@ -15,10 +15,15 @@
* 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 <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "appenv.h"
#include "actionarea.h"
......@@ -26,8 +31,16 @@
#include "interface.h"
#include "gimprc.h"
#include "config.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
#ifndef NATIVE_WIN32
# define USER_INSTALL "user_install"
#else
# define STRICT
# include <windows.h>
# define USER_INSTALL "user_install.bat"
#endif
static void install_run (InstallCallback);
static void install_help (InstallCallback);
......@@ -48,11 +61,7 @@ install_verify (InstallCallback install_callback)
struct stat stat_buf;
filename = gimp_directory ();
if ('\000' == filename[0])
{
g_message (_("No home directory--skipping GIMP user installation."));
(* install_callback) ();
}
/* gimp_directory now always returns something */
if (stat (filename, &stat_buf) != 0)
properly_installed = FALSE;
......@@ -373,6 +382,47 @@ help_quit_callback (GtkWidget *w,
gtk_exit (0);
}
#ifdef NATIVE_WIN32
static char *
quote_spaces (char *string)
{
int nspaces = 0;
char *p = string, *q, *new;
while (*p)
{
if (*p == ' ')
nspaces++;
p++;
}
if (nspaces == 0)
return g_strdup (string);
new = g_malloc (strlen (string) + nspaces*2 + 1);
p = string;
q = new;
while (*p)
{
if (*p == ' ')
{
*q++ = '"';
*q++ = ' ';
*q++ = '"';
}
else
*q++ = *p;
p++;
}
*q = '\0';
return new;
}
#endif
static void
install_run (InstallCallback callback)
{
......@@ -389,7 +439,6 @@ install_run (InstallCallback callback)
GdkFont *font;
FILE *pfp;
char buffer[2048];
char *gimp_data_dir;
struct stat stat_buf;
int err;
int executable = TRUE;
......@@ -430,14 +479,13 @@ install_run (InstallCallback callback)
/* Realize the text widget before inserting text strings */
gtk_widget_realize (text);
#ifndef NATIVE_WIN32
gtk_text_insert (GTK_TEXT (text), font_strong, NULL, NULL, _("User Installation Log\n\n"), -1);
#endif
/* Generate output */
if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL)
g_snprintf (buffer, sizeof(buffer), "%s/user_install", gimp_data_dir);
else
g_snprintf (buffer, sizeof(buffer), "%s/user_install", DATADIR);
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL,
gimp_data_directory ());
if ((err = stat (buffer, &stat_buf)) != 0)
{
gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buffer, -1);
......@@ -445,6 +493,7 @@ install_run (InstallCallback callback)
_(" does not exist. Cannot install.\n"), -1);
executable = FALSE;
}
#ifdef S_IXUSR
else if (! (S_IXUSR & stat_buf.st_mode) || ! (S_IRUSR & stat_buf.st_mode))
{
gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buffer, -1);
......@@ -452,21 +501,51 @@ install_run (InstallCallback callback)
_(" has invalid permissions.\nCannot install."), -1);
executable = FALSE;
}
#endif
if (executable == TRUE)
{
if (gimp_data_dir)
g_snprintf (buffer, sizeof(buffer), "%s/user_install %s %s",
gimp_data_dir, gimp_data_dir, gimp_directory ());
else
g_snprintf (buffer, sizeof(buffer), "%s/user_install %s %s",
DATADIR, DATADIR, gimp_directory ());
#ifdef NATIVE_WIN32
char *quoted_data_dir, *quoted_user_dir;
/* On Windows, it is common for the GIMP data directory
* to have spaces in it ("c:\Program Files\GIMP"). Put spaces in quotes.
*/
quoted_data_dir = quote_spaces (gimp_data_directory ());
quoted_user_dir = quote_spaces (gimp_directory ());
/* The Microsoft _popen doesn't work in Windows applications, sigh.
* Do the installation by calling system(). The user_install.bat
* ends with a pause command, so the user has to press enter in
* the console window to continue, and thus has a chance to read
* at the window contents.
*/
AllocConsole ();
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s",
quoted_data_dir, quoted_data_dir,
quoted_user_dir);
if (system (buffer) == -1)
executable = FALSE;
g_free (quoted_data_dir);
g_free (quoted_user_dir);
gtk_text_insert (GTK_TEXT (text), font_strong, NULL, NULL,
"Did you notice any error messages\n"
"in the console window? If not, installation\n"
"was successful! Otherwise, quit and investigate\n"
"the possible reason...\n", -1);
#else
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s",
gimp_data_directory (), gimp_data_directory(),
gimp_directory ());
/* urk - should really use something better than popen(), since
* we can't tell if the installation script failed --austin */
if ((pfp = popen (buffer, "r")) != NULL)
{
while (fgets (buffer, 2048, pfp))
while (fgets (buffer, sizeof (buffer), pfp))
gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buffer, -1);
pclose (pfp);
......@@ -476,6 +555,8 @@ install_run (InstallCallback callback)
else
executable = FALSE;
}
#endif /* !NATIVE_WIN32 */
if (executable == FALSE)
gtk_text_insert (GTK_TEXT (text), font, NULL, NULL,
_("\nInstallation failed. Contact system administrator.\n"), -1);
......@@ -492,6 +573,10 @@ install_continue_callback (GtkWidget *w,
{
InstallCallback callback;
#ifdef NATIVE_WIN32
FreeConsole ();
#endif
callback = (InstallCallback) client_data;
gtk_widget_destroy (install_widget);
(* callback) ();
......
......@@ -15,6 +15,9 @@
* 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 "appenv.h"
#include "actionarea.h"
......@@ -24,6 +27,7 @@
#include "color_area.h"
#include "commands.h"
#include "devices.h"
#include "dialog_handler.h"
#include "disp_callbacks.h"
#include "errors.h"
#include "gdisplay.h"
......
......@@ -15,6 +15,9 @@
* 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 "appenv.h"
#include "actionarea.h"
......@@ -24,6 +27,7 @@
#include "color_area.h"
#include "commands.h"
#include "devices.h"
#include "dialog_handler.h"
#include "disp_callbacks.h"
#include "errors.h"
#include "gdisplay.h"
......
......@@ -214,15 +214,12 @@ load_idea_manager( idea_manager *ideas )
{
FILE *fp = NULL;
gchar *desktopfile;
gchar *home_dir;
if ( ! idea_list )
{
home_dir = g_get_home_dir();
/* open persistant desktop file. */
desktopfile = append2( home_dir, FALSE, IDEAPATH, FALSE );
fp = fopen( desktopfile, "rb" );
desktopfile = gimp_personal_rc_file ("ideas");
fp = fopen( desktopfile, "r" );
g_free( desktopfile );
/* Read in persistant desktop information. */
......@@ -291,13 +288,10 @@ save_idea_manager( idea_manager *ideas )
{
FILE *fp;
gchar *desktopfile;
gchar *home_dir;
home_dir = g_get_home_dir();
/* open persistant desktop file. */
desktopfile = append2( home_dir, FALSE, IDEAPATH, FALSE );
fp = fopen( desktopfile, "wb" );
desktopfile = gimp_personal_rc_file ("ideas");
fp = fopen( desktopfile, "w" );
g_free( desktopfile );
if ( fp )
......@@ -435,13 +429,10 @@ static void idea_add_in_position_with_select( gchar *title, gint position, gbool
{
FILE *fp = NULL;
gchar *desktopfile;
gchar *home_dir;
home_dir = g_get_home_dir();
/* open persistant desktop file. */
desktopfile = append2( home_dir, FALSE, IDEAPATH, FALSE );
fp = fopen( desktopfile, "rb" );
desktopfile = gimp_personal_rc_file ("ideas");
fp = fopen( desktopfile, "r" );
g_free( desktopfile );
/* Read in persistant desktop information. */
......
......@@ -13,6 +13,7 @@
* GNU General Public License for more details.
*/
#include <string.h>
#include "docindex.h"
#include "docindexif.h"
......
......@@ -37,9 +37,6 @@ int getinteger( FILE *fp );
gchar *append2( gchar *string1, gboolean del1, gchar *string2, gboolean del2);
gint reset_usize( gpointer data );
#define IDEAPATH "/" GIMPDIR "/ideas"
struct bool_char_pair
{
gboolean boole;
......
......@@ -71,12 +71,21 @@ fatal_error (char *fmt, ...)
va_list args;
va_start (args, fmt);
#ifndef NATIVE_WIN32
printf ("%s fatal error: ", prog_name);
vprintf (fmt, args);
printf ("\n");
#else
g_error ("%s: %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 ();
#endif
app_exit (1);
}
......@@ -91,7 +100,9 @@ terminate (char *fmt, ...)
printf ("\n");
va_end (args);
#ifndef NATIVE_WIN32
if (use_debug_handler)
g_on_error_query (prog_name);
#endif
gdk_exit (1);
}
......@@ -198,6 +198,13 @@ get_token (ParseInfo *info)
else if (slashed || (buffer[info->position] != '"'))
{
slashed = FALSE;
if (slashed && buffer[info->position] == 'n')
tokenbuf[tokenpos++] = '\n';
else if (slashed && buffer[info->position] == 'r')
tokenbuf[tokenpos++] = '\r';
else if (slashed && buffer[info->position] == 'z') /* ^Z */
tokenbuf[tokenpos++] = '\032';
else
tokenbuf[tokenpos++] = buffer[info->position];
info->position += 1;
}
......
EXPORTS
gimp_color_selector_register
gimp_color_selector_unregister
wilber ICON "wilber.ico"
......@@ -35,6 +35,7 @@
#include "gimpsignal.h"
#include "libgimp/gimpintl.h"
#include "libgimp/parasite.h"
#include "layer_pvt.h"
#include "tile_manager_pvt.h"
......
......@@ -15,13 +15,21 @@
* 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>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <glib.h>
#include "app_procs.h"
......@@ -37,8 +45,8 @@
#include "session.h"
#include "tools.h"
#include "config.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
#define ERROR 0
#define DONE 1
......@@ -182,7 +190,11 @@ static char* gimprc_find_token (char *token);
static void gimprc_set_token (char *token, char *value);
static Argument * gimprc_query (Argument *args);
static void add_gimp_directory_token (char *gimp_dir);
static char* open_backup_file (char *filename, FILE **fp_new, FILE **fp_old);
static char* open_backup_file (char *filename,
char *secondary_filename,
char