Commit d0519fd3 authored by Manish Singh's avatar Manish Singh

use G_OS_WIN32 and G_HAVE_CYGWIN #defines

* app/app_procs.c
* app/gdisplay_color.[ch]
* app/gdisplay_color_ui.c: make the ui usable

* app/gdisplay.c: enable cdisplay support

* modules/Makefile.am
* modules/cdisplay_gamma.c: moved gamma functionality to separate

-Yosh
parent 7f54f56e
Mon Oct 4 12:16:44 PDT 1999 Manish Singh <yosh@gimp.org>
* app/app_procs.c
* app/appenv.h
* app/batch.c
* app/datafiles.c
* app/errorconsole.c
* app/errors.c
* app/fileops.[ch]
* app/general.c
* app/gimprc.c
* app/install.c
* app/main.c
* app/module_db.c
* app/plug_in.[ch]
* app/temp_buf.c
* app/tile_swap.c
* libgimp/gimp.[ch]
* libgimp/gimpenv.c
* libgimp/gimpfileselection.c
* libgimp/gimpwire.c
* libgimp/parasite.c
* plug-ins/FractalExplorer/FractalExplorer.c
* plug-ins/common/gbr.c
* plug-ins/common/gz.c
* plug-ins/common/hrz.c
* plug-ins/common/pat.c
* plug-ins/common/pnm.c
* plug-ins/common/ps.c
* plug-ins/faxg3/faxg3.c
* plug-ins/gap/gap_lib.h
* plug-ins/gfig/gfig.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/script-fu/interp_slib.c
* plug-ins/script-fu/script-fu-console.c
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/script-fu.c
* tools/gcg/gcg.c: use G_OS_WIN32 and G_HAVE_CYGWIN #defines
* app/app_procs.c
* app/gdisplay_color.[ch]
* app/gdisplay_color_ui.c: make the ui usable
* app/gdisplay.c: enable cdisplay support
* modules/Makefile.am
* modules/cdisplay_gamma.c: moved gamma functionality to separate lib
Mon Oct 4 19:02:08 CEST 1999 Olof S Kylander <olof@gimp.org>
* Makefile.am fix of a typo
......
......@@ -42,17 +42,17 @@
#include <unistd.h>
#endif
#ifdef WIN32
#if defined(G_OS_WIN32) || defined(G_HAVE_CYGWIN)
#define STRICT
#include <windows.h>
#include <process.h>
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
#include <fcntl.h>
#include <io.h>
#endif
#ifdef __CYGWIN32__
#ifdef G_HAVE_CYGWIN
#define O_TEXT 0x0100 /* text file */
#define _O_TEXT 0x0100 /* text file */
#define O_BINARY 0x0200 /* binary file */
......@@ -183,7 +183,7 @@ static ProcRecord *last_plug_in = NULL;
static int shm_ID = -1;
static guchar *shm_addr = NULL;
#ifdef WIN32
#if defined(G_OS_WIN32) || defined(G_HAVE_CYGWIN)
static HANDLE shm_handle;
#endif
......@@ -220,7 +220,7 @@ plug_in_init_shm (void)
#endif
}
#else
#ifdef WIN32
#if defined(G_OS_WIN32) || defined(G_HAVE_CYGWIN)
/* Use Win32 shared memory mechanisms for
* transfering tile data.
*/
......@@ -421,7 +421,7 @@ plug_in_kill (void)
GSList *tmp;
PlugIn *plug_in;
#ifdef WIN32
#if defined(G_OS_WIN32) || defined(G_HAVE_CYGWIN)
CloseHandle (shm_handle);
#else
#ifdef HAVE_SHM_H
......@@ -829,7 +829,7 @@ plug_in_open (PlugIn *plug_in)
return 0;
}
#if defined(__CYGWIN32__) || defined(__EMX__)
#if defined(G_HAVE_CYGWIN) || defined(__EMX__)
/* Set to binary mode */
setmode(my_read[0], _O_BINARY);
setmode(my_write[0], _O_BINARY);
......@@ -837,7 +837,7 @@ plug_in_open (PlugIn *plug_in)
setmode(my_write[1], _O_BINARY);
#endif
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
......@@ -852,7 +852,7 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes.
*/
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d",
g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d",
......@@ -889,7 +889,7 @@ plug_in_open (PlugIn *plug_in)
fcntl(my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1);
#endif
#if defined (__CYGWIN32__) || defined (NATIVE_WIN32) || defined(__EMX__)
#if defined(G_OS_WIN32) || defined (G_HAVE_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
if (plug_in->pid == -1)
#else
......@@ -926,7 +926,7 @@ plug_in_open (PlugIn *plug_in)
g_io_channel_unref (plug_in->his_write);
plug_in->his_write = NULL;
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
/* The plug-in tells us its thread id */
if (!plug_in->query)
{
......@@ -961,7 +961,7 @@ plug_in_close (PlugIn *plug_in,
int kill_it)
{
int status;
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
struct timeval tv;
#endif
......@@ -978,7 +978,7 @@ plug_in_close (PlugIn *plug_in,
plug_in_pop ();
/* give the plug-in some time (10 ms) */
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
tv.tv_sec = 0;
tv.tv_usec = 100; /* But this is 0.1 ms? */
select (0, NULL, NULL, NULL, &tv);
......@@ -989,7 +989,7 @@ plug_in_close (PlugIn *plug_in,
/* If necessary, kill the filter.
*/
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL);
......@@ -1364,7 +1364,7 @@ plug_in_handle_message (WireMessage *msg)
gtk_main_quit ();
break;
case GP_REQUEST_WAKEUPS:
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
g_io_channel_win32_pipe_request_wakeups (current_plug_in->my_write,
current_plug_in->his_thread_id,
current_plug_in->his_read_fd);
......
......@@ -32,7 +32,7 @@
#include <unistd.h>
#endif
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
#include <process.h> /* For _getpid() */
#endif
......@@ -494,7 +494,7 @@ app_init (void)
RESET_BAR();
internal_procs_init ();
gdisplay_color_init ();
color_display_init ();
RESET_BAR();
parse_buffers_init ();
......@@ -789,7 +789,7 @@ toast_old_temp_files (void)
*/
int pid = atoi (entry->d_name + 9);
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
if (kill (pid, 0))
#else
/* On Windows, you can't remove open files anyhow,
......
......@@ -47,7 +47,7 @@ extern int we_are_exiting; /* this is used in session_get_window_info() */
extern GimpSet* image_context;
extern MessageHandlerType message_handler;
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
char *quote_spaces (char *string);
#endif
......
......@@ -30,7 +30,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
#include <process.h> /* For _getpid() */
#endif
......
......@@ -15,7 +15,7 @@
#include <pthread.h>
#endif
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
#include <io.h>
#endif
......
......@@ -70,7 +70,7 @@ batch_init ()
{
if (!read_from_stdin)
{
#ifndef NATIVE_WIN32 /* for now */
#ifndef G_OS_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;
......@@ -129,7 +129,7 @@ batch_run_cmd (char *cmd)
return;
}
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
static void
batch_read (gpointer data,
......@@ -185,7 +185,7 @@ batch_read (gpointer data,
}
}
#endif /* !NATIVE_WIN32 */
#endif /* !G_OS_WIN32 */
static void
batch_pserver (int run_mode,
......
......@@ -34,7 +34,7 @@
#include <dirent.h>
#endif
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
......
......@@ -340,6 +340,9 @@ gdisplay_delete (GDisplay *gdisp)
gdisp->idle_render.active = FALSE;
}
/* detach any color displays */
gdisplay_color_detach_all (gdisp);
/* get rid of signals handled by this display */
gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp);
......@@ -1256,6 +1259,12 @@ gdisplay_display_area (GDisplay *gdisp,
int x2, y2;
int dx, dy;
int i, j;
GList *list;
guchar *buf;
int bpp;
buf = gximage_get_data ();
bpp = gximage_get_bpp ();
sx = SCALEX (gdisp, gdisp->gimage->width);
sy = SCALEY (gdisp, gdisp->gimage->height);
......@@ -1333,6 +1342,15 @@ gdisplay_display_area (GDisplay *gdisp,
dx, dy,
0, 0, 0, 0);
#endif
list = gdisp->cd_list;
while (list)
{
ColorDisplayNode *node = (ColorDisplayNode *) list->data;
node->cd_convert (node->cd_ID, buf, dx, dy, bpp);
list = list->next;
}
gximage_put (gdisp->canvas->window,
j, i, dx, dy,
gdisp->offset_x,
......
......@@ -34,7 +34,7 @@
#include <dirent.h>
#endif
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
......
......@@ -453,7 +453,7 @@ valid_module_name (const char *filename)
len = strlen (basename);
#if !defined(WIN32) && !defined(__EMX__)
#if !defined(G_OS_WIN32) && !defined(G_HAVE_CYGWIN) && !defined(__EMX__)
if (len < 3 + 1 + 3)
return FALSE;
......
......@@ -35,7 +35,7 @@
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
# ifndef __EMX__
# define USER_INSTALL "user_install"
# else
......@@ -339,7 +339,7 @@ help_quit_callback (GtkWidget *widget,
gtk_exit (0);
}
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
char *
quote_spaces (char *string)
......@@ -430,7 +430,7 @@ install_run (InstallCallback callback)
/* Realize the text widget before inserting text strings */
gtk_widget_realize (text);
#ifndef NATIVE_WIN32
#ifndef G_OS_WIN32
gtk_text_insert (GTK_TEXT (text), font_strong, NULL, NULL, _("User Installation Log\n\n"), -1);
#endif
......@@ -456,7 +456,7 @@ install_run (InstallCallback callback)
if (executable == TRUE)
{
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
char *quoted_data_dir, *quoted_user_dir;
/* On Windows, it is common for the GIMP data directory
......@@ -519,7 +519,7 @@ install_run (InstallCallback callback)
}
else
executable = FALSE;
#endif /* !NATIVE_WIN32 */
#endif /* !G_OS_WIN32 */
}
if (executable == FALSE)
......@@ -538,7 +538,7 @@ install_continue_callback (GtkWidget *widget,
{
InstallCallback callback;
#ifdef NATIVE_WIN32
#ifdef G_OS_WIN32
FreeConsole ();
#endif
......
......@@ -340,6 +340,9 @@ gdisplay_delete (GDisplay *gdisp)
gdisp->idle_render.active = FALSE;
}
/* detach any color displays */
gdisplay_color_detach_all (gdisp);
/* get rid of signals handled by this display */
gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp);
......@@ -1256,6 +1259,12 @@ gdisplay_display_area (GDisplay *gdisp,
int x2, y2;
int dx, dy;
int i, j;
GList *list;
guchar *buf;
int bpp;
buf = gximage_get_data ();
bpp = gximage_get_bpp ();
sx = SCALEX (gdisp, gdisp->gimage->width);
sy = SCALEY (gdisp, gdisp->gimage->height);
......@@ -1333,6 +1342,15 @@ gdisplay_display_area (GDisplay *gdisp,
dx, dy,
0, 0, 0, 0);
#endif
list = gdisp->cd_list;
while (list)
{
ColorDisplayNode *node = (ColorDisplayNode *) list->data;
node->cd_convert (node->cd_ID, buf, dx, dy, bpp);
list = list->next;
}
gximage_put (gdisp->canvas->window,
j, i, dx, dy,
gdisp->offset_x,
......
......@@ -29,11 +29,21 @@ typedef struct _ColorDisplayDialog ColorDisplayDialog;
struct _ColorDisplayDialog
{
GtkWidget *shell;
GtkWidget *src;
GtkWidget *dest;
gint src_row;
gint dest_row;
gboolean modified;
GList *old_nodes;
GDisplay *gdisp;
};
static ColorDisplayDialog cdd = { NULL, NULL, NULL };
static ColorDisplayDialog cdd = { NULL, NULL, NULL, 0, 0, FALSE, NULL, NULL };
typedef void (*ButtonCallback) (GtkWidget *, gpointer);
......@@ -45,17 +55,38 @@ struct _ButtonInfo
ButtonCallback callback;
};
static void color_display_ok_callback (GtkWidget *, gpointer);
static void color_display_cancel_callback (GtkWidget *, gpointer);
static gint color_display_destroy_callback (GtkWidget *, gpointer);
static void color_display_add_callback (GtkWidget *, gpointer);
static void color_display_remove_callback (GtkWidget *, gpointer);
static void color_display_up_callback (GtkWidget *, gpointer);
static void color_display_down_callback (GtkWidget *, gpointer);
static void color_display_configure_callback (GtkWidget *, gpointer);
static void src_list_populate (const char *name,
gpointer user_data);
static void color_display_ok_callback (GtkWidget *widget,
gpointer data);
static void color_display_cancel_callback (GtkWidget *widget,
gpointer data);
static void color_display_add_callback (GtkWidget *widget,
gpointer data);
static void color_display_remove_callback (GtkWidget *widget,
gpointer data);
static void color_display_up_callback (GtkWidget *widget,
gpointer data);
static void color_display_down_callback (GtkWidget *widget,
gpointer data);
static void color_display_configure_callback (GtkWidget *widget,
gpointer data);
static void src_list_populate (const char *name,
gpointer data);
static void dest_list_populate (GList *node_list);
static void select_src (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *event,
gpointer data);
static void select_dest (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *event,
gpointer data);
#define LIST_WIDTH 180
#define LIST_HEIGHT 180
static void
make_dialog (void)
......@@ -102,10 +133,15 @@ make_dialog (void)
titles[0] = _("Available Filters");
titles[1] = NULL;
cdd.src = gtk_clist_new_with_titles (1, titles);
gtk_widget_set_usize (cdd.src, LIST_WIDTH, LIST_HEIGHT);
gtk_clist_column_titles_passive (GTK_CLIST (cdd.src));
gtk_clist_set_auto_sort (GTK_CLIST (cdd.src), TRUE);
gtk_container_add (GTK_CONTAINER (scrolled_win), cdd.src);
gtk_signal_connect (GTK_OBJECT (cdd.src), "select_row",
GTK_SIGNAL_FUNC (select_src),
NULL);
vbbox = gtk_vbutton_box_new ();
gtk_vbutton_box_set_layout_default (GTK_BUTTONBOX_START);
gtk_box_pack_start (GTK_BOX (hbox), vbbox, FALSE, FALSE, 2);
......@@ -120,9 +156,14 @@ make_dialog (void)
titles[0] = _("Active Filters");
titles[1] = NULL;
cdd.dest = gtk_clist_new_with_titles (1, titles);
gtk_widget_set_usize (cdd.dest, LIST_WIDTH, LIST_HEIGHT);
gtk_clist_column_titles_passive (GTK_CLIST (cdd.dest));
gtk_container_add (GTK_CONTAINER (scrolled_win), cdd.dest);
gtk_signal_connect (GTK_OBJECT (cdd.src), "select_row",
GTK_SIGNAL_FUNC (select_dest),
NULL);
for (i = 0; i < 5; i++)
{
GtkWidget *button;
......@@ -142,46 +183,126 @@ static void
color_display_ok_callback (GtkWidget *widget,
gpointer data)
{
GList *list;
gtk_widget_hide (GTK_WIDGET (data));
if (cdd.modified)
{
list = cdd.old_nodes;
while (list)
{
if (!g_list_find (cdd.gdisp->cd_list, list->data))
gdisplay_color_detach_destroy (cdd.gdisp, list->data);
list = list->next;
}
g_list_free (cdd.old_nodes);
}
gdisplays_flush ();
}
static void
color_display_cancel_callback (GtkWidget *widget,
gpointer data)
{
GList *list;
gtk_widget_hide (GTK_WIDGET (data));
}
if (cdd.modified)
{
list = cdd.gdisp->cd_list;
cdd.gdisp->cd_list = cdd.old_nodes;
static gint
color_display_destroy_callback (GtkWidget *widget,
gpointer data)
{
g_free (data);
return FALSE;
while (list)
{
if (!g_list_find (cdd.old_nodes, list->data))
gdisplay_color_detach_destroy (cdd.gdisp, list->data);
list = list->next;
}
}
gdisplays_flush ();
}
static void
color_display_add_callback (GtkWidget *widget,
gpointer data)
{
gchar *name = NULL;
ColorDisplayNode *node;
gint row;
gtk_clist_get_text (GTK_CLIST (cdd.src), cdd.src_row, 0, &name);
cdd.modified = TRUE;
node = gdisplay_color_attach (cdd.gdisp, name);
row = gtk_clist_append (GTK_CLIST (cdd.dest), &name);
gtk_clist_set_row_data (GTK_CLIST (cdd.dest), row, node);
gdisplays_flush ();
}
static void
color_display_remove_callback (GtkWidget *widget,
gpointer data)
{
ColorDisplayNode *node;
node = (ColorDisplayNode *) gtk_clist_get_row_data (GTK_CLIST (cdd.dest),
cdd.dest_row);
gtk_clist_remove (GTK_CLIST (cdd.dest), cdd.dest_row);
cdd.modified = TRUE;
if (g_list_find (cdd.old_nodes, node))
gdisplay_color_detach (cdd.gdisp, node);
else
gdisplay_color_detach_destroy (cdd.gdisp, node);
gdisplays_flush ();
}
static void
color_display_up_callback (GtkWidget *widget,
gpointer data)
{
ColorDisplayNode *node;
node = (ColorDisplayNode *) gtk_clist_get_row_data (GTK_CLIST (cdd.dest),
cdd.dest_row);
gtk_clist_row_move (GTK_CLIST (cdd.dest), cdd.dest_row, cdd.dest_row - 1);
gdisplay_color_reorder_up (cdd.gdisp, node);
cdd.modified = TRUE;
gdisplays_flush ();
}
static void
color_display_down_callback (GtkWidget *widget,
gpointer data)
{
ColorDisplayNode *node;
node = (ColorDisplayNode *) gtk_clist_get_row_data (GTK_CLIST (cdd.dest),
cdd.dest_row);
gtk_clist_row_move (GTK_CLIST (cdd.dest), cdd.dest_row, cdd.dest_row + 1);
gdisplay_color_reorder_down (cdd.gdisp, node);
cdd.modified = TRUE;
gdisplays_flush ();
}
static void
......@@ -199,14 +320,60 @@ gdisplay_color_ui (GDisplay *gdisp)
gtk_clist_clear (GTK_CLIST (cdd.src));
gtk_clist_clear (GTK_CLIST (cdd.dest));
gimp_color_display_foreach (src_list_populate, cdd.src);
color_display_foreach (src_list_populate, cdd.src);
if (gdisp)
{
cdd.old_nodes = gdisp->cd_list;
dest_list_populate (gdisp->cd_list);
gdisp->cd_list = g_list_copy (cdd.old_nodes);
}
cdd.gdisp = gdisp;
gtk_widget_show (cdd.shell);
}
static void
src_list_populate (const char *name,
gpointer user_data)
gpointer data)
{
gtk_clist_append (GTK_CLIST (data), (gchar **) &name);
}
static void
dest_list_populate (GList *node_list)
{
ColorDisplayNode *node;
int row;
while (node_list)
{
node = (ColorDisplayNode *) node_list->data;
row = gtk_clist_append (GTK_CLIST (cdd.dest), &node->cd_name);
gtk_clist_set_row_data (GTK_CLIST (cdd.dest), row, node);
node_list = node_list->next;
}
}
static void
select_src (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *event,
gpointer data)
{
cdd.src_row = row;
}